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" |
56 #include "ui/base/models/button_menu_item_model.h" | 57 #include "ui/base/models/button_menu_item_model.h" |
57 #include "ui/base/resource/resource_bundle.h" | 58 #include "ui/base/resource/resource_bundle.h" |
58 #include "ui/gfx/image/image.h" | 59 #include "ui/gfx/image/image.h" |
59 #include "ui/gfx/image/image_skia.h" | 60 #include "ui/gfx/image/image_skia.h" |
60 | 61 |
62 #if defined(OS_CHROMEOS) | |
63 #include "ui/base/touch/touch_factory.h" | |
64 #endif | |
65 | |
61 #if defined(TOOLKIT_GTK) | 66 #if defined(TOOLKIT_GTK) |
62 #include <gtk/gtk.h> | 67 #include <gtk/gtk.h> |
63 #include "chrome/browser/ui/gtk/gtk_util.h" | 68 #include "chrome/browser/ui/gtk/gtk_util.h" |
64 #endif | 69 #endif |
65 | 70 |
66 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
67 #include "base/win/metro.h" | 72 #include "base/win/metro.h" |
68 #include "base/win/windows_version.h" | 73 #include "base/win/windows_version.h" |
69 #include "chrome/browser/enumerate_modules_model_win.h" | 74 #include "chrome/browser/enumerate_modules_model_win.h" |
70 #endif | 75 #endif |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 360 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
356 | 361 |
357 chrome::ExecuteCommand(browser_, command_id); | 362 chrome::ExecuteCommand(browser_, command_id); |
358 } | 363 } |
359 | 364 |
360 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 365 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
361 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 366 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
362 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 367 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
363 } else if (command_id == IDC_PROFILING_ENABLED) { | 368 } else if (command_id == IDC_PROFILING_ENABLED) { |
364 return Profiling::BeingProfiled(); | 369 return Profiling::BeingProfiled(); |
370 } else if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) { | |
371 WebContents* current_tab = chrome::GetActiveWebContents(browser_); | |
sky
2012/09/07 18:05:30
Move this logic into a function, IsRequestingTable
sschmitz
2012/09/07 22:33:09
Done.
| |
372 if (!current_tab) | |
373 return false; | |
374 content::NavigationEntry* entry = | |
375 current_tab->GetController().GetActiveEntry(); | |
376 if (!entry) | |
377 return false; | |
378 return entry->GetIsOverridingUserAgent(); | |
365 } | 379 } |
366 | 380 |
367 return false; | 381 return false; |
368 } | 382 } |
369 | 383 |
370 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 384 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
371 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 385 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
372 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 386 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
373 if (error) | 387 if (error) |
374 return true; | 388 return true; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 540 |
527 if (browser_defaults::kShowSyncSetupMenuItem && | 541 if (browser_defaults::kShowSyncSetupMenuItem && |
528 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { | 542 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { |
529 const string16 short_product_name = | 543 const string16 short_product_name = |
530 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 544 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
531 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 545 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( |
532 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 546 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); |
533 AddSeparator(ui::NORMAL_SEPARATOR); | 547 AddSeparator(ui::NORMAL_SEPARATOR); |
534 } | 548 } |
535 | 549 |
536 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | 550 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);\ |
sky
2012/09/07 18:05:30
WHy the \ ?
sschmitz
2012/09/07 22:33:09
Oops, removed. Done.
| |
551 | |
552 #if defined(OS_CHROMEOS) | |
553 // Note: on Chromebooks with default to "Desktop Site" even for | |
sky
2012/09/07 18:05:30
Again, how come we don't have one in about:flags ?
sschmitz
2012/09/07 22:33:09
Removed one flag, removed the "and is-touch-device
| |
554 // Chromebooks with a touch screen. | |
555 // The following toggle lets the user switch to | |
556 // "Tablet Site". This functionality is under two flags: | |
557 // - to turn in on only for touch devices (intended use) | |
558 // - to turn it on regardless of touch device (for testing) | |
559 bool enable_flag = CommandLine::ForCurrentProcess()->HasSwitch( | |
560 switches::kEnableRequestTabletSite); | |
561 bool force_flag = CommandLine::ForCurrentProcess()->HasSwitch( | |
562 switches::kEnableRequestTabletSiteEvenIfNonTouchDevice); | |
563 if (force_flag || | |
564 (enable_flag && ui::TouchFactory::GetInstance()->IsTouchDevicePresent())) | |
565 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, | |
566 IDS_TOGGLE_REQUEST_TABLET_SITE); | |
567 #endif | |
537 | 568 |
538 // On ChromeOS-Touch, we don't want the about/background pages menu options. | 569 // On ChromeOS-Touch, we don't want the about/background pages menu options. |
539 #if defined(OS_CHROMEOS) | 570 #if defined(OS_CHROMEOS) |
540 if (!is_new_menu) | 571 if (!is_new_menu) |
541 #endif | 572 #endif |
542 { | 573 { |
543 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 574 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
544 // We use the task manager to show background pages. | 575 // We use the task manager to show background pages. |
545 if (chrome::CanOpenTaskManager()) { | 576 if (chrome::CanOpenTaskManager()) { |
546 string16 num_background_pages = base::FormatNumber( | 577 string16 num_background_pages = base::FormatNumber( |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 zoom_label_ = l10n_util::GetStringFUTF16( | 717 zoom_label_ = l10n_util::GetStringFUTF16( |
687 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 718 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
688 } | 719 } |
689 | 720 |
690 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 721 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
691 Profile* profile = browser_->profile()->GetOriginalProfile(); | 722 Profile* profile = browser_->profile()->GetOriginalProfile(); |
692 return sync_ui_util::GetSyncMenuLabel( | 723 return sync_ui_util::GetSyncMenuLabel( |
693 ProfileSyncServiceFactory::GetForProfile(profile), | 724 ProfileSyncServiceFactory::GetForProfile(profile), |
694 *SigninManagerFactory::GetForProfile(profile)); | 725 *SigninManagerFactory::GetForProfile(profile)); |
695 } | 726 } |
OLD | NEW |