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

Side by Side Diff: chrome/browser/external_protocol/external_protocol_handler.cc

Issue 1657933003: Fixes the interactive default browser UX for policy setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 10 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
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/external_protocol/external_protocol_handler.h" 5 #include "chrome/browser/external_protocol/external_protocol_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 20 matching lines...) Expand all
31 using content::BrowserThread; 31 using content::BrowserThread;
32 32
33 // Whether we accept requests for launching external protocols. This is set to 33 // Whether we accept requests for launching external protocols. This is set to
34 // false every time an external protocol is requested, and set back to true on 34 // false every time an external protocol is requested, and set back to true on
35 // each user gesture. This variable should only be accessed from the UI thread. 35 // each user gesture. This variable should only be accessed from the UI thread.
36 static bool g_accept_requests = true; 36 static bool g_accept_requests = true;
37 37
38 namespace { 38 namespace {
39 39
40 // Functions enabling unit testing. Using a NULL delegate will use the default 40 // Functions enabling unit testing. Using a NULL delegate will use the default
41 // behavior; if a delegate is provided it will be used instead. 41 // behavior; if a delegate is provided it will be used instead. Also, Ownership
42 // of |observer| is passed to the new worker.
42 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( 43 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
43 ShellIntegration::DefaultWebClientObserver* observer, 44 ShellIntegration::DefaultWebClientObserver* observer,
44 const std::string& protocol, 45 const std::string& protocol,
45 ExternalProtocolHandler::Delegate* delegate) { 46 ExternalProtocolHandler::Delegate* delegate) {
46 if (!delegate) 47 if (!delegate)
47 return new ShellIntegration::DefaultProtocolClientWorker(observer, 48 return new ShellIntegration::DefaultProtocolClientWorker(
48 protocol); 49 observer, protocol,
50 /*delete_observer=*/true);
49 51
50 return delegate->CreateShellWorker(observer, protocol); 52 return delegate->CreateShellWorker(observer, protocol);
51 } 53 }
52 54
53 ExternalProtocolHandler::BlockState GetBlockStateWithDelegate( 55 ExternalProtocolHandler::BlockState GetBlockStateWithDelegate(
54 const std::string& scheme, 56 const std::string& scheme,
55 ExternalProtocolHandler::Delegate* delegate) { 57 ExternalProtocolHandler::Delegate* delegate) {
56 if (!delegate) 58 if (!delegate)
57 return ExternalProtocolHandler::GetBlockState(scheme); 59 return ExternalProtocolHandler::GetBlockState(scheme);
58 60
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 RunExternalProtocolDialogWithDelegate( 141 RunExternalProtocolDialogWithDelegate(
140 escaped_url_, render_process_host_id_, tab_contents_id_, 142 escaped_url_, render_process_host_id_, tab_contents_id_,
141 page_transition_, has_user_gesture_, delegate_); 143 page_transition_, has_user_gesture_, delegate_);
142 return; 144 return;
143 } 145 }
144 146
145 LaunchUrlWithoutSecurityCheckWithDelegate( 147 LaunchUrlWithoutSecurityCheckWithDelegate(
146 escaped_url_, render_process_host_id_, tab_contents_id_, delegate_); 148 escaped_url_, render_process_host_id_, tab_contents_id_, delegate_);
147 } 149 }
148 150
149 bool IsOwnedByWorker() override { return true; }
150
151 private: 151 private:
152 ExternalProtocolHandler::Delegate* delegate_; 152 ExternalProtocolHandler::Delegate* delegate_;
153 const GURL escaped_url_; 153 const GURL escaped_url_;
154 const int render_process_host_id_; 154 const int render_process_host_id_;
155 const int tab_contents_id_; 155 const int tab_contents_id_;
156 const bool prompt_user_; 156 const bool prompt_user_;
157 const ui::PageTransition page_transition_; 157 const ui::PageTransition page_transition_;
158 const bool has_user_gesture_; 158 const bool has_user_gesture_;
159 }; 159 };
160 160
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // static 325 // static
326 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { 326 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) {
327 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); 327 registry->RegisterDictionaryPref(prefs::kExcludedSchemes);
328 } 328 }
329 329
330 // static 330 // static
331 void ExternalProtocolHandler::PermitLaunchUrl() { 331 void ExternalProtocolHandler::PermitLaunchUrl() {
332 DCHECK(base::MessageLoopForUI::IsCurrent()); 332 DCHECK(base::MessageLoopForUI::IsCurrent());
333 g_accept_requests = true; 333 g_accept_requests = true;
334 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698