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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // SetAsDefault. | 203 // SetAsDefault. |
204 virtual void OnSetAsDefaultConcluded(bool succeeded) {} | 204 virtual void OnSetAsDefaultConcluded(bool succeeded) {} |
205 // Observer classes that return true to OwnedByWorker are automatically | 205 // Observer classes that return true to OwnedByWorker are automatically |
206 // freed by the worker when they are no longer needed. False by default. | 206 // freed by the worker when they are no longer needed. False by default. |
207 virtual bool IsOwnedByWorker(); | 207 virtual bool IsOwnedByWorker(); |
208 // An observer can permit or decline set-as-default operation if it | 208 // An observer can permit or decline set-as-default operation if it |
209 // requires triggering user interaction. By default not allowed. | 209 // requires triggering user interaction. By default not allowed. |
210 virtual bool IsInteractiveSetDefaultPermitted(); | 210 virtual bool IsInteractiveSetDefaultPermitted(); |
211 }; | 211 }; |
212 | 212 |
| 213 // The locations from which the user can set Chrome as the default browser. |
| 214 // This enum is used for UMA. Do not modify the ordering. |
| 215 enum SetDefaultBrowserLocation { |
| 216 INFO_BAR, |
| 217 SETTINGS, |
| 218 NUM_SET_DEFAULT_BROWSER_LOCATION_TYPES |
| 219 }; |
| 220 |
213 // Helper objects that handle checking if Chrome is the default browser | 221 // Helper objects that handle checking if Chrome is the default browser |
214 // or application for a url protocol on Windows and Linux, and also setting | 222 // or application for a url protocol on Windows and Linux, and also setting |
215 // it as the default. These operations are performed asynchronously on the | 223 // it as the default. These operations are performed asynchronously on the |
216 // file thread since registry access (on Windows) or the preference database | 224 // file thread since registry access (on Windows) or the preference database |
217 // (on Linux) are involved and this can be slow. | 225 // (on Linux) are involved and this can be slow. |
218 class DefaultWebClientWorker | 226 class DefaultWebClientWorker |
219 : public base::RefCountedThreadSafe<DefaultWebClientWorker> { | 227 : public base::RefCountedThreadSafe<DefaultWebClientWorker> { |
220 public: | 228 public: |
221 explicit DefaultWebClientWorker(DefaultWebClientObserver* observer); | 229 explicit DefaultWebClientWorker(DefaultWebClientObserver* observer); |
222 | 230 |
223 // Checks to see if Chrome is the default web client application. The result | 231 // Checks to see if Chrome is the default web client application. The result |
224 // will be passed back to the observer via the SetDefaultWebClientUIState | 232 // will be passed back to the observer via the SetDefaultWebClientUIState |
225 // function. If there is no observer, this function does not do anything. | 233 // function. If there is no observer, this function does not do anything. |
226 void StartCheckIsDefault(); | 234 void StartCheckIsDefault(); |
227 | 235 |
228 // Sets Chrome as the default web client application. If there is an | 236 // Sets Chrome as the default web client application. If there is an |
229 // observer, once the operation has completed the new default will be | 237 // observer, once the operation has completed the new default will be |
230 // queried and the current status reported via SetDefaultWebClientUIState. | 238 // queried and the current status reported via SetDefaultWebClientUIState. |
231 void StartSetAsDefault(); | 239 void StartSetAsDefault(); |
232 | 240 |
233 // Called to notify the worker that the view is gone. | 241 // Called to notify the worker that the view is gone. |
234 void ObserverDestroyed(); | 242 void ObserverDestroyed(); |
235 | 243 |
236 protected: | 244 protected: |
237 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>; | 245 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>; |
238 | 246 |
239 // Possible result codes for a set-as-default operation. | 247 // Possible result codes for a set-as-default operation. |
240 // Do not modify the ordering as it is important for UMA. | 248 // Do not modify the ordering as it is important for UMA. |
241 enum AttemptResult { | 249 enum AttemptResult { |
242 // No errors encountered. | 250 // Chrome was set as the default browser. |
243 SUCCESS, | 251 SUCCESS, |
244 // Chrome was already the default web client. This counts as a successful | 252 // Chrome was already the default web client. This counts as a successful |
245 // attempt. | 253 // attempt. |
246 ALREADY_DEFAULT, | 254 ALREADY_DEFAULT, |
247 // Chrome was not set as the default web client. | 255 // Chrome was not set as the default web client. |
248 FAILURE, | 256 FAILURE, |
249 // The attempt was abandoned because the observer was destroyed. | 257 // The attempt was abandoned because the observer was destroyed. |
250 ABANDONED, | 258 ABANDONED, |
251 // Failed to launch the process to set Chrome as the default web client | 259 // Failed to launch the process to set Chrome as the default web client |
252 // asynchronously. | 260 // asynchronously. |
253 LAUNCH_FAILURE, | 261 LAUNCH_FAILURE, |
254 // Another worker is already in progress to make Chrome the default web | 262 // Another worker is already in progress to make Chrome the default web |
255 // client. | 263 // client. |
256 OTHER_WORKER, | 264 OTHER_WORKER, |
257 // The user initiated another attempt while the asynchronous operation was | 265 // The user initiated another attempt while the asynchronous operation was |
258 // already in progress. | 266 // already in progress. |
259 RETRY, | 267 RETRY, |
| 268 // No errors were encountered yet Chrome is still not the default browser. |
| 269 NO_ERRORS_NOT_DEFAULT, |
260 NUM_ATTEMPT_RESULT_TYPES | 270 NUM_ATTEMPT_RESULT_TYPES |
261 }; | 271 }; |
262 | 272 |
263 virtual ~DefaultWebClientWorker(); | 273 virtual ~DefaultWebClientWorker(); |
264 | 274 |
265 // Communicates the result to the observer. In contrast to | 275 // Communicates the result to the observer. In contrast to |
266 // OnSetAsDefaultAttemptComplete(), this should not be called multiple | 276 // OnSetAsDefaultAttemptComplete(), this should not be called multiple |
267 // times. | 277 // times. |
268 void OnCheckIsDefaultComplete(DefaultWebClientState state); | 278 void OnCheckIsDefaultComplete(DefaultWebClientState state); |
269 | 279 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DefaultWebClientObserver* observer_; | 326 DefaultWebClientObserver* observer_; |
317 | 327 |
318 // Flag that indicates the return value of InitializeSetAsDefault(). If | 328 // Flag that indicates the return value of InitializeSetAsDefault(). If |
319 // true, FinalizeSetAsDefault() will be called to clear what was | 329 // true, FinalizeSetAsDefault() will be called to clear what was |
320 // initialized. | 330 // initialized. |
321 bool set_as_default_initialized_ = false; | 331 bool set_as_default_initialized_ = false; |
322 | 332 |
323 // Records the time it takes to set the default browser. | 333 // Records the time it takes to set the default browser. |
324 base::TimeTicks start_time_; | 334 base::TimeTicks start_time_; |
325 | 335 |
| 336 #if defined(OS_WIN) |
| 337 // Wait until Chrome has been confirmed as the default browser before |
| 338 // reporting a successful attempt. |
| 339 bool check_default_should_report_success_ = false; |
| 340 #endif // defined(OS_WIN) |
| 341 |
326 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); | 342 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); |
327 }; | 343 }; |
328 | 344 |
329 // Worker for checking and setting the default browser. | 345 // Worker for checking and setting the default browser. |
330 class DefaultBrowserWorker : public DefaultWebClientWorker { | 346 class DefaultBrowserWorker : public DefaultWebClientWorker { |
331 public: | 347 public: |
332 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); | 348 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); |
333 | 349 |
334 private: | 350 private: |
335 ~DefaultBrowserWorker() override; | 351 ~DefaultBrowserWorker() override; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // Set Chrome as the default handler for this protocol. | 397 // Set Chrome as the default handler for this protocol. |
382 void SetAsDefault(bool interactive_permitted) override; | 398 void SetAsDefault(bool interactive_permitted) override; |
383 | 399 |
384 std::string protocol_; | 400 std::string protocol_; |
385 | 401 |
386 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); | 402 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); |
387 }; | 403 }; |
388 }; | 404 }; |
389 | 405 |
390 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ | 406 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ |
OLD | NEW |