| 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 #include "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/policy/policy_path_parser.h" | 16 #include "chrome/browser/policy/policy_path_parser.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
| 20 #include "components/version_info/version_info.h" | 20 #include "components/version_info/version_info.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 | 22 |
| 23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 29 #include "chrome/browser/shell_integration_win.h" | 29 #include "chrome/browser/shell_integration_win.h" |
| 30 #include "chrome/installer/util/shell_util.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if !defined(OS_WIN) | 33 #if !defined(OS_WIN) |
| 33 #include "chrome/common/channel_info.h" | 34 #include "chrome/common/channel_info.h" |
| 34 #include "chrome/grit/chromium_strings.h" | 35 #include "chrome/grit/chromium_strings.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 using content::BrowserThread; | 39 using content::BrowserThread; |
| 39 | 40 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 switch (GetDefaultWebClientSetPermission()) { | 238 switch (GetDefaultWebClientSetPermission()) { |
| 238 case SET_DEFAULT_NOT_ALLOWED: | 239 case SET_DEFAULT_NOT_ALLOWED: |
| 239 NOTREACHED(); | 240 NOTREACHED(); |
| 240 break; | 241 break; |
| 241 case SET_DEFAULT_UNATTENDED: | 242 case SET_DEFAULT_UNATTENDED: |
| 242 SetAsDefaultBrowser(); | 243 SetAsDefaultBrowser(); |
| 243 break; | 244 break; |
| 244 case SET_DEFAULT_INTERACTIVE: | 245 case SET_DEFAULT_INTERACTIVE: |
| 245 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
| 246 if (interactive_permitted_) { | 247 if (interactive_permitted_) { |
| 247 // The Windows 8 API for choosing the default browser was deprecated on | 248 switch (ShellUtil::GetInteractiveSetDefaultMode()) { |
| 248 // Windows 10. | 249 case ShellUtil::INTENT_PICKER: |
| 249 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { | 250 win::SetAsDefaultBrowserUsingIntentPicker(); |
| 250 win::SetAsDefaultBrowserUsingSystemSettings(on_finished_callback); | 251 break; |
| 251 return; | 252 case ShellUtil::SYSTEM_SETTINGS: |
| 252 } else { | 253 win::SetAsDefaultBrowserUsingSystemSettings(on_finished_callback); |
| 253 win::SetAsDefaultBrowserUsingIntentPicker(); | 254 // Early return because the function above takes care of calling |
| 255 // |on_finished_callback|. |
| 256 return; |
| 254 } | 257 } |
| 255 } | 258 } |
| 256 #endif // defined(OS_WIN) | 259 #endif // defined(OS_WIN) |
| 257 break; | 260 break; |
| 258 } | 261 } |
| 259 on_finished_callback.Run(); | 262 on_finished_callback.Run(); |
| 260 } | 263 } |
| 261 | 264 |
| 262 /////////////////////////////////////////////////////////////////////////////// | 265 /////////////////////////////////////////////////////////////////////////////// |
| 263 // DefaultProtocolClientWorker | 266 // DefaultProtocolClientWorker |
| (...skipping 21 matching lines...) Expand all Loading... |
| 285 const base::Closure& on_finished_callback) { | 288 const base::Closure& on_finished_callback) { |
| 286 switch (GetDefaultWebClientSetPermission()) { | 289 switch (GetDefaultWebClientSetPermission()) { |
| 287 case SET_DEFAULT_NOT_ALLOWED: | 290 case SET_DEFAULT_NOT_ALLOWED: |
| 288 // Not allowed, do nothing. | 291 // Not allowed, do nothing. |
| 289 break; | 292 break; |
| 290 case SET_DEFAULT_UNATTENDED: | 293 case SET_DEFAULT_UNATTENDED: |
| 291 SetAsDefaultProtocolClient(protocol_); | 294 SetAsDefaultProtocolClient(protocol_); |
| 292 break; | 295 break; |
| 293 case SET_DEFAULT_INTERACTIVE: | 296 case SET_DEFAULT_INTERACTIVE: |
| 294 #if defined(OS_WIN) | 297 #if defined(OS_WIN) |
| 295 // TODO(pmonette): Implement a working flow for Windows 10. | 298 if (interactive_permitted_) { |
| 296 if (interactive_permitted_) | 299 switch (ShellUtil::GetInteractiveSetDefaultMode()) { |
| 297 win::SetAsDefaultProtocolClientUsingIntentPicker(protocol_); | 300 case ShellUtil::INTENT_PICKER: |
| 301 win::SetAsDefaultProtocolClientUsingIntentPicker(protocol_); |
| 302 break; |
| 303 case ShellUtil::SYSTEM_SETTINGS: |
| 304 win::SetAsDefaultProtocolClientUsingSystemSettings( |
| 305 protocol_, on_finished_callback); |
| 306 // Early return because the function above takes care of calling |
| 307 // |on_finished_callback|. |
| 308 return; |
| 309 } |
| 310 } |
| 298 #endif // defined(OS_WIN) | 311 #endif // defined(OS_WIN) |
| 299 break; | 312 break; |
| 300 } | 313 } |
| 301 on_finished_callback.Run(); | 314 on_finished_callback.Run(); |
| 302 } | 315 } |
| 303 | 316 |
| 304 } // namespace shell_integration | 317 } // namespace shell_integration |
| OLD | NEW |