OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/callback.h" | 10 #include "base/callback.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 base::string16 GetAppShortcutsSubdirName(); | 122 base::string16 GetAppShortcutsSubdirName(); |
123 #endif | 123 #endif |
124 | 124 |
125 // The type of callback used to communicate processing state to consumers of | 125 // The type of callback used to communicate processing state to consumers of |
126 // DefaultBrowserWorker and DefaultProtocolClientWorker. | 126 // DefaultBrowserWorker and DefaultProtocolClientWorker. |
127 using DefaultWebClientWorkerCallback = | 127 using DefaultWebClientWorkerCallback = |
128 base::Callback<void(DefaultWebClientState)>; | 128 base::Callback<void(DefaultWebClientState)>; |
129 | 129 |
130 // Helper objects that handle checking if Chrome is the default browser | 130 // Helper objects that handle checking if Chrome is the default browser |
131 // or application for a url protocol on Windows and Linux, and also setting | 131 // or application for a url protocol on Windows and Linux, and also setting |
132 // it as the default. These operations are performed asynchronously on the | 132 // it as the default. These operations are performed asynchronously on a |
133 // file thread since registry access (on Windows) or the preference database | 133 // blocking sequence since registry access (on Windows) or the preference |
134 // (on Linux) are involved and this can be slow. | 134 // database (on Linux) are involved and this can be slow. |
135 // By default, the worker will present the user with an interactive flow if | 135 // By default, the worker will present the user with an interactive flow if |
136 // required by the platform. This can be suppressed via | 136 // required by the platform. This can be suppressed via |
137 // set_interactive_permitted(), in which case an attempt to set Chrome as | 137 // set_interactive_permitted(), in which case an attempt to set Chrome as |
138 // the default handler will silently fail on such platforms. | 138 // the default handler will silently fail on such platforms. |
139 class DefaultWebClientWorker | 139 class DefaultWebClientWorker |
140 : public base::RefCountedThreadSafe<DefaultWebClientWorker> { | 140 : public base::RefCountedThreadSafe<DefaultWebClientWorker> { |
141 public: | 141 public: |
142 // Controls whether the worker can use user interaction to set the default | 142 // Controls whether the worker can use user interaction to set the default |
143 // web client. If false, the set-as-default operation will fail on OS where | 143 // web client. If false, the set-as-default operation will fail on OS where |
144 // it is required. | 144 // it is required. |
(...skipping 22 matching lines...) Expand all Loading... |
167 // |is_following_set_as_default| is true, |state| will be reported to UMA as | 167 // |is_following_set_as_default| is true, |state| will be reported to UMA as |
168 // the result of the set-as-default operation. | 168 // the result of the set-as-default operation. |
169 void OnCheckIsDefaultComplete(DefaultWebClientState state, | 169 void OnCheckIsDefaultComplete(DefaultWebClientState state, |
170 bool is_following_set_as_default); | 170 bool is_following_set_as_default); |
171 | 171 |
172 // When false, the operation to set as default will fail for interactive | 172 // When false, the operation to set as default will fail for interactive |
173 // flows. | 173 // flows. |
174 bool interactive_permitted_ = true; | 174 bool interactive_permitted_ = true; |
175 | 175 |
176 private: | 176 private: |
177 // Checks whether Chrome is the default web client. Always called on the | 177 // Checks whether Chrome is the default web client. Always called on the a |
178 // FILE thread. When |is_following_set_as_default| is true, The default state | 178 // blocking sequence. When |is_following_set_as_default| is true, The default |
179 // will be reported to UMA as the result of the set-as-default operation. | 179 // state will be reported to UMA as the result of the set-as-default |
| 180 // operation. |
180 void CheckIsDefault(bool is_following_set_as_default); | 181 void CheckIsDefault(bool is_following_set_as_default); |
181 | 182 |
182 // Sets Chrome as the default web client. Always called on the FILE thread. | 183 // Sets Chrome as the default web client. Always called on a blocking |
| 184 // sequence. |
183 void SetAsDefault(); | 185 void SetAsDefault(); |
184 | 186 |
185 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. | 187 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. |
186 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; | 188 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; |
187 | 189 |
188 // The callback may be run synchronously or at an arbitrary time later on this | 190 // The callback may be run synchronously or at an arbitrary time later on this |
189 // thread. | 191 // thread. |
190 // Note: Subclasses MUST make sure |on_finished_callback| is executed. | 192 // Note: Subclasses MUST make sure |on_finished_callback| is executed. |
191 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0; | 193 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0; |
192 | 194 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override; | 250 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override; |
249 | 251 |
250 std::string protocol_; | 252 std::string protocol_; |
251 | 253 |
252 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); | 254 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); |
253 }; | 255 }; |
254 | 256 |
255 } // namespace shell_integration | 257 } // namespace shell_integration |
256 | 258 |
257 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ | 259 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ |
OLD | NEW |