命令响应控制器初始化-从Browser对象开始
来源:互联网 发布:知而行天下 编辑:程序博客网 时间:2024/05/21 18:39
void BrowserCommandController::ExecuteCommandWithDisposition(
int id,
WindowOpenDisposition disposition)
根据传入的命令id,执行对应的响应函数
而BrowserCommandController这个对象是在Browser的构造函数时创建的,并以Browser自身构造BrowserCommandController对象
以下是Browser构造函数实现,在这里构造了若干元素,工具条,标签相关的东西
Browser::Browser(const CreateParams& params)
: extension_registry_observer_(this),
type_(params.type),
profile_(params.profile),
window_(NULL),
tab_strip_model_delegate_(new chrome::BrowserTabStripModelDelegate(this)),
tab_strip_model_(
new TabStripModel(tab_strip_model_delegate_.get(), params.profile)),
app_name_(params.app_name),
is_trusted_source_(params.trusted_source),
cancel_download_confirmation_state_(NOT_PROMPTED),
override_bounds_(params.initial_bounds),
initial_show_state_(params.initial_show_state),
is_session_restore_(params.is_session_restore),
content_setting_bubble_model_delegate_(
new BrowserContentSettingBubbleModelDelegate(this)),
toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)),
live_tab_context_(new BrowserLiveTabContext(this)),
synced_window_delegate_(new BrowserSyncedWindowDelegate(this)),
bookmark_bar_state_(BookmarkBar::HIDDEN),
command_controller_(new chrome::BrowserCommandController(this)),
window_has_shown_(false),
chrome_updater_factory_(this),
weak_factory_(this) {
// If this causes a crash then a window is being opened using a profile type
// that is disallowed by policy. The crash prevents the disabled window type
// from opening at all, but the path that triggered it should be fixed.
CHECK(IncognitoModePrefs::CanOpenBrowser(profile_));
CHECK(!profile_->IsGuestSession() || profile_->IsOffTheRecord())
<< "Only off the record browser may be opened in guest mode";
DCHECK(!profile_->IsSystemProfile())
<< "The system profile should never have a real browser.";
// TODO(mlerman): After this hits stable channel, see if there are counts
// for this metric. If not, change the DCHECK above to a CHECK.
if (profile_->IsSystemProfile())
content::RecordAction(base::UserMetricsAction("BrowserForSystemProfile"));
// TODO(jeremy): Move to initializer list once flag is removed.
if (IsFastTabUnloadEnabled())
fast_unload_controller_.reset(new chrome::FastUnloadController(this));
else
unload_controller_.reset(new chrome::UnloadController(this));
tab_strip_model_->AddObserver(this);
toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get(),
content::kMaxURLDisplayChars));
search_model_.reset(new SearchModel());
search_delegate_.reset(new SearchDelegate(search_model_.get()));
extension_registry_observer_.Add(
extensions::ExtensionRegistry::Get(profile_));
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
content::NotificationService::AllSources());
#if defined(ENABLE_THEMES)
registrar_.Add(
this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(profile_)));
#endif
registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
content::NotificationService::AllSources());
profile_pref_registrar_.Init(profile_->GetPrefs());
profile_pref_registrar_.Add(
prefs::kDevToolsDisabled,
base::Bind(&Browser::OnDevToolsDisabledChanged, base::Unretained(this)));
profile_pref_registrar_.Add(
bookmarks::prefs::kShowBookmarkBar,
base::Bind(&Browser::UpdateBookmarkBarState, base::Unretained(this),
BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE));
// NOTE: These prefs all need to be explicitly destroyed in the destructor
// or you'll get a nasty surprise when you run the incognito tests.
encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
profile_->GetPrefs());
if (search::IsInstantExtendedAPIEnabled() && is_type_tabbed())
instant_controller_.reset(new BrowserInstantController(this));
if (extensions::HostedAppBrowserController::IsForHostedApp(this)) {
hosted_app_controller_.reset(
new extensions::HostedAppBrowserController(this));
}
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT);
ProfileMetrics::LogProfileLaunch(profile_);
window_ = params.window ? params.window : CreateBrowserWindow(this);
if (hosted_app_controller_)
hosted_app_controller_->UpdateLocationBarVisibility(false);
// Create the extension window controller before sending notifications.
extension_window_controller_.reset(
new BrowserExtensionWindowController(this));
SessionService* session_service =
SessionServiceFactory::GetForProfileForSessionRestore(profile_);
if (session_service)
session_service->WindowOpened(this);
// TODO(beng): move to ChromeBrowserMain:
if (first_run::ShouldDoPersonalDataManagerFirstRun()) {
#if defined(OS_WIN)
// Notify PDM that this is a first run.
ImportAutofillDataWin(
autofill::PersonalDataManagerFactory::GetForProfile(profile_));
#endif // defined(OS_WIN)
}
exclusive_access_manager_.reset(
new ExclusiveAccessManager(window_->GetExclusiveAccessContext()));
// TODO(beng): Move BrowserList::AddBrowser() to the end of this function and
// replace uses of this with BL's notifications.
BrowserList::AddBrowser(this);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_BROWSER_WINDOW_READY, content::Source<Browser>(this),
content::NotificationService::NoDetails());
}
profile_ 在浏览器打开首页的时候有提及这种对象,还没细看是不是有关系。
toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)) 这里创建与工具条有关的,应该是响应工具条的命令,与这个相关的是ToolbarView
command_controller_(new chrome::BrowserCommandController(this)) 上面提及的命令响应控制器
重要一点是BrowserList::AddBrowser(this);把每一个browser都加入到浏览器列表中,以后枚举标签可能要用到这个列表
这里有Browser的简要描述
http://dev.chromium.org/developers/design-documents/browser-window
- 命令响应控制器初始化-从Browser对象开始
- yii2 控制器初始化和对象初始化
- 1. 从对象开始
- 从vi命令开始
- UI 指派初始化方法 视图控制器 button响应方法
- Browser 对象
- Browser对象
- Browser对象
- x86从 start_kernel 开始的中断初始化
- java 从面向对象开始。。
- MVC从基础开始-学习1-对控制器的操作
- Browser 对象(Window 对象)
- Browser 对象(Navigator 对象)
- 从string对象初始化来看构造函数
- 初始化从相同类型的一个对象
- javascript Browser对象篇
- JavaScript中Browser 对象
- Browser 对象(一、history)
- 一款很好用的桌面录屏软件
- HBase介绍
- matlab常用代码
- jsp的七个动作指令
- DataTime 用法大全
- 命令响应控制器初始化-从Browser对象开始
- JMeter和Badboy的部署
- CURL 学习 1
- UI图标资源站
- Linuxshell字符串截取与拼接
- 一种适合于MC与SMC算法的哈希表设计
- nginx pathinfo配置,适用于较高版本的nginx
- 程序员平时该如何学习来提升自己的技术
- android tools命名空间