| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 25 matching lines...) Expand all Loading... |
| 36 #include "chrome/browser/ui/metro_pin_tab_helper.h" | 36 #include "chrome/browser/ui/metro_pin_tab_helper.h" |
| 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 38 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 38 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 39 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 39 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 40 #include "chrome/browser/upgrade_detector.h" | 40 #include "chrome/browser/upgrade_detector.h" |
| 41 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 42 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 44 #include "chrome/common/profiling.h" | 44 #include "chrome/common/profiling.h" |
| 45 #include "content/public/browser/host_zoom_map.h" | 45 #include "content/public/browser/host_zoom_map.h" |
| 46 #include "content/public/browser/navigation_entry.h" |
| 46 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
| 47 #include "content/public/browser/notification_source.h" | 48 #include "content/public/browser/notification_source.h" |
| 48 #include "content/public/browser/notification_types.h" | 49 #include "content/public/browser/notification_types.h" |
| 49 #include "content/public/browser/user_metrics.h" | 50 #include "content/public/browser/user_metrics.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "grit/chromium_strings.h" | 52 #include "grit/chromium_strings.h" |
| 52 #include "grit/generated_resources.h" | 53 #include "grit/generated_resources.h" |
| 53 #include "grit/theme_resources.h" | 54 #include "grit/theme_resources.h" |
| 54 #include "ui/base/l10n/l10n_util.h" | 55 #include "ui/base/l10n/l10n_util.h" |
| 55 #include "ui/base/layout.h" | 56 #include "ui/base/layout.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 356 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
| 356 | 357 |
| 357 chrome::ExecuteCommand(browser_, command_id); | 358 chrome::ExecuteCommand(browser_, command_id); |
| 358 } | 359 } |
| 359 | 360 |
| 360 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 361 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
| 361 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 362 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
| 362 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 363 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 363 } else if (command_id == IDC_PROFILING_ENABLED) { | 364 } else if (command_id == IDC_PROFILING_ENABLED) { |
| 364 return Profiling::BeingProfiled(); | 365 return Profiling::BeingProfiled(); |
| 366 } else if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) { |
| 367 return chrome::IsRequestingTabletSite(browser_); |
| 365 } | 368 } |
| 366 | 369 |
| 367 return false; | 370 return false; |
| 368 } | 371 } |
| 369 | 372 |
| 370 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 373 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
| 371 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 374 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
| 372 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 375 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
| 373 if (error) | 376 if (error) |
| 374 return true; | 377 return true; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { | 541 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { |
| 539 const string16 short_product_name = | 542 const string16 short_product_name = |
| 540 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 543 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| 541 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 544 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( |
| 542 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 545 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); |
| 543 AddSeparator(ui::NORMAL_SEPARATOR); | 546 AddSeparator(ui::NORMAL_SEPARATOR); |
| 544 } | 547 } |
| 545 | 548 |
| 546 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | 549 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
| 547 | 550 |
| 551 #if defined(OS_CHROMEOS) |
| 552 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 553 switches::kEnableRequestTabletSite)) |
| 554 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
| 555 IDS_TOGGLE_REQUEST_TABLET_SITE); |
| 556 #endif |
| 557 |
| 548 // On ChromeOS-Touch, we don't want the about/background pages menu options. | 558 // On ChromeOS-Touch, we don't want the about/background pages menu options. |
| 549 #if defined(OS_CHROMEOS) | 559 #if defined(OS_CHROMEOS) |
| 550 if (!is_new_menu) | 560 if (!is_new_menu) |
| 551 #endif | 561 #endif |
| 552 { | 562 { |
| 553 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 563 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
| 554 // We use the task manager to show background pages. | 564 // We use the task manager to show background pages. |
| 555 if (chrome::CanOpenTaskManager()) { | 565 if (chrome::CanOpenTaskManager()) { |
| 556 string16 num_background_pages = base::FormatNumber( | 566 string16 num_background_pages = base::FormatNumber( |
| 557 TaskManager::GetBackgroundPageCount()); | 567 TaskManager::GetBackgroundPageCount()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 zoom_label_ = l10n_util::GetStringFUTF16( | 701 zoom_label_ = l10n_util::GetStringFUTF16( |
| 692 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 702 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 693 } | 703 } |
| 694 | 704 |
| 695 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 705 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
| 696 Profile* profile = browser_->profile()->GetOriginalProfile(); | 706 Profile* profile = browser_->profile()->GetOriginalProfile(); |
| 697 return sync_ui_util::GetSyncMenuLabel( | 707 return sync_ui_util::GetSyncMenuLabel( |
| 698 ProfileSyncServiceFactory::GetForProfile(profile), | 708 ProfileSyncServiceFactory::GetForProfile(profile), |
| 699 *SigninManagerFactory::GetForProfile(profile)); | 709 *SigninManagerFactory::GetForProfile(profile)); |
| 700 } | 710 } |
| OLD | NEW |