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

Side by Side 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, 4 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 | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/ref_counted.h"
11
12 class MessageLoop;
13
10 class ShellIntegration { 14 class ShellIntegration {
11 public: 15 public:
12 // Sets Chrome as default browser (only for current user). Returns false if 16 // Sets Chrome as default browser (only for current user). Returns false if
13 // this operation fails. 17 // this operation fails.
14 static bool SetAsDefaultBrowser(); 18 static bool SetAsDefaultBrowser();
15 19
16 // Returns true if this instance of Chrome is the default browser. (Defined 20 // Returns true if this instance of Chrome is the default browser. (Defined
17 // as being the handler for the http/https protocols... we don't want to 21 // as being the handler for the http/https protocols... we don't want to
18 // report false here if the user has simply chosen to open HTML files in a 22 // report false here if the user has simply chosen to open HTML files in a
19 // text editor and ftp links with a FTP client). 23 // text editor and ftp links with a FTP client).
20 static bool IsDefaultBrowser(); 24 static bool IsDefaultBrowser();
21 25
22 // Returns true if Firefox is likely to be the default browser for the current 26 // Returns true if Firefox is likely to be the default browser for the current
23 // user. This method is very fast so it can be invoked in the UI thread. 27 // user. This method is very fast so it can be invoked in the UI thread.
24 static bool IsFirefoxDefaultBrowser(); 28 static bool IsFirefoxDefaultBrowser();
29
30
31 // The current default browser UI state
32 enum DefaultBrowserUIState {
33 STATE_PROCESSING,
34 STATE_DEFAULT,
35 STATE_NOT_DEFAULT
36 };
37
38 class DefaultBrowserObserver {
39 public:
40 // Updates the UI state to reflect the current default browser state.
41 virtual void SetDefaultBrowserUIState(DefaultBrowserUIState state) = 0;
42 };
43 // A helper object that handles checking if Chrome is the default browser on
44 // Windows and also setting it as the default browser. These operations are
45 // performed asynchronously on the file thread since registry access is
46 // involved and this can be slow.
47 //
48 class DefaultBrowserWorker
49 : public base::RefCountedThreadSafe<DefaultBrowserWorker> {
50 public:
51 explicit DefaultBrowserWorker(DefaultBrowserObserver* observer);
52 virtual ~DefaultBrowserWorker() {};
53
54 // Checks if Chrome is the default browser.
55 void StartCheckDefaultBrowser();
56
57 // Sets Chrome as the default browser.
58 void StartSetAsDefaultBrowser();
59
60 // Called to notify the worker that the view is gone.
61 void ObserverDestroyed();
62
63 private:
64 // Functions that track the process of checking if Chrome is the default
65 // browser. |ExecuteCheckDefaultBrowser| checks the registry on the file
66 // thread. |CompleteCheckDefaultBrowser| notifies the view to update on the
67 // UI thread.
68 void ExecuteCheckDefaultBrowser();
69 void CompleteCheckDefaultBrowser(bool is_default);
70
71 // Functions that track the process of setting Chrome as the default
72 // browser. |ExecuteSetAsDefaultBrowser| updates the registry on the file
73 // thread. |CompleteSetAsDefaultBrowser| notifies the view to update on the
74 // UI thread.
75 void ExecuteSetAsDefaultBrowser();
76 void CompleteSetAsDefaultBrowser();
77
78 // Updates the UI in our associated view with the current default browser
79 // state.
80 void UpdateUI(bool is_default);
81
82 DefaultBrowserObserver* observer_;
83
84 MessageLoop* ui_loop_;
85 MessageLoop* file_loop_;
86
87 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
88 };
89
25 }; 90 };
26 91
27 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H__ 92 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H__
OLDNEW
« 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