Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 WebContents* current_tab = GetActiveWebContents(browser); | |
| 871 if (!current_tab) | |
| 872 return; | |
| 873 NavigationController& controller = current_tab->GetController(); | |
| 874 NavigationEntry* entry = controller.GetActiveEntry(); | |
| 875 if (!entry) | |
| 876 return; | |
| 877 if (entry->GetIsOverridingUserAgent()) { | |
| 878 entry->SetIsOverridingUserAgent(false); | |
| 879 } else { | |
| 880 entry->SetIsOverridingUserAgent(true); | |
| 881 current_tab->SetUserAgentOverride( | |
| 882 webkit_glue::BuildUserAgentOverrideForTabletSiteFromUserAgent( | |
| 883 content::GetUserAgent(entry->GetOriginalRequestURL()))); | |
| 884 } | |
| 885 controller.ReloadOriginalRequestURL(true); | |
| 886 } | |
| 887 | |
| 888 bool CanRequestTabletSite(Browser* browser) { | |
| 889 if (!browser) | |
| 890 return false; | |
| 891 WebContents* current_tab = GetActiveWebContents(browser); | |
| 892 if (!current_tab) | |
| 893 return false; | |
| 894 if (!current_tab->GetController().GetActiveEntry()) | |
|
Charlie Reis
2012/08/13 20:38:46
nit: return !!current_tab->GetController().GetActi
sschmitz
2012/09/06 16:44:02
Done.
| |
| 895 return false; | |
| 896 return true; | |
| 897 } | |
| 898 | |
| 867 void ToggleFullscreenMode(Browser* browser) { | 899 void ToggleFullscreenMode(Browser* browser) { |
| 868 browser->fullscreen_controller()->ToggleFullscreenMode(); | 900 browser->fullscreen_controller()->ToggleFullscreenMode(); |
| 869 } | 901 } |
| 870 | 902 |
| 871 void ClearCache(Browser* browser) { | 903 void ClearCache(Browser* browser) { |
| 872 BrowsingDataRemover* remover = new BrowsingDataRemover(browser->profile(), | 904 BrowsingDataRemover* remover = new BrowsingDataRemover(browser->profile(), |
| 873 BrowsingDataRemover::EVERYTHING, | 905 BrowsingDataRemover::EVERYTHING, |
| 874 base::Time()); | 906 base::Time()); |
| 875 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, | 907 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, |
| 876 BrowsingDataHelper::UNPROTECTED_WEB); | 908 BrowsingDataHelper::UNPROTECTED_WEB); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 if (!tab_contents) | 1021 if (!tab_contents) |
| 990 tab_contents = new TabContents(contents); | 1022 tab_contents = new TabContents(contents); |
| 991 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1023 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 992 | 1024 |
| 993 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1025 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 994 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1026 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 995 app_browser->window()->Show(); | 1027 app_browser->window()->Show(); |
| 996 } | 1028 } |
| 997 | 1029 |
| 998 } // namespace chrome | 1030 } // namespace chrome |
| OLD | NEW |