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 { | |
| 871 WebContents* current_tab = GetActiveWebContents(browser); | |
| 872 if (!current_tab) return; | |
|
Rick Byers
2012/08/03 15:53:06
newline before return
If there's no current tab,
sschmitz
2012/08/03 18:11:43
I made a code change elsewhere to disable the cont
| |
| 873 NavigationController& controller = current_tab->GetController(); | |
| 874 NavigationEntry* entry = controller.GetActiveEntry(); | |
| 875 if (!entry) return; | |
|
Rick Byers
2012/08/03 15:53:06
If there's no active entry we should probably stil
sschmitz
2012/08/03 18:11:43
Same as above: control is disabled; comment in cod
| |
| 876 if (entry->GetIsOverridingUserAgent()) { | |
| 877 entry->SetIsOverridingUserAgent(false); | |
| 878 const int entryCount = controller.GetEntryCount(); | |
| 879 for (int ii = 0; ii < entryCount; ++ii) { | |
| 880 NavigationEntry* entryAtIdx = controller.GetEntryAtIndex(ii); | |
| 881 if (entryAtIdx) entryAtIdx->SetIsOverridingUserAgent(false); | |
| 882 } | |
| 883 current_tab->SetUserAgentOverride(std::string()); | |
| 884 } else { | |
| 885 entry->SetIsOverridingUserAgent(true); | |
| 886 const int entryCount = controller.GetEntryCount(); | |
| 887 for (int ii = 0; ii < entryCount; ++ii) { | |
| 888 NavigationEntry* entryAtIdx = controller.GetEntryAtIndex(ii); | |
| 889 if (entryAtIdx) entryAtIdx->SetIsOverridingUserAgent(true); | |
| 890 } | |
| 891 current_tab->SetUserAgentOverride( | |
| 892 webkit_glue::BuildUserAgentOverrideForTabletSiteFromUserAgent( | |
| 893 content::GetUserAgent(entry->GetOriginalRequestURL()))); | |
| 894 } | |
| 895 controller.Reload(true); | |
| 896 } | |
| 897 | |
| 867 void ToggleFullscreenMode(Browser* browser) { | 898 void ToggleFullscreenMode(Browser* browser) { |
| 868 browser->fullscreen_controller()->ToggleFullscreenMode(); | 899 browser->fullscreen_controller()->ToggleFullscreenMode(); |
| 869 } | 900 } |
| 870 | 901 |
| 871 void ClearCache(Browser* browser) { | 902 void ClearCache(Browser* browser) { |
| 872 BrowsingDataRemover* remover = new BrowsingDataRemover(browser->profile(), | 903 BrowsingDataRemover* remover = new BrowsingDataRemover(browser->profile(), |
| 873 BrowsingDataRemover::EVERYTHING, | 904 BrowsingDataRemover::EVERYTHING, |
| 874 base::Time()); | 905 base::Time()); |
| 875 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, | 906 remover->Remove(BrowsingDataRemover::REMOVE_CACHE, |
| 876 BrowsingDataHelper::UNPROTECTED_WEB); | 907 BrowsingDataHelper::UNPROTECTED_WEB); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 if (!tab_contents) | 1020 if (!tab_contents) |
| 990 tab_contents = new TabContents(contents); | 1021 tab_contents = new TabContents(contents); |
| 991 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1022 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 992 | 1023 |
| 993 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1024 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 994 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1025 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 995 app_browser->window()->Show(); | 1026 app_browser->window()->Show(); |
| 996 } | 1027 } |
| 997 | 1028 |
| 998 } // namespace chrome | 1029 } // namespace chrome |
| OLD | NEW |