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