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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 10584042: Bring up a content settings icon for ungestured registerProtocolHandler call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Repair merge to head Created 8 years, 5 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 | Annotate | Revision Log
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.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/autofill/personal_data_manager_factory.h" 30 #include "chrome/browser/autofill/personal_data_manager_factory.h"
31 #include "chrome/browser/background/background_contents_service.h" 31 #include "chrome/browser/background/background_contents_service.h"
32 #include "chrome/browser/background/background_contents_service_factory.h" 32 #include "chrome/browser/background/background_contents_service_factory.h"
33 #include "chrome/browser/bookmarks/bookmark_model.h" 33 #include "chrome/browser/bookmarks/bookmark_model.h"
34 #include "chrome/browser/bookmarks/bookmark_utils.h" 34 #include "chrome/browser/bookmarks/bookmark_utils.h"
35 #include "chrome/browser/browser_process.h" 35 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/browser_shutdown.h" 36 #include "chrome/browser/browser_shutdown.h"
37 #include "chrome/browser/character_encoding.h" 37 #include "chrome/browser/character_encoding.h"
38 #include "chrome/browser/chrome_page_zoom.h" 38 #include "chrome/browser/chrome_page_zoom.h"
39 #include "chrome/browser/content_settings/host_content_settings_map.h" 39 #include "chrome/browser/content_settings/host_content_settings_map.h"
40 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
40 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 41 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
41 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" 42 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
42 #include "chrome/browser/debugger/devtools_toggle_action.h" 43 #include "chrome/browser/debugger/devtools_toggle_action.h"
43 #include "chrome/browser/debugger/devtools_window.h" 44 #include "chrome/browser/debugger/devtools_window.h"
44 #include "chrome/browser/download/download_crx_util.h" 45 #include "chrome/browser/download/download_crx_util.h"
45 #include "chrome/browser/download/download_item_model.h" 46 #include "chrome/browser/download/download_item_model.h"
46 #include "chrome/browser/download/download_service.h" 47 #include "chrome/browser/download/download_service.h"
47 #include "chrome/browser/download/download_service_factory.h" 48 #include "chrome/browser/download/download_service_factory.h"
48 #include "chrome/browser/download/download_shelf.h" 49 #include "chrome/browser/download/download_shelf.h"
49 #include "chrome/browser/download/download_started_animation.h" 50 #include "chrome/browser/download/download_started_animation.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 NULL, 921 NULL,
921 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), 922 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT),
922 true)); 923 true));
923 } 924 }
924 925
925 // static 926 // static
926 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, 927 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents,
927 const std::string& protocol, 928 const std::string& protocol,
928 const GURL& url, 929 const GURL& url,
929 const string16& title, 930 const string16& title,
930 bool user_gesture) { 931 bool user_gesture,
932 BrowserWindow* window) {
931 TabContents* tab_contents = TabContents::FromWebContents(web_contents); 933 TabContents* tab_contents = TabContents::FromWebContents(web_contents);
932 if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) 934 if (!tab_contents || tab_contents->profile()->IsOffTheRecord())
933 return; 935 return;
934 936
935 ProtocolHandler handler = 937 ProtocolHandler handler =
936 ProtocolHandler::CreateProtocolHandler(protocol, url, title); 938 ProtocolHandler::CreateProtocolHandler(protocol, url, title);
937 939
938 ProtocolHandlerRegistry* registry = 940 ProtocolHandlerRegistry* registry =
939 tab_contents->profile()->GetProtocolHandlerRegistry(); 941 tab_contents->profile()->GetProtocolHandlerRegistry();
942 TabSpecificContentSettings* content_settings =
943 tab_contents->content_settings();
944
945 if (!user_gesture && window) {
946 content_settings->set_pending_protocol_handler(handler);
947 content_settings->set_previous_protocol_handler(
948 registry->GetHandlerFor(handler.protocol()));
949 window->GetLocationBar()->UpdateContentSettingsIcons();
950 return;
951 }
952
953 // Make sure content-setting icon is turned off in case the page does
954 // ungestured and gestured RPH calls.
955 if (window) {
956 content_settings->ClearPendingProtocolHandler();
957 window->GetLocationBar()->UpdateContentSettingsIcons();
958 }
940 959
941 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { 960 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) {
942 content::RecordAction( 961 content::RecordAction(
943 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 962 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
944 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); 963 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
945 964
946 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = 965 RegisterProtocolHandlerInfoBarDelegate* rph_delegate =
947 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, 966 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper,
948 registry, 967 registry,
949 handler); 968 handler);
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 void Browser::JSOutOfMemory(WebContents* web_contents) { 1898 void Browser::JSOutOfMemory(WebContents* web_contents) {
1880 JSOutOfMemoryHelper(web_contents); 1899 JSOutOfMemoryHelper(web_contents);
1881 } 1900 }
1882 1901
1883 void Browser::RegisterProtocolHandler(WebContents* web_contents, 1902 void Browser::RegisterProtocolHandler(WebContents* web_contents,
1884 const std::string& protocol, 1903 const std::string& protocol,
1885 const GURL& url, 1904 const GURL& url,
1886 const string16& title, 1905 const string16& title,
1887 bool user_gesture) { 1906 bool user_gesture) {
1888 RegisterProtocolHandlerHelper( 1907 RegisterProtocolHandlerHelper(
1889 web_contents, protocol, url, title, user_gesture); 1908 web_contents, protocol, url, title, user_gesture, window());
1890 } 1909 }
1891 1910
1892 void Browser::RegisterIntentHandler( 1911 void Browser::RegisterIntentHandler(
1893 WebContents* web_contents, 1912 WebContents* web_contents,
1894 const webkit_glue::WebIntentServiceData& data, 1913 const webkit_glue::WebIntentServiceData& data,
1895 bool user_gesture) { 1914 bool user_gesture) {
1896 RegisterIntentHandlerHelper(web_contents, data, user_gesture); 1915 RegisterIntentHandlerHelper(web_contents, data, user_gesture);
1897 } 1916 }
1898 1917
1899 void Browser::WebIntentDispatch( 1918 void Browser::WebIntentDispatch(
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 if (contents && !allow_js_access) { 2835 if (contents && !allow_js_access) {
2817 contents->web_contents()->GetController().LoadURL( 2836 contents->web_contents()->GetController().LoadURL(
2818 target_url, 2837 target_url,
2819 content::Referrer(), 2838 content::Referrer(),
2820 content::PAGE_TRANSITION_LINK, 2839 content::PAGE_TRANSITION_LINK,
2821 std::string()); // No extra headers. 2840 std::string()); // No extra headers.
2822 } 2841 }
2823 2842
2824 return contents != NULL; 2843 return contents != NULL;
2825 } 2844 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698