summaryrefslogtreecommitdiffstats
path: root/chrome/browser/shell_integration.h
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 01:57:31 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 01:57:31 +0000
commitd24c4015c3976d20001f6de03a09a7d0ef99ffb4 (patch)
treeb15c6d9840e215a37dccdd66cda07f074f2d2734 /chrome/browser/shell_integration.h
parent55eeaa5bce8adec47150cd32b764a3fdead0c9d5 (diff)
downloadchromium_src-d24c4015c3976d20001f6de03a09a7d0ef99ffb4.zip
chromium_src-d24c4015c3976d20001f6de03a09a7d0ef99ffb4.tar.gz
chromium_src-d24c4015c3976d20001f6de03a09a7d0ef99ffb4.tar.bz2
Fix running default browser check/setting in UI thread on Linux.
Rename shell_integration.cc to shell_integration_win.cc, so shell_integration.cc can be used for cross-platform stuff. Move DefaultBrowserWorker from GeneralPageView to ShellIntegration. BUG=17179 Review URL: http://codereview.chromium.org/160218 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21794 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/shell_integration.h')
-rw-r--r--chrome/browser/shell_integration.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index 46219af..4059266 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -7,6 +7,10 @@
#include <string>
+#include "base/ref_counted.h"
+
+class MessageLoop;
+
class ShellIntegration {
public:
// Sets Chrome as default browser (only for current user). Returns false if
@@ -22,6 +26,67 @@ class ShellIntegration {
// 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();
+
+
+ // The current default browser UI state
+ enum DefaultBrowserUIState {
+ STATE_PROCESSING,
+ STATE_DEFAULT,
+ STATE_NOT_DEFAULT
+ };
+
+ class DefaultBrowserObserver {
+ public:
+ // Updates the UI state to reflect the current default browser state.
+ virtual void SetDefaultBrowserUIState(DefaultBrowserUIState state) = 0;
+ virtual ~DefaultBrowserObserver() {}
+ };
+ // 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> {
+ public:
+ explicit DefaultBrowserWorker(DefaultBrowserObserver* observer);
+ virtual ~DefaultBrowserWorker() {}
+
+ // Checks if Chrome is the default browser.
+ void StartCheckDefaultBrowser();
+
+ // Sets Chrome as the default browser.
+ void StartSetAsDefaultBrowser();
+
+ // Called to notify the worker that the view is gone.
+ void ObserverDestroyed();
+
+ private:
+ // 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
+ // UI thread.
+ void ExecuteCheckDefaultBrowser();
+ void CompleteCheckDefaultBrowser(bool is_default);
+
+ // 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
+ // UI thread.
+ void ExecuteSetAsDefaultBrowser();
+ void CompleteSetAsDefaultBrowser();
+
+ // Updates the UI in our associated view with the current default browser
+ // state.
+ void UpdateUI(bool is_default);
+
+ DefaultBrowserObserver* observer_;
+
+ MessageLoop* ui_loop_;
+ MessageLoop* file_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
+ };
};
#endif // CHROME_BROWSER_SHELL_INTEGRATION_H__