OLD | NEW |
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 Loading... |
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" |
70 #include "webkit/glue/web_intent_data.h" | 71 #include "webkit/glue/web_intent_data.h" |
71 #include "webkit/glue/webkit_glue.h" | 72 #include "webkit/glue/webkit_glue.h" |
| 73 #include "webkit/user_agent/user_agent_util.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 |
80 | 82 |
| 83 namespace { |
| 84 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; |
| 85 } |
| 86 |
81 using content::NavigationController; | 87 using content::NavigationController; |
82 using content::NavigationEntry; | 88 using content::NavigationEntry; |
83 using content::OpenURLParams; | 89 using content::OpenURLParams; |
84 using content::Referrer; | 90 using content::Referrer; |
85 using content::SSLStatus; | 91 using content::SSLStatus; |
86 using content::UserMetricsAction; | 92 using content::UserMetricsAction; |
87 using content::WebContents; | 93 using content::WebContents; |
88 | 94 |
89 // TODO(avi): Kill this when TabContents goes away. | 95 // TODO(avi): Kill this when TabContents goes away. |
90 class BrowserCommandsTabContentsCreator { | 96 class BrowserCommandsTabContentsCreator { |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 | 868 |
863 void OpenUpdateChromeDialog(Browser* browser) { | 869 void OpenUpdateChromeDialog(Browser* browser) { |
864 content::RecordAction(UserMetricsAction("UpdateChrome")); | 870 content::RecordAction(UserMetricsAction("UpdateChrome")); |
865 browser->window()->ShowUpdateChromeDialog(); | 871 browser->window()->ShowUpdateChromeDialog(); |
866 } | 872 } |
867 | 873 |
868 void ToggleSpeechInput(Browser* browser) { | 874 void ToggleSpeechInput(Browser* browser) { |
869 GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput(); | 875 GetActiveWebContents(browser)->GetRenderViewHost()->ToggleSpeechInput(); |
870 } | 876 } |
871 | 877 |
| 878 bool CanRequestTabletSite(WebContents* current_tab) { |
| 879 if (!current_tab) |
| 880 return false; |
| 881 return current_tab->GetController().GetActiveEntry() != NULL; |
| 882 } |
| 883 |
| 884 bool IsRequestingTabletSite(Browser* browser) { |
| 885 WebContents* current_tab = chrome::GetActiveWebContents(browser); |
| 886 if (!current_tab) |
| 887 return false; |
| 888 content::NavigationEntry* entry = |
| 889 current_tab->GetController().GetActiveEntry(); |
| 890 if (!entry) |
| 891 return false; |
| 892 return entry->GetIsOverridingUserAgent(); |
| 893 } |
| 894 |
| 895 void ToggleRequestTabletSite(Browser* browser) { |
| 896 WebContents* current_tab = GetActiveWebContents(browser); |
| 897 if (!current_tab) |
| 898 return; |
| 899 NavigationController& controller = current_tab->GetController(); |
| 900 NavigationEntry* entry = controller.GetActiveEntry(); |
| 901 if (!entry) |
| 902 return; |
| 903 if (entry->GetIsOverridingUserAgent()) { |
| 904 entry->SetIsOverridingUserAgent(false); |
| 905 } else { |
| 906 entry->SetIsOverridingUserAgent(true); |
| 907 current_tab->SetUserAgentOverride( |
| 908 webkit_glue::BuildUserAgentFromOSAndProduct( |
| 909 kOsOverrideForTabletSite, |
| 910 content::GetContentClient()->GetProduct())); |
| 911 } |
| 912 controller.ReloadOriginalRequestURL(true); |
| 913 } |
| 914 |
872 void ToggleFullscreenMode(Browser* browser) { | 915 void ToggleFullscreenMode(Browser* browser) { |
873 browser->fullscreen_controller()->ToggleFullscreenMode(); | 916 browser->fullscreen_controller()->ToggleFullscreenMode(); |
874 } | 917 } |
875 | 918 |
876 void ClearCache(Browser* browser) { | 919 void ClearCache(Browser* browser) { |
877 BrowsingDataRemover* remover = | 920 BrowsingDataRemover* remover = |
878 BrowsingDataRemover::CreateForUnboundedRange(browser->profile()); | 921 BrowsingDataRemover::CreateForUnboundedRange(browser->profile()); |
879 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, | 922 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, |
880 BrowsingDataHelper::UNPROTECTED_WEB); | 923 BrowsingDataHelper::UNPROTECTED_WEB); |
881 // BrowsingDataRemover takes care of deleting itself when done. | 924 // BrowsingDataRemover takes care of deleting itself when done. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 BrowserCommandsTabContentsCreator::CreateTabContents(contents); | 1042 BrowserCommandsTabContentsCreator::CreateTabContents(contents); |
1000 } | 1043 } |
1001 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1044 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
1002 | 1045 |
1003 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1046 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1004 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1047 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1005 app_browser->window()->Show(); | 1048 app_browser->window()->Show(); |
1006 } | 1049 } |
1007 | 1050 |
1008 } // namespace chrome | 1051 } // namespace chrome |
OLD | NEW |