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

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

Issue 200025: Allow the default browser check to return "unknown" and reflect that in the UI. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
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/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 14
15 class FilePath; 15 class FilePath;
16 class MessageLoop; 16 class MessageLoop;
17 17
18 class ShellIntegration { 18 class ShellIntegration {
19 public: 19 public:
20 // Sets Chrome as default browser (only for current user). Returns false if 20 // Sets Chrome as default browser (only for current user). Returns false if
21 // this operation fails. 21 // this operation fails.
22 static bool SetAsDefaultBrowser(); 22 static bool SetAsDefaultBrowser();
23 23
24 // Returns true if this instance of Chrome is the default browser. (Defined 24 // On Linux, it may not be possible to determine or set the default browser
25 // as being the handler for the http/https protocols... we don't want to 25 // on some desktop environments or configurations. So, we use this enum and
26 // report false here if the user has simply chosen to open HTML files in a 26 // not a plain bool. (Note however that if used like a bool, this enum will
27 // text editor and ftp links with a FTP client). 27 // have reasonable behavior.)
28 static bool IsDefaultBrowser(); 28 enum DefaultBrowserState {
29 NOT_DEFAULT_BROWSER = 0,
30 IS_DEFAULT_BROWSER,
31 UNKNOWN_DEFAULT_BROWSER
32 };
33
34 // Attempt to determine if this instance of Chrome is the default browser and
35 // return the appropriate state. (Defined as being the handler for HTTP/HTTPS
36 // protocols; we don't want to report "no" here if the user has simply chosen
37 // to open HTML files in a text editor and FTP links with an FTP client.)
38 static DefaultBrowserState IsDefaultBrowser();
29 39
30 // Returns true if Firefox is likely to be the default browser for the current 40 // Returns true if Firefox is likely to be the default browser for the current
31 // user. This method is very fast so it can be invoked in the UI thread. 41 // user. This method is very fast so it can be invoked in the UI thread.
32 static bool IsFirefoxDefaultBrowser(); 42 static bool IsFirefoxDefaultBrowser();
33 43
34 #if defined(OS_LINUX) 44 #if defined(OS_LINUX)
35 // Returns filename for .desktop file based on |url|, sanitized for security. 45 // Returns filename for .desktop file based on |url|, sanitized for security.
36 static FilePath GetDesktopShortcutFilename(const GURL& url); 46 static FilePath GetDesktopShortcutFilename(const GURL& url);
37 47
38 // Returns contents for .desktop file based on |template_contents|, |url| 48 // Returns contents for .desktop file based on |template_contents|, |url|
(...skipping 13 matching lines...) Expand all
52 62
53 // Creates a desktop shortcut. It is not guaranteed to exist immediately after 63 // Creates a desktop shortcut. It is not guaranteed to exist immediately after
54 // returning from this function, because actual file operation is done on the 64 // returning from this function, because actual file operation is done on the
55 // file thread. 65 // file thread.
56 static void CreateDesktopShortcut(const ShortcutInfo& shortcut_info); 66 static void CreateDesktopShortcut(const ShortcutInfo& shortcut_info);
57 #endif // defined(OS_LINUX) 67 #endif // defined(OS_LINUX)
58 68
59 // The current default browser UI state 69 // The current default browser UI state
60 enum DefaultBrowserUIState { 70 enum DefaultBrowserUIState {
61 STATE_PROCESSING, 71 STATE_PROCESSING,
62 STATE_DEFAULT, 72 STATE_NOT_DEFAULT,
63 STATE_NOT_DEFAULT 73 STATE_IS_DEFAULT,
74 STATE_UNKNOWN
64 }; 75 };
65 76
66 class DefaultBrowserObserver { 77 class DefaultBrowserObserver {
67 public: 78 public:
68 // Updates the UI state to reflect the current default browser state. 79 // Updates the UI state to reflect the current default browser state.
69 virtual void SetDefaultBrowserUIState(DefaultBrowserUIState state) = 0; 80 virtual void SetDefaultBrowserUIState(DefaultBrowserUIState state) = 0;
70 virtual ~DefaultBrowserObserver() {} 81 virtual ~DefaultBrowserObserver() {}
71 }; 82 };
72 // A helper object that handles checking if Chrome is the default browser on 83 // A helper object that handles checking if Chrome is the default browser on
73 // Windows and also setting it as the default browser. These operations are 84 // Windows and also setting it as the default browser. These operations are
(...skipping 14 matching lines...) Expand all
88 99
89 // Called to notify the worker that the view is gone. 100 // Called to notify the worker that the view is gone.
90 void ObserverDestroyed(); 101 void ObserverDestroyed();
91 102
92 private: 103 private:
93 // Functions that track the process of checking if Chrome is the default 104 // Functions that track the process of checking if Chrome is the default
94 // browser. |ExecuteCheckDefaultBrowser| checks the registry on the file 105 // browser. |ExecuteCheckDefaultBrowser| checks the registry on the file
95 // thread. |CompleteCheckDefaultBrowser| notifies the view to update on the 106 // thread. |CompleteCheckDefaultBrowser| notifies the view to update on the
96 // UI thread. 107 // UI thread.
97 void ExecuteCheckDefaultBrowser(); 108 void ExecuteCheckDefaultBrowser();
98 void CompleteCheckDefaultBrowser(bool is_default); 109 void CompleteCheckDefaultBrowser(DefaultBrowserState state);
99 110
100 // Functions that track the process of setting Chrome as the default 111 // Functions that track the process of setting Chrome as the default
101 // browser. |ExecuteSetAsDefaultBrowser| updates the registry on the file 112 // browser. |ExecuteSetAsDefaultBrowser| updates the registry on the file
102 // thread. |CompleteSetAsDefaultBrowser| notifies the view to update on the 113 // thread. |CompleteSetAsDefaultBrowser| notifies the view to update on the
103 // UI thread. 114 // UI thread.
104 void ExecuteSetAsDefaultBrowser(); 115 void ExecuteSetAsDefaultBrowser();
105 void CompleteSetAsDefaultBrowser(); 116 void CompleteSetAsDefaultBrowser();
106 117
107 // Updates the UI in our associated view with the current default browser 118 // Updates the UI in our associated view with the current default browser
108 // state. 119 // state.
109 void UpdateUI(bool is_default); 120 void UpdateUI(DefaultBrowserState state);
110 121
111 DefaultBrowserObserver* observer_; 122 DefaultBrowserObserver* observer_;
112 123
113 MessageLoop* ui_loop_; 124 MessageLoop* ui_loop_;
114 MessageLoop* file_loop_; 125 MessageLoop* file_loop_;
115 126
116 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); 127 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
117 }; 128 };
118 }; 129 };
119 130
120 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H__ 131 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698