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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "base/version.h" | 19 #include "base/version.h" |
| 20 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 20 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 21 #include "chrome/browser/extensions/crx_installer.h" | 21 #include "chrome/browser/extensions/crx_installer.h" |
| 22 #include "chrome/browser/extensions/extension_install_ui_util.h" | 22 #include "chrome/browser/extensions/extension_install_ui_util.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_util.h" | |
| 24 #include "chrome/browser/extensions/install_tracker.h" | 25 #include "chrome/browser/extensions/install_tracker.h" |
| 25 #include "chrome/browser/gpu/gpu_feature_checker.h" | 26 #include "chrome/browser/gpu/gpu_feature_checker.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/ui/app_list/app_list_service.h" | 29 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 29 #include "chrome/browser/ui/app_list/app_list_util.h" | 30 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 30 #include "chrome/common/extensions/extension_constants.h" | 31 #include "chrome/common/extensions/extension_constants.h" |
| 31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 32 #include "components/crx_file/id_util.h" | 33 #include "components/crx_file/id_util.h" |
| 33 #include "components/prefs/pref_service.h" | 34 #include "components/prefs/pref_service.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 45 | 46 |
| 46 namespace BeginInstallWithManifest3 = | 47 namespace BeginInstallWithManifest3 = |
| 47 api::webstore_private::BeginInstallWithManifest3; | 48 api::webstore_private::BeginInstallWithManifest3; |
| 48 namespace CompleteInstall = api::webstore_private::CompleteInstall; | 49 namespace CompleteInstall = api::webstore_private::CompleteInstall; |
| 49 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; | 50 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; |
| 50 namespace GetEphemeralAppsEnabled = | 51 namespace GetEphemeralAppsEnabled = |
| 51 api::webstore_private::GetEphemeralAppsEnabled; | 52 api::webstore_private::GetEphemeralAppsEnabled; |
| 52 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; | 53 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; |
| 53 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; | 54 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; |
| 54 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; | 55 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; |
| 56 namespace IsExtensionPendingCustodianApproval = | |
| 57 api::webstore_private::IsExtensionPendingCustodianApproval; | |
| 55 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; | 58 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; |
| 56 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; | 59 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; |
| 57 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; | 60 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; |
| 58 | 61 |
| 59 namespace { | 62 namespace { |
| 60 | 63 |
| 61 // Holds the Approvals between the time we prompt and start the installs. | 64 // Holds the Approvals between the time we prompt and start the installs. |
| 62 class PendingApprovals { | 65 class PendingApprovals { |
| 63 public: | 66 public: |
| 64 PendingApprovals(); | 67 PendingApprovals(); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 | 582 |
| 580 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 583 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
| 581 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 584 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
| 582 | 585 |
| 583 ExtensionFunction::ResponseAction | 586 ExtensionFunction::ResponseAction |
| 584 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { | 587 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { |
| 585 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( | 588 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( |
| 586 false))); | 589 false))); |
| 587 } | 590 } |
| 588 | 591 |
| 592 WebstorePrivateIsExtensionPendingCustodianApprovalFunction:: | |
| 593 WebstorePrivateIsExtensionPendingCustodianApprovalFunction() | |
| 594 : chrome_details_(this) {} | |
| 595 | |
| 596 WebstorePrivateIsExtensionPendingCustodianApprovalFunction:: | |
| 597 ~WebstorePrivateIsExtensionPendingCustodianApprovalFunction() {} | |
| 598 | |
| 599 ExtensionFunction::ResponseAction | |
| 600 WebstorePrivateIsExtensionPendingCustodianApprovalFunction::Run() { | |
| 601 std::unique_ptr<IsExtensionPendingCustodianApproval::Params> params( | |
| 602 IsExtensionPendingCustodianApproval::Params::Create(*args_)); | |
| 603 EXTENSION_FUNCTION_VALIDATE(params); | |
| 604 | |
| 605 Profile* profile = chrome_details_.GetProfile(); | |
| 606 | |
| 607 if (!profile->IsSupervised()) { | |
| 608 return RespondNow(ArgumentList( | |
| 609 IsExtensionPendingCustodianApproval::Results::Create(false))); | |
|
Marc Treib
2016/06/29 08:23:12
nit: Maybe create a helper method "Respond(bool re
mamir
2016/06/29 11:40:20
I created a BuildResponse method instead to be con
| |
| 610 } | |
| 611 | |
| 612 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); | |
| 613 | |
| 614 const Extension* extension = | |
| 615 registry->GetExtensionById(params->id, ExtensionRegistry::EVERYTHING); | |
| 616 if (!extension) { | |
| 617 return RespondNow(ArgumentList( | |
| 618 IsExtensionPendingCustodianApproval::Results::Create(false))); | |
| 619 } | |
| 620 | |
| 621 ExtensionPrefs* extensions_prefs = ExtensionPrefs::Get(browser_context()); | |
| 622 | |
| 623 if (extensions::util::NeedCustodianApprovalForPermissionIncrease(profile) && | |
| 624 extensions_prefs->HasDisableReason( | |
| 625 params->id, Extension::DISABLE_PERMISSIONS_INCREASE)) { | |
| 626 return RespondNow(ArgumentList( | |
| 627 IsExtensionPendingCustodianApproval::Results::Create(true))); | |
| 628 } | |
| 629 | |
| 630 bool is_pending_approval = extensions_prefs->HasDisableReason( | |
| 631 params->id, Extension::DISABLE_CUSTODIAN_APPROVAL_REQUIRED); | |
| 632 | |
| 633 return RespondNow( | |
| 634 ArgumentList(IsExtensionPendingCustodianApproval::Results::Create( | |
| 635 is_pending_approval))); | |
| 636 } | |
| 637 | |
| 589 } // namespace extensions | 638 } // namespace extensions |
| OLD | NEW |