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 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_H_ | 5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_H_ |
6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_ | 6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 bool SetAsDefaultBrowser(); | 27 bool SetAsDefaultBrowser(); |
28 | 28 |
29 // Initiates an OS shell flow which (if followed by the user) should set | 29 // Initiates an OS shell flow which (if followed by the user) should set |
30 // Chrome as the default browser. Returns false if the flow cannot be | 30 // Chrome as the default browser. Returns false if the flow cannot be |
31 // initialized, if it is not supported (introduced for Windows 8) or if the | 31 // initialized, if it is not supported (introduced for Windows 8) or if the |
32 // user cancels the operation. This is a blocking call and requires a FILE | 32 // user cancels the operation. This is a blocking call and requires a FILE |
33 // thread. If Chrome is already default browser, no interactive dialog will be | 33 // thread. If Chrome is already default browser, no interactive dialog will be |
34 // shown and this method returns true. | 34 // shown and this method returns true. |
35 bool SetAsDefaultBrowserInteractive(); | 35 bool SetAsDefaultBrowserInteractive(); |
36 | 36 |
37 // Initiates the interaction with the system settings for the default browser. | |
38 // The function takes care of making sure |on_finished_callback| will get called | |
39 // exactly once when the interaction is finished. | |
40 void SetAsDefaultBrowserUsingSystemSettings(base::Closure on_finished_callback); | |
grt (UTC plus 2)
2016/03/29 16:45:02
nit: pass callbacks by const-ref
Patrick Monette
2016/03/29 17:43:08
Done.
| |
41 | |
37 // Sets Chrome as the default client application for the given protocol | 42 // Sets Chrome as the default client application for the given protocol |
38 // (only for the current user). Returns false if this operation fails. | 43 // (only for the current user). Returns false if this operation fails. |
39 bool SetAsDefaultProtocolClient(const std::string& protocol); | 44 bool SetAsDefaultProtocolClient(const std::string& protocol); |
40 | 45 |
41 // Initiates an OS shell flow which (if followed by the user) should set | 46 // Initiates an OS shell flow which (if followed by the user) should set |
42 // Chrome as the default handler for |protocol|. Returns false if the flow | 47 // Chrome as the default handler for |protocol|. Returns false if the flow |
43 // cannot be initialized, if it is not supported (introduced for Windows 8) | 48 // cannot be initialized, if it is not supported (introduced for Windows 8) |
44 // or if the user cancels the operation. This is a blocking call and requires | 49 // or if the user cancels the operation. This is a blocking call and requires |
45 // a FILE thread. If Chrome is already default for |protocol|, no interactive | 50 // a FILE thread. If Chrome is already default for |protocol|, no interactive |
46 // dialog will be shown and this method returns true. | 51 // dialog will be shown and this method returns true. |
47 bool SetAsDefaultProtocolClientInteractive(const std::string& protocol); | 52 bool SetAsDefaultProtocolClientInteractive(const std::string& protocol); |
48 | 53 |
49 // Windows 8 and Windows 10 introduced different ways to set the default | 54 // Windows 8 and Windows 10 introduced different ways to set the default |
50 // browser. | 55 // browser. |
51 enum DefaultWebClientSetPermission { | 56 enum DefaultWebClientSetPermission { |
52 // The browser distribution is not permitted to be made default. | 57 // The browser distribution is not permitted to be made default. |
53 SET_DEFAULT_NOT_ALLOWED, | 58 SET_DEFAULT_NOT_ALLOWED, |
54 // No special permission or interaction is required to set the default | 59 // No special permission or interaction is required to set the default |
55 // browser. This is used in Linux, Mac and Windows 7 and under. | 60 // browser. This is used in Linux, Mac and Windows 7 and under. |
56 SET_DEFAULT_UNATTENDED, | 61 SET_DEFAULT_UNATTENDED, |
57 // On Windows 8, a browser can be made default only in an interactive flow. | 62 // On Windows 8, a browser can be made default only in an interactive flow. |
58 SET_DEFAULT_INTERACTIVE, | 63 SET_DEFAULT_INTERACTIVE, |
64 // On Windows 10+, the system settings page for default apps is opened. | |
65 SET_DEFAULT_OPEN_SETTINGS, | |
59 }; | 66 }; |
60 | 67 |
61 // Returns requirements for making the running browser the user's default. | 68 // Returns requirements for making the running browser the user's default. |
62 DefaultWebClientSetPermission CanSetAsDefaultBrowser(); | 69 DefaultWebClientSetPermission CanSetAsDefaultBrowser(); |
63 | 70 |
64 // Returns requirements for making the running browser the user's default | 71 // Returns requirements for making the running browser the user's default |
65 // client application for specific protocols. | 72 // client application for specific protocols. |
66 DefaultWebClientSetPermission CanSetAsDefaultProtocolClient(); | 73 DefaultWebClientSetPermission CanSetAsDefaultProtocolClient(); |
67 | 74 |
68 // Returns true if making the running browser the default client for any | 75 // Returns true if making the running browser the default client for any |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 // Checks whether Chrome is the default web client. Always called on the | 232 // Checks whether Chrome is the default web client. Always called on the |
226 // FILE thread. When |is_following_set_as_default| is true, The default state | 233 // FILE thread. When |is_following_set_as_default| is true, The default state |
227 // will be reported to UMA as the result of the set-as-default operation. | 234 // will be reported to UMA as the result of the set-as-default operation. |
228 void CheckIsDefault(bool is_following_set_as_default); | 235 void CheckIsDefault(bool is_following_set_as_default); |
229 | 236 |
230 // Sets Chrome as the default web client. Always called on the FILE thread. | 237 // Sets Chrome as the default web client. Always called on the FILE thread. |
231 void SetAsDefault(); | 238 void SetAsDefault(); |
232 | 239 |
233 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. | 240 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. |
234 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; | 241 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; |
235 virtual void SetAsDefaultImpl() = 0; | 242 |
243 // Subclasses MUST make sure the callback is executed. | |
244 virtual void SetAsDefaultImpl(base::Closure on_finished_callback) = 0; | |
236 | 245 |
237 // Reports the result for the set-as-default operation. | 246 // Reports the result for the set-as-default operation. |
238 void ReportSetDefaultResult(DefaultWebClientState state); | 247 void ReportSetDefaultResult(DefaultWebClientState state); |
239 | 248 |
240 // Updates the UI in our associated view with the current default web | 249 // Updates the UI in our associated view with the current default web |
241 // client state. | 250 // client state. |
242 void UpdateUI(DefaultWebClientState state); | 251 void UpdateUI(DefaultWebClientState state); |
243 | 252 |
244 // Called with the default state after the worker is done. | 253 // Called with the default state after the worker is done. |
245 DefaultWebClientWorkerCallback callback_; | 254 DefaultWebClientWorkerCallback callback_; |
(...skipping 15 matching lines...) Expand all Loading... | |
261 public: | 270 public: |
262 explicit DefaultBrowserWorker(const DefaultWebClientWorkerCallback& callback); | 271 explicit DefaultBrowserWorker(const DefaultWebClientWorkerCallback& callback); |
263 | 272 |
264 private: | 273 private: |
265 ~DefaultBrowserWorker() override; | 274 ~DefaultBrowserWorker() override; |
266 | 275 |
267 // Check if Chrome is the default browser. | 276 // Check if Chrome is the default browser. |
268 DefaultWebClientState CheckIsDefaultImpl() override; | 277 DefaultWebClientState CheckIsDefaultImpl() override; |
269 | 278 |
270 // Set Chrome as the default browser. | 279 // Set Chrome as the default browser. |
271 void SetAsDefaultImpl() override; | 280 void SetAsDefaultImpl(base::Closure on_finished_callback) override; |
272 | 281 |
273 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); | 282 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); |
274 }; | 283 }; |
275 | 284 |
276 // Worker for checking and setting the default client application | 285 // Worker for checking and setting the default client application |
277 // for a given protocol. A different worker instance is needed for each | 286 // for a given protocol. A different worker instance is needed for each |
278 // protocol you are interested in, so to check or set the default for | 287 // protocol you are interested in, so to check or set the default for |
279 // multiple protocols you should use multiple worker objects. | 288 // multiple protocols you should use multiple worker objects. |
280 class DefaultProtocolClientWorker : public DefaultWebClientWorker { | 289 class DefaultProtocolClientWorker : public DefaultWebClientWorker { |
281 public: | 290 public: |
282 DefaultProtocolClientWorker(const DefaultWebClientWorkerCallback& callback, | 291 DefaultProtocolClientWorker(const DefaultWebClientWorkerCallback& callback, |
283 const std::string& protocol); | 292 const std::string& protocol); |
284 | 293 |
285 const std::string& protocol() const { return protocol_; } | 294 const std::string& protocol() const { return protocol_; } |
286 | 295 |
287 protected: | 296 protected: |
288 ~DefaultProtocolClientWorker() override; | 297 ~DefaultProtocolClientWorker() override; |
289 | 298 |
290 private: | 299 private: |
291 // Check if Chrome is the default handler for this protocol. | 300 // Check if Chrome is the default handler for this protocol. |
292 DefaultWebClientState CheckIsDefaultImpl() override; | 301 DefaultWebClientState CheckIsDefaultImpl() override; |
293 | 302 |
294 // Set Chrome as the default handler for this protocol. | 303 // Set Chrome as the default handler for this protocol. |
295 void SetAsDefaultImpl() override; | 304 void SetAsDefaultImpl(base::Closure on_finished_callback) override; |
296 | 305 |
297 std::string protocol_; | 306 std::string protocol_; |
298 | 307 |
299 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); | 308 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); |
300 }; | 309 }; |
301 | 310 |
302 } // namespace shell_integration | 311 } // namespace shell_integration |
303 | 312 |
304 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ | 313 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ |
OLD | NEW |