OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 12 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
13 #include "chrome/browser/net/chrome_url_request_context.h" | 13 #include "chrome/browser/net/chrome_url_request_context.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/profiles/profile_io_data.h" | 15 #include "chrome/browser/profiles/profile_io_data.h" |
16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/custom_handlers/protocol_handler.h" | 18 #include "chrome/common/custom_handlers/protocol_handler.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "content/browser/browser_thread.h" | 20 #include "content/browser/browser_thread.h" |
21 #include "content/browser/child_process_security_policy.h" | 21 #include "content/browser/child_process_security_policy.h" |
22 #include "content/common/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "net/base/network_delegate.h" | 23 #include "net/base/network_delegate.h" |
24 #include "net/url_request/url_request_redirect_job.h" | 24 #include "net/url_request/url_request_redirect_job.h" |
25 | 25 |
26 // ProtocolHandlerRegistry ----------------------------------------------------- | 26 // ProtocolHandlerRegistry ----------------------------------------------------- |
27 | 27 |
28 ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, | 28 ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, |
29 Delegate* delegate) | 29 Delegate* delegate) |
30 : profile_(profile), | 30 : profile_(profile), |
31 delegate_(delegate), | 31 delegate_(delegate), |
32 enabled_(true), | 32 enabled_(true), |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 DCHECK(IsRegistered(handler)); | 564 DCHECK(IsRegistered(handler)); |
565 ProtocolHandlerMultiMap::iterator p = | 565 ProtocolHandlerMultiMap::iterator p = |
566 protocol_handlers_.find(handler.protocol()); | 566 protocol_handlers_.find(handler.protocol()); |
567 ProtocolHandlerList& list = p->second; | 567 ProtocolHandlerList& list = p->second; |
568 list.erase(std::find(list.begin(), list.end(), handler)); | 568 list.erase(std::find(list.begin(), list.end(), handler)); |
569 list.insert(list.begin(), handler); | 569 list.insert(list.begin(), handler); |
570 } | 570 } |
571 | 571 |
572 void ProtocolHandlerRegistry::NotifyChanged() { | 572 void ProtocolHandlerRegistry::NotifyChanged() { |
573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
574 NotificationService::current()->Notify( | 574 content::NotificationService::current()->Notify( |
575 chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, | 575 chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, |
576 content::Source<Profile>(profile_), | 576 content::Source<Profile>(profile_), |
577 NotificationService::NoDetails()); | 577 content::NotificationService::NoDetails()); |
578 } | 578 } |
579 | 579 |
580 // IO thread methods ----------------------------------------------------------- | 580 // IO thread methods ----------------------------------------------------------- |
581 | 581 |
582 void ProtocolHandlerRegistry::ClearDefaultIO(const std::string& scheme) { | 582 void ProtocolHandlerRegistry::ClearDefaultIO(const std::string& scheme) { |
583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
584 default_handlers_io_.erase(scheme); | 584 default_handlers_io_.erase(scheme); |
585 } | 585 } |
586 | 586 |
587 void ProtocolHandlerRegistry::SetDefaultIO(const ProtocolHandler& handler) { | 587 void ProtocolHandlerRegistry::SetDefaultIO(const ProtocolHandler& handler) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 } | 690 } |
691 } else { | 691 } else { |
692 NOTREACHED(); | 692 NOTREACHED(); |
693 } | 693 } |
694 } | 694 } |
695 | 695 |
696 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( | 696 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( |
697 ShellIntegration::DefaultProtocolClientWorker* worker) { | 697 ShellIntegration::DefaultProtocolClientWorker* worker) { |
698 worker_ = worker; | 698 worker_ = worker; |
699 } | 699 } |
OLD | NEW |