| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
| 17 | 17 |
| 18 class CommandLine; | 18 class CommandLine; |
| 19 | 19 |
| 20 #if defined(USE_X11) | |
| 21 namespace base { | |
| 22 class Environment; | |
| 23 } | |
| 24 #endif | |
| 25 | |
| 26 class ShellIntegration { | 20 class ShellIntegration { |
| 27 public: | 21 public: |
| 28 // Sets Chrome as the default browser (only for the current user). Returns | 22 // Sets Chrome as the default browser (only for the current user). Returns |
| 29 // false if this operation fails. | 23 // false if this operation fails. |
| 30 static bool SetAsDefaultBrowser(); | 24 static bool SetAsDefaultBrowser(); |
| 31 | 25 |
| 32 // Sets Chrome as the default client application for the given protocol | 26 // Sets Chrome as the default client application for the given protocol |
| 33 // (only for the current user). Returns false if this operation fails. | 27 // (only for the current user). Returns false if this operation fails. |
| 34 static bool SetAsDefaultProtocolClient(const std::string& protocol); | 28 static bool SetAsDefaultProtocolClient(const std::string& protocol); |
| 35 | 29 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 106 |
| 113 // Set up command line arguments for launching a platform app. | 107 // Set up command line arguments for launching a platform app. |
| 114 // The command line will have the switches --app-id, --user-data-dir and | 108 // The command line will have the switches --app-id, --user-data-dir and |
| 115 // --load-extension, using values |extension_app_id|, |user_data_dir| and | 109 // --load-extension, using values |extension_app_id|, |user_data_dir| and |
| 116 // |extension_path| respectively. | 110 // |extension_path| respectively. |
| 117 static CommandLine CommandLineArgsForPlatformApp( | 111 static CommandLine CommandLineArgsForPlatformApp( |
| 118 const std::string& extension_app_id, | 112 const std::string& extension_app_id, |
| 119 const FilePath& user_data_dir, | 113 const FilePath& user_data_dir, |
| 120 const FilePath& extension_path); | 114 const FilePath& extension_path); |
| 121 | 115 |
| 122 #if defined(USE_X11) | |
| 123 // Returns filename of the desktop shortcut used to launch the browser. | |
| 124 static std::string GetDesktopName(base::Environment* env); | |
| 125 | |
| 126 static bool GetDesktopShortcutTemplate(base::Environment* env, | |
| 127 std::string* output); | |
| 128 | |
| 129 // Returns filename for .desktop file based on |url|, sanitized for security. | |
| 130 static FilePath GetDesktopShortcutFilename(const GURL& url); | |
| 131 | |
| 132 // Returns contents for .desktop file based on |template_contents|, |url| | |
| 133 // and |title|. The |template_contents| should be contents of .desktop file | |
| 134 // used to launch Chrome. | |
| 135 static std::string GetDesktopFileContents( | |
| 136 const std::string& template_contents, | |
| 137 const std::string& app_name, | |
| 138 const GURL& url, | |
| 139 const std::string& extension_id, | |
| 140 const bool is_platform_app, | |
| 141 const FilePath& web_app_path, | |
| 142 const FilePath& extension_path, | |
| 143 const string16& title, | |
| 144 const std::string& icon_name); | |
| 145 | |
| 146 static bool CreateDesktopShortcut(const ShortcutInfo& shortcut_info, | |
| 147 const std::string& shortcut_template); | |
| 148 #endif // defined(USE_X11) | |
| 149 | |
| 150 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
| 151 // Generates Win7 app id for given app name and profile path. The returned app | 117 // Generates Win7 app id for given app name and profile path. The returned app |
| 152 // id is in the format of "|app_name|[.<profile_id>]". "profile_id" is | 118 // id is in the format of "|app_name|[.<profile_id>]". "profile_id" is |
| 153 // appended when user override the default value. | 119 // appended when user override the default value. |
| 154 static string16 GetAppId(const string16& app_name, | 120 static string16 GetAppId(const string16& app_name, |
| 155 const FilePath& profile_path); | 121 const FilePath& profile_path); |
| 156 | 122 |
| 157 // Generates Win7 app id for Chromium by calling GetAppId with | 123 // Generates Win7 app id for Chromium by calling GetAppId with |
| 158 // chrome::kBrowserAppID as app_name. | 124 // chrome::kBrowserAppID as app_name. |
| 159 static string16 GetChromiumAppId(const FilePath& profile_path); | 125 static string16 GetChromiumAppId(const FilePath& profile_path); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // Set Chrome as the default handler for this protocol. | 262 // Set Chrome as the default handler for this protocol. |
| 297 virtual void SetAsDefault() OVERRIDE; | 263 virtual void SetAsDefault() OVERRIDE; |
| 298 | 264 |
| 299 std::string protocol_; | 265 std::string protocol_; |
| 300 | 266 |
| 301 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); | 267 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); |
| 302 }; | 268 }; |
| 303 }; | 269 }; |
| 304 | 270 |
| 305 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ | 271 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ |
| OLD | NEW |