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

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

Issue 12207104: Refactor app_list_util.h into AppListService abstract base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments, avoid at_exit work 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
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_service.h"
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_constants.h" 33 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/extensions/extension_l10n_util.h" 34 #include "chrome/common/extensions/extension_l10n_util.h"
35 #include "chrome/common/extensions/extension_manifest_constants.h" 35 #include "chrome/common/extensions/extension_manifest_constants.h"
36 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
37 #include "content/public/browser/gpu_data_manager.h" 37 #include "content/public/browser/gpu_data_manager.h"
38 #include "content/public/browser/notification_details.h" 38 #include "content/public/browser/notification_details.h"
39 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 apps::GetIsAppLauncherEnabled(base::Bind( 468 apps::GetIsAppLauncherEnabled(base::Bind(
469 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, 469 &CompleteInstallFunction::OnGetAppLauncherEnabled, this,
470 approval_->extension_id)); 470 approval_->extension_id));
471 } 471 }
472 472
473 void CompleteInstallFunction::OnGetAppLauncherEnabled( 473 void CompleteInstallFunction::OnGetAppLauncherEnabled(
474 std::string id, 474 std::string id,
475 bool app_launcher_enabled) { 475 bool app_launcher_enabled) {
476 if (app_launcher_enabled) { 476 if (app_launcher_enabled) {
477 std::string name; 477 std::string name;
478 #if defined(ENABLE_APP_LIST)
479 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, 478 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName,
480 &name)) { 479 &name)) {
481 NOTREACHED(); 480 NOTREACHED();
482 } 481 }
483 // Tell the app list about the install that we just started. 482 // Tell the app list about the install that we just started.
484 if (is_app_) { 483 if (is_app_) {
485 chrome::NotifyAppListOfBeginExtensionInstall( 484 AppListService::Get()->OnBeginExtensionInstall(
486 profile(), id, name, approval_->installing_icon); 485 profile(), id, name, approval_->installing_icon);
487 } 486 }
488 #endif
489 } 487 }
490 488
491 // The extension will install through the normal extension install flow, but 489 // The extension will install through the normal extension install flow, but
492 // the whitelist entry will bypass the normal permissions install dialog. 490 // the whitelist entry will bypass the normal permissions install dialog.
493 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 491 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
494 profile(), this, 492 profile(), this,
495 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), 493 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()),
496 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); 494 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE);
497 installer->Start(); 495 installer->Start();
498 } 496 }
499 497
500 void CompleteInstallFunction::OnExtensionInstallSuccess( 498 void CompleteInstallFunction::OnExtensionInstallSuccess(
501 const std::string& id) { 499 const std::string& id) {
502 if (test_webstore_installer_delegate) 500 if (test_webstore_installer_delegate)
503 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); 501 test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
504 502
505 SendResponse(true); 503 SendResponse(true);
506 504
507 // Matches the AddRef in RunImpl(). 505 // Matches the AddRef in RunImpl().
508 Release(); 506 Release();
509 } 507 }
510 508
511 void CompleteInstallFunction::OnExtensionInstallFailure( 509 void CompleteInstallFunction::OnExtensionInstallFailure(
512 const std::string& id, 510 const std::string& id,
513 const std::string& error, 511 const std::string& error,
514 WebstoreInstaller::FailureReason reason) { 512 WebstoreInstaller::FailureReason reason) {
515 #if defined(ENABLE_APP_LIST)
516 if (is_app_) 513 if (is_app_)
517 chrome::NotifyAppListOfExtensionInstallFailure(profile(), id); 514 AppListService::Get()->OnExtensionInstallFailure(profile(), id);
518 #endif
519 if (test_webstore_installer_delegate) { 515 if (test_webstore_installer_delegate) {
520 test_webstore_installer_delegate->OnExtensionInstallFailure( 516 test_webstore_installer_delegate->OnExtensionInstallFailure(
521 id, error, reason); 517 id, error, reason);
522 } 518 }
523 519
524 error_ = error; 520 error_ = error;
525 SendResponse(false); 521 SendResponse(false);
526 522
527 // Matches the AddRef in RunImpl(). 523 // Matches the AddRef in RunImpl().
528 Release(); 524 Release();
529 } 525 }
530 526
531 void CompleteInstallFunction::OnExtensionDownloadProgress( 527 void CompleteInstallFunction::OnExtensionDownloadProgress(
532 const std::string& id, 528 const std::string& id,
533 content::DownloadItem* item) { 529 content::DownloadItem* item) {
534 #if defined(ENABLE_APP_LIST)
535 if (is_app_) { 530 if (is_app_) {
536 chrome::NotifyAppListOfDownloadProgress(profile(), id, 531 AppListService::Get()->OnDownloadProgress(
537 item->PercentComplete()); 532 profile(), id, item->PercentComplete());
538 } 533 }
539 #endif
540 } 534 }
541 535
542 bool GetBrowserLoginFunction::RunImpl() { 536 bool GetBrowserLoginFunction::RunImpl() {
543 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); 537 SetResult(CreateLoginResult(profile_->GetOriginalProfile()));
544 return true; 538 return true;
545 } 539 }
546 540
547 bool GetStoreLoginFunction::RunImpl() { 541 bool GetStoreLoginFunction::RunImpl() {
548 ExtensionService* service = 542 ExtensionService* service =
549 extensions::ExtensionSystem::Get(profile_)->extension_service(); 543 extensions::ExtensionSystem::Get(profile_)->extension_service();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); 590 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this));
597 return true; 591 return true;
598 } 592 }
599 593
600 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { 594 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) {
601 SetResult(Value::CreateBooleanValue(is_enabled)); 595 SetResult(Value::CreateBooleanValue(is_enabled));
602 SendResponse(true); 596 SendResponse(true);
603 } 597 }
604 598
605 } // namespace extensions 599 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698