Chromium Code Reviews| 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 APPS_SHELL_INTEGRATION_H_ |
|
Ben Goodger (Google)
2013/02/25 16:02:31
I would consider putting this stuff in a subdir si
| |
| 6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_ | 6 #define APPS_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/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
| 16 | 16 |
| 17 class CommandLine; | 17 class CommandLine; |
| 18 | 18 |
| 19 class ShellIntegration { | 19 class ShellIntegration { |
| 20 public: | 20 public: |
| 21 // Sets Chrome as the default browser (only for the current user). Returns | 21 // Sets Chrome as the default browser (only for the current user). Returns |
| 22 // false if this operation fails. | 22 // false if this operation fails. |
| 23 static bool SetAsDefaultBrowser(); | 23 static bool SetAsDefaultBrowser(); |
| 24 | 24 |
| 25 // Initiates an OS shell flow which (if followed by the user) should set | 25 // Initiates an OS shell flow which (if followed by the user) should set |
| 26 // Chrome as the default browser. Returns false if the flow cannot be | 26 // Chrome as the default browser. Returns false if the flow cannot be |
| 27 // initialized, if it is not supported (introduced for Windows 8) or if the | 27 // initialized, if it is not supported (introduced for Windows 8) or if the |
| 28 // user cancels the operation. This is a blocking call and requires a FILE | 28 // user cancels the operation. This is a blocking call and requires a FILE |
| 29 // thread. If Chrome is already default browser, no interactive dialog will be | 29 // thread. If Chrome is already default browser, no interactive dialog will be |
| 30 // shown and this method returns true. | 30 // shown and this method returns true. |
| 31 static bool SetAsDefaultBrowserInteractive(); | 31 static bool SetAsDefaultBrowserInteractive(); |
|
Ben Goodger (Google)
2013/02/25 16:02:31
All of these "default browser" functions should st
| |
| 32 | 32 |
| 33 // Sets Chrome as the default client application for the given protocol | 33 // Sets Chrome as the default client application for the given protocol |
| 34 // (only for the current user). Returns false if this operation fails. | 34 // (only for the current user). Returns false if this operation fails. |
| 35 static bool SetAsDefaultProtocolClient(const std::string& protocol); | 35 static bool SetAsDefaultProtocolClient(const std::string& protocol); |
| 36 | 36 |
| 37 // Initiates an OS shell flow which (if followed by the user) should set | 37 // Initiates an OS shell flow which (if followed by the user) should set |
| 38 // Chrome as the default handler for |protocol|. Returns false if the flow | 38 // Chrome as the default handler for |protocol|. Returns false if the flow |
| 39 // cannot be initialized, if it is not supported (introduced for Windows 8) | 39 // cannot be initialized, if it is not supported (introduced for Windows 8) |
| 40 // or if the user cancels the operation. This is a blocking call and requires | 40 // or if the user cancels the operation. This is a blocking call and requires |
| 41 // a FILE thread. If Chrome is already default for |protocol|, no interactive | 41 // a FILE thread. If Chrome is already default for |protocol|, no interactive |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // Attempt to determine if this instance of Chrome is the default browser and | 76 // Attempt to determine if this instance of Chrome is the default browser and |
| 77 // return the appropriate state. (Defined as being the handler for HTTP/HTTPS | 77 // return the appropriate state. (Defined as being the handler for HTTP/HTTPS |
| 78 // protocols; we don't want to report "no" here if the user has simply chosen | 78 // protocols; we don't want to report "no" here if the user has simply chosen |
| 79 // to open HTML files in a text editor and FTP links with an FTP client.) | 79 // to open HTML files in a text editor and FTP links with an FTP client.) |
| 80 static DefaultWebClientState GetDefaultBrowser(); | 80 static DefaultWebClientState GetDefaultBrowser(); |
| 81 | 81 |
| 82 // Returns true if Firefox is likely to be the default browser for the current | 82 // Returns true if Firefox is likely to be the default browser for the current |
| 83 // user. This method is very fast so it can be invoked in the UI thread. | 83 // user. This method is very fast so it can be invoked in the UI thread. |
| 84 static bool IsFirefoxDefaultBrowser(); | 84 static bool IsFirefoxDefaultBrowser(); |
|
Ben Goodger (Google)
2013/02/25 16:02:31
ditto for these two methods.
| |
| 85 | 85 |
| 86 // Attempt to determine if this instance of Chrome is the default client | 86 // Attempt to determine if this instance of Chrome is the default client |
| 87 // application for the given protocol and return the appropriate state. | 87 // application for the given protocol and return the appropriate state. |
| 88 static DefaultWebClientState | 88 static DefaultWebClientState |
| 89 IsDefaultProtocolClient(const std::string& protocol); | 89 IsDefaultProtocolClient(const std::string& protocol); |
| 90 | 90 |
| 91 struct ShortcutInfo { | 91 struct ShortcutInfo { |
| 92 ShortcutInfo(); | 92 ShortcutInfo(); |
| 93 ~ShortcutInfo(); | 93 ~ShortcutInfo(); |
| 94 | 94 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 // Updates the UI in our associated view with the current default web | 274 // Updates the UI in our associated view with the current default web |
| 275 // client state. | 275 // client state. |
| 276 void UpdateUI(DefaultWebClientState state); | 276 void UpdateUI(DefaultWebClientState state); |
| 277 | 277 |
| 278 DefaultWebClientObserver* observer_; | 278 DefaultWebClientObserver* observer_; |
| 279 | 279 |
| 280 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); | 280 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 // Worker for checking and setting the default browser. | 283 // Worker for checking and setting the default browser. |
| 284 class DefaultBrowserWorker : public DefaultWebClientWorker { | 284 class DefaultBrowserWorker : public DefaultWebClientWorker { |
|
Ben Goodger (Google)
2013/02/25 16:02:31
etc.
| |
| 285 public: | 285 public: |
| 286 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); | 286 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); |
| 287 | 287 |
| 288 private: | 288 private: |
| 289 virtual ~DefaultBrowserWorker() {} | 289 virtual ~DefaultBrowserWorker() {} |
| 290 | 290 |
| 291 // Check if Chrome is the default browser. | 291 // Check if Chrome is the default browser. |
| 292 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; | 292 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; |
| 293 | 293 |
| 294 // Set Chrome as the default browser. | 294 // Set Chrome as the default browser. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 317 | 317 |
| 318 // Set Chrome as the default handler for this protocol. | 318 // Set Chrome as the default handler for this protocol. |
| 319 virtual bool SetAsDefault(bool interactive_permitted) OVERRIDE; | 319 virtual bool SetAsDefault(bool interactive_permitted) OVERRIDE; |
| 320 | 320 |
| 321 std::string protocol_; | 321 std::string protocol_; |
| 322 | 322 |
| 323 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); | 323 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); |
| 324 }; | 324 }; |
| 325 }; | 325 }; |
| 326 | 326 |
| 327 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ | 327 #endif // APPS_SHELL_INTEGRATION_H_ |
| OLD | NEW |