Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 10827146: crbug.com/127841 - Request Tablet Site on CB with touch screen. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Disable RTS control when no tab or no nav. entry; impl. reviewer comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ffd6f216e956eb74524cb53bd5daa8d5d2f8bb8d 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,17 @@ 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) {
+ if (!browser_)
+ return false; // The control is disabled (dim) in this case
+ content::WebContents* current_tab = chrome::GetActiveWebContents(browser_);
+ if (!current_tab)
+ return false; // The control is disabled (dim) in this case
+ content::NavigationEntry *entry =
+ current_tab->GetController().GetActiveEntry();
+ if (!entry)
+ return false; // The control is disabled (dim) in this case
gone 2012/08/03 20:13:26 Make a catch-all comment stating this instead of t
sschmitz 2012/08/03 21:20:51 Done.
+ return entry->GetIsOverridingUserAgent();
}
return false;
@@ -372,6 +385,19 @@ bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const {
if (error)
return true;
+ if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) {
+ if (!browser_)
+ return false;
+ content::WebContents* current_tab = chrome::GetActiveWebContents(browser_);
+ if (!current_tab)
+ return false;
+ content::NavigationEntry *entry =
+ current_tab->GetController().GetActiveEntry();
+ if (!entry)
+ return false;
gone 2012/08/03 20:13:26 Re-factor this check out into its own function sin
sschmitz 2012/08/03 21:20:51 Done.
+ // Now fall through to normal behavior
+ }
+
return chrome::IsCommandEnabled(browser_, command_id);
}
@@ -505,6 +531,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 enableFlag = CommandLine::ForCurrentProcess()->HasSwitch(
gone 2012/08/03 20:13:26 Style: don't use camel case
sschmitz 2012/08/03 21:20:51 Done.
+ switches::kEnableRequestTabletSite);
+ bool forceFlag = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRequestTabletSiteEvenIfNonTouchDevice);
+ if (forceFlag ||
+ (enableFlag && 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(

Powered by Google App Engine
This is Rietveld 408576698