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

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: Fix merge 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 NULL, 846 NULL,
846 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), 847 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT),
847 true)); 848 true));
848 } 849 }
849 850
850 // static 851 // static
851 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, 852 void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents,
852 const std::string& protocol, 853 const std::string& protocol,
853 const GURL& url, 854 const GURL& url,
854 const string16& title, 855 const string16& title,
855 bool user_gesture) { 856 bool user_gesture,
857 BrowserWindow* window) {
856 TabContents* tab_contents = TabContents::FromWebContents(web_contents); 858 TabContents* tab_contents = TabContents::FromWebContents(web_contents);
857 if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) 859 if (!tab_contents || tab_contents->profile()->IsOffTheRecord())
858 return; 860 return;
859 861
860 ProtocolHandler handler = 862 ProtocolHandler handler =
861 ProtocolHandler::CreateProtocolHandler(protocol, url, title); 863 ProtocolHandler::CreateProtocolHandler(protocol, url, title);
862 864
863 ProtocolHandlerRegistry* registry = 865 ProtocolHandlerRegistry* registry =
864 tab_contents->profile()->GetProtocolHandlerRegistry(); 866 tab_contents->profile()->GetProtocolHandlerRegistry();
867 TabSpecificContentSettings* content_settings =
868 tab_contents->content_settings();
865 869
866 // TODO(gbillock): Replace this policy with one that shows the content 870 if (!user_gesture && window) {
867 // settings icon. 871 content_settings->set_pending_protocol_handler(handler);
868 if (!user_gesture) 872 content_settings->set_previous_protocol_handler(
873 registry->GetHandlerFor(handler.protocol()));
874 window->GetLocationBar()->UpdateContentSettingsIcons();
869 return; 875 return;
876 }
877
878 // Make sure content-setting icon is turned off in case the page does
879 // ungestured and gestured RPH calls.
880 if (window) {
881 content_settings->ClearPendingProtocolHandler();
882 window->GetLocationBar()->UpdateContentSettingsIcons();
883 }
870 884
871 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { 885 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) {
872 content::RecordAction( 886 content::RecordAction(
873 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 887 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
874 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); 888 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
875 889
876 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = 890 RegisterProtocolHandlerInfoBarDelegate* rph_delegate =
877 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, 891 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper,
878 registry, 892 registry,
879 handler); 893 handler);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 void Browser::JSOutOfMemory(WebContents* web_contents) { 1595 void Browser::JSOutOfMemory(WebContents* web_contents) {
1582 JSOutOfMemoryHelper(web_contents); 1596 JSOutOfMemoryHelper(web_contents);
1583 } 1597 }
1584 1598
1585 void Browser::RegisterProtocolHandler(WebContents* web_contents, 1599 void Browser::RegisterProtocolHandler(WebContents* web_contents,
1586 const std::string& protocol, 1600 const std::string& protocol,
1587 const GURL& url, 1601 const GURL& url,
1588 const string16& title, 1602 const string16& title,
1589 bool user_gesture) { 1603 bool user_gesture) {
1590 RegisterProtocolHandlerHelper( 1604 RegisterProtocolHandlerHelper(
1591 web_contents, protocol, url, title, user_gesture); 1605 web_contents, protocol, url, title, user_gesture, window());
1592 } 1606 }
1593 1607
1594 void Browser::RegisterIntentHandler( 1608 void Browser::RegisterIntentHandler(
1595 WebContents* web_contents, 1609 WebContents* web_contents,
1596 const webkit_glue::WebIntentServiceData& data, 1610 const webkit_glue::WebIntentServiceData& data,
1597 bool user_gesture) { 1611 bool user_gesture) {
1598 RegisterIntentHandlerHelper(web_contents, data, user_gesture); 1612 RegisterIntentHandlerHelper(web_contents, data, user_gesture);
1599 } 1613 }
1600 1614
1601 void Browser::WebIntentDispatch( 1615 void Browser::WebIntentDispatch(
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 if (contents && !allow_js_access) { 2275 if (contents && !allow_js_access) {
2262 contents->web_contents()->GetController().LoadURL( 2276 contents->web_contents()->GetController().LoadURL(
2263 target_url, 2277 target_url,
2264 content::Referrer(), 2278 content::Referrer(),
2265 content::PAGE_TRANSITION_LINK, 2279 content::PAGE_TRANSITION_LINK,
2266 std::string()); // No extra headers. 2280 std::string()); // No extra headers.
2267 } 2281 }
2268 2282
2269 return contents != NULL; 2283 return contents != NULL;
2270 } 2284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698