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

Side by Side Diff: chrome/browser/extensions/external_policy_loader_unittest.cc

Issue 1495403002: Observe adding external extensions via windows registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing files Created 4 years, 11 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Manifest::EXTERNAL_POLICY_DOWNLOAD, 63 Manifest::EXTERNAL_POLICY_DOWNLOAD,
64 Extension::NO_FLAGS)); 64 Extension::NO_FLAGS));
65 65
66 // Extensions will be removed from this list as they visited, 66 // Extensions will be removed from this list as they visited,
67 // so it should be emptied by the end. 67 // so it should be emptied by the end.
68 expected_extensions_ = expected_extensions; 68 expected_extensions_ = expected_extensions;
69 provider_->VisitRegisteredExtension(); 69 provider_->VisitRegisteredExtension();
70 EXPECT_TRUE(expected_extensions_.empty()); 70 EXPECT_TRUE(expected_extensions_.empty());
71 } 71 }
72 72
73 bool OnExternalExtensionFileFound(const std::string& id, 73 bool OnExternalExtensionFileFound(
74 const Version* version, 74 extensions::ExternalExtensionInstallInfoFile* info) override {
75 const base::FilePath& path,
76 Manifest::Location unused,
77 int unused2,
78 bool unused3,
79 bool unused4) override {
80 ADD_FAILURE() << "There should be no external extensions from files."; 75 ADD_FAILURE() << "There should be no external extensions from files.";
81 return false; 76 return false;
82 } 77 }
83 78
84 bool OnExternalExtensionUpdateUrlFound(const std::string& id, 79 bool OnExternalExtensionUpdateUrlFound(
85 const std::string& install_parameter, 80 extensions::ExternalExtensionInstallInfoUpdateUrl* info,
86 const GURL& update_url, 81 bool is_initial_load) override {
87 Manifest::Location location,
88 int unused1,
89 bool unused2) override {
90 // Extension has the correct location. 82 // Extension has the correct location.
91 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location); 83 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, info->download_location);
92 84
93 // Provider returns the correct location when asked. 85 // Provider returns the correct location when asked.
94 Manifest::Location location1; 86 Manifest::Location location1;
95 scoped_ptr<Version> version1; 87 scoped_ptr<Version> version1;
96 provider_->GetExtensionDetails(id, &location1, &version1); 88 provider_->GetExtensionDetails(info->extension_id, &location1, &version1);
97 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location1); 89 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location1);
98 EXPECT_FALSE(version1.get()); 90 EXPECT_FALSE(version1.get());
99 91
100 // Remove the extension from our list. 92 // Remove the extension from our list.
101 EXPECT_EQ(1U, expected_extensions_.erase(id)); 93 EXPECT_EQ(1U, expected_extensions_.erase(info->extension_id));
102 return true; 94 return true;
103 } 95 }
104 96
105 void OnExternalProviderReady( 97 void OnExternalProviderReady(
106 const ExternalProviderInterface* provider) override { 98 const ExternalProviderInterface* provider) override {
107 EXPECT_EQ(provider, provider_.get()); 99 EXPECT_EQ(provider, provider_.get());
108 EXPECT_TRUE(provider->IsReady()); 100 EXPECT_TRUE(provider->IsReady());
109 } 101 }
110 102
103 void OnExternalProviderUpdateComplete(
104 const ExternalProviderInterface* provider,
105 const ScopedVector<ExternalExtensionInstallInfoUpdateUrl>&
106 update_url_extensions,
107 const ScopedVector<ExternalExtensionInstallInfoFile>& file_extensions,
108 const std::set<std::string>& removed_extensions) override {
109 ADD_FAILURE() << "Only win registry provider is expected to call this.";
110 }
111
111 private: 112 private:
112 std::set<std::string> expected_extensions_; 113 std::set<std::string> expected_extensions_;
113 114
114 scoped_ptr<TestingProfile> profile_; 115 scoped_ptr<TestingProfile> profile_;
115 116
116 scoped_ptr<ExternalProviderImpl> provider_; 117 scoped_ptr<ExternalProviderImpl> provider_;
117 118
118 DISALLOW_COPY_AND_ASSIGN(MockExternalPolicyProviderVisitor); 119 DISALLOW_COPY_AND_ASSIGN(MockExternalPolicyProviderVisitor);
119 }; 120 };
120 121
(...skipping 26 matching lines...) Expand all
147 forced_extensions.SetString("invalid", "http://www.example.com/crx"); 148 forced_extensions.SetString("invalid", "http://www.example.com/crx");
148 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", 149 forced_extensions.SetString("dddddddddddddddddddddddddddddddd",
149 std::string()); 150 std::string());
150 forced_extensions.SetString("invalid", "bad"); 151 forced_extensions.SetString("invalid", "bad");
151 152
152 MockExternalPolicyProviderVisitor mv; 153 MockExternalPolicyProviderVisitor mv;
153 mv.Visit(forced_extensions, expected_extensions); 154 mv.Visit(forced_extensions, expected_extensions);
154 } 155 }
155 156
156 } // namespace extensions 157 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698