| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } else { | 418 } else { |
| 419 success = true; | 419 success = true; |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 return success; | 423 return success; |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace | 426 } // namespace |
| 427 | 427 |
| 428 bool ShellIntegration::CanSetAsDefaultBrowser() { | 428 ShellIntegration::DefaultWebClientSetPermission |
| 429 return BrowserDistribution::GetDistribution()->CanSetAsDefault(); | 429 ShellIntegration::CanSetAsDefaultBrowser() { |
| 430 if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) |
| 431 return SET_DEFAULT_NOT_ALLOWED; |
| 432 |
| 433 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
| 434 return SET_DEFAULT_INTERACTIVE; |
| 435 else |
| 436 return SET_DEFAULT_UNATTENDED; |
| 430 } | 437 } |
| 431 | 438 |
| 432 bool ShellIntegration::SetAsDefaultBrowser() { | 439 bool ShellIntegration::SetAsDefaultBrowser() { |
| 433 FilePath chrome_exe; | 440 FilePath chrome_exe; |
| 434 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 441 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
| 435 LOG(ERROR) << "Error getting app exe path"; | 442 LOG(ERROR) << "Error getting app exe path"; |
| 436 return false; | 443 return false; |
| 437 } | 444 } |
| 438 | 445 |
| 439 // From UI currently we only allow setting default browser for current user. | 446 // From UI currently we only allow setting default browser for current user. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 464 wprotocol)) { | 471 wprotocol)) { |
| 465 LOG(ERROR) << "Chrome could not be set as default handler for " | 472 LOG(ERROR) << "Chrome could not be set as default handler for " |
| 466 << protocol << "."; | 473 << protocol << "."; |
| 467 return false; | 474 return false; |
| 468 } | 475 } |
| 469 | 476 |
| 470 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; | 477 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; |
| 471 return true; | 478 return true; |
| 472 } | 479 } |
| 473 | 480 |
| 481 bool ShellIntegration::SetAsDefaultBrowserInteractive() { |
| 482 FilePath chrome_exe; |
| 483 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
| 484 NOTREACHED() << "Error getting app exe path"; |
| 485 return false; |
| 486 } |
| 487 |
| 488 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 489 if (!ShellUtil::ShowMakeChromeDefaultSystemUI(dist, chrome_exe.value())) { |
| 490 LOG(ERROR) << "Failed to launch the set-default-browser Windows UI."; |
| 491 return false; |
| 492 } |
| 493 |
| 494 VLOG(1) << "Set-as-default Windows UI triggered."; |
| 495 return true; |
| 496 } |
| 497 |
| 474 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { | 498 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { |
| 475 // When we check for default browser we don't necessarily want to count file | 499 // When we check for default browser we don't necessarily want to count file |
| 476 // type handlers and icons as having changed the default browser status, | 500 // type handlers and icons as having changed the default browser status, |
| 477 // since the user may have changed their shell settings to cause HTML files | 501 // since the user may have changed their shell settings to cause HTML files |
| 478 // to open with a text editor for example. We also don't want to aggressively | 502 // to open with a text editor for example. We also don't want to aggressively |
| 479 // claim FTP, since the user may have a separate FTP client. It is an open | 503 // claim FTP, since the user may have a separate FTP client. It is an open |
| 480 // question as to how to "heal" these settings. Perhaps the user should just | 504 // question as to how to "heal" these settings. Perhaps the user should just |
| 481 // re-run the installer or run with the --set-default-browser command line | 505 // re-run the installer or run with the --set-default-browser command line |
| 482 // flag. There is doubtless some other key we can hook into to cause "Repair" | 506 // flag. There is doubtless some other key we can hook into to cause "Repair" |
| 483 // to show up in Add/Remove programs for us. | 507 // to show up in Add/Remove programs for us. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 BrowserThread::PostTask( | 596 BrowserThread::PostTask( |
| 573 BrowserThread::FILE, FROM_HERE, | 597 BrowserThread::FILE, FROM_HERE, |
| 574 base::Bind(&MigrateChromiumShortcutsCallback)); | 598 base::Bind(&MigrateChromiumShortcutsCallback)); |
| 575 } | 599 } |
| 576 | 600 |
| 577 bool ShellIntegration::ActivateMetroChrome() { | 601 bool ShellIntegration::ActivateMetroChrome() { |
| 578 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 602 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 579 const string16 app_id(dist->GetBrowserAppId()); | 603 const string16 app_id(dist->GetBrowserAppId()); |
| 580 return ActivateApplication(app_id); | 604 return ActivateApplication(app_id); |
| 581 } | 605 } |
| OLD | NEW |