OLD | NEW |
---|---|
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 Loading... | |
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. |
grt (UTC plus 2)
2016/02/03 15:39:56
please add something like:
// Ownership of |observ
Patrick Monette
2016/02/03 23:01:38
Done.
| |
42 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( | 42 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( |
43 ShellIntegration::DefaultWebClientObserver* observer, | 43 ShellIntegration::DefaultWebClientObserver* observer, |
44 const std::string& protocol, | 44 const std::string& protocol, |
45 ExternalProtocolHandler::Delegate* delegate) { | 45 ExternalProtocolHandler::Delegate* delegate) { |
46 if (!delegate) | 46 if (!delegate) |
47 return new ShellIntegration::DefaultProtocolClientWorker(observer, | 47 return new ShellIntegration::DefaultProtocolClientWorker(observer, protocol, |
48 protocol); | 48 true); |
49 | 49 |
50 return delegate->CreateShellWorker(observer, protocol); | 50 return delegate->CreateShellWorker(observer, protocol); |
51 } | 51 } |
52 | 52 |
53 ExternalProtocolHandler::BlockState GetBlockStateWithDelegate( | 53 ExternalProtocolHandler::BlockState GetBlockStateWithDelegate( |
54 const std::string& scheme, | 54 const std::string& scheme, |
55 ExternalProtocolHandler::Delegate* delegate) { | 55 ExternalProtocolHandler::Delegate* delegate) { |
56 if (!delegate) | 56 if (!delegate) |
57 return ExternalProtocolHandler::GetBlockState(scheme); | 57 return ExternalProtocolHandler::GetBlockState(scheme); |
58 | 58 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 RunExternalProtocolDialogWithDelegate( | 139 RunExternalProtocolDialogWithDelegate( |
140 escaped_url_, render_process_host_id_, tab_contents_id_, | 140 escaped_url_, render_process_host_id_, tab_contents_id_, |
141 page_transition_, has_user_gesture_, delegate_); | 141 page_transition_, has_user_gesture_, delegate_); |
142 return; | 142 return; |
143 } | 143 } |
144 | 144 |
145 LaunchUrlWithoutSecurityCheckWithDelegate( | 145 LaunchUrlWithoutSecurityCheckWithDelegate( |
146 escaped_url_, render_process_host_id_, tab_contents_id_, delegate_); | 146 escaped_url_, render_process_host_id_, tab_contents_id_, delegate_); |
147 } | 147 } |
148 | 148 |
149 bool IsOwnedByWorker() override { return true; } | |
150 | |
151 private: | 149 private: |
152 ExternalProtocolHandler::Delegate* delegate_; | 150 ExternalProtocolHandler::Delegate* delegate_; |
153 const GURL escaped_url_; | 151 const GURL escaped_url_; |
154 const int render_process_host_id_; | 152 const int render_process_host_id_; |
155 const int tab_contents_id_; | 153 const int tab_contents_id_; |
156 const bool prompt_user_; | 154 const bool prompt_user_; |
157 const ui::PageTransition page_transition_; | 155 const ui::PageTransition page_transition_; |
158 const bool has_user_gesture_; | 156 const bool has_user_gesture_; |
159 }; | 157 }; |
160 | 158 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 // static | 323 // static |
326 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 324 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
327 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); | 325 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); |
328 } | 326 } |
329 | 327 |
330 // static | 328 // static |
331 void ExternalProtocolHandler::PermitLaunchUrl() { | 329 void ExternalProtocolHandler::PermitLaunchUrl() { |
332 DCHECK(base::MessageLoopForUI::IsCurrent()); | 330 DCHECK(base::MessageLoopForUI::IsCurrent()); |
333 g_accept_requests = true; | 331 g_accept_requests = true; |
334 } | 332 } |
OLD | NEW |