Chromium Code Reviews| Index: chrome/browser/ui/toolbar/wrench_menu_model.cc |
| diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc |
| index 6f5e608d7e244f07a7c6e8f31456c952ba70add2..7a913b19d36dcf4ac3dfd8f6a0b36071d64befe3 100644 |
| --- a/chrome/browser/ui/toolbar/wrench_menu_model.cc |
| +++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc |
| @@ -42,6 +42,7 @@ |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/profiling.h" |
| #include "content/public/browser/host_zoom_map.h" |
| +#include "content/public/browser/navigation_entry.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_source.h" |
| #include "content/public/browser/notification_types.h" |
| @@ -54,6 +55,7 @@ |
| #include "ui/base/layout.h" |
| #include "ui/base/models/button_menu_item_model.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/base/touch/touch_factory.h" |
| #include "ui/gfx/image/image.h" |
| #include "ui/gfx/image/image_skia.h" |
| @@ -361,6 +363,11 @@ bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
| return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| } else if (command_id == IDC_PROFILING_ENABLED) { |
| return Profiling::BeingProfiled(); |
| + } else if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) { |
| + content::NavigationEntry* entry = GetActiveNavigationEntry(); |
|
sky
2012/08/06 21:41:06
Can this functionality (and 382) be moved to brows
sschmitz
2012/08/07 02:19:49
I moved "382", IsCommandEnabled, to browser_comman
|
| + if (!entry) |
| + return false; // The control is disabled in this case. |
| + return entry->GetIsOverridingUserAgent(); |
| } |
| return false; |
| @@ -372,6 +379,13 @@ bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
| if (error) |
| return true; |
| + if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) { |
| + // Disable the control when there is no active navigation entry. |
| + // Otherwise follow "normal" rules. |
| + if (!GetActiveNavigationEntry()) |
| + return false; |
| + } |
| + |
| return chrome::IsCommandEnabled(browser_, command_id); |
| } |
| @@ -505,6 +519,23 @@ void WrenchMenuModel::Build() { |
| AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
| +#if defined(OS_CHROMEOS) |
| + // Note: on Chromebooks with default to "Desktop Site" even for |
| + // Chromebooks with a touch screen. |
| + // The following toggle lets the user switch to |
| + // "Tablet Site". This functionality is under two flags: |
| + // - to turn in on only for touch devices (intended use) |
| + // - to turn it on regardless of touch device (for testing) |
| + bool enable_flag = CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableRequestTabletSite); |
| + bool force_flag = CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableRequestTabletSiteEvenIfNonTouchDevice); |
| + if (force_flag || |
| + (enable_flag && ui::TouchFactory::GetInstance()->IsTouchDevicePresent())) |
| + AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
| + IDS_TOGGLE_REQUEST_TABLET_SITE); |
| +#endif |
| + |
| if (!is_touch_menu) { |
| AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
| string16 num_background_pages = base::FormatNumber( |
| @@ -640,6 +671,15 @@ void WrenchMenuModel::UpdateZoomControls() { |
| IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| } |
| +content::NavigationEntry* WrenchMenuModel::GetActiveNavigationEntry() const { |
| + if (!browser_) |
| + return NULL; |
| + content::WebContents* current_tab = chrome::GetActiveWebContents(browser_); |
| + if (!current_tab) |
| + return NULL; |
| + return current_tab->GetController().GetActiveEntry(); |
| +} |
| + |
| string16 WrenchMenuModel::GetSyncMenuLabel() const { |
| Profile* profile = browser_->profile()->GetOriginalProfile(); |
| return sync_ui_util::GetSyncMenuLabel( |