Chromium Code Reviews| Index: chrome/browser/shell_integration.h |
| diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h |
| index 575575e9175ecc92cc9f805e1c3f5acca2e4febd..b91d7db6fc0be05e1a31486fd84fa29fde06dfd4 100644 |
| --- a/chrome/browser/shell_integration.h |
| +++ b/chrome/browser/shell_integration.h |
| @@ -30,26 +30,35 @@ class ShellIntegration { |
| // this operation fails. |
| static bool SetAsDefaultBrowser(); |
| + // Sets Chrome as client application for the given protocol (only for |
| + // current user). Returns false if this operation fails. |
| + static bool SetAsDefaultProtocolClient(const std::string& protocol); |
| + |
| // On Linux, it may not be possible to determine or set the default browser |
| // on some desktop environments or configurations. So, we use this enum and |
| // not a plain bool. (Note however that if used like a bool, this enum will |
| // have reasonable behavior.) |
| - enum DefaultBrowserState { |
| - NOT_DEFAULT_BROWSER = 0, |
| - IS_DEFAULT_BROWSER, |
| - UNKNOWN_DEFAULT_BROWSER |
| + enum DefaultClientAppState { |
|
Mark Mentovai
2011/05/23 00:23:52
In isolation, DefaultClientAppState doesn’t tell m
benwells
2011/05/23 06:08:37
Agreed, it doesn't say enough. I avoided the word
benwells
2011/05/24 06:10:38
Done.
|
| + NOT_DEFAULT_CLIENT_APP = 0, |
| + IS_DEFAULT_CLIENT_APP, |
| + UNKNOWN_DEFAULT_CLIENT_APP |
|
Mark Mentovai
2011/05/23 00:23:52
My own preference would be for the UNKNOWN element
benwells
2011/05/24 06:10:38
Done.
|
| }; |
| // Attempt to determine if this instance of Chrome is the default browser and |
| // return the appropriate state. (Defined as being the handler for HTTP/HTTPS |
| // protocols; we don't want to report "no" here if the user has simply chosen |
| // to open HTML files in a text editor and FTP links with an FTP client.) |
| - static DefaultBrowserState IsDefaultBrowser(); |
| + static DefaultClientAppState IsDefaultBrowser(); |
| // Returns true if Firefox is likely to be the default browser for the current |
| // user. This method is very fast so it can be invoked in the UI thread. |
| static bool IsFirefoxDefaultBrowser(); |
| + // Attempt to determine if this instance of Chrome is the default client |
| + // application for the given protocol and return the appropriate state. |
| + static DefaultClientAppState |
| + IsDefaultProtocolClient(const std::string& protocol); |
| + |
| struct ShortcutInfo { |
| ShortcutInfo(); |
| ~ShortcutInfo(); |
| @@ -123,65 +132,70 @@ class ShellIntegration { |
| static void MigrateChromiumShortcuts(); |
| #endif // defined(OS_WIN) |
| - // The current default browser UI state |
| - enum DefaultBrowserUIState { |
| + // The current default browser / client application UI state |
| + enum DefaultClientAppUIState { |
| STATE_PROCESSING, |
| STATE_NOT_DEFAULT, |
| STATE_IS_DEFAULT, |
| STATE_UNKNOWN |
| }; |
| - class DefaultBrowserObserver { |
| + class DefaultClientAppObserver { |
| public: |
| // Updates the UI state to reflect the current default browser state. |
| - virtual void SetDefaultBrowserUIState(DefaultBrowserUIState state) = 0; |
| - virtual ~DefaultBrowserObserver() {} |
| + virtual void SetDefaultClientAppUIState(DefaultClientAppUIState state) = 0; |
| + virtual ~DefaultClientAppObserver() {} |
| }; |
| - // A helper object that handles checking if Chrome is the default browser on |
| - // Windows and also setting it as the default browser. These operations are |
| - // performed asynchronously on the file thread since registry access is |
| - // involved and this can be slow. |
| - // |
| - class DefaultBrowserWorker |
| - : public base::RefCountedThreadSafe<DefaultBrowserWorker> { |
| + // A helper object that handles checking if Chrome is the default browser |
| + // or application for a url protocol on Windows and Linux, and also setting |
| + // it as the default. These operations are performed asynchronously on the |
| + // file thread since registry access is involved and this can be slow. |
|
Mark Mentovai
2011/05/23 00:23:52
Any comment in this file that mentions the “regist
benwells
2011/05/24 06:10:38
Done.
|
| + class DefaultClientAppWorker |
|
Mark Mentovai
2011/05/23 00:23:52
I believe that this interface is now too cumbersom
benwells
2011/05/23 06:08:37
Yes, there would be some hazard if you tried to re
benwells
2011/05/24 06:10:38
Done.
|
| + : public base::RefCountedThreadSafe<DefaultClientAppWorker> { |
| public: |
| - explicit DefaultBrowserWorker(DefaultBrowserObserver* observer); |
| + explicit DefaultClientAppWorker(DefaultClientAppObserver* observer); |
| - // Checks if Chrome is the default browser. |
| + // Checks to see if Chrome is the default browser or protocol client. |
| void StartCheckDefaultBrowser(); |
| + void StartCheckDefaultProtocolClient(const std::string& protocol); |
| - // Sets Chrome as the default browser. |
| + // Sets Chrome as the default browser or protocol client. |
| void StartSetAsDefaultBrowser(); |
| + void StartSetAsDefaultProtocolClient(const std::string& protocol); |
| // Called to notify the worker that the view is gone. |
| void ObserverDestroyed(); |
| private: |
| - friend class base::RefCountedThreadSafe<DefaultBrowserWorker>; |
| + friend class base::RefCountedThreadSafe<DefaultClientAppWorker>; |
| - virtual ~DefaultBrowserWorker() {} |
| + virtual ~DefaultClientAppWorker() {} |
| // Functions that track the process of checking if Chrome is the default |
| - // browser. |ExecuteCheckDefaultBrowser| checks the registry on the file |
| - // thread. |CompleteCheckDefaultBrowser| notifies the view to update on the |
| + // browser. |ExecuteCheckDefault*| checks the registry on the file thread. |
| + // |CompleteCheckDefaultApplication| notifies the view to update on the |
| // UI thread. |
| void ExecuteCheckDefaultBrowser(); |
| - void CompleteCheckDefaultBrowser(DefaultBrowserState state); |
| + void ExecuteCheckDefaultProtocolClient(); |
| + void CompleteCheckDefaultApplication(DefaultClientAppState state); |
| // Functions that track the process of setting Chrome as the default |
| - // browser. |ExecuteSetAsDefaultBrowser| updates the registry on the file |
| - // thread. |CompleteSetAsDefaultBrowser| notifies the view to update on the |
| + // browser. |ExecuteSetAsDefault*| updates the registry on the file |
| + // thread. |CompleteSetAsDefault*| notifies the view to update on the |
| // UI thread. |
| void ExecuteSetAsDefaultBrowser(); |
| + void ExecuteSetAsDefaultProtocolClient(); |
| void CompleteSetAsDefaultBrowser(); |
| + void CompleteSetAsDefaultProtocolClient(); |
| // Updates the UI in our associated view with the current default browser |
| // state. |
| - void UpdateUI(DefaultBrowserState state); |
| + void UpdateUI(DefaultClientAppState state); |
| - DefaultBrowserObserver* observer_; |
| + DefaultClientAppObserver* observer_; |
| + std::string protocol_; |
| - DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); |
| + DISALLOW_COPY_AND_ASSIGN(DefaultClientAppWorker); |
| }; |
| }; |