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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 358 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
358 | 359 |
359 chrome::ExecuteCommand(browser_, command_id); | 360 chrome::ExecuteCommand(browser_, command_id); |
360 } | 361 } |
361 | 362 |
362 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 363 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
363 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 364 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
364 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 365 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
365 } else if (command_id == IDC_PROFILING_ENABLED) { | 366 } else if (command_id == IDC_PROFILING_ENABLED) { |
366 return Profiling::BeingProfiled(); | 367 return Profiling::BeingProfiled(); |
| 368 } else if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) { |
| 369 return chrome::IsRequestingTabletSite(browser_); |
367 } | 370 } |
368 | 371 |
369 return false; | 372 return false; |
370 } | 373 } |
371 | 374 |
372 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 375 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
373 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 376 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
374 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 377 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
375 if (error) | 378 if (error) |
376 return true; | 379 return true; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { | 543 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { |
541 const string16 short_product_name = | 544 const string16 short_product_name = |
542 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 545 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
543 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 546 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( |
544 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 547 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); |
545 AddSeparator(ui::NORMAL_SEPARATOR); | 548 AddSeparator(ui::NORMAL_SEPARATOR); |
546 } | 549 } |
547 | 550 |
548 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | 551 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
549 | 552 |
| 553 #if defined(OS_CHROMEOS) |
| 554 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 555 switches::kEnableRequestTabletSite)) |
| 556 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
| 557 IDS_TOGGLE_REQUEST_TABLET_SITE); |
| 558 #endif |
| 559 |
550 // On ChromeOS-Touch, we don't want the about/background pages menu options. | 560 // On ChromeOS-Touch, we don't want the about/background pages menu options. |
551 #if defined(OS_CHROMEOS) | 561 #if defined(OS_CHROMEOS) |
552 if (!is_new_menu) | 562 if (!is_new_menu) |
553 #endif | 563 #endif |
554 { | 564 { |
555 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 565 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
556 // We use the task manager to show background pages. | 566 // We use the task manager to show background pages. |
557 if (chrome::CanOpenTaskManager()) { | 567 if (chrome::CanOpenTaskManager()) { |
558 string16 num_background_pages = base::FormatNumber( | 568 string16 num_background_pages = base::FormatNumber( |
559 TaskManager::GetBackgroundPageCount()); | 569 TaskManager::GetBackgroundPageCount()); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 zoom_label_ = l10n_util::GetStringFUTF16( | 703 zoom_label_ = l10n_util::GetStringFUTF16( |
694 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 704 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
695 } | 705 } |
696 | 706 |
697 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 707 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
698 Profile* profile = browser_->profile()->GetOriginalProfile(); | 708 Profile* profile = browser_->profile()->GetOriginalProfile(); |
699 return sync_ui_util::GetSyncMenuLabel( | 709 return sync_ui_util::GetSyncMenuLabel( |
700 ProfileSyncServiceFactory::GetForProfile(profile), | 710 ProfileSyncServiceFactory::GetForProfile(profile), |
701 *SigninManagerFactory::GetForProfile(profile)); | 711 *SigninManagerFactory::GetForProfile(profile)); |
702 } | 712 } |
OLD | NEW |