Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 12298015: Change NotifyAppList*() functions into observers on a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
39 #include "content/public/browser/notification_source.h" 41 #include "content/public/browser/notification_source.h"
40 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
41 #include "extensions/common/error_utils.h" 43 #include "extensions/common/error_utils.h"
42 #include "grit/chromium_strings.h" 44 #include "grit/chromium_strings.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 apps::GetIsAppLauncherEnabled(base::Bind( 470 apps::GetIsAppLauncherEnabled(base::Bind(
469 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, 471 &CompleteInstallFunction::OnGetAppLauncherEnabled, this,
470 approval_->extension_id)); 472 approval_->extension_id));
471 } 473 }
472 474
473 void CompleteInstallFunction::OnGetAppLauncherEnabled( 475 void CompleteInstallFunction::OnGetAppLauncherEnabled(
474 std::string id, 476 std::string id,
475 bool app_launcher_enabled) { 477 bool app_launcher_enabled) {
476 if (app_launcher_enabled) { 478 if (app_launcher_enabled) {
477 std::string name; 479 std::string name;
478 #if defined(ENABLE_APP_LIST)
479 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, 480 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName,
480 &name)) { 481 &name)) {
481 NOTREACHED(); 482 NOTREACHED();
482 } 483 }
483 // Tell the app list about the install that we just started. 484 extensions::InstallTracker* tracker =
484 if (is_app_) { 485 extensions::InstallTrackerFactory::GetForProfile(profile());
485 chrome::NotifyAppListOfBeginExtensionInstall( 486 tracker->OnBeginExtensionInstall(
486 profile(), id, name, approval_->installing_icon); 487 id, name, approval_->installing_icon, is_app_);
487 }
488 #endif
489 } 488 }
490 489
491 // The extension will install through the normal extension install flow, but 490 // The extension will install through the normal extension install flow, but
492 // the whitelist entry will bypass the normal permissions install dialog. 491 // the whitelist entry will bypass the normal permissions install dialog.
493 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 492 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
494 profile(), this, 493 profile(), this,
495 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), 494 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()),
496 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); 495 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE);
497 installer->Start(); 496 installer->Start();
498 } 497 }
499 498
500 void CompleteInstallFunction::OnExtensionInstallSuccess( 499 void CompleteInstallFunction::OnExtensionInstallSuccess(
501 const std::string& id) { 500 const std::string& id) {
502 if (test_webstore_installer_delegate) 501 if (test_webstore_installer_delegate)
503 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); 502 test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
504 503
505 SendResponse(true); 504 SendResponse(true);
506 505
507 // Matches the AddRef in RunImpl(). 506 // Matches the AddRef in RunImpl().
508 Release(); 507 Release();
509 } 508 }
510 509
511 void CompleteInstallFunction::OnExtensionInstallFailure( 510 void CompleteInstallFunction::OnExtensionInstallFailure(
512 const std::string& id, 511 const std::string& id,
513 const std::string& error, 512 const std::string& error,
514 WebstoreInstaller::FailureReason reason) { 513 WebstoreInstaller::FailureReason reason) {
515 #if defined(ENABLE_APP_LIST) 514 extensions::InstallTracker* tracker =
516 if (is_app_) 515 extensions::InstallTrackerFactory::GetForProfile(profile());
517 chrome::NotifyAppListOfExtensionInstallFailure(profile(), id); 516 tracker->OnInstallFailure(id);
518 #endif
519 if (test_webstore_installer_delegate) { 517 if (test_webstore_installer_delegate) {
520 test_webstore_installer_delegate->OnExtensionInstallFailure( 518 test_webstore_installer_delegate->OnExtensionInstallFailure(
521 id, error, reason); 519 id, error, reason);
522 } 520 }
523 521
524 error_ = error; 522 error_ = error;
525 SendResponse(false); 523 SendResponse(false);
526 524
527 // Matches the AddRef in RunImpl(). 525 // Matches the AddRef in RunImpl().
528 Release(); 526 Release();
529 } 527 }
530 528
531 void CompleteInstallFunction::OnExtensionDownloadProgress( 529 void CompleteInstallFunction::OnExtensionDownloadProgress(
532 const std::string& id, 530 const std::string& id,
533 content::DownloadItem* item) { 531 content::DownloadItem* item) {
534 #if defined(ENABLE_APP_LIST) 532 extensions::InstallTracker* tracker =
535 if (is_app_) { 533 extensions::InstallTrackerFactory::GetForProfile(profile());
536 chrome::NotifyAppListOfDownloadProgress(profile(), id, 534 tracker->OnDownloadProgress(id, item->PercentComplete());
537 item->PercentComplete());
538 }
539 #endif
540 } 535 }
541 536
542 bool GetBrowserLoginFunction::RunImpl() { 537 bool GetBrowserLoginFunction::RunImpl() {
543 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); 538 SetResult(CreateLoginResult(profile_->GetOriginalProfile()));
544 return true; 539 return true;
545 } 540 }
546 541
547 bool GetStoreLoginFunction::RunImpl() { 542 bool GetStoreLoginFunction::RunImpl() {
548 ExtensionService* service = 543 ExtensionService* service =
549 extensions::ExtensionSystem::Get(profile_)->extension_service(); 544 extensions::ExtensionSystem::Get(profile_)->extension_service();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); 591 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this));
597 return true; 592 return true;
598 } 593 }
599 594
600 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { 595 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) {
601 SetResult(Value::CreateBooleanValue(is_enabled)); 596 SetResult(Value::CreateBooleanValue(is_enabled));
602 SendResponse(true); 597 SendResponse(true);
603 } 598 }
604 599
605 } // namespace extensions 600 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/install_observer.h » ('j') | chrome/browser/extensions/install_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698