[email protected] | 5a20b19 | 2012-03-01 06:01:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 4a0765a | 2009-05-08 23:12:25 | [diff] [blame] | 5 | #include "chrome/browser/shell_integration.h" |
| 6 | |
[email protected] | c5efb95 | 2011-11-01 01:28:36 | [diff] [blame] | 7 | #include "base/bind.h" |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 8 | #include "base/command_line.h" |
| 9 | #include "base/file_util.h" |
[email protected] | b96aa93 | 2009-08-12 21:34:49 | [diff] [blame] | 10 | #include "base/path_service.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 11 | #include "base/prefs/pref_service.h" |
[email protected] | 24a555b6 | 2013-06-10 22:01:17 | [diff] [blame] | 12 | #include "base/strings/string_util.h" |
[email protected] | e309f31 | 2013-06-07 21:50:08 | [diff] [blame] | 13 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 124901f5 | 2013-03-27 14:42:10 | [diff] [blame] | 14 | #include "base/threading/thread_restrictions.h" |
[email protected] | ba26a44 | 2013-02-20 15:32:55 | [diff] [blame] | 15 | #include "chrome/browser/policy/policy_path_parser.h" |
[email protected] | b96aa93 | 2009-08-12 21:34:49 | [diff] [blame] | 16 | #include "chrome/common/chrome_paths.h" |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 17 | #include "chrome/common/chrome_switches.h" |
[email protected] | e450fa6 | 2011-02-01 12:52:56 | [diff] [blame] | 18 | #include "chrome/common/pref_names.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 19 | #include "content/public/browser/browser_thread.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 21 | #if defined(OS_CHROMEOS) |
| 22 | #include "chromeos/chromeos_switches.h" |
| 23 | #endif |
| 24 | |
[email protected] | 2f5bc32 | 2013-12-04 08:58:15 | [diff] [blame] | 25 | #if !defined(OS_WIN) |
| 26 | #include "chrome/common/chrome_version_info.h" |
[email protected] | af39f00 | 2014-08-22 10:18:18 | [diff] [blame^] | 27 | #include "chrome/grit/chromium_strings.h" |
[email protected] | 2f5bc32 | 2013-12-04 08:58:15 | [diff] [blame] | 28 | #include "ui/base/l10n/l10n_util.h" |
| 29 | #endif |
| 30 | |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 31 | using content::BrowserThread; |
| 32 | |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 33 | ShellIntegration::DefaultWebClientSetPermission |
| 34 | ShellIntegration::CanSetAsDefaultProtocolClient() { |
[email protected] | a01481b | 2011-07-15 04:30:02 | [diff] [blame] | 35 | // Allowed as long as the browser can become the operating system default |
| 36 | // browser. |
| 37 | return CanSetAsDefaultBrowser(); |
| 38 | } |
| 39 | |
[email protected] | 9561bc91 | 2012-03-07 02:41:16 | [diff] [blame] | 40 | static const struct ShellIntegration::AppModeInfo* gAppModeInfo = NULL; |
| 41 | |
| 42 | // static |
| 43 | void ShellIntegration::SetAppModeInfo(const struct AppModeInfo* info) { |
| 44 | gAppModeInfo = info; |
| 45 | } |
| 46 | |
| 47 | // static |
| 48 | const struct ShellIntegration::AppModeInfo* ShellIntegration::AppModeInfo() { |
| 49 | return gAppModeInfo; |
| 50 | } |
| 51 | |
| 52 | // static |
| 53 | bool ShellIntegration::IsRunningInAppMode() { |
| 54 | return gAppModeInfo != NULL; |
| 55 | } |
| 56 | |
[email protected] | b1039293 | 2011-03-08 21:28:14 | [diff] [blame] | 57 | // static |
| 58 | CommandLine ShellIntegration::CommandLineArgsForLauncher( |
[email protected] | 2f1c09d | 2011-01-14 14:58:14 | [diff] [blame] | 59 | const GURL& url, |
[email protected] | 5c93a0c1 | 2012-05-02 19:45:24 | [diff] [blame] | 60 | const std::string& extension_app_id, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 61 | const base::FilePath& profile_path) { |
[email protected] | 124901f5 | 2013-03-27 14:42:10 | [diff] [blame] | 62 | base::ThreadRestrictions::AssertIOAllowed(); |
[email protected] | b1039293 | 2011-03-08 21:28:14 | [diff] [blame] | 63 | CommandLine new_cmd_line(CommandLine::NO_PROGRAM); |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 64 | |
[email protected] | fb06aea8 | 2014-02-26 15:48:47 | [diff] [blame] | 65 | AppendProfileArgs( |
| 66 | extension_app_id.empty() ? base::FilePath() : profile_path, |
| 67 | &new_cmd_line); |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 68 | |
| 69 | // If |extension_app_id| is present, we use the kAppId switch rather than |
| 70 | // the kApp switch (the launch url will be read from the extension app |
| 71 | // during launch. |
[email protected] | ec5b50d | 2010-10-09 16:35:18 | [diff] [blame] | 72 | if (!extension_app_id.empty()) { |
[email protected] | b1039293 | 2011-03-08 21:28:14 | [diff] [blame] | 73 | new_cmd_line.AppendSwitchASCII(switches::kAppId, extension_app_id); |
[email protected] | 64048bd | 2010-03-08 23:28:58 | [diff] [blame] | 74 | } else { |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 75 | // Use '--app=url' instead of just 'url' to launch the browser with minimal |
| 76 | // chrome. |
| 77 | // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
[email protected] | b1039293 | 2011-03-08 21:28:14 | [diff] [blame] | 78 | new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 79 | } |
[email protected] | b1039293 | 2011-03-08 21:28:14 | [diff] [blame] | 80 | return new_cmd_line; |
[email protected] | 28375ae | 2010-02-05 04:45:50 | [diff] [blame] | 81 | } |
| 82 | |
[email protected] | fb06aea8 | 2014-02-26 15:48:47 | [diff] [blame] | 83 | // static |
| 84 | void ShellIntegration::AppendProfileArgs( |
| 85 | const base::FilePath& profile_path, |
| 86 | CommandLine* command_line) { |
| 87 | DCHECK(command_line); |
| 88 | const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 89 | |
| 90 | // Use the same UserDataDir for new launches that we currently have set. |
| 91 | base::FilePath user_data_dir = |
| 92 | cmd_line.GetSwitchValuePath(switches::kUserDataDir); |
| 93 | #if defined(OS_MACOSX) || defined(OS_WIN) |
| 94 | policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); |
| 95 | #endif |
| 96 | if (!user_data_dir.empty()) { |
| 97 | // Make sure user_data_dir is an absolute path. |
| 98 | user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); |
| 99 | if (!user_data_dir.empty() && base::PathExists(user_data_dir)) |
| 100 | command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 101 | } |
| 102 | |
| 103 | #if defined(OS_CHROMEOS) |
| 104 | base::FilePath profile = cmd_line.GetSwitchValuePath( |
| 105 | chromeos::switches::kLoginProfile); |
| 106 | if (!profile.empty()) |
| 107 | command_line->AppendSwitchPath(chromeos::switches::kLoginProfile, profile); |
| 108 | #else |
| 109 | if (!profile_path.empty()) |
| 110 | command_line->AppendSwitchPath(switches::kProfileDirectory, |
| 111 | profile_path.BaseName()); |
| 112 | #endif |
| 113 | } |
| 114 | |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 115 | #if !defined(OS_WIN) |
[email protected] | 2f5bc32 | 2013-12-04 08:58:15 | [diff] [blame] | 116 | |
| 117 | base::string16 ShellIntegration::GetAppShortcutsSubdirName() { |
| 118 | if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_CANARY) |
| 119 | return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY); |
| 120 | return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME); |
| 121 | } |
| 122 | |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 123 | // static |
| 124 | bool ShellIntegration::SetAsDefaultBrowserInteractive() { |
| 125 | return false; |
| 126 | } |
[email protected] | ee9d89d | 2012-09-25 18:21:03 | [diff] [blame] | 127 | |
| 128 | // static |
| 129 | bool ShellIntegration::SetAsDefaultProtocolClientInteractive( |
| 130 | const std::string& protocol) { |
| 131 | return false; |
| 132 | } |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 133 | #endif |
| 134 | |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 135 | bool ShellIntegration::DefaultWebClientObserver::IsOwnedByWorker() { |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | bool ShellIntegration::DefaultWebClientObserver:: |
| 140 | IsInteractiveSetDefaultPermitted() { |
| 141 | return false; |
| 142 | } |
| 143 | |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 144 | /////////////////////////////////////////////////////////////////////////////// |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 145 | // ShellIntegration::DefaultWebClientWorker |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 146 | // |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 147 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 148 | ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker( |
| 149 | DefaultWebClientObserver* observer) |
[email protected] | 0d3dc8e2 | 2009-11-03 02:27:01 | [diff] [blame] | 150 | : observer_(observer) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 151 | } |
| 152 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 153 | void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() { |
| 154 | if (observer_) { |
| 155 | observer_->SetDefaultWebClientUIState(STATE_PROCESSING); |
| 156 | BrowserThread::PostTask( |
| 157 | BrowserThread::FILE, FROM_HERE, |
[email protected] | c5efb95 | 2011-11-01 01:28:36 | [diff] [blame] | 158 | base::Bind( |
| 159 | &DefaultWebClientWorker::ExecuteCheckIsDefault, this)); |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
| 163 | void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() { |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 164 | bool interactive_permitted = false; |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 165 | if (observer_) { |
| 166 | observer_->SetDefaultWebClientUIState(STATE_PROCESSING); |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 167 | interactive_permitted = observer_->IsInteractiveSetDefaultPermitted(); |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 168 | } |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 169 | BrowserThread::PostTask( |
| 170 | BrowserThread::FILE, FROM_HERE, |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 171 | base::Bind(&DefaultWebClientWorker::ExecuteSetAsDefault, this, |
| 172 | interactive_permitted)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 173 | } |
| 174 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 175 | void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() { |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 176 | // Our associated view has gone away, so we shouldn't call back to it if |
| 177 | // our worker thread returns after the view is dead. |
[email protected] | bcb999d | 2011-05-31 15:11:35 | [diff] [blame] | 178 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 179 | observer_ = NULL; |
| 180 | } |
| 181 | |
| 182 | /////////////////////////////////////////////////////////////////////////////// |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 183 | // DefaultWebClientWorker, private: |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 184 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 185 | void ShellIntegration::DefaultWebClientWorker::ExecuteCheckIsDefault() { |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 186 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 187 | DefaultWebClientState state = CheckIsDefault(); |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 188 | BrowserThread::PostTask( |
| 189 | BrowserThread::UI, FROM_HERE, |
[email protected] | c5efb95 | 2011-11-01 01:28:36 | [diff] [blame] | 190 | base::Bind( |
| 191 | &DefaultWebClientWorker::CompleteCheckIsDefault, this, state)); |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 192 | } |
| 193 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 194 | void ShellIntegration::DefaultWebClientWorker::CompleteCheckIsDefault( |
| 195 | DefaultWebClientState state) { |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 196 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | 264f74d1 | 2009-09-04 23:39:58 | [diff] [blame] | 197 | UpdateUI(state); |
[email protected] | 97e2e3f | 2011-07-22 10:21:25 | [diff] [blame] | 198 | // The worker has finished everything it needs to do, so free the observer |
| 199 | // if we own it. |
| 200 | if (observer_ && observer_->IsOwnedByWorker()) { |
| 201 | delete observer_; |
| 202 | observer_ = NULL; |
| 203 | } |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 204 | } |
| 205 | |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 206 | void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault( |
| 207 | bool interactive_permitted) { |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 208 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 209 | |
| 210 | bool result = SetAsDefault(interactive_permitted); |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 211 | BrowserThread::PostTask( |
| 212 | BrowserThread::UI, FROM_HERE, |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 213 | base::Bind(&DefaultWebClientWorker::CompleteSetAsDefault, this, result)); |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 214 | } |
| 215 | |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 216 | void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault( |
| 217 | bool succeeded) { |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 218 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 219 | // First tell the observer what the SetAsDefault call has returned. |
| 220 | if (observer_) |
| 221 | observer_->OnSetAsDefaultConcluded(succeeded); |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 222 | // Set as default completed, check again to make sure it stuck... |
| 223 | StartCheckIsDefault(); |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 224 | } |
| 225 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 226 | void ShellIntegration::DefaultWebClientWorker::UpdateUI( |
| 227 | DefaultWebClientState state) { |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 228 | if (observer_) { |
[email protected] | 264f74d1 | 2009-09-04 23:39:58 | [diff] [blame] | 229 | switch (state) { |
[email protected] | 8988665 | 2012-12-11 18:09:07 | [diff] [blame] | 230 | case NOT_DEFAULT: |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 231 | observer_->SetDefaultWebClientUIState(STATE_NOT_DEFAULT); |
[email protected] | 264f74d1 | 2009-09-04 23:39:58 | [diff] [blame] | 232 | break; |
[email protected] | 8988665 | 2012-12-11 18:09:07 | [diff] [blame] | 233 | case IS_DEFAULT: |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 234 | observer_->SetDefaultWebClientUIState(STATE_IS_DEFAULT); |
[email protected] | 264f74d1 | 2009-09-04 23:39:58 | [diff] [blame] | 235 | break; |
[email protected] | 8988665 | 2012-12-11 18:09:07 | [diff] [blame] | 236 | case UNKNOWN_DEFAULT: |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 237 | observer_->SetDefaultWebClientUIState(STATE_UNKNOWN); |
[email protected] | 264f74d1 | 2009-09-04 23:39:58 | [diff] [blame] | 238 | break; |
| 239 | default: |
| 240 | break; |
| 241 | } |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 242 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 243 | } |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 244 | |
| 245 | /////////////////////////////////////////////////////////////////////////////// |
| 246 | // ShellIntegration::DefaultBrowserWorker |
| 247 | // |
| 248 | |
| 249 | ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker( |
| 250 | DefaultWebClientObserver* observer) |
| 251 | : DefaultWebClientWorker(observer) { |
| 252 | } |
| 253 | |
| 254 | /////////////////////////////////////////////////////////////////////////////// |
| 255 | // DefaultBrowserWorker, private: |
| 256 | |
| 257 | ShellIntegration::DefaultWebClientState |
| 258 | ShellIntegration::DefaultBrowserWorker::CheckIsDefault() { |
[email protected] | 8988665 | 2012-12-11 18:09:07 | [diff] [blame] | 259 | return ShellIntegration::GetDefaultBrowser(); |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 260 | } |
| 261 | |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 262 | bool ShellIntegration::DefaultBrowserWorker::SetAsDefault( |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 263 | bool interactive_permitted) { |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 264 | bool result = false; |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 265 | switch (ShellIntegration::CanSetAsDefaultBrowser()) { |
| 266 | case ShellIntegration::SET_DEFAULT_UNATTENDED: |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 267 | result = ShellIntegration::SetAsDefaultBrowser(); |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 268 | break; |
| 269 | case ShellIntegration::SET_DEFAULT_INTERACTIVE: |
| 270 | if (interactive_permitted) |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 271 | result = ShellIntegration::SetAsDefaultBrowserInteractive(); |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 272 | break; |
| 273 | default: |
| 274 | NOTREACHED(); |
| 275 | } |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 276 | |
| 277 | return result; |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /////////////////////////////////////////////////////////////////////////////// |
| 281 | // ShellIntegration::DefaultProtocolClientWorker |
| 282 | // |
| 283 | |
| 284 | ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker( |
| 285 | DefaultWebClientObserver* observer, const std::string& protocol) |
| 286 | : DefaultWebClientWorker(observer), |
| 287 | protocol_(protocol) { |
| 288 | } |
| 289 | |
| 290 | /////////////////////////////////////////////////////////////////////////////// |
| 291 | // DefaultProtocolClientWorker, private: |
| 292 | |
| 293 | ShellIntegration::DefaultWebClientState |
| 294 | ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { |
| 295 | return ShellIntegration::IsDefaultProtocolClient(protocol_); |
| 296 | } |
| 297 | |
[email protected] | 693baa5d | 2012-06-22 22:23:38 | [diff] [blame] | 298 | bool ShellIntegration::DefaultProtocolClientWorker::SetAsDefault( |
[email protected] | bd046bd4 | 2012-06-08 05:07:32 | [diff] [blame] | 299 | bool interactive_permitted) { |
[email protected] | ee9d89d | 2012-09-25 18:21:03 | [diff] [blame] | 300 | bool result = false; |
| 301 | switch (ShellIntegration::CanSetAsDefaultProtocolClient()) { |
[email protected] | e7f7987 | 2013-09-13 01:39:31 | [diff] [blame] | 302 | case ShellIntegration::SET_DEFAULT_NOT_ALLOWED: |
| 303 | result = false; |
| 304 | break; |
[email protected] | ee9d89d | 2012-09-25 18:21:03 | [diff] [blame] | 305 | case ShellIntegration::SET_DEFAULT_UNATTENDED: |
| 306 | result = ShellIntegration::SetAsDefaultProtocolClient(protocol_); |
| 307 | break; |
| 308 | case ShellIntegration::SET_DEFAULT_INTERACTIVE: |
| 309 | if (interactive_permitted) { |
| 310 | result = ShellIntegration::SetAsDefaultProtocolClientInteractive( |
| 311 | protocol_); |
| 312 | } |
| 313 | break; |
[email protected] | ee9d89d | 2012-09-25 18:21:03 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | return result; |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 317 | } |