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

Side by Side Diff: chrome/browser/custom_handlers/protocol_handler_registry.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: Fix merge issue 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/custom_handlers/protocol_handler_registry.h" 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (worker_) { 254 if (worker_) {
255 if (ShouldRemoveHandlersNotInOS() && 255 if (ShouldRemoveHandlersNotInOS() &&
256 (state == shell_integration::STATE_NOT_DEFAULT)) { 256 (state == shell_integration::STATE_NOT_DEFAULT)) {
257 registry_->ClearDefault(worker_->protocol()); 257 registry_->ClearDefault(worker_->protocol());
258 } 258 }
259 } else { 259 } else {
260 NOTREACHED(); 260 NOTREACHED();
261 } 261 }
262 } 262 }
263 263
264 bool ProtocolHandlerRegistry::DefaultClientObserver::
265 IsInteractiveSetDefaultPermitted() {
266 return true;
267 }
268
269 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( 264 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker(
270 shell_integration::DefaultProtocolClientWorker* worker) { 265 shell_integration::DefaultProtocolClientWorker* worker) {
271 worker_ = worker; 266 worker_ = worker;
272 } 267 }
273 268
274 bool ProtocolHandlerRegistry::DefaultClientObserver::IsOwnedByWorker() {
275 return true;
276 }
277
278 // Delegate -------------------------------------------------------------------- 269 // Delegate --------------------------------------------------------------------
279 270
280 ProtocolHandlerRegistry::Delegate::~Delegate() {} 271 ProtocolHandlerRegistry::Delegate::~Delegate() {}
281 272
282 void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( 273 void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler(
283 const std::string& protocol) { 274 const std::string& protocol) {
284 ChildProcessSecurityPolicy* policy = 275 ChildProcessSecurityPolicy* policy =
285 ChildProcessSecurityPolicy::GetInstance(); 276 ChildProcessSecurityPolicy::GetInstance();
286 if (!policy->IsWebSafeScheme(protocol)) { 277 if (!policy->IsWebSafeScheme(protocol)) {
287 policy->RegisterWebSafeScheme(protocol); 278 policy->RegisterWebSafeScheme(protocol);
288 } 279 }
289 } 280 }
290 281
291 void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( 282 void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler(
292 const std::string& protocol) { 283 const std::string& protocol) {
293 } 284 }
294 285
295 bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( 286 bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered(
296 const std::string& protocol) { 287 const std::string& protocol) {
297 // NOTE(koz): This function is safe to call from any thread, despite living 288 // NOTE(koz): This function is safe to call from any thread, despite living
298 // in ProfileIOData. 289 // in ProfileIOData.
299 return ProfileIOData::IsHandledProtocol(protocol); 290 return ProfileIOData::IsHandledProtocol(protocol);
300 } 291 }
301 292
302 shell_integration::DefaultProtocolClientWorker* 293 shell_integration::DefaultProtocolClientWorker*
303 ProtocolHandlerRegistry::Delegate::CreateShellWorker( 294 ProtocolHandlerRegistry::Delegate::CreateShellWorker(
304 shell_integration::DefaultWebClientObserver* observer, 295 shell_integration::DefaultWebClientObserver* observer,
305 const std::string& protocol) { 296 const std::string& protocol) {
306 return new shell_integration::DefaultProtocolClientWorker(observer, protocol); 297 return new shell_integration::DefaultProtocolClientWorker(
298 observer, protocol, /*delete_observer=*/true);
307 } 299 }
308 300
309 ProtocolHandlerRegistry::DefaultClientObserver* 301 ProtocolHandlerRegistry::DefaultClientObserver*
310 ProtocolHandlerRegistry::Delegate::CreateShellObserver( 302 ProtocolHandlerRegistry::Delegate::CreateShellObserver(
311 ProtocolHandlerRegistry* registry) { 303 ProtocolHandlerRegistry* registry) {
312 return new DefaultClientObserver(registry); 304 return new DefaultClientObserver(registry);
313 } 305 }
314 306
315 void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( 307 void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient(
316 const std::string& protocol, ProtocolHandlerRegistry* registry) { 308 const std::string& protocol, ProtocolHandlerRegistry* registry) {
317 DefaultClientObserver* observer = CreateShellObserver(registry); 309 DefaultClientObserver* observer = CreateShellObserver(registry);
318 // The worker pointer is reference counted. While it is running the 310 // The worker pointer is reference counted. While it is running, the
319 // message loops of the FILE and UI thread will hold references to it 311 // message loops of the FILE and UI thread will hold references to it
320 // and it will be automatically freed once all its tasks have finished. 312 // and it will be automatically freed once all its tasks have finished.
321 scoped_refptr<shell_integration::DefaultProtocolClientWorker> worker; 313 scoped_refptr<shell_integration::DefaultProtocolClientWorker> worker;
322 worker = CreateShellWorker(observer, protocol); 314 worker = CreateShellWorker(observer, protocol);
323 observer->SetWorker(worker.get()); 315 observer->SetWorker(worker.get());
324 registry->default_client_observers_.push_back(observer); 316 registry->default_client_observers_.push_back(observer);
325 worker->StartSetAsDefault(); 317 worker->StartSetAsDefault();
326 } 318 }
327 319
328 // ProtocolHandlerRegistry ----------------------------------------------------- 320 // ProtocolHandlerRegistry -----------------------------------------------------
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 958
967 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 959 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
968 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { 960 ProtocolHandlerRegistry::CreateJobInterceptorFactory() {
969 DCHECK_CURRENTLY_ON(BrowserThread::UI); 961 DCHECK_CURRENTLY_ON(BrowserThread::UI);
970 // this is always created on the UI thread (in profile_io's 962 // this is always created on the UI thread (in profile_io's
971 // InitializeOnUIThread. Any method calls must be done 963 // InitializeOnUIThread. Any method calls must be done
972 // on the IO thread (this is checked). 964 // on the IO thread (this is checked).
973 return scoped_ptr<JobInterceptorFactory>( 965 return scoped_ptr<JobInterceptorFactory>(
974 new JobInterceptorFactory(io_thread_delegate_.get())); 966 new JobInterceptorFactory(io_thread_delegate_.get()));
975 } 967 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698