OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/status/browser_status_area_view.h" | 5 #include "chrome/browser/chromeos/status/browser_status_area_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/menus/simple_menu_model.h" |
8 #include "app/theme_provider.h" | 9 #include "app/theme_provider.h" |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/browser/app_menu_model.h" | 12 #include "chrome/browser/app_menu_model.h" |
12 #include "chrome/browser/browser.h" | 13 #include "chrome/browser/browser.h" |
13 #include "chrome/browser/browser_window.h" | 14 #include "chrome/browser/browser_window.h" |
14 #include "chrome/browser/browser_theme_provider.h" | 15 #include "chrome/browser/browser_theme_provider.h" |
15 #include "chrome/browser/chromeos/frame/browser_view.h" | 16 #include "chrome/browser/chromeos/frame/browser_view.h" |
16 #include "chrome/browser/chromeos/status/status_area_button.h" | 17 #include "chrome/browser/chromeos/status/status_area_button.h" |
17 #include "chrome/browser/chromeos/status/status_area_view.h" | 18 #include "chrome/browser/chromeos/status/status_area_view.h" |
18 #include "chrome/browser/pref_service.h" | 19 #include "chrome/browser/pref_service.h" |
19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/views/theme_background.h" | 21 #include "chrome/browser/views/theme_background.h" |
21 #include "chrome/browser/views/toolbar_view.h" | 22 #include "chrome/browser/views/toolbar_view.h" |
| 23 #include "chrome/browser/wrench_menu_model.h" |
22 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
23 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
24 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
25 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
26 #include "views/controls/menu/menu.h" | 28 #include "views/controls/menu/menu.h" |
27 #include "views/controls/menu/menu_2.h" | 29 #include "views/controls/menu/menu_2.h" |
28 #include "views/window/window.h" | 30 #include "views/window/window.h" |
29 | 31 |
30 namespace chromeos { | 32 namespace chromeos { |
31 | 33 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 menu_view_ = new StatusAreaButton(this); | 107 menu_view_ = new StatusAreaButton(this); |
106 menu_view_->SetIcon(*theme->GetBitmapNamed(IDR_STATUSBAR_MENU)); | 108 menu_view_->SetIcon(*theme->GetBitmapNamed(IDR_STATUSBAR_MENU)); |
107 AddChildView(menu_view_); | 109 AddChildView(menu_view_); |
108 | 110 |
109 set_background(new ThemeBackground(browser_view_)); | 111 set_background(new ThemeBackground(browser_view_)); |
110 | 112 |
111 app_menu_contents_.reset(CreateAppMenuModel(this)); | 113 app_menu_contents_.reset(CreateAppMenuModel(this)); |
112 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); | 114 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); |
113 } | 115 } |
114 | 116 |
115 AppMenuModel* BrowserStatusAreaView::CreateAppMenuModel( | 117 menus::SimpleMenuModel* BrowserStatusAreaView::CreateAppMenuModel( |
116 menus::SimpleMenuModel::Delegate* delegate) { | 118 menus::SimpleMenuModel::Delegate* delegate) { |
117 Browser* browser = browser_view_->browser(); | 119 Browser* browser = browser_view_->browser(); |
118 AppMenuModel* menu_model = new AppMenuModel(delegate, browser); | 120 menus::SimpleMenuModel* menu_model; |
| 121 |
| 122 if (WrenchMenuModel::IsEnabled()) |
| 123 menu_model = new WrenchMenuModel(delegate, browser); |
| 124 else |
| 125 menu_model = new AppMenuModel(delegate, browser); |
119 | 126 |
120 // Options menu always uses StatusAreaView as delegate, so | 127 // Options menu always uses StatusAreaView as delegate, so |
121 // we can reuse it. | 128 // we can reuse it. |
122 if (!options_menu_contents_.get()) | 129 if (!options_menu_contents_.get()) |
123 options_menu_contents_.reset(new OptionsMenuModel(browser_view_)); | 130 options_menu_contents_.reset(new OptionsMenuModel(browser_view_)); |
124 | 131 |
125 #if !defined(OS_CHROMEOS) | |
126 int sync_index = menu_model->GetIndexOfCommandId(IDC_SYNC_BOOKMARKS); | |
127 DCHECK_GE(sync_index, 0); | |
128 menu_model->InsertItemWithStringIdAt( | |
129 sync_index + 1, IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); | |
130 menu_model->InsertSeparatorAt(sync_index + 1); | |
131 #endif | |
132 | |
133 int options_index = menu_model->GetIndexOfCommandId(IDC_OPTIONS); | 132 int options_index = menu_model->GetIndexOfCommandId(IDC_OPTIONS); |
134 DCHECK_GE(options_index, 0); | 133 DCHECK_GE(options_index, 0); |
135 menu_model->InsertSubMenuAt( | 134 menu_model->InsertSubMenuAt( |
136 options_index + 1, | 135 options_index + 1, |
137 IDC_EXPERIMENTAL, | 136 IDC_EXPERIMENTAL, |
138 ASCIIToUTF16("Experimental"), | 137 ASCIIToUTF16("Experimental"), |
139 options_menu_contents_.get()); | 138 options_menu_contents_.get()); |
140 return menu_model; | 139 return menu_model; |
141 } | 140 } |
142 | 141 |
(...skipping 19 matching lines...) Expand all Loading... |
162 | 161 |
163 void BrowserStatusAreaView::ExecuteCommand(int command_id) { | 162 void BrowserStatusAreaView::ExecuteCommand(int command_id) { |
164 browser_view_->browser()->ExecuteCommand(command_id); | 163 browser_view_->browser()->ExecuteCommand(command_id); |
165 } | 164 } |
166 | 165 |
167 void BrowserStatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { | 166 void BrowserStatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { |
168 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 167 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
169 } | 168 } |
170 | 169 |
171 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |