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

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: removed spurious newline Created 8 years, 3 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/browser/web_intents_dispatcher.h" 65 #include "content/public/browser/web_intents_dispatcher.h"
66 #include "content/public/common/content_client.h"
66 #include "content/public/common/content_restriction.h" 67 #include "content/public/common/content_restriction.h"
67 #include "content/public/common/renderer_preferences.h" 68 #include "content/public/common/renderer_preferences.h"
68 #include "content/public/common/url_constants.h" 69 #include "content/public/common/url_constants.h"
69 #include "net/base/escape.h" 70 #include "net/base/escape.h"
71 #include "webkit/glue/user_agent.h"
70 #include "webkit/glue/web_intent_data.h" 72 #include "webkit/glue/web_intent_data.h"
71 #include "webkit/glue/webkit_glue.h" 73 #include "webkit/glue/webkit_glue.h"
72 74
73 #if defined(OS_MACOSX) 75 #if defined(OS_MACOSX)
74 #include "ui/base/cocoa/find_pasteboard.h" 76 #include "ui/base/cocoa/find_pasteboard.h"
75 #endif 77 #endif
76 78
77 #if defined(OS_WIN) 79 #if defined(OS_WIN)
78 #include "base/win/metro.h" 80 #include "base/win/metro.h"
79 #endif 81 #endif
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 863
862 void OpenUpdateChromeDialog(Browser* browser) { 864 void OpenUpdateChromeDialog(Browser* browser) {
863 content::RecordAction(UserMetricsAction("UpdateChrome")); 865 content::RecordAction(UserMetricsAction("UpdateChrome"));
864 browser->window()->ShowUpdateChromeDialog(); 866 browser->window()->ShowUpdateChromeDialog();
865 } 867 }
866 868
867 void ToggleSpeechInput(Browser* browser) { 869 void ToggleSpeechInput(Browser* browser) {
868 GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput(); 870 GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput();
869 } 871 }
870 872
873 void ToggleRequestTabletSite(Browser* browser) {
874 WebContents* current_tab = GetActiveWebContents(browser);
875 if (!current_tab)
876 return;
877 NavigationController& controller = current_tab->GetController();
878 NavigationEntry* entry = controller.GetActiveEntry();
879 if (!entry)
880 return;
881 if (entry->GetIsOverridingUserAgent()) {
882 entry->SetIsOverridingUserAgent(false);
883 } else {
884 entry->SetIsOverridingUserAgent(true);
885 current_tab->SetUserAgentOverride(
886 webkit_glue::BuildUserAgentOverrideForTabletSiteFromProduct(
887 content::GetContentClient()->GetProduct()));
888 }
889 controller.ReloadOriginalRequestURL(true);
890 }
891
892 bool CanRequestTabletSite(Browser* browser) {
893 if (!browser)
894 return false;
895 WebContents* current_tab = GetActiveWebContents(browser);
896 if (!current_tab)
897 return false;
898 return !!current_tab->GetController().GetActiveEntry();
gone 2012/09/06 18:08:32 Is this supposed to be a double !!?
sschmitz 2012/09/06 18:52:45 Yes, but since you ask, I changed to "... != NULL"
899 }
900
871 void ToggleFullscreenMode(Browser* browser) { 901 void ToggleFullscreenMode(Browser* browser) {
872 browser->fullscreen_controller()->ToggleFullscreenMode(); 902 browser->fullscreen_controller()->ToggleFullscreenMode();
873 } 903 }
874 904
875 void ClearCache(Browser* browser) { 905 void ClearCache(Browser* browser) {
876 BrowsingDataRemover* remover = 906 BrowsingDataRemover* remover =
877 BrowsingDataRemover::CreateForUnboundedRange(browser->profile()); 907 BrowsingDataRemover::CreateForUnboundedRange(browser->profile());
878 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, 908 remover->Remove(BrowsingDataRemover::REMOVE_CACHE,
879 BrowsingDataHelper::UNPROTECTED_WEB); 909 BrowsingDataHelper::UNPROTECTED_WEB);
880 // BrowsingDataRemover takes care of deleting itself when done. 910 // BrowsingDataRemover takes care of deleting itself when done.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 BrowserCommandsTabContentsCreator::CreateTabContents(contents); 1028 BrowserCommandsTabContentsCreator::CreateTabContents(contents);
999 } 1029 }
1000 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 1030 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
1001 1031
1002 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1032 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1003 contents->GetRenderViewHost()->SyncRendererPrefs(); 1033 contents->GetRenderViewHost()->SyncRendererPrefs();
1004 app_browser->window()->Show(); 1034 app_browser->window()->Show();
1005 } 1035 }
1006 1036
1007 } // namespace chrome 1037 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698