OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/toolbar/wrench_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "chrome/browser/tabs/tab_strip_model.h" | 24 #include "chrome/browser/tabs/tab_strip_model.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 26 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
27 #include "chrome/browser/upgrade_detector.h" | 27 #include "chrome/browser/upgrade_detector.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
30 #include "chrome/common/notification_source.h" | 30 #include "chrome/common/notification_source.h" |
31 #include "chrome/common/notification_type.h" | 31 #include "chrome/common/notification_type.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/profiling.h" |
33 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
35 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/models/button_menu_item_model.h" | 38 #include "ui/base/models/button_menu_item_model.h" |
38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
39 | 40 |
40 #if defined(OS_LINUX) | 41 #if defined(OS_LINUX) |
41 #include <gtk/gtk.h> | 42 #include <gtk/gtk.h> |
42 #include "chrome/browser/ui/gtk/gtk_util.h" | 43 #include "chrome/browser/ui/gtk/gtk_util.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 AddSeparator(); | 178 AddSeparator(); |
178 | 179 |
179 encoding_menu_model_.reset(new EncodingMenuModel(browser)); | 180 encoding_menu_model_.reset(new EncodingMenuModel(browser)); |
180 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, | 181 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, |
181 encoding_menu_model_.get()); | 182 encoding_menu_model_.get()); |
182 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); | 183 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); |
183 if (g_browser_process->have_inspector_files()) { | 184 if (g_browser_process->have_inspector_files()) { |
184 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); | 185 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); |
185 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); | 186 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); |
186 } | 187 } |
| 188 |
| 189 #if defined(ENABLE_PROFILING) || !defined(NO_TCMALLOC) |
| 190 AddSeparator(); |
| 191 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); |
| 192 #endif |
187 } | 193 } |
188 | 194 |
189 //////////////////////////////////////////////////////////////////////////////// | 195 //////////////////////////////////////////////////////////////////////////////// |
190 // WrenchMenuModel | 196 // WrenchMenuModel |
191 | 197 |
192 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider, | 198 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider, |
193 Browser* browser) | 199 Browser* browser) |
194 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 200 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
195 provider_(provider), | 201 provider_(provider), |
196 browser_(browser), | 202 browser_(browser), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 278 } |
273 } | 279 } |
274 | 280 |
275 void WrenchMenuModel::ExecuteCommand(int command_id) { | 281 void WrenchMenuModel::ExecuteCommand(int command_id) { |
276 browser_->ExecuteCommand(command_id); | 282 browser_->ExecuteCommand(command_id); |
277 } | 283 } |
278 | 284 |
279 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 285 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
280 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 286 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
281 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 287 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 288 } else if (command_id == IDC_PROFILING_ENABLED) { |
| 289 return Profiling::BeingProfiled(); |
282 } | 290 } |
283 | 291 |
284 return false; | 292 return false; |
285 } | 293 } |
286 | 294 |
287 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 295 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
288 return browser_->command_updater()->IsCommandEnabled(command_id); | 296 return browser_->command_updater()->IsCommandEnabled(command_id); |
289 } | 297 } |
290 | 298 |
291 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { | 299 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 &enable_increment, &enable_decrement); | 510 &enable_increment, &enable_decrement); |
503 } | 511 } |
504 zoom_label_ = l10n_util::GetStringFUTF16( | 512 zoom_label_ = l10n_util::GetStringFUTF16( |
505 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 513 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
506 } | 514 } |
507 | 515 |
508 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 516 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
509 return sync_ui_util::GetSyncMenuLabel( | 517 return sync_ui_util::GetSyncMenuLabel( |
510 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 518 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |
511 } | 519 } |
OLD | NEW |