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

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: grt comments 2 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(observer, protocol,
48 protocol); 49 true);
49 50
50 return delegate->CreateShellWorker(observer, protocol); 51 return delegate->CreateShellWorker(observer, protocol);
51 } 52 }
52 53
53 ExternalProtocolHandler::BlockState GetBlockStateWithDelegate( 54 ExternalProtocolHandler::BlockState GetBlockStateWithDelegate(
54 const std::string& scheme, 55 const std::string& scheme,
55 ExternalProtocolHandler::Delegate* delegate) { 56 ExternalProtocolHandler::Delegate* delegate) {
56 if (!delegate) 57 if (!delegate)
57 return ExternalProtocolHandler::GetBlockState(scheme); 58 return ExternalProtocolHandler::GetBlockState(scheme);
58 59
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 RunExternalProtocolDialogWithDelegate( 140 RunExternalProtocolDialogWithDelegate(
140 escaped_url_, render_process_host_id_, tab_contents_id_, 141 escaped_url_, render_process_host_id_, tab_contents_id_,
141 page_transition_, has_user_gesture_, delegate_); 142 page_transition_, has_user_gesture_, delegate_);
142 return; 143 return;
143 } 144 }
144 145
145 LaunchUrlWithoutSecurityCheckWithDelegate( 146 LaunchUrlWithoutSecurityCheckWithDelegate(
146 escaped_url_, render_process_host_id_, tab_contents_id_, delegate_); 147 escaped_url_, render_process_host_id_, tab_contents_id_, delegate_);
147 } 148 }
148 149
149 bool IsOwnedByWorker() override { return true; }
150
151 private: 150 private:
152 ExternalProtocolHandler::Delegate* delegate_; 151 ExternalProtocolHandler::Delegate* delegate_;
153 const GURL escaped_url_; 152 const GURL escaped_url_;
154 const int render_process_host_id_; 153 const int render_process_host_id_;
155 const int tab_contents_id_; 154 const int tab_contents_id_;
156 const bool prompt_user_; 155 const bool prompt_user_;
157 const ui::PageTransition page_transition_; 156 const ui::PageTransition page_transition_;
158 const bool has_user_gesture_; 157 const bool has_user_gesture_;
159 }; 158 };
160 159
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // static 324 // static
326 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { 325 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) {
327 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); 326 registry->RegisterDictionaryPref(prefs::kExcludedSchemes);
328 } 327 }
329 328
330 // static 329 // static
331 void ExternalProtocolHandler::PermitLaunchUrl() { 330 void ExternalProtocolHandler::PermitLaunchUrl() {
332 DCHECK(base::MessageLoopForUI::IsCurrent()); 331 DCHECK(base::MessageLoopForUI::IsCurrent());
333 g_accept_requests = true; 332 g_accept_requests = true;
334 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698