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()) |
| 395 return CHANGE_DEFAULT_NOT_ALLOWED; |
| 396 |
| 397 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
| 398 return CHANGE_DEFAULT_INTERACTIVE; |
| 399 else |
| 400 return CHANGE_DEFAULT_UNATTENDED; |
394 } | 401 } |
395 | 402 |
396 bool ShellIntegration::SetAsDefaultBrowser() { | 403 bool ShellIntegration::SetAsDefaultBrowser() { |
397 FilePath chrome_exe; | 404 FilePath chrome_exe; |
398 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 405 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
399 LOG(ERROR) << "Error getting app exe path"; | 406 LOG(ERROR) << "Error getting app exe path"; |
400 return false; | 407 return false; |
401 } | 408 } |
402 | 409 |
403 // From UI currently we only allow setting default browser for current user. | 410 // From UI currently we only allow setting default browser for current user. |
(...skipping 24 matching lines...) Expand all Loading... |
428 wprotocol)) { | 435 wprotocol)) { |
429 LOG(ERROR) << "Chrome could not be set as default handler for " | 436 LOG(ERROR) << "Chrome could not be set as default handler for " |
430 << protocol << "."; | 437 << protocol << "."; |
431 return false; | 438 return false; |
432 } | 439 } |
433 | 440 |
434 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; | 441 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; |
435 return true; | 442 return true; |
436 } | 443 } |
437 | 444 |
| 445 bool ShellIntegration::SetAsDefaultBrowserInteractive() { |
| 446 FilePath chrome_exe; |
| 447 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
| 448 NOTREACHED() << "Error getting app exe path"; |
| 449 return false; |
| 450 } |
| 451 |
| 452 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 453 if (!ShellUtil::ShowMakeChromeDefaultSystemUI(dist, ShellUtil::CURRENT_USER, |
| 454 chrome_exe.value(), true)) { |
| 455 LOG(ERROR) << "Failed to launch the set-default-browser Windows UI."; |
| 456 return false; |
| 457 } |
| 458 |
| 459 VLOG(1) << "Set-as-default Windows UI triggered."; |
| 460 return true; |
| 461 } |
| 462 |
438 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { | 463 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { |
439 // When we check for default browser we don't necessarily want to count file | 464 // 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, | 465 // 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 | 466 // 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 | 467 // 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 | 468 // 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 | 469 // 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 | 470 // 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" | 471 // flag. There is doubtless some other key we can hook into to cause "Repair" |
447 // to show up in Add/Remove programs for us. | 472 // to show up in Add/Remove programs for us. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 555 } |
531 | 556 |
532 void ShellIntegration::MigrateChromiumShortcuts() { | 557 void ShellIntegration::MigrateChromiumShortcuts() { |
533 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 558 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
534 return; | 559 return; |
535 | 560 |
536 BrowserThread::PostTask( | 561 BrowserThread::PostTask( |
537 BrowserThread::FILE, FROM_HERE, | 562 BrowserThread::FILE, FROM_HERE, |
538 base::Bind(&MigrateChromiumShortcutsCallback)); | 563 base::Bind(&MigrateChromiumShortcutsCallback)); |
539 } | 564 } |
OLD | NEW |