| 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" |
| 11 #include "base/i18n/number_formatting.h" | 11 #include "base/i18n/number_formatting.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/sync/sync_global_error.h" |
| 21 #include "chrome/browser/sync/sync_ui_util.h" | 22 #include "chrome/browser/sync/sync_ui_util.h" |
| 22 #include "chrome/browser/sync/sync_global_error.h" | |
| 23 #include "chrome/browser/tabs/tab_strip_model.h" | 23 #include "chrome/browser/tabs/tab_strip_model.h" |
| 24 #include "chrome/browser/task_manager/task_manager.h" | 24 #include "chrome/browser/task_manager/task_manager.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
| 27 #include "chrome/browser/ui/global_error.h" | 27 #include "chrome/browser/ui/global_error.h" |
| 28 #include "chrome/browser/ui/global_error_service.h" | 28 #include "chrome/browser/ui/global_error_service.h" |
| 29 #include "chrome/browser/ui/global_error_service_factory.h" | 29 #include "chrome/browser/ui/global_error_service_factory.h" |
| 30 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 30 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 31 #include "chrome/browser/upgrade_detector.h" | 31 #include "chrome/browser/upgrade_detector.h" |
| 32 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/profiling.h" | 35 #include "chrome/common/profiling.h" |
| 36 #include "content/browser/tab_contents/tab_contents.h" | 36 #include "content/browser/tab_contents/tab_contents.h" |
| 37 #include "content/browser/user_metrics.h" | |
| 38 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 39 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
| 40 #include "content/public/browser/notification_types.h" | 39 #include "content/public/browser/notification_types.h" |
| 40 #include "content/public/browser/user_metrics.h" |
| 41 #include "grit/chromium_strings.h" | 41 #include "grit/chromium_strings.h" |
| 42 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
| 43 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 45 #include "ui/base/models/button_menu_item_model.h" | 45 #include "ui/base/models/button_menu_item_model.h" |
| 46 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
| 47 #include "ui/gfx/image/image.h" | 47 #include "ui/gfx/image/image.h" |
| 48 | 48 |
| 49 #if defined(TOOLKIT_USES_GTK) | 49 #if defined(TOOLKIT_USES_GTK) |
| 50 #include <gtk/gtk.h> | 50 #include <gtk/gtk.h> |
| 51 #include "chrome/browser/ui/gtk/gtk_util.h" | 51 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 55 #include "chrome/browser/enumerate_modules_model_win.h" | 55 #include "chrome/browser/enumerate_modules_model_win.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 using content::UserMetricsAction; |
| 59 |
| 58 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
| 59 // EncodingMenuModel | 61 // EncodingMenuModel |
| 60 | 62 |
| 61 EncodingMenuModel::EncodingMenuModel(Browser* browser) | 63 EncodingMenuModel::EncodingMenuModel(Browser* browser) |
| 62 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 64 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| 63 browser_(browser) { | 65 browser_(browser) { |
| 64 Build(); | 66 Build(); |
| 65 } | 67 } |
| 66 | 68 |
| 67 EncodingMenuModel::~EncodingMenuModel() { | 69 EncodingMenuModel::~EncodingMenuModel() { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 ProfileSyncService* service = | 331 ProfileSyncService* service = |
| 330 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); | 332 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); |
| 331 SyncGlobalError* error = service->sync_global_error(); | 333 SyncGlobalError* error = service->sync_global_error(); |
| 332 if (error && error->HasCustomizedSyncMenuItem()) { | 334 if (error && error->HasCustomizedSyncMenuItem()) { |
| 333 error->ExecuteMenuItem(browser_); | 335 error->ExecuteMenuItem(browser_); |
| 334 return; | 336 return; |
| 335 } | 337 } |
| 336 } | 338 } |
| 337 | 339 |
| 338 if (command_id == IDC_HELP_PAGE) | 340 if (command_id == IDC_HELP_PAGE) |
| 339 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 341 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
| 340 | 342 |
| 341 browser_->ExecuteCommand(command_id); | 343 browser_->ExecuteCommand(command_id); |
| 342 } | 344 } |
| 343 | 345 |
| 344 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 346 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
| 345 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 347 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
| 346 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 348 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 347 } else if (command_id == IDC_PROFILING_ENABLED) { | 349 } else if (command_id == IDC_PROFILING_ENABLED) { |
| 348 return Profiling::BeingProfiled(); | 350 return Profiling::BeingProfiled(); |
| 349 } | 351 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 &enable_increment, &enable_decrement); | 594 &enable_increment, &enable_decrement); |
| 593 } | 595 } |
| 594 zoom_label_ = l10n_util::GetStringFUTF16( | 596 zoom_label_ = l10n_util::GetStringFUTF16( |
| 595 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 597 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 596 } | 598 } |
| 597 | 599 |
| 598 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 600 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
| 599 return sync_ui_util::GetSyncMenuLabel( | 601 return sync_ui_util::GetSyncMenuLabel( |
| 600 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 602 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |
| 601 } | 603 } |
| OLD | NEW |