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

Unified Diff: chrome/browser/shell_integration.h

Issue 160218: Fix running default browser check/setting in UI thread on Linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/options/general_page_gtk.cc ('k') | chrome/browser/shell_integration.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration.h
===================================================================
--- chrome/browser/shell_integration.h (revision 21781)
+++ chrome/browser/shell_integration.h (working copy)
@@ -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 @@
// 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;
+ };
+ // 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__
« no previous file with comments | « chrome/browser/gtk/options/general_page_gtk.cc ('k') | chrome/browser/shell_integration.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698