| 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/extensions/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
| 6 | 6 |
| 7 #include "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/about_flags.h" | 16 #include "chrome/browser/about_flags.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/extensions/crx_installer.h" | 18 #include "chrome/browser/extensions/crx_installer.h" |
| 19 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 19 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 20 #include "chrome/browser/extensions/extension_prefs.h" | 20 #include "chrome/browser/extensions/extension_prefs.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
| 23 #include "chrome/browser/extensions/install_tracker.h" |
| 24 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 23 #include "chrome/browser/extensions/webstore_installer.h" | 25 #include "chrome/browser/extensions/webstore_installer.h" |
| 24 #include "chrome/browser/gpu/gpu_feature_checker.h" | 26 #include "chrome/browser/gpu/gpu_feature_checker.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/signin/token_service.h" | 28 #include "chrome/browser/signin/token_service.h" |
| 27 #include "chrome/browser/signin/token_service_factory.h" | 29 #include "chrome/browser/signin/token_service_factory.h" |
| 28 #include "chrome/browser/sync/profile_sync_service.h" | 30 #include "chrome/browser/sync/profile_sync_service.h" |
| 29 #include "chrome/browser/sync/profile_sync_service_factory.h" | 31 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 30 #include "chrome/browser/ui/app_list/app_list_util.h" | 32 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/common/extensions/extension.h" |
| 33 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
| 34 #include "chrome/common/extensions/extension_l10n_util.h" | 37 #include "chrome/common/extensions/extension_l10n_util.h" |
| 35 #include "chrome/common/extensions/extension_manifest_constants.h" | 38 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 36 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 37 #include "content/public/browser/gpu_data_manager.h" | 40 #include "content/public/browser/gpu_data_manager.h" |
| 38 #include "content/public/browser/notification_details.h" | 41 #include "content/public/browser/notification_details.h" |
| 39 #include "content/public/browser/notification_source.h" | 42 #include "content/public/browser/notification_source.h" |
| 40 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 41 #include "extensions/common/error_utils.h" | 44 #include "extensions/common/error_utils.h" |
| 42 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 apps::GetIsAppLauncherEnabled(base::Bind( | 471 apps::GetIsAppLauncherEnabled(base::Bind( |
| 469 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, | 472 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, |
| 470 approval_->extension_id)); | 473 approval_->extension_id)); |
| 471 } | 474 } |
| 472 | 475 |
| 473 void CompleteInstallFunction::OnGetAppLauncherEnabled( | 476 void CompleteInstallFunction::OnGetAppLauncherEnabled( |
| 474 std::string id, | 477 std::string id, |
| 475 bool app_launcher_enabled) { | 478 bool app_launcher_enabled) { |
| 476 if (app_launcher_enabled) { | 479 if (app_launcher_enabled) { |
| 477 std::string name; | 480 std::string name; |
| 478 #if defined(ENABLE_APP_LIST) | |
| 479 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, | 481 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, |
| 480 &name)) { | 482 &name)) { |
| 481 NOTREACHED(); | 483 NOTREACHED(); |
| 482 } | 484 } |
| 485 #if defined(ENABLE_APP_LIST) |
| 486 // Show the app list so it receives install progress notifications. |
| 487 chrome::ShowAppList(profile()); |
| 488 #endif |
| 483 // Tell the app list about the install that we just started. | 489 // Tell the app list about the install that we just started. |
| 484 if (is_app_) { | 490 extensions::InstallTracker* tracker = |
| 485 chrome::NotifyAppListOfBeginExtensionInstall( | 491 extensions::InstallTrackerFactory::GetForProfile(profile()); |
| 486 profile(), id, name, approval_->installing_icon); | 492 tracker->OnBeginExtensionInstall( |
| 487 } | 493 id, name, approval_->installing_icon, is_app_); |
| 488 #endif | |
| 489 } | 494 } |
| 490 | 495 |
| 491 // The extension will install through the normal extension install flow, but | 496 // The extension will install through the normal extension install flow, but |
| 492 // the whitelist entry will bypass the normal permissions install dialog. | 497 // the whitelist entry will bypass the normal permissions install dialog. |
| 493 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 498 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
| 494 profile(), this, | 499 profile(), this, |
| 495 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 500 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
| 496 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); | 501 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); |
| 497 installer->Start(); | 502 installer->Start(); |
| 498 } | 503 } |
| 499 | 504 |
| 500 void CompleteInstallFunction::OnExtensionInstallSuccess( | 505 void CompleteInstallFunction::OnExtensionInstallSuccess( |
| 501 const std::string& id) { | 506 const std::string& id) { |
| 502 if (test_webstore_installer_delegate) | 507 if (test_webstore_installer_delegate) |
| 503 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 508 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
| 504 | 509 |
| 505 SendResponse(true); | 510 SendResponse(true); |
| 506 | 511 |
| 507 // Matches the AddRef in RunImpl(). | 512 // Matches the AddRef in RunImpl(). |
| 508 Release(); | 513 Release(); |
| 509 } | 514 } |
| 510 | 515 |
| 511 void CompleteInstallFunction::OnExtensionInstallFailure( | 516 void CompleteInstallFunction::OnExtensionInstallFailure( |
| 512 const std::string& id, | 517 const std::string& id, |
| 513 const std::string& error, | 518 const std::string& error, |
| 514 WebstoreInstaller::FailureReason reason) { | 519 WebstoreInstaller::FailureReason reason) { |
| 515 #if defined(ENABLE_APP_LIST) | 520 extensions::InstallTracker* tracker = |
| 516 if (is_app_) | 521 extensions::InstallTrackerFactory::GetForProfile(profile()); |
| 517 chrome::NotifyAppListOfExtensionInstallFailure(profile(), id); | 522 tracker->OnInstallFailure(id); |
| 518 #endif | |
| 519 if (test_webstore_installer_delegate) { | 523 if (test_webstore_installer_delegate) { |
| 520 test_webstore_installer_delegate->OnExtensionInstallFailure( | 524 test_webstore_installer_delegate->OnExtensionInstallFailure( |
| 521 id, error, reason); | 525 id, error, reason); |
| 522 } | 526 } |
| 523 | 527 |
| 524 error_ = error; | 528 error_ = error; |
| 525 SendResponse(false); | 529 SendResponse(false); |
| 526 | 530 |
| 527 // Matches the AddRef in RunImpl(). | 531 // Matches the AddRef in RunImpl(). |
| 528 Release(); | 532 Release(); |
| 529 } | 533 } |
| 530 | 534 |
| 531 void CompleteInstallFunction::OnExtensionDownloadProgress( | 535 void CompleteInstallFunction::OnExtensionDownloadProgress( |
| 532 const std::string& id, | 536 const std::string& id, |
| 533 content::DownloadItem* item) { | 537 content::DownloadItem* item) { |
| 534 #if defined(ENABLE_APP_LIST) | 538 extensions::InstallTracker* tracker = |
| 535 if (is_app_) { | 539 extensions::InstallTrackerFactory::GetForProfile(profile()); |
| 536 chrome::NotifyAppListOfDownloadProgress(profile(), id, | 540 tracker->OnDownloadProgress(id, item->PercentComplete()); |
| 537 item->PercentComplete()); | |
| 538 } | |
| 539 #endif | |
| 540 } | 541 } |
| 541 | 542 |
| 542 bool GetBrowserLoginFunction::RunImpl() { | 543 bool GetBrowserLoginFunction::RunImpl() { |
| 543 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); | 544 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); |
| 544 return true; | 545 return true; |
| 545 } | 546 } |
| 546 | 547 |
| 547 bool GetStoreLoginFunction::RunImpl() { | 548 bool GetStoreLoginFunction::RunImpl() { |
| 548 ExtensionService* service = | 549 ExtensionService* service = |
| 549 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 550 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); | 597 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); |
| 597 return true; | 598 return true; |
| 598 } | 599 } |
| 599 | 600 |
| 600 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { | 601 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { |
| 601 SetResult(Value::CreateBooleanValue(is_enabled)); | 602 SetResult(Value::CreateBooleanValue(is_enabled)); |
| 602 SendResponse(true); | 603 SendResponse(true); |
| 603 } | 604 } |
| 604 | 605 |
| 605 } // namespace extensions | 606 } // namespace extensions |
| OLD | NEW |