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

Unified Diff: chrome/browser/ui/browser_commands.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/browser_commands.cc
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 423efc915ea14d1bdfdb860592384f17b6eef198..bdad378f70c325a59a293f0262c55ff96043db0e 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -62,10 +62,12 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+#include "content/public/common/content_client.h"
#include "content/public/common/content_restriction.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/url_constants.h"
#include "net/base/escape.h"
+#include "webkit/glue/user_agent.h"
#include "webkit/glue/webkit_glue.h"
#if defined(OS_MACOSX)
@@ -864,6 +866,37 @@ void ToggleSpeechInput(Browser* browser) {
GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput();
}
+void ToggleRequestTabletSite(Browser* browser)
+{
+ WebContents* current_tab = GetActiveWebContents(browser);
+ if (!current_tab)
+ return; // The control is disabled in this case
gone 2012/08/03 20:13:26 Maybe put a general comment above about the contro
sschmitz 2012/08/03 21:20:51 Done.
+ NavigationController& controller = current_tab->GetController();
+ NavigationEntry* entry = controller.GetActiveEntry();
+ if (!entry)
+ return; // The control is disabled (dim) in this case
+ if (entry->GetIsOverridingUserAgent()) {
+ entry->SetIsOverridingUserAgent(false);
+ const int entryCount = controller.GetEntryCount();
+ for (int ii = 0; ii < entryCount; ++ii) {
+ NavigationEntry* entryAtIdx = controller.GetEntryAtIndex(ii);
gone 2012/08/03 20:13:26 Can't remember what the style guide says exactly,
sschmitz 2012/08/03 21:20:51 Done.
+ if (entryAtIdx) entryAtIdx->SetIsOverridingUserAgent(false);
+ }
+ current_tab->SetUserAgentOverride(std::string());
+ } else {
+ entry->SetIsOverridingUserAgent(true);
+ const int entryCount = controller.GetEntryCount();
+ for (int ii = 0; ii < entryCount; ++ii) {
+ NavigationEntry* entryAtIdx = controller.GetEntryAtIndex(ii);
+ if (entryAtIdx) entryAtIdx->SetIsOverridingUserAgent(true);
+ }
+ current_tab->SetUserAgentOverride(
+ webkit_glue::BuildUserAgentOverrideForTabletSiteFromUserAgent(
+ content::GetUserAgent(entry->GetOriginalRequestURL())));
+ }
+ controller.Reload(true);
+}
+
void ToggleFullscreenMode(Browser* browser) {
browser->fullscreen_controller()->ToggleFullscreenMode();
}

Powered by Google App Engine
This is Rietveld 408576698