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/thread_task_runner_handle.h" | 17 #include "base/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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 | 599 |
| 597 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 600 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
| 598 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 601 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
| 599 | 602 |
| 600 ExtensionFunction::ResponseAction | 603 ExtensionFunction::ResponseAction |
| 601 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { | 604 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { |
| 602 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( | 605 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( |
| 603 false))); | 606 false))); |
| 604 } | 607 } |
| 605 | 608 |
| 609 WebstorePrivateIsExtensionPendingCustodianApprovalFunction:: | |
| 610 WebstorePrivateIsExtensionPendingCustodianApprovalFunction() | |
| 611 : chrome_details_(this) {} | |
| 612 | |
| 613 WebstorePrivateIsExtensionPendingCustodianApprovalFunction:: | |
| 614 ~WebstorePrivateIsExtensionPendingCustodianApprovalFunction() {} | |
| 615 | |
| 616 ExtensionFunction::ResponseAction | |
| 617 WebstorePrivateIsExtensionPendingCustodianApprovalFunction::Run() { | |
| 618 std::unique_ptr<IsExtensionPendingCustodianApproval::Params> params( | |
| 619 IsExtensionPendingCustodianApproval::Params::Create(*args_)); | |
| 620 EXTENSION_FUNCTION_VALIDATE(params); | |
| 621 | |
| 622 Profile* profile = chrome_details_.GetProfile(); | |
| 623 | |
| 624 if (!profile->IsSupervised()) { | |
| 625 return RespondNow(ArgumentList( | |
| 626 IsExtensionPendingCustodianApproval::Results::Create(false))); | |
| 627 } | |
| 628 | |
| 629 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); | |
| 630 | |
| 631 const Extension* extension = | |
| 632 registry->GetExtensionById(params->id, ExtensionRegistry::EVERYTHING); | |
| 633 if (!extension) { | |
| 634 return RespondNow(ArgumentList( | |
| 635 IsExtensionPendingCustodianApproval::Results::Create(false))); | |
| 636 } | |
| 637 | |
| 638 ExtensionPrefs* extensions_prefs = ExtensionPrefs::Get(browser_context()); | |
| 639 | |
| 640 if (extensions::util::NeedCustodianApprovalForPermissionIncrease(profile) && | |
| 641 extensions_prefs->HasDisableReason( | |
| 642 params->id, Extension::DISABLE_PERMISSIONS_INCREASE)) { | |
| 643 return RespondNow(ArgumentList( | |
| 644 IsExtensionPendingCustodianApproval::Results::Create(true))); | |
| 645 } | |
| 646 | |
| 647 bool isPendingApproval = extensions_prefs->HasDisableReason( | |
|
Marc Treib
2016/05/09 14:50:57
is_pending_approval
mamir
2016/05/09 15:30:15
Sorry, again!
Done.
| |
| 648 params->id, Extension::DISABLE_CUSTODIAN_APPROVAL_REQUIRED); | |
| 649 | |
| 650 return RespondNow(ArgumentList( | |
| 651 IsExtensionPendingCustodianApproval::Results::Create(isPendingApproval))); | |
| 652 } | |
| 653 | |
| 606 } // namespace extensions | 654 } // namespace extensions |
| OLD | NEW |