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

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: Created 7 years, 10 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/webstore_installer.h" 23 #include "chrome/browser/extensions/webstore_installer.h"
24 #include "chrome/browser/gpu/gpu_feature_checker.h" 24 #include "chrome/browser/gpu/gpu_feature_checker.h"
25 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/signin/token_service.h" 26 #include "chrome/browser/signin/token_service.h"
27 #include "chrome/browser/signin/token_service_factory.h" 27 #include "chrome/browser/signin/token_service_factory.h"
28 #include "chrome/browser/sync/profile_sync_service.h" 28 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/sync/profile_sync_service_factory.h" 29 #include "chrome/browser/sync/profile_sync_service_factory.h"
30 #include "chrome/browser/ui/app_list/app_list_util.h" 30 #include "chrome/browser/ui/app_list/app_list_util.h"
benwells 2013/02/18 07:56:36 Is this include still needed?
koz (OOO until 15th September) 2013/02/19 03:20:36 Nope, good catch.
31 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/extensions/extension.h"
33 #include "chrome/common/extensions/extension_constants.h" 34 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/extensions/extension_l10n_util.h" 35 #include "chrome/common/extensions/extension_l10n_util.h"
35 #include "chrome/common/extensions/extension_manifest_constants.h" 36 #include "chrome/common/extensions/extension_manifest_constants.h"
36 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
37 #include "content/public/browser/gpu_data_manager.h" 38 #include "content/public/browser/gpu_data_manager.h"
38 #include "content/public/browser/notification_details.h" 39 #include "content/public/browser/notification_details.h"
40 #include "content/public/browser/notification_service.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"
43 #include "grit/generated_resources.h" 45 #include "grit/generated_resources.h"
44 #include "ui/base/l10n/l10n_util.h" 46 #include "ui/base/l10n/l10n_util.h"
45 47
46 #if defined(OS_WIN) 48 #if defined(OS_WIN)
47 #include "chrome/browser/extensions/app_host_installer_win.h" 49 #include "chrome/browser/extensions/app_host_installer_win.h"
48 #include "chrome/installer/util/browser_distribution.h" 50 #include "chrome/installer/util/browser_distribution.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 apps::GetIsAppLauncherEnabled(base::Bind( 467 apps::GetIsAppLauncherEnabled(base::Bind(
466 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, 468 &CompleteInstallFunction::OnGetAppLauncherEnabled, this,
467 approval_->extension_id)); 469 approval_->extension_id));
468 } 470 }
469 471
470 void CompleteInstallFunction::OnGetAppLauncherEnabled( 472 void CompleteInstallFunction::OnGetAppLauncherEnabled(
471 std::string id, 473 std::string id,
472 bool app_launcher_enabled) { 474 bool app_launcher_enabled) {
473 if (app_launcher_enabled) { 475 if (app_launcher_enabled) {
474 std::string name; 476 std::string name;
475 #if defined(ENABLE_APP_LIST) 477 #if defined(ENABLE_APP_LIST)
benwells 2013/02/18 07:56:36 Should we kill the #if? This is nice and generic n
koz (OOO until 15th September) 2013/02/19 03:20:36 Done.
476 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, 478 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName,
477 &name)) { 479 &name)) {
478 NOTREACHED(); 480 NOTREACHED();
479 } 481 }
480 // Tell the app list about the install that we just started. 482 // Tell the app list about the install that we just started.
481 chrome::NotifyAppListOfBeginExtensionInstall( 483 ExtensionInstallingDetails details(
482 profile(), id, name, approval_->installing_icon); 484 id, name, approval_->installing_icon, true);
485 content::NotificationService::current()->Notify(
486 chrome::NOTIFICATION_EXTENSION_INSTALL_BEGIN,
487 content::Source<Profile>(profile()),
488 content::Details<ExtensionInstallingDetails>(&details));
483 #endif 489 #endif
484 } 490 }
485 491
486 // The extension will install through the normal extension install flow, but 492 // The extension will install through the normal extension install flow, but
487 // the whitelist entry will bypass the normal permissions install dialog. 493 // the whitelist entry will bypass the normal permissions install dialog.
488 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 494 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
489 profile(), this, 495 profile(), this,
490 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), 496 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()),
491 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); 497 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE);
492 installer->Start(); 498 installer->Start();
493 } 499 }
494 500
495 void CompleteInstallFunction::OnExtensionInstallSuccess( 501 void CompleteInstallFunction::OnExtensionInstallSuccess(
496 const std::string& id) { 502 const std::string& id) {
497 if (test_webstore_installer_delegate) 503 if (test_webstore_installer_delegate)
498 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); 504 test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
499 505
500 SendResponse(true); 506 SendResponse(true);
501 507
502 // Matches the AddRef in RunImpl(). 508 // Matches the AddRef in RunImpl().
503 Release(); 509 Release();
504 } 510 }
505 511
506 void CompleteInstallFunction::OnExtensionInstallFailure( 512 void CompleteInstallFunction::OnExtensionInstallFailure(
507 const std::string& id, 513 const std::string& id,
508 const std::string& error, 514 const std::string& error,
509 WebstoreInstaller::FailureReason reason) { 515 WebstoreInstaller::FailureReason reason) {
510 #if defined(ENABLE_APP_LIST) 516 #if defined(ENABLE_APP_LIST)
benwells 2013/02/18 07:56:36 Kill the #if, kill the #if, kill the #if.
koz (OOO until 15th September) 2013/02/19 03:20:36 Done.
511 chrome::NotifyAppListOfExtensionInstallFailure(profile(), id); 517 std::string extension_id(id);
518 content::NotificationService::current()->Notify(
519 chrome::NOTIFICATION_EXTENSION_INSTALL_FAIL,
520 content::Source<Profile>(profile()),
521 content::Details<std::string>(&extension_id));
512 #endif 522 #endif
513 if (test_webstore_installer_delegate) { 523 if (test_webstore_installer_delegate) {
514 test_webstore_installer_delegate->OnExtensionInstallFailure( 524 test_webstore_installer_delegate->OnExtensionInstallFailure(
515 id, error, reason); 525 id, error, reason);
516 } 526 }
517 527
518 error_ = error; 528 error_ = error;
519 SendResponse(false); 529 SendResponse(false);
520 530
521 // Matches the AddRef in RunImpl(). 531 // Matches the AddRef in RunImpl().
522 Release(); 532 Release();
523 } 533 }
524 534
525 void CompleteInstallFunction::OnExtensionDownloadProgress( 535 void CompleteInstallFunction::OnExtensionDownloadProgress(
526 const std::string& id, 536 const std::string& id,
527 content::DownloadItem* item) { 537 content::DownloadItem* item) {
528 #if defined(ENABLE_APP_LIST) 538 #if defined(ENABLE_APP_LIST)
benwells 2013/02/18 07:56:36 Die, #if, die!
koz (OOO until 15th September) 2013/02/19 03:20:36 Done.
529 chrome::NotifyAppListOfDownloadProgress(profile(), id, 539 std::pair<std::string, int> details(id, item->PercentComplete());
530 item->PercentComplete()); 540 content::NotificationService::current()->Notify(
541 chrome::NOTIFICATION_EXTENSION_INSTALL_FAIL,
542 content::Source<Profile>(profile()),
543 content::Details<std::pair<std::string, int> >(&details));
531 #endif 544 #endif
532 } 545 }
533 546
534 bool GetBrowserLoginFunction::RunImpl() { 547 bool GetBrowserLoginFunction::RunImpl() {
535 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); 548 SetResult(CreateLoginResult(profile_->GetOriginalProfile()));
536 return true; 549 return true;
537 } 550 }
538 551
539 bool GetStoreLoginFunction::RunImpl() { 552 bool GetStoreLoginFunction::RunImpl() {
540 ExtensionService* service = 553 ExtensionService* service =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); 601 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this));
589 return true; 602 return true;
590 } 603 }
591 604
592 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { 605 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) {
593 SetResult(Value::CreateBooleanValue(is_enabled)); 606 SetResult(Value::CreateBooleanValue(is_enabled));
594 SendResponse(true); 607 SendResponse(true);
595 } 608 }
596 609
597 } // namespace extensions 610 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_view_delegate.h » ('j') | chrome/common/extensions/extension.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698