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

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: Review comments. Move to radio buttons 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 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 NULL, 1974 NULL,
1974 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), 1975 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT),
1975 true)); 1976 true));
1976 } 1977 }
1977 1978
1978 // static 1979 // static
1979 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, 1980 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents,
1980 const std::string& protocol, 1981 const std::string& protocol,
1981 const GURL& url, 1982 const GURL& url,
1982 const string16& title, 1983 const string16& title,
1983 bool user_gesture) { 1984 bool user_gesture,
1985 BrowserWindow* window) {
1984 TabContents* tab_contents = TabContents::FromWebContents(web_contents); 1986 TabContents* tab_contents = TabContents::FromWebContents(web_contents);
1985 if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) 1987 if (!tab_contents || tab_contents->profile()->IsOffTheRecord())
1986 return; 1988 return;
1987 1989
1988 ProtocolHandler handler = 1990 ProtocolHandler handler =
1989 ProtocolHandler::CreateProtocolHandler(protocol, url, title); 1991 ProtocolHandler::CreateProtocolHandler(protocol, url, title);
1990 1992
1991 ProtocolHandlerRegistry* registry = 1993 ProtocolHandlerRegistry* registry =
1992 tab_contents->profile()->GetProtocolHandlerRegistry(); 1994 tab_contents->profile()->GetProtocolHandlerRegistry();
1995 TabSpecificContentSettings* content_settings =
1996 tab_contents->content_settings();
1997
1998 if (!user_gesture && window) {
1999 content_settings->SetPendingProtocolHandler(handler);
2000 content_settings->SetPreviousProtocolHandler(
2001 registry->GetHandlerFor(handler.protocol()));
2002 window->GetLocationBar()->UpdateContentSettingsIcons();
2003 return;
2004 }
2005
2006 // Make sure content-setting icon is turned off in case the page does
2007 // ungestured and gestured RPH calls.
2008 content_settings->SetPendingProtocolHandler(
2009 ProtocolHandler::EmptyProtocolHandler());
2010 window->GetLocationBar()->UpdateContentSettingsIcons();
1993 2011
1994 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { 2012 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) {
1995 content::RecordAction( 2013 content::RecordAction(
1996 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 2014 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
1997 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); 2015 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
1998 2016
1999 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = 2017 RegisterProtocolHandlerInfoBarDelegate* rph_delegate =
2000 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, 2018 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper,
2001 registry, 2019 registry,
2002 handler); 2020 handler);
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
3354 void Browser::JSOutOfMemory(WebContents* web_contents) { 3372 void Browser::JSOutOfMemory(WebContents* web_contents) {
3355 JSOutOfMemoryHelper(web_contents); 3373 JSOutOfMemoryHelper(web_contents);
3356 } 3374 }
3357 3375
3358 void Browser::RegisterProtocolHandler(WebContents* web_contents, 3376 void Browser::RegisterProtocolHandler(WebContents* web_contents,
3359 const std::string& protocol, 3377 const std::string& protocol,
3360 const GURL& url, 3378 const GURL& url,
3361 const string16& title, 3379 const string16& title,
3362 bool user_gesture) { 3380 bool user_gesture) {
3363 RegisterProtocolHandlerHelper( 3381 RegisterProtocolHandlerHelper(
3364 web_contents, protocol, url, title, user_gesture); 3382 web_contents, protocol, url, title, user_gesture, window());
3365 } 3383 }
3366 3384
3367 void Browser::RegisterIntentHandler( 3385 void Browser::RegisterIntentHandler(
3368 WebContents* web_contents, 3386 WebContents* web_contents,
3369 const webkit_glue::WebIntentServiceData& data, 3387 const webkit_glue::WebIntentServiceData& data,
3370 bool user_gesture) { 3388 bool user_gesture) {
3371 RegisterIntentHandlerHelper(web_contents, data, user_gesture); 3389 RegisterIntentHandlerHelper(web_contents, data, user_gesture);
3372 } 3390 }
3373 3391
3374 void Browser::WebIntentDispatch( 3392 void Browser::WebIntentDispatch(
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
4941 if (contents && !allow_js_access) { 4959 if (contents && !allow_js_access) {
4942 contents->web_contents()->GetController().LoadURL( 4960 contents->web_contents()->GetController().LoadURL(
4943 target_url, 4961 target_url,
4944 content::Referrer(), 4962 content::Referrer(),
4945 content::PAGE_TRANSITION_LINK, 4963 content::PAGE_TRANSITION_LINK,
4946 std::string()); // No extra headers. 4964 std::string()); // No extra headers.
4947 } 4965 }
4948 4966
4949 return contents != NULL; 4967 return contents != NULL;
4950 } 4968 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698