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

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

Issue 10808059: Fix up code to check whether we can silently handle RPH calls before gesture check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 return; 860 return;
861 861
862 ProtocolHandler handler = 862 ProtocolHandler handler =
863 ProtocolHandler::CreateProtocolHandler(protocol, url, title); 863 ProtocolHandler::CreateProtocolHandler(protocol, url, title);
864 864
865 ProtocolHandlerRegistry* registry = 865 ProtocolHandlerRegistry* registry =
866 tab_contents->profile()->GetProtocolHandlerRegistry(); 866 tab_contents->profile()->GetProtocolHandlerRegistry();
867 TabSpecificContentSettings* content_settings = 867 TabSpecificContentSettings* content_settings =
868 tab_contents->content_settings(); 868 tab_contents->content_settings();
869 869
870 if (registry->SilentlyHandleRegisterHandlerRequest(handler))
871 return;
872
870 if (!user_gesture && window) { 873 if (!user_gesture && window) {
871 content_settings->set_pending_protocol_handler(handler); 874 content_settings->set_pending_protocol_handler(handler);
872 content_settings->set_previous_protocol_handler( 875 content_settings->set_previous_protocol_handler(
873 registry->GetHandlerFor(handler.protocol())); 876 registry->GetHandlerFor(handler.protocol()));
874 window->GetLocationBar()->UpdateContentSettingsIcons(); 877 window->GetLocationBar()->UpdateContentSettingsIcons();
875 return; 878 return;
876 } 879 }
877 880
878 // Make sure content-setting icon is turned off in case the page does 881 // Make sure content-setting icon is turned off in case the page does
879 // ungestured and gestured RPH calls. 882 // ungestured and gestured RPH calls.
880 if (window) { 883 if (window) {
881 content_settings->ClearPendingProtocolHandler(); 884 content_settings->ClearPendingProtocolHandler();
882 window->GetLocationBar()->UpdateContentSettingsIcons(); 885 window->GetLocationBar()->UpdateContentSettingsIcons();
883 } 886 }
884 887
885 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { 888 content::RecordAction(
886 content::RecordAction( 889 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
887 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 890 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
888 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
889 891
890 RegisterProtocolHandlerInfoBarDelegate* rph_delegate = 892 RegisterProtocolHandlerInfoBarDelegate* rph_delegate =
891 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, 893 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper,
892 registry, 894 registry,
893 handler); 895 handler);
894 896
895 for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { 897 for (size_t i = 0; i < infobar_helper->infobar_count(); i++) {
896 InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); 898 InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i);
897 RegisterProtocolHandlerInfoBarDelegate* cast_delegate = 899 RegisterProtocolHandlerInfoBarDelegate* cast_delegate =
898 delegate->AsRegisterProtocolHandlerInfoBarDelegate(); 900 delegate->AsRegisterProtocolHandlerInfoBarDelegate();
899 if (cast_delegate != NULL && cast_delegate->IsReplacedBy(rph_delegate)) { 901 if (cast_delegate != NULL && cast_delegate->IsReplacedBy(rph_delegate)) {
900 infobar_helper->ReplaceInfoBar(cast_delegate, rph_delegate); 902 infobar_helper->ReplaceInfoBar(cast_delegate, rph_delegate);
901 rph_delegate = NULL; 903 rph_delegate = NULL;
902 break; 904 break;
903 }
904 } 905 }
906 }
905 907
906 if (rph_delegate != NULL) 908 if (rph_delegate != NULL)
907 infobar_helper->AddInfoBar(rph_delegate); 909 infobar_helper->AddInfoBar(rph_delegate);
908 }
909 } 910 }
910 911
911 // static 912 // static
912 void Browser::FindReplyHelper(WebContents* web_contents, 913 void Browser::FindReplyHelper(WebContents* web_contents,
913 int request_id, 914 int request_id,
914 int number_of_matches, 915 int number_of_matches,
915 const gfx::Rect& selection_rect, 916 const gfx::Rect& selection_rect,
916 int active_match_ordinal, 917 int active_match_ordinal,
917 bool final_update) { 918 bool final_update) {
918 TabContents* tab_contents = TabContents::FromWebContents(web_contents); 919 TabContents* tab_contents = TabContents::FromWebContents(web_contents);
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 if (contents && !allow_js_access) { 2276 if (contents && !allow_js_access) {
2276 contents->web_contents()->GetController().LoadURL( 2277 contents->web_contents()->GetController().LoadURL(
2277 target_url, 2278 target_url,
2278 content::Referrer(), 2279 content::Referrer(),
2279 content::PAGE_TRANSITION_LINK, 2280 content::PAGE_TRANSITION_LINK,
2280 std::string()); // No extra headers. 2281 std::string()); // No extra headers.
2281 } 2282 }
2282 2283
2283 return contents != NULL; 2284 return contents != NULL;
2284 } 2285 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698