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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/about_flags.h" | 14 #include "chrome/browser/about_flags.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/extensions/app_launcher.h" | 16 #include "chrome/browser/extensions/app_launcher.h" |
17 #include "chrome/browser/extensions/crx_installer.h" | 17 #include "chrome/browser/extensions/crx_installer.h" |
18 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 18 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
19 #include "chrome/browser/extensions/extension_prefs.h" | 19 #include "chrome/browser/extensions/extension_prefs.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
22 #include "chrome/browser/extensions/webstore_installer.h" | 22 #include "chrome/browser/extensions/webstore_installer.h" |
23 #include "chrome/browser/gpu/gpu_feature_checker.h" | 23 #include "chrome/browser/gpu/gpu_feature_checker.h" |
24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.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_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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 UpdateIsAppLauncherEnabled(base::Bind( | 461 UpdateIsAppLauncherEnabled(base::Bind( |
462 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, | 462 &CompleteInstallFunction::OnGetAppLauncherEnabled, this, |
463 approval_->extension_id)); | 463 approval_->extension_id)); |
464 } | 464 } |
465 | 465 |
466 void CompleteInstallFunction::OnGetAppLauncherEnabled( | 466 void CompleteInstallFunction::OnGetAppLauncherEnabled( |
467 std::string id, | 467 std::string id, |
468 bool app_launcher_enabled) { | 468 bool app_launcher_enabled) { |
469 if (app_launcher_enabled) { | 469 if (app_launcher_enabled) { |
470 std::string name; | 470 std::string name; |
471 #if defined(ENABLE_APP_LIST) | |
472 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, | 471 if (!approval_->parsed_manifest->GetString(extension_manifest_keys::kName, |
473 &name)) { | 472 &name)) { |
474 NOTREACHED(); | 473 NOTREACHED(); |
475 } | 474 } |
476 // Tell the app list about the install that we just started. | 475 // Tell the app list about the install that we just started. |
477 chrome::NotifyAppListOfBeginExtensionInstall( | 476 AppListService::Get()->NotifyAppListOfBeginExtensionInstall( |
478 profile(), id, name, approval_->installing_icon); | 477 profile(), id, name, approval_->installing_icon); |
479 #endif | |
480 } | 478 } |
481 | 479 |
482 // The extension will install through the normal extension install flow, but | 480 // The extension will install through the normal extension install flow, but |
483 // the whitelist entry will bypass the normal permissions install dialog. | 481 // the whitelist entry will bypass the normal permissions install dialog. |
484 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 482 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
485 profile(), this, | 483 profile(), this, |
486 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 484 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
487 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); | 485 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); |
488 installer->Start(); | 486 installer->Start(); |
489 } | 487 } |
(...skipping 21 matching lines...) Expand all Loading... |
511 error_ = error; | 509 error_ = error; |
512 SendResponse(false); | 510 SendResponse(false); |
513 | 511 |
514 // Matches the AddRef in RunImpl(). | 512 // Matches the AddRef in RunImpl(). |
515 Release(); | 513 Release(); |
516 } | 514 } |
517 | 515 |
518 void CompleteInstallFunction::OnExtensionDownloadProgress( | 516 void CompleteInstallFunction::OnExtensionDownloadProgress( |
519 const std::string& id, | 517 const std::string& id, |
520 content::DownloadItem* item) { | 518 content::DownloadItem* item) { |
521 #if defined(ENABLE_APP_LIST) | 519 AppListService::Get()->NotifyAppListOfDownloadProgress( |
522 chrome::NotifyAppListOfDownloadProgress(profile(), id, | 520 profile(), id, item->PercentComplete()); |
523 item->PercentComplete()); | |
524 #endif | |
525 } | 521 } |
526 | 522 |
527 bool GetBrowserLoginFunction::RunImpl() { | 523 bool GetBrowserLoginFunction::RunImpl() { |
528 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); | 524 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); |
529 return true; | 525 return true; |
530 } | 526 } |
531 | 527 |
532 bool GetStoreLoginFunction::RunImpl() { | 528 bool GetStoreLoginFunction::RunImpl() { |
533 ExtensionService* service = | 529 ExtensionService* service = |
534 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 530 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); | 577 &GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted, this)); |
582 return true; | 578 return true; |
583 } | 579 } |
584 | 580 |
585 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { | 581 void GetIsLauncherEnabledFunction::OnIsLauncherCheckCompleted(bool is_enabled) { |
586 SetResult(Value::CreateBooleanValue(is_enabled)); | 582 SetResult(Value::CreateBooleanValue(is_enabled)); |
587 SendResponse(true); | 583 SendResponse(true); |
588 } | 584 } |
589 | 585 |
590 } // namespace extensions | 586 } // namespace extensions |
OLD | NEW |