| 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" |
| 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 Loading... |
| 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 bool CanRequestTabletSite(WebContents* current_tab) { |
| 874 if (!current_tab) |
| 875 return false; |
| 876 return current_tab->GetController().GetActiveEntry() != NULL; |
| 877 } |
| 878 |
| 879 bool IsRequestingTabletSite(Browser* browser) { |
| 880 WebContents* current_tab = chrome::GetActiveWebContents(browser); |
| 881 if (!current_tab) |
| 882 return false; |
| 883 content::NavigationEntry* entry = |
| 884 current_tab->GetController().GetActiveEntry(); |
| 885 if (!entry) |
| 886 return false; |
| 887 return entry->GetIsOverridingUserAgent(); |
| 888 } |
| 889 |
| 890 void ToggleRequestTabletSite(Browser* browser) { |
| 891 WebContents* current_tab = GetActiveWebContents(browser); |
| 892 if (!current_tab) |
| 893 return; |
| 894 NavigationController& controller = current_tab->GetController(); |
| 895 NavigationEntry* entry = controller.GetActiveEntry(); |
| 896 if (!entry) |
| 897 return; |
| 898 if (entry->GetIsOverridingUserAgent()) { |
| 899 entry->SetIsOverridingUserAgent(false); |
| 900 } else { |
| 901 entry->SetIsOverridingUserAgent(true); |
| 902 current_tab->SetUserAgentOverride( |
| 903 webkit_glue::BuildUserAgentOverrideForTabletSiteFromProduct( |
| 904 content::GetContentClient()->GetProduct())); |
| 905 } |
| 906 controller.ReloadOriginalRequestURL(true); |
| 907 } |
| 908 |
| 871 void ToggleFullscreenMode(Browser* browser) { | 909 void ToggleFullscreenMode(Browser* browser) { |
| 872 browser->fullscreen_controller()->ToggleFullscreenMode(); | 910 browser->fullscreen_controller()->ToggleFullscreenMode(); |
| 873 } | 911 } |
| 874 | 912 |
| 875 void ClearCache(Browser* browser) { | 913 void ClearCache(Browser* browser) { |
| 876 BrowsingDataRemover* remover = | 914 BrowsingDataRemover* remover = |
| 877 BrowsingDataRemover::CreateForUnboundedRange(browser->profile()); | 915 BrowsingDataRemover::CreateForUnboundedRange(browser->profile()); |
| 878 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, | 916 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, |
| 879 BrowsingDataHelper::UNPROTECTED_WEB); | 917 BrowsingDataHelper::UNPROTECTED_WEB); |
| 880 // BrowsingDataRemover takes care of deleting itself when done. | 918 // BrowsingDataRemover takes care of deleting itself when done. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 BrowserCommandsTabContentsCreator::CreateTabContents(contents); | 1036 BrowserCommandsTabContentsCreator::CreateTabContents(contents); |
| 999 } | 1037 } |
| 1000 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1038 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 1001 | 1039 |
| 1002 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1040 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1003 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1041 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1004 app_browser->window()->Show(); | 1042 app_browser->window()->Show(); |
| 1005 } | 1043 } |
| 1006 | 1044 |
| 1007 } // namespace chrome | 1045 } // namespace chrome |
| OLD | NEW |