Chromium Code Reviews| 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" | |
| 31 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/extensions/extension.h" | |
| 33 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
| 34 #include "chrome/common/extensions/extension_l10n_util.h" | 36 #include "chrome/common/extensions/extension_l10n_util.h" |
| 35 #include "chrome/common/extensions/extension_manifest_constants.h" | 37 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 36 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 37 #include "content/public/browser/gpu_data_manager.h" | 39 #include "content/public/browser/gpu_data_manager.h" |
| 38 #include "content/public/browser/notification_details.h" | 40 #include "content/public/browser/notification_details.h" |
| 41 #include "content/public/browser/notification_service.h" | |
|
benwells
2013/02/21 06:15:38
nit: remove notification_service.h
koz (OOO until 15th September)
2013/02/25 02:39:28
Done.
| |
| 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" |
| 43 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 45 | 48 |
| 46 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 47 #include "chrome/browser/extensions/app_host_installer_win.h" | 50 #include "chrome/browser/extensions/app_host_installer_win.h" |
| 48 #include "chrome/installer/util/browser_distribution.h" | 51 #include "chrome/installer/util/browser_distribution.h" |
| (...skipping 419 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 } |
| 483 // Tell the app list about the install that we just started. | 485 extensions::InstallTracker* tracker = |
| 484 if (is_app_) { | 486 extensions::InstallTrackerFactory::GetForProfile(profile()); |
| 485 chrome::NotifyAppListOfBeginExtensionInstall( | 487 tracker->OnBeginExtensionInstall( |
| 486 profile(), id, name, approval_->installing_icon); | 488 id, name, approval_->installing_icon, is_app_); |
| 487 } | |
| 488 #endif | |
| 489 } | 489 } |
| 490 | 490 |
| 491 // The extension will install through the normal extension install flow, but | 491 // The extension will install through the normal extension install flow, but |
| 492 // the whitelist entry will bypass the normal permissions install dialog. | 492 // the whitelist entry will bypass the normal permissions install dialog. |
| 493 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 493 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
| 494 profile(), this, | 494 profile(), this, |
| 495 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 495 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
| 496 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); | 496 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); |
| 497 installer->Start(); | 497 installer->Start(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 void CompleteInstallFunction::OnExtensionInstallSuccess( | 500 void CompleteInstallFunction::OnExtensionInstallSuccess( |
| 501 const std::string& id) { | 501 const std::string& id) { |
| 502 if (test_webstore_installer_delegate) | 502 if (test_webstore_installer_delegate) |
| 503 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 503 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
| 504 | 504 |
| 505 SendResponse(true); | 505 SendResponse(true); |
| 506 | 506 |
| 507 // Matches the AddRef in RunImpl(). | 507 // Matches the AddRef in RunImpl(). |
| 508 Release(); | 508 Release(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void CompleteInstallFunction::OnExtensionInstallFailure( | 511 void CompleteInstallFunction::OnExtensionInstallFailure( |
| 512 const std::string& id, | 512 const std::string& id, |
| 513 const std::string& error, | 513 const std::string& error, |
| 514 WebstoreInstaller::FailureReason reason) { | 514 WebstoreInstaller::FailureReason reason) { |
| 515 #if defined(ENABLE_APP_LIST) | 515 extensions::InstallTracker* tracker = |
| 516 if (is_app_) | 516 extensions::InstallTrackerFactory::GetForProfile(profile()); |
| 517 chrome::NotifyAppListOfExtensionInstallFailure(profile(), id); | 517 tracker->OnInstallFailure(id); |
| 518 #endif | |
| 519 if (test_webstore_installer_delegate) { | 518 if (test_webstore_installer_delegate) { |
| 520 test_webstore_installer_delegate->OnExtensionInstallFailure( | 519 test_webstore_installer_delegate->OnExtensionInstallFailure( |
| 521 id, error, reason); | 520 id, error, reason); |
| 522 } | 521 } |
| 523 | 522 |
| 524 error_ = error; | 523 error_ = error; |
| 525 SendResponse(false); | 524 SendResponse(false); |
| 526 | 525 |
| 527 // Matches the AddRef in RunImpl(). | 526 // Matches the AddRef in RunImpl(). |
| 528 Release(); | 527 Release(); |
| 529 } | 528 } |
| 530 | 529 |
| 531 void CompleteInstallFunction::OnExtensionDownloadProgress( | 530 void CompleteInstallFunction::OnExtensionDownloadProgress( |
| 532 const std::string& id, | 531 const std::string& id, |
| 533 content::DownloadItem* item) { | 532 content::DownloadItem* item) { |
| 534 #if defined(ENABLE_APP_LIST) | 533 extensions::InstallTracker* tracker = |
| 535 if (is_app_) { | 534 extensions::InstallTrackerFactory::GetForProfile(profile()); |
| 536 chrome::NotifyAppListOfDownloadProgress(profile(), id, | 535 tracker->OnDownloadProgress(id, item->PercentComplete()); |
| 537 item->PercentComplete()); | |
| 538 } | |
| 539 #endif | |
| 540 } | 536 } |
| 541 | 537 |
| 542 bool GetBrowserLoginFunction::RunImpl() { | 538 bool GetBrowserLoginFunction::RunImpl() { |
| 543 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); | 539 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); |
| 544 return true; | 540 return true; |
| 545 } | 541 } |
| 546 | 542 |
| 547 bool GetStoreLoginFunction::RunImpl() { | 543 bool GetStoreLoginFunction::RunImpl() { |
| 548 ExtensionService* service = | 544 ExtensionService* service = |
| 549 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 545 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); | 592 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); |
| 597 return true; | 593 return true; |
| 598 } | 594 } |
| 599 | 595 |
| 600 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { | 596 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { |
| 601 SetResult(Value::CreateBooleanValue(is_enabled)); | 597 SetResult(Value::CreateBooleanValue(is_enabled)); |
| 602 SendResponse(true); | 598 SendResponse(true); |
| 603 } | 599 } |
| 604 | 600 |
| 605 } // namespace extensions | 601 } // namespace extensions |
| OLD | NEW |