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

Side by Side 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 unified diff | Download patch
OLDNEW
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/browser_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "chrome/common/chrome_switches.h" 55 #include "chrome/common/chrome_switches.h"
56 #include "chrome/common/pref_names.h" 56 #include "chrome/common/pref_names.h"
57 #include "content/public/browser/devtools_agent_host_registry.h" 57 #include "content/public/browser/devtools_agent_host_registry.h"
58 #include "content/public/browser/navigation_controller.h" 58 #include "content/public/browser/navigation_controller.h"
59 #include "content/public/browser/navigation_entry.h" 59 #include "content/public/browser/navigation_entry.h"
60 #include "content/public/browser/page_navigator.h" 60 #include "content/public/browser/page_navigator.h"
61 #include "content/public/browser/render_view_host.h" 61 #include "content/public/browser/render_view_host.h"
62 #include "content/public/browser/user_metrics.h" 62 #include "content/public/browser/user_metrics.h"
63 #include "content/public/browser/web_contents.h" 63 #include "content/public/browser/web_contents.h"
64 #include "content/public/browser/web_contents_view.h" 64 #include "content/public/browser/web_contents_view.h"
65 #include "content/public/common/content_client.h"
65 #include "content/public/common/content_restriction.h" 66 #include "content/public/common/content_restriction.h"
66 #include "content/public/common/renderer_preferences.h" 67 #include "content/public/common/renderer_preferences.h"
67 #include "content/public/common/url_constants.h" 68 #include "content/public/common/url_constants.h"
68 #include "net/base/escape.h" 69 #include "net/base/escape.h"
70 #include "webkit/glue/user_agent.h"
69 #include "webkit/glue/webkit_glue.h" 71 #include "webkit/glue/webkit_glue.h"
70 72
71 #if defined(OS_MACOSX) 73 #if defined(OS_MACOSX)
72 #include "ui/base/cocoa/find_pasteboard.h" 74 #include "ui/base/cocoa/find_pasteboard.h"
73 #endif 75 #endif
74 76
75 #if defined(OS_WIN) 77 #if defined(OS_WIN)
76 #include "base/win/metro.h" 78 #include "base/win/metro.h"
77 #endif 79 #endif
78 80
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 859
858 void OpenUpdateChromeDialog(Browser* browser) { 860 void OpenUpdateChromeDialog(Browser* browser) {
859 content::RecordAction(UserMetricsAction("UpdateChrome")); 861 content::RecordAction(UserMetricsAction("UpdateChrome"));
860 browser->window()->ShowUpdateChromeDialog(); 862 browser->window()->ShowUpdateChromeDialog();
861 } 863 }
862 864
863 void ToggleSpeechInput(Browser* browser) { 865 void ToggleSpeechInput(Browser* browser) {
864 GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput(); 866 GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput();
865 } 867 }
866 868
869 void ToggleRequestTabletSite(Browser* browser)
870 {
871 WebContents* current_tab = GetActiveWebContents(browser);
872 if (!current_tab)
873 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.
874 NavigationController& controller = current_tab->GetController();
875 NavigationEntry* entry = controller.GetActiveEntry();
876 if (!entry)
877 return; // The control is disabled (dim) in this case
878 if (entry->GetIsOverridingUserAgent()) {
879 entry->SetIsOverridingUserAgent(false);
880 const int entryCount = controller.GetEntryCount();
881 for (int ii = 0; ii < entryCount; ++ii) {
882 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.
883 if (entryAtIdx) entryAtIdx->SetIsOverridingUserAgent(false);
884 }
885 current_tab->SetUserAgentOverride(std::string());
886 } else {
887 entry->SetIsOverridingUserAgent(true);
888 const int entryCount = controller.GetEntryCount();
889 for (int ii = 0; ii < entryCount; ++ii) {
890 NavigationEntry* entryAtIdx = controller.GetEntryAtIndex(ii);
891 if (entryAtIdx) entryAtIdx->SetIsOverridingUserAgent(true);
892 }
893 current_tab->SetUserAgentOverride(
894 webkit_glue::BuildUserAgentOverrideForTabletSiteFromUserAgent(
895 content::GetUserAgent(entry->GetOriginalRequestURL())));
896 }
897 controller.Reload(true);
898 }
899
867 void ToggleFullscreenMode(Browser* browser) { 900 void ToggleFullscreenMode(Browser* browser) {
868 browser->fullscreen_controller()->ToggleFullscreenMode(); 901 browser->fullscreen_controller()->ToggleFullscreenMode();
869 } 902 }
870 903
871 void ClearCache(Browser* browser) { 904 void ClearCache(Browser* browser) {
872 BrowsingDataRemover* remover = new BrowsingDataRemover(browser->profile(), 905 BrowsingDataRemover* remover = new BrowsingDataRemover(browser->profile(),
873 BrowsingDataRemover::EVERYTHING, 906 BrowsingDataRemover::EVERYTHING,
874 base::Time()); 907 base::Time());
875 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, 908 remover->Remove(BrowsingDataRemover::REMOVE_CACHE,
876 BrowsingDataHelper::UNPROTECTED_WEB); 909 BrowsingDataHelper::UNPROTECTED_WEB);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 if (!tab_contents) 1022 if (!tab_contents)
990 tab_contents = new TabContents(contents); 1023 tab_contents = new TabContents(contents);
991 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 1024 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
992 1025
993 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1026 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
994 contents->GetRenderViewHost()->SyncRendererPrefs(); 1027 contents->GetRenderViewHost()->SyncRendererPrefs();
995 app_browser->window()->Show(); 1028 app_browser->window()->Show();
996 } 1029 }
997 1030
998 } // namespace chrome 1031 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698