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

Side by Side Diff: chrome/browser/shell_integration.h

Issue 1832853003: DefaultBrowserWorker now fully supports opening the settings for Win10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment + nits Created 4 years, 8 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 #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
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(
sky 2016/04/07 18:18:47 If this is win specific can it be in an ifdef?
Patrick Monette 2016/04/08 22:26:08 I don't like #ifdef for windows here. Moved win sp
41 const base::Closure& on_finished_callback);
42
37 // Sets Chrome as the default client application for the given protocol 43 // Sets Chrome as the default client application for the given protocol
38 // (only for the current user). Returns false if this operation fails. 44 // (only for the current user). Returns false if this operation fails.
39 bool SetAsDefaultProtocolClient(const std::string& protocol); 45 bool SetAsDefaultProtocolClient(const std::string& protocol);
40 46
41 // Initiates an OS shell flow which (if followed by the user) should set 47 // 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 48 // 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) 49 // 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 50 // 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 51 // a FILE thread. If Chrome is already default for |protocol|, no interactive
46 // dialog will be shown and this method returns true. 52 // dialog will be shown and this method returns true.
47 bool SetAsDefaultProtocolClientInteractive(const std::string& protocol); 53 bool SetAsDefaultProtocolClientInteractive(const std::string& protocol);
48 54
49 // Windows 8 and Windows 10 introduced different ways to set the default 55 // Windows 8 and Windows 10 introduced different ways to set the default
50 // browser. 56 // browser.
51 enum DefaultWebClientSetPermission { 57 enum DefaultWebClientSetPermission {
52 // The browser distribution is not permitted to be made default. 58 // The browser distribution is not permitted to be made default.
53 SET_DEFAULT_NOT_ALLOWED, 59 SET_DEFAULT_NOT_ALLOWED,
54 // No special permission or interaction is required to set the default 60 // No special permission or interaction is required to set the default
55 // browser. This is used in Linux, Mac and Windows 7 and under. 61 // browser. This is used in Linux, Mac and Windows 7 and under.
56 SET_DEFAULT_UNATTENDED, 62 SET_DEFAULT_UNATTENDED,
57 // On Windows 8, a browser can be made default only in an interactive flow. 63 // On Windows 8, a browser can be made default only in an interactive flow.
58 SET_DEFAULT_INTERACTIVE, 64 SET_DEFAULT_INTERACTIVE,
65 // On Windows 10+, the system settings page for default apps is opened.
66 SET_DEFAULT_OPEN_SETTINGS,
59 }; 67 };
60 68
61 // Returns requirements for making the running browser the user's default. 69 // Returns requirements for making the running browser the user's default.
62 DefaultWebClientSetPermission CanSetAsDefaultBrowser(); 70 DefaultWebClientSetPermission CanSetAsDefaultBrowser();
63 71
64 // Returns requirements for making the running browser the user's default 72 // Returns requirements for making the running browser the user's default
65 // client application for specific protocols. 73 // client application for specific protocols.
66 DefaultWebClientSetPermission CanSetAsDefaultProtocolClient(); 74 DefaultWebClientSetPermission CanSetAsDefaultProtocolClient();
67 75
68 // Returns true if making the running browser the default client for any 76 // Returns true if making the running browser the default client for any
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Checks whether Chrome is the default web client. Always called on the 233 // 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 234 // 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. 235 // will be reported to UMA as the result of the set-as-default operation.
228 void CheckIsDefault(bool is_following_set_as_default); 236 void CheckIsDefault(bool is_following_set_as_default);
229 237
230 // Sets Chrome as the default web client. Always called on the FILE thread. 238 // Sets Chrome as the default web client. Always called on the FILE thread.
231 void SetAsDefault(); 239 void SetAsDefault();
232 240
233 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. 241 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses.
234 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; 242 virtual DefaultWebClientState CheckIsDefaultImpl() = 0;
235 virtual void SetAsDefaultImpl() = 0; 243
244 // The callback may be run synchronously or at an arbitrary time later on this
245 // thread.
246 // Note: Subclasses MUST make sure |on_finished_callback| is executed.
247 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0;
236 248
237 // Reports the result for the set-as-default operation. 249 // Reports the result for the set-as-default operation.
238 void ReportSetDefaultResult(DefaultWebClientState state); 250 void ReportSetDefaultResult(DefaultWebClientState state);
239 251
240 // Updates the UI in our associated view with the current default web 252 // Updates the UI in our associated view with the current default web
241 // client state. 253 // client state.
242 void UpdateUI(DefaultWebClientState state); 254 void UpdateUI(DefaultWebClientState state);
243 255
244 // Called with the default state after the worker is done. 256 // Called with the default state after the worker is done.
245 DefaultWebClientWorkerCallback callback_; 257 DefaultWebClientWorkerCallback callback_;
(...skipping 15 matching lines...) Expand all
261 public: 273 public:
262 explicit DefaultBrowserWorker(const DefaultWebClientWorkerCallback& callback); 274 explicit DefaultBrowserWorker(const DefaultWebClientWorkerCallback& callback);
263 275
264 private: 276 private:
265 ~DefaultBrowserWorker() override; 277 ~DefaultBrowserWorker() override;
266 278
267 // Check if Chrome is the default browser. 279 // Check if Chrome is the default browser.
268 DefaultWebClientState CheckIsDefaultImpl() override; 280 DefaultWebClientState CheckIsDefaultImpl() override;
269 281
270 // Set Chrome as the default browser. 282 // Set Chrome as the default browser.
271 void SetAsDefaultImpl() override; 283 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override;
272 284
273 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); 285 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
274 }; 286 };
275 287
276 // Worker for checking and setting the default client application 288 // Worker for checking and setting the default client application
277 // for a given protocol. A different worker instance is needed for each 289 // 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 290 // protocol you are interested in, so to check or set the default for
279 // multiple protocols you should use multiple worker objects. 291 // multiple protocols you should use multiple worker objects.
280 class DefaultProtocolClientWorker : public DefaultWebClientWorker { 292 class DefaultProtocolClientWorker : public DefaultWebClientWorker {
281 public: 293 public:
282 DefaultProtocolClientWorker(const DefaultWebClientWorkerCallback& callback, 294 DefaultProtocolClientWorker(const DefaultWebClientWorkerCallback& callback,
283 const std::string& protocol); 295 const std::string& protocol);
284 296
285 const std::string& protocol() const { return protocol_; } 297 const std::string& protocol() const { return protocol_; }
286 298
287 protected: 299 protected:
288 ~DefaultProtocolClientWorker() override; 300 ~DefaultProtocolClientWorker() override;
289 301
290 private: 302 private:
291 // Check if Chrome is the default handler for this protocol. 303 // Check if Chrome is the default handler for this protocol.
292 DefaultWebClientState CheckIsDefaultImpl() override; 304 DefaultWebClientState CheckIsDefaultImpl() override;
293 305
294 // Set Chrome as the default handler for this protocol. 306 // Set Chrome as the default handler for this protocol.
295 void SetAsDefaultImpl() override; 307 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override;
296 308
297 std::string protocol_; 309 std::string protocol_;
298 310
299 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); 311 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
300 }; 312 };
301 313
302 } // namespace shell_integration 314 } // namespace shell_integration
303 315
304 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ 316 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/shell_integration.cc » ('j') | chrome/browser/shell_integration_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698