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 <windows.h> | 7 #include <windows.h> |
8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
9 #include <propkey.h> | 9 #include <propkey.h> |
10 #include <propvarutil.h> | 10 #include <propvarutil.h> |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 | 382 |
383 if (kLocations[i].sub_dir) | 383 if (kLocations[i].sub_dir) |
384 path = path.Append(kLocations[i].sub_dir); | 384 path = path.Append(kLocations[i].sub_dir); |
385 | 385 |
386 MigrateWin7ShortcutsInPath(chrome_exe, path); | 386 MigrateWin7ShortcutsInPath(chrome_exe, path); |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
390 } // namespace | 390 } // namespace |
391 | 391 |
392 bool ShellIntegration::CanSetAsDefaultBrowser() { | 392 ShellIntegration::DefaultSettingsChangePermission |
393 return BrowserDistribution::GetDistribution()->CanSetAsDefault(); | 393 ShellIntegration::CanSetAsDefaultBrowser() { |
394 if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) { | |
grt (UTC plus 2)
2012/05/25 20:27:38
no braces for these one-liners
motek.
2012/05/28 17:40:33
Done.
| |
395 return CHANGE_DEFAULT_NOT_ALLOWED; | |
396 } | |
397 | |
398 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | |
grt (UTC plus 2)
2012/05/25 20:27:38
no braces for these
motek.
2012/05/28 17:40:33
Done.
| |
399 return CHANGE_DEFAULT_INTERACTIVE; | |
400 } else { | |
401 return CHANGE_DEFAULT_UNATTENDED; | |
402 } | |
394 } | 403 } |
395 | 404 |
396 bool ShellIntegration::SetAsDefaultBrowser() { | 405 bool ShellIntegration::SetAsDefaultBrowser() { |
397 FilePath chrome_exe; | 406 FilePath chrome_exe; |
398 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 407 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
399 LOG(ERROR) << "Error getting app exe path"; | 408 LOG(ERROR) << "Error getting app exe path"; |
400 return false; | 409 return false; |
401 } | 410 } |
402 | 411 |
403 // From UI currently we only allow setting default browser for current user. | 412 // From UI currently we only allow setting default browser for current user. |
(...skipping 24 matching lines...) Expand all Loading... | |
428 wprotocol)) { | 437 wprotocol)) { |
429 LOG(ERROR) << "Chrome could not be set as default handler for " | 438 LOG(ERROR) << "Chrome could not be set as default handler for " |
430 << protocol << "."; | 439 << protocol << "."; |
431 return false; | 440 return false; |
432 } | 441 } |
433 | 442 |
434 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; | 443 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; |
435 return true; | 444 return true; |
436 } | 445 } |
437 | 446 |
447 bool ShellIntegration::StartSetAsDefaultBrowserInteractive() { | |
448 FilePath chrome_exe; | |
449 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | |
450 LOG(ERROR) << "Error getting app exe path"; | |
grt (UTC plus 2)
2012/05/25 20:27:38
i think NOTREACHED(); or LOG(DFATAL) << ...; would
motek.
2012/05/28 17:40:33
Fair enough. I just copied&pasted this without giv
| |
451 return false; | |
452 } | |
453 | |
454 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
455 if (!ShellUtil::ShowMakeChromeDefaultSystemUI(dist, ShellUtil::CURRENT_USER, | |
456 chrome_exe.value(), true)) { | |
457 LOG(ERROR) << "Failed to launch the set-default-browser Windows UI."; | |
458 return false; | |
459 } | |
460 | |
461 VLOG(1) << "Set-as-default Windows UI triggered."; | |
462 return true; | |
463 } | |
464 | |
438 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { | 465 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { |
439 // When we check for default browser we don't necessarily want to count file | 466 // When we check for default browser we don't necessarily want to count file |
440 // type handlers and icons as having changed the default browser status, | 467 // type handlers and icons as having changed the default browser status, |
441 // since the user may have changed their shell settings to cause HTML files | 468 // since the user may have changed their shell settings to cause HTML files |
442 // to open with a text editor for example. We also don't want to aggressively | 469 // to open with a text editor for example. We also don't want to aggressively |
443 // claim FTP, since the user may have a separate FTP client. It is an open | 470 // claim FTP, since the user may have a separate FTP client. It is an open |
444 // question as to how to "heal" these settings. Perhaps the user should just | 471 // question as to how to "heal" these settings. Perhaps the user should just |
445 // re-run the installer or run with the --set-default-browser command line | 472 // re-run the installer or run with the --set-default-browser command line |
446 // flag. There is doubtless some other key we can hook into to cause "Repair" | 473 // flag. There is doubtless some other key we can hook into to cause "Repair" |
447 // to show up in Add/Remove programs for us. | 474 // to show up in Add/Remove programs for us. |
448 static const wchar_t* const kChromeProtocols[] = { L"http", L"https" }; | 475 static const wchar_t* const kChromeProtocols[] = { L"http", L"https" }; |
449 | |
grt (UTC plus 2)
2012/05/25 20:27:38
nit: please add this newline back. it was my favo
motek.
2012/05/28 17:40:33
Done.
| |
450 return ProbeProtocolHandlers(kChromeProtocols, arraysize(kChromeProtocols)); | 476 return ProbeProtocolHandlers(kChromeProtocols, arraysize(kChromeProtocols)); |
451 } | 477 } |
452 | 478 |
453 ShellIntegration::DefaultWebClientState | 479 ShellIntegration::DefaultWebClientState |
454 ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) { | 480 ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) { |
455 if (protocol.empty()) | 481 if (protocol.empty()) |
456 return UNKNOWN_DEFAULT_WEB_CLIENT; | 482 return UNKNOWN_DEFAULT_WEB_CLIENT; |
457 | 483 |
458 string16 wide_protocol(UTF8ToUTF16(protocol)); | 484 string16 wide_protocol(UTF8ToUTF16(protocol)); |
459 const wchar_t* const protocols[] = { wide_protocol.c_str() }; | 485 const wchar_t* const protocols[] = { wide_protocol.c_str() }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 } | 556 } |
531 | 557 |
532 void ShellIntegration::MigrateChromiumShortcuts() { | 558 void ShellIntegration::MigrateChromiumShortcuts() { |
533 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 559 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
534 return; | 560 return; |
535 | 561 |
536 BrowserThread::PostTask( | 562 BrowserThread::PostTask( |
537 BrowserThread::FILE, FROM_HERE, | 563 BrowserThread::FILE, FROM_HERE, |
538 base::Bind(&MigrateChromiumShortcutsCallback)); | 564 base::Bind(&MigrateChromiumShortcutsCallback)); |
539 } | 565 } |
OLD | NEW |