diff options
-rw-r--r-- | chrome/browser/chromeos/chromeos_browser_view.cc | 3 | ||||
-rwxr-xr-x | chrome/browser/chromeos/status_area_view.cc | 71 | ||||
-rw-r--r-- | chrome/browser/chromeos/status_area_view.h | 5 |
3 files changed, 34 insertions, 45 deletions
diff --git a/chrome/browser/chromeos/chromeos_browser_view.cc b/chrome/browser/chromeos/chromeos_browser_view.cc index 1f10ad05..4ebf8dd 100644 --- a/chrome/browser/chromeos/chromeos_browser_view.cc +++ b/chrome/browser/chromeos/chromeos_browser_view.cc @@ -22,6 +22,7 @@ #include "chrome/browser/views/tabs/tab.h" #include "chrome/browser/views/tabs/tab_overview_types.h" #include "chrome/browser/views/tabs/tab_strip.h" +#include "chrome/browser/views/toolbar_view.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/x11_util.h" #include "grit/generated_resources.h" @@ -349,6 +350,8 @@ void ChromeosBrowserView::Init() { status_area_->SetID(VIEW_ID_STATUS_AREA); AddChildView(status_area_); status_area_->Init(); + ToolbarView* toolbar_view = GetToolbarView(); + toolbar_view->SetAppMenuModel(status_area_->CreateAppMenuModel(toolbar_view)); SkBitmap* theme_toolbar = theme_provider->GetBitmapNamed(IDR_THEME_TOOLBAR); spacer_ = new Spacer(theme_toolbar); diff --git a/chrome/browser/chromeos/status_area_view.cc b/chrome/browser/chromeos/status_area_view.cc index 63f8798..a957c7a 100755 --- a/chrome/browser/chromeos/status_area_view.cc +++ b/chrome/browser/chromeos/status_area_view.cc @@ -11,6 +11,7 @@ #include "app/theme_provider.h" #include "base/string_util.h" #include "chrome/app/chrome_dll_resource.h" +#include "chrome/browser/app_menu_model.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/browser_theme_provider.h" @@ -22,6 +23,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/theme_background.h" +#include "chrome/browser/views/toolbar_view.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "grit/chromium_strings.h" @@ -143,6 +145,9 @@ void StatusAreaView::Init() { AddChildView(menu_view_); set_background(new ThemeBackground(browser_view_)); + + app_menu_contents_.reset(CreateAppMenuModel(this)); + app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); } void StatusAreaView::Update() { @@ -201,49 +206,28 @@ void StatusAreaView::SetOpenTabsMode(OpenTabsMode mode) { open_tabs_mode_ = mode; } -void StatusAreaView::CreateAppMenu() { - if (app_menu_contents_.get()) - return; - - options_menu_contents_.reset(new OptionsMenuModel(browser_view_->browser())); - - app_menu_contents_.reset(new menus::SimpleMenuModel(this)); - app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); - app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); - app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, - IDS_NEW_INCOGNITO_WINDOW); - app_menu_contents_->AddSeparator(); - app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, - IDS_SHOW_BOOKMARK_BAR); - app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); - app_menu_contents_->AddSeparator(); - app_menu_contents_->AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); - app_menu_contents_->AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, - IDS_BOOKMARK_MANAGER); - app_menu_contents_->AddItemWithStringId(IDC_SHOW_DOWNLOADS, - IDS_SHOW_DOWNLOADS); - // Create the manage extensions menu item. - app_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS, - IDS_SHOW_EXTENSIONS); - app_menu_contents_->AddSeparator(); - app_menu_contents_->AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, - IDS_CLEAR_BROWSING_DATA); - app_menu_contents_->AddItemWithStringId(IDC_IMPORT_SETTINGS, - IDS_IMPORT_SETTINGS); - app_menu_contents_->AddSeparator(); - app_menu_contents_->AddItem(IDC_OPTIONS, - l10n_util::GetStringFUTF16( - IDS_OPTIONS, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); - app_menu_contents_->AddSubMenu(ASCIIToUTF16("Compact nav bar"), - options_menu_contents_.get()); - app_menu_contents_->AddItem(IDC_ABOUT, - l10n_util::GetStringFUTF16( - IDS_ABOUT, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); - app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); - - app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); +AppMenuModel* StatusAreaView::CreateAppMenuModel( + menus::SimpleMenuModel::Delegate* delegate) { + Browser* browser = browser_view_->browser(); + AppMenuModel* menu_model = new AppMenuModel(delegate, browser); + + // Options menu always uses StatusAreaView as delegate, so + // we can reuse it. + if (!options_menu_contents_.get()) + options_menu_contents_.reset(new OptionsMenuModel(browser)); + + int sync_index = menu_model->GetIndexOfCommandId(IDC_SYNC_BOOKMARKS); + DCHECK_GE(sync_index, 0); + menu_model->InsertItemWithStringIdAt( + sync_index + 1, IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); + menu_model->InsertSeparatorAt(sync_index + 1); + + int options_index = menu_model->GetIndexOfCommandId(IDC_OPTIONS); + DCHECK_GE(options_index, 0); + menu_model->InsertSubMenuAt( + options_index + 1, + ASCIIToUTF16("Compact nav bar"), options_menu_contents_.get()); + return menu_model; } bool StatusAreaView::IsCommandIdChecked(int command_id) const { @@ -271,7 +255,6 @@ void StatusAreaView::ExecuteCommand(int command_id) { } void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { - CreateAppMenu(); app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); } diff --git a/chrome/browser/chromeos/status_area_view.h b/chrome/browser/chromeos/status_area_view.h index 12b7804..1eb9e10 100644 --- a/chrome/browser/chromeos/status_area_view.h +++ b/chrome/browser/chromeos/status_area_view.h @@ -12,6 +12,7 @@ #include "views/controls/menu/menu_2.h" #include "views/view.h" +class AppMenuModel; class BrowserView; namespace chromeos { @@ -43,6 +44,9 @@ class StatusAreaView : public views::View, // toggle the app menu visibility. void Update(); + // Creates an AppMenuModel for chromeos. + AppMenuModel* CreateAppMenuModel(menus::SimpleMenuModel::Delegate* delegate); + // views::View* overrides. virtual gfx::Size GetPreferredSize(); virtual void Layout(); @@ -51,7 +55,6 @@ class StatusAreaView : public views::View, static void SetOpenTabsMode(OpenTabsMode mode); private: - void CreateAppMenu(); // menus::SimpleMenuModel::Delegate implementation. virtual bool IsCommandIdChecked(int command_id) const; |