OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/feature_list.h" | |
15 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
16 #include "base/macros.h" | 15 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
18 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
19 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
20 #include "base/test/mock_entropy_provider.h" | 19 #include "base/test/mock_entropy_provider.h" |
| 20 #include "base/test/scoped_feature_list.h" |
21 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" | 21 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
22 #include "chrome/browser/extensions/component_loader.h" | 22 #include "chrome/browser/extensions/component_loader.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_service_test_with_install.h" | 24 #include "chrome/browser/extensions/extension_service_test_with_install.h" |
25 #include "chrome/browser/extensions/extension_sync_data.h" | 25 #include "chrome/browser/extensions/extension_sync_data.h" |
26 #include "chrome/browser/extensions/extension_sync_service.h" | 26 #include "chrome/browser/extensions/extension_sync_service.h" |
27 #include "chrome/browser/extensions/extension_util.h" | 27 #include "chrome/browser/extensions/extension_util.h" |
28 #include "chrome/browser/extensions/scripting_permissions_modifier.h" | 28 #include "chrome/browser/extensions/scripting_permissions_modifier.h" |
29 #include "chrome/browser/extensions/updater/extension_updater.h" | 29 #include "chrome/browser/extensions/updater/extension_updater.h" |
30 #include "chrome/browser/sync/profile_sync_service_factory.h" | 30 #include "chrome/browser/sync/profile_sync_service_factory.h" |
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 } | 1576 } |
1577 | 1577 |
1578 void TearDown() override { | 1578 void TearDown() override { |
1579 supervised_user_service()->SetDelegate(nullptr); | 1579 supervised_user_service()->SetDelegate(nullptr); |
1580 | 1580 |
1581 ExtensionServiceSyncTest::TearDown(); | 1581 ExtensionServiceSyncTest::TearDown(); |
1582 } | 1582 } |
1583 | 1583 |
1584 protected: | 1584 protected: |
1585 void InitSupervisedUserInitiatedExtensionInstallFeature(bool enabled) { | 1585 void InitSupervisedUserInitiatedExtensionInstallFeature(bool enabled) { |
1586 base::FeatureList::ClearInstanceForTesting(); | |
1587 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | |
1588 if (enabled) { | 1586 if (enabled) { |
1589 feature_list->InitializeFromCommandLine( | 1587 scoped_feature_list_.InitAndEnableFeature( |
1590 "SupervisedUserInitiatedExtensionInstall", std::string()); | 1588 supervised_users::kSupervisedUserInitiatedExtensionInstall); |
1591 } | 1589 } |
1592 base::FeatureList::SetInstance(std::move(feature_list)); | |
1593 } | 1590 } |
1594 | 1591 |
1595 bool IsPendingCustodianApproval(const std::string& extension_id) { | 1592 bool IsPendingCustodianApproval(const std::string& extension_id) { |
1596 auto function = make_scoped_refptr( | 1593 auto function = make_scoped_refptr( |
1597 new WebstorePrivateIsPendingCustodianApprovalFunction()); | 1594 new WebstorePrivateIsPendingCustodianApprovalFunction()); |
1598 | 1595 |
1599 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( | 1596 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
1600 function.get(), "[\"" + extension_id + "\"]", browser_context())); | 1597 function.get(), "[\"" + extension_id + "\"]", browser_context())); |
1601 | 1598 |
1602 bool copy_bool_result = false; | 1599 bool copy_bool_result = false; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 return data_dir().AppendASCII("permissions_increase"); | 1728 return data_dir().AppendASCII("permissions_increase"); |
1732 } | 1729 } |
1733 base::FilePath dir_path(const std::string& version) const { | 1730 base::FilePath dir_path(const std::string& version) const { |
1734 return base_path().AppendASCII("v" + version); | 1731 return base_path().AppendASCII("v" + version); |
1735 } | 1732 } |
1736 base::FilePath pem_path() const { | 1733 base::FilePath pem_path() const { |
1737 return base_path().AppendASCII("permissions.pem"); | 1734 return base_path().AppendASCII("permissions.pem"); |
1738 } | 1735 } |
1739 | 1736 |
1740 base::FieldTrialList field_trial_list_; | 1737 base::FieldTrialList field_trial_list_; |
| 1738 base::test::ScopedFeatureList scoped_feature_list_; |
1741 }; | 1739 }; |
1742 | 1740 |
1743 class MockPermissionRequestCreator : public PermissionRequestCreator { | 1741 class MockPermissionRequestCreator : public PermissionRequestCreator { |
1744 public: | 1742 public: |
1745 MockPermissionRequestCreator() {} | 1743 MockPermissionRequestCreator() {} |
1746 ~MockPermissionRequestCreator() override {} | 1744 ~MockPermissionRequestCreator() override {} |
1747 | 1745 |
1748 bool IsEnabled() const override { return true; } | 1746 bool IsEnabled() const override { return true; } |
1749 | 1747 |
1750 void CreateURLAccessRequest(const GURL& url_requested, | 1748 void CreateURLAccessRequest(const GURL& url_requested, |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 break; | 2466 break; |
2469 } | 2467 } |
2470 } | 2468 } |
2471 } | 2469 } |
2472 EXPECT_TRUE(found_delete); | 2470 EXPECT_TRUE(found_delete); |
2473 | 2471 |
2474 // Make sure there is one extension, and there are no more apps. | 2472 // Make sure there is one extension, and there are no more apps. |
2475 EXPECT_EQ(1u, extensions_processor.data().size()); | 2473 EXPECT_EQ(1u, extensions_processor.data().size()); |
2476 EXPECT_TRUE(apps_processor.data().empty()); | 2474 EXPECT_TRUE(apps_processor.data().empty()); |
2477 } | 2475 } |
OLD | NEW |