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

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 Created 8 years, 6 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 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 NULL, 1128 NULL,
1128 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), 1129 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT),
1129 true)); 1130 true));
1130 } 1131 }
1131 1132
1132 // static 1133 // static
1133 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, 1134 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents,
1134 const std::string& protocol, 1135 const std::string& protocol,
1135 const GURL& url, 1136 const GURL& url,
1136 const string16& title, 1137 const string16& title,
1137 bool user_gesture) { 1138 bool user_gesture,
1139 BrowserWindow* window) {
1138 TabContents* tab_contents = TabContents::FromWebContents(web_contents); 1140 TabContents* tab_contents = TabContents::FromWebContents(web_contents);
1139 if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) 1141 if (!tab_contents || tab_contents->profile()->IsOffTheRecord())
1140 return; 1142 return;
1141 1143
1142 ProtocolHandler handler = 1144 ProtocolHandler handler =
1143 ProtocolHandler::CreateProtocolHandler(protocol, url, title); 1145 ProtocolHandler::CreateProtocolHandler(protocol, url, title);
1144 1146
1145 ProtocolHandlerRegistry* registry = 1147 ProtocolHandlerRegistry* registry =
1146 tab_contents->profile()->GetProtocolHandlerRegistry(); 1148 tab_contents->profile()->GetProtocolHandlerRegistry();
1149 TabSpecificContentSettings* content_settings =
1150 tab_contents->content_settings();
1151
1152 if (!user_gesture && window) {
1153 content_settings->set_pending_protocol_handler(handler);
1154 content_settings->set_previous_protocol_handler(
1155 registry->GetHandlerFor(handler.protocol()));
1156 window->GetLocationBar()->UpdateContentSettingsIcons();
1157 return;
1158 }
1159
1160 // Make sure content-setting icon is turned off in case the page does
1161 // ungestured and gestured RPH calls.
1162 if (window) {
1163 content_settings->ClearPendingProtocolHandler();
1164 window->GetLocationBar()->UpdateContentSettingsIcons();
1165 }
1147 1166
1148 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { 1167 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) {
1149 content::RecordAction( 1168 content::RecordAction(
1150 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 1169 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
1151 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); 1170 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
1152 1171
1153 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = 1172 RegisterProtocolHandlerInfoBarDelegate* rph_delegate =
1154 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, 1173 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper,
1155 registry, 1174 registry,
1156 handler); 1175 handler);
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 void Browser::JSOutOfMemory(WebContents* web_contents) { 2521 void Browser::JSOutOfMemory(WebContents* web_contents) {
2503 JSOutOfMemoryHelper(web_contents); 2522 JSOutOfMemoryHelper(web_contents);
2504 } 2523 }
2505 2524
2506 void Browser::RegisterProtocolHandler(WebContents* web_contents, 2525 void Browser::RegisterProtocolHandler(WebContents* web_contents,
2507 const std::string& protocol, 2526 const std::string& protocol,
2508 const GURL& url, 2527 const GURL& url,
2509 const string16& title, 2528 const string16& title,
2510 bool user_gesture) { 2529 bool user_gesture) {
2511 RegisterProtocolHandlerHelper( 2530 RegisterProtocolHandlerHelper(
2512 web_contents, protocol, url, title, user_gesture); 2531 web_contents, protocol, url, title, user_gesture, window());
2513 } 2532 }
2514 2533
2515 void Browser::RegisterIntentHandler( 2534 void Browser::RegisterIntentHandler(
2516 WebContents* web_contents, 2535 WebContents* web_contents,
2517 const webkit_glue::WebIntentServiceData& data, 2536 const webkit_glue::WebIntentServiceData& data,
2518 bool user_gesture) { 2537 bool user_gesture) {
2519 RegisterIntentHandlerHelper(web_contents, data, user_gesture); 2538 RegisterIntentHandlerHelper(web_contents, data, user_gesture);
2520 } 2539 }
2521 2540
2522 void Browser::WebIntentDispatch( 2541 void Browser::WebIntentDispatch(
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 if (contents && !allow_js_access) { 3918 if (contents && !allow_js_access) {
3900 contents->web_contents()->GetController().LoadURL( 3919 contents->web_contents()->GetController().LoadURL(
3901 target_url, 3920 target_url,
3902 content::Referrer(), 3921 content::Referrer(),
3903 content::PAGE_TRANSITION_LINK, 3922 content::PAGE_TRANSITION_LINK,
3904 std::string()); // No extra headers. 3923 std::string()); // No extra headers.
3905 } 3924 }
3906 3925
3907 return contents != NULL; 3926 return contents != NULL;
3908 } 3927 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698