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