| 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/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 extent->AddPattern(URLPattern(schemes, pattern)); | 145 extent->AddPattern(URLPattern(schemes, pattern)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace | 148 } // namespace |
| 149 | 149 |
| 150 class MockExtensionProvider : public ExternalExtensionProviderInterface { | 150 class MockExtensionProvider : public ExternalExtensionProviderInterface { |
| 151 public: | 151 public: |
| 152 MockExtensionProvider( | 152 MockExtensionProvider( |
| 153 VisitorInterface* visitor, | 153 VisitorInterface* visitor, |
| 154 Extension::Location location) | 154 Extension::Location location) |
| 155 : location_(location), | 155 : location_(location), visitor_(visitor), visit_count_(0) { |
| 156 visitor_(visitor), | |
| 157 visit_count_(0), | |
| 158 creation_flags_(Extension::NO_FLAGS) { | |
| 159 } | |
| 160 | |
| 161 MockExtensionProvider( | |
| 162 VisitorInterface* visitor, | |
| 163 Extension::Location location, | |
| 164 int creation_flags) | |
| 165 : location_(location), | |
| 166 visitor_(visitor), | |
| 167 visit_count_(0), | |
| 168 creation_flags_(creation_flags) { | |
| 169 } | 156 } |
| 170 | 157 |
| 171 virtual ~MockExtensionProvider() {} | 158 virtual ~MockExtensionProvider() {} |
| 172 | 159 |
| 173 void UpdateOrAddExtension(const std::string& id, | 160 void UpdateOrAddExtension(const std::string& id, |
| 174 const std::string& version, | 161 const std::string& version, |
| 175 const FilePath& path) { | 162 const FilePath& path) { |
| 176 extension_map_[id] = std::make_pair(version, path); | 163 extension_map_[id] = std::make_pair(version, path); |
| 177 } | 164 } |
| 178 | 165 |
| 179 void RemoveExtension(const std::string& id) { | 166 void RemoveExtension(const std::string& id) { |
| 180 extension_map_.erase(id); | 167 extension_map_.erase(id); |
| 181 } | 168 } |
| 182 | 169 |
| 183 // ExternalExtensionProvider implementation: | 170 // ExternalExtensionProvider implementation: |
| 184 virtual void VisitRegisteredExtension() OVERRIDE { | 171 virtual void VisitRegisteredExtension() OVERRIDE { |
| 185 visit_count_++; | 172 visit_count_++; |
| 186 for (DataMap::const_iterator i = extension_map_.begin(); | 173 for (DataMap::const_iterator i = extension_map_.begin(); |
| 187 i != extension_map_.end(); ++i) { | 174 i != extension_map_.end(); ++i) { |
| 188 scoped_ptr<Version> version; | 175 scoped_ptr<Version> version; |
| 189 version.reset(Version::GetVersionFromString(i->second.first)); | 176 version.reset(Version::GetVersionFromString(i->second.first)); |
| 190 | 177 |
| 191 visitor_->OnExternalExtensionFileFound( | 178 visitor_->OnExternalExtensionFileFound( |
| 192 i->first, version.get(), i->second.second, location_, | 179 i->first, version.get(), i->second.second, location_, |
| 193 creation_flags_, false); | 180 Extension::NO_FLAGS, false); |
| 194 } | 181 } |
| 195 visitor_->OnExternalProviderReady(this); | 182 visitor_->OnExternalProviderReady(this); |
| 196 } | 183 } |
| 197 | 184 |
| 198 virtual bool HasExtension(const std::string& id) const OVERRIDE { | 185 virtual bool HasExtension(const std::string& id) const OVERRIDE { |
| 199 return extension_map_.find(id) != extension_map_.end(); | 186 return extension_map_.find(id) != extension_map_.end(); |
| 200 } | 187 } |
| 201 | 188 |
| 202 virtual bool GetExtensionDetails( | 189 virtual bool GetExtensionDetails( |
| 203 const std::string& id, | 190 const std::string& id, |
| 204 Extension::Location* location, | 191 Extension::Location* location, |
| 205 scoped_ptr<Version>* version) const OVERRIDE { | 192 scoped_ptr<Version>* version) const OVERRIDE { |
| 206 DataMap::const_iterator it = extension_map_.find(id); | 193 DataMap::const_iterator it = extension_map_.find(id); |
| 207 if (it == extension_map_.end()) | 194 if (it == extension_map_.end()) |
| 208 return false; | 195 return false; |
| 209 | 196 |
| 210 if (version) | 197 if (version) |
| 211 version->reset(Version::GetVersionFromString(it->second.first)); | 198 version->reset(Version::GetVersionFromString(it->second.first)); |
| 212 | 199 |
| 213 if (location) | 200 if (location) |
| 214 *location = location_; | 201 *location = location_; |
| 215 | 202 |
| 216 return true; | 203 return true; |
| 217 } | 204 } |
| 218 | 205 |
| 219 virtual bool IsReady() const OVERRIDE { | 206 virtual bool IsReady() const OVERRIDE { |
| 220 return true; | 207 return true; |
| 221 } | 208 } |
| 222 | 209 |
| 223 virtual int GetCreationFlags() const OVERRIDE { | |
| 224 return creation_flags_; | |
| 225 } | |
| 226 | |
| 227 virtual void ServiceShutdown() OVERRIDE { | 210 virtual void ServiceShutdown() OVERRIDE { |
| 228 } | 211 } |
| 229 | 212 |
| 230 int visit_count() const { return visit_count_; } | 213 int visit_count() const { return visit_count_; } |
| 231 void set_visit_count(int visit_count) { | 214 void set_visit_count(int visit_count) { |
| 232 visit_count_ = visit_count; | 215 visit_count_ = visit_count; |
| 233 } | 216 } |
| 234 | 217 |
| 235 private: | 218 private: |
| 236 typedef std::map< std::string, std::pair<std::string, FilePath> > DataMap; | 219 typedef std::map< std::string, std::pair<std::string, FilePath> > DataMap; |
| 237 DataMap extension_map_; | 220 DataMap extension_map_; |
| 238 Extension::Location location_; | 221 Extension::Location location_; |
| 239 VisitorInterface* visitor_; | 222 VisitorInterface* visitor_; |
| 240 | 223 |
| 241 // visit_count_ tracks the number of calls to VisitRegisteredExtension(). | 224 // visit_count_ tracks the number of calls to VisitRegisteredExtension(). |
| 242 // Mutable because it must be incremented on each call to | 225 // Mutable because it must be incremented on each call to |
| 243 // VisitRegisteredExtension(), which must be a const method to inherit | 226 // VisitRegisteredExtension(), which must be a const method to inherit |
| 244 // from the class being mocked. | 227 // from the class being mocked. |
| 245 mutable int visit_count_; | 228 mutable int visit_count_; |
| 246 | 229 |
| 247 int creation_flags_; | |
| 248 | |
| 249 DISALLOW_COPY_AND_ASSIGN(MockExtensionProvider); | 230 DISALLOW_COPY_AND_ASSIGN(MockExtensionProvider); |
| 250 }; | 231 }; |
| 251 | 232 |
| 252 class MockProviderVisitor | 233 class MockProviderVisitor |
| 253 : public ExternalExtensionProviderInterface::VisitorInterface { | 234 : public ExternalExtensionProviderInterface::VisitorInterface { |
| 254 public: | 235 public: |
| 255 | 236 |
| 256 // The provider will return |fake_base_path| from | 237 // The provider will return |fake_base_path| from |
| 257 // GetBaseCrxFilePath(). User can test the behavior with | 238 // GetBaseCrxFilePath(). User can test the behavior with |
| 258 // and without an empty path using this parameter. | 239 // and without an empty path using this parameter. |
| 259 explicit MockProviderVisitor(FilePath fake_base_path) | 240 explicit MockProviderVisitor(FilePath fake_base_path) |
| 260 : ids_found_(0), | 241 : ids_found_(0), |
| 261 fake_base_path_(fake_base_path) { | 242 fake_base_path_(fake_base_path), |
| 243 expected_creation_flags_(Extension::NO_FLAGS) { |
| 244 } |
| 245 |
| 246 MockProviderVisitor(FilePath fake_base_path, int expected_creation_flags) |
| 247 : ids_found_(0), |
| 248 fake_base_path_(fake_base_path), |
| 249 expected_creation_flags_(expected_creation_flags) { |
| 262 } | 250 } |
| 263 | 251 |
| 264 int Visit(const std::string& json_data) { | 252 int Visit(const std::string& json_data) { |
| 265 // Give the test json file to the provider for parsing. | 253 // Give the test json file to the provider for parsing. |
| 266 provider_.reset(new ExternalExtensionProviderImpl( | 254 provider_.reset(new ExternalExtensionProviderImpl( |
| 267 this, | 255 this, |
| 268 new ExternalTestingExtensionLoader(json_data, fake_base_path_), | 256 new ExternalTestingExtensionLoader(json_data, fake_base_path_), |
| 269 Extension::EXTERNAL_PREF, | 257 Extension::EXTERNAL_PREF, |
| 270 Extension::EXTERNAL_PREF_DOWNLOAD, | 258 Extension::EXTERNAL_PREF_DOWNLOAD, |
| 271 Extension::NO_FLAGS)); | 259 Extension::NO_FLAGS)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 291 | 279 |
| 292 return ids_found_; | 280 return ids_found_; |
| 293 } | 281 } |
| 294 | 282 |
| 295 virtual bool OnExternalExtensionFileFound(const std::string& id, | 283 virtual bool OnExternalExtensionFileFound(const std::string& id, |
| 296 const Version* version, | 284 const Version* version, |
| 297 const FilePath& path, | 285 const FilePath& path, |
| 298 Extension::Location unused, | 286 Extension::Location unused, |
| 299 int creation_flags, | 287 int creation_flags, |
| 300 bool mark_acknowledged) { | 288 bool mark_acknowledged) { |
| 301 EXPECT_EQ(Extension::NO_FLAGS, creation_flags); | 289 EXPECT_EQ(expected_creation_flags_, creation_flags); |
| 302 | 290 |
| 303 ++ids_found_; | 291 ++ids_found_; |
| 304 DictionaryValue* pref; | 292 DictionaryValue* pref; |
| 305 // This tests is to make sure that the provider only notifies us of the | 293 // This tests is to make sure that the provider only notifies us of the |
| 306 // values we gave it. So if the id we doesn't exist in our internal | 294 // values we gave it. So if the id we doesn't exist in our internal |
| 307 // dictionary then something is wrong. | 295 // dictionary then something is wrong. |
| 308 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) | 296 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) |
| 309 << "Got back ID (" << id.c_str() << ") we weren't expecting"; | 297 << "Got back ID (" << id.c_str() << ") we weren't expecting"; |
| 310 | 298 |
| 311 EXPECT_TRUE(path.IsAbsolute()); | 299 EXPECT_TRUE(path.IsAbsolute()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 353 |
| 366 virtual void OnExternalProviderReady( | 354 virtual void OnExternalProviderReady( |
| 367 const ExternalExtensionProviderInterface* provider) { | 355 const ExternalExtensionProviderInterface* provider) { |
| 368 EXPECT_EQ(provider, provider_.get()); | 356 EXPECT_EQ(provider, provider_.get()); |
| 369 EXPECT_TRUE(provider->IsReady()); | 357 EXPECT_TRUE(provider->IsReady()); |
| 370 } | 358 } |
| 371 | 359 |
| 372 private: | 360 private: |
| 373 int ids_found_; | 361 int ids_found_; |
| 374 FilePath fake_base_path_; | 362 FilePath fake_base_path_; |
| 363 int expected_creation_flags_; |
| 375 scoped_ptr<ExternalExtensionProviderImpl> provider_; | 364 scoped_ptr<ExternalExtensionProviderImpl> provider_; |
| 376 scoped_ptr<DictionaryValue> prefs_; | 365 scoped_ptr<DictionaryValue> prefs_; |
| 377 | 366 |
| 378 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); | 367 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); |
| 379 }; | 368 }; |
| 380 | 369 |
| 381 // Our message loop may be used in tests which require it to be an IO loop. | 370 // Our message loop may be used in tests which require it to be an IO loop. |
| 382 ExtensionServiceTestBase::ExtensionServiceTestBase() | 371 ExtensionServiceTestBase::ExtensionServiceTestBase() |
| 383 : loop_(MessageLoop::TYPE_IO), | 372 : loop_(MessageLoop::TYPE_IO), |
| 384 service_(NULL), | 373 service_(NULL), |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 // extension object. | 1244 // extension object. |
| 1256 TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) { | 1245 TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) { |
| 1257 const char kPrefFromBookmark[] = "from_bookmark"; | 1246 const char kPrefFromBookmark[] = "from_bookmark"; |
| 1258 | 1247 |
| 1259 InitializeEmptyExtensionService(); | 1248 InitializeEmptyExtensionService(); |
| 1260 | 1249 |
| 1261 FilePath path = data_dir_.AppendASCII("good.crx"); | 1250 FilePath path = data_dir_.AppendASCII("good.crx"); |
| 1262 set_extensions_enabled(true); | 1251 set_extensions_enabled(true); |
| 1263 | 1252 |
| 1264 // Register and install an external extension. | 1253 // Register and install an external extension. |
| 1265 MockExtensionProvider* provider = | 1254 scoped_ptr<Version> version(Version::GetVersionFromString("1.0.0.0")); |
| 1266 new MockExtensionProvider(service_, | 1255 service_->OnExternalExtensionFileFound( |
| 1267 Extension::EXTERNAL_POLICY_DOWNLOAD, | 1256 good_crx, |
| 1268 Extension::FROM_BOOKMARK); | 1257 version.get(), |
| 1269 AddMockExternalProvider(provider); | 1258 path, |
| 1270 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", | 1259 Extension::EXTERNAL_PREF, |
| 1271 data_dir_.AppendASCII("good.crx")); | 1260 Extension::FROM_BOOKMARK, |
| 1272 service_->CheckForExternalUpdates(); | 1261 false /* mark_acknowledged */); |
| 1273 loop_.RunAllPending(); | 1262 loop_.RunAllPending(); |
| 1274 | 1263 |
| 1275 const Extension* extension = service_->GetExtensionById(good_crx, false); | 1264 const Extension* extension = service_->GetExtensionById(good_crx, false); |
| 1276 ASSERT_TRUE(extension); | 1265 ASSERT_TRUE(extension); |
| 1277 ASSERT_TRUE(extension->from_bookmark()); | 1266 ASSERT_TRUE(extension->from_bookmark()); |
| 1278 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); | 1267 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); |
| 1279 | 1268 |
| 1280 // Upgrade to version 2.0, the flag should be preserved. | 1269 // Upgrade to version 2.0, the flag should be preserved. |
| 1281 path = data_dir_.AppendASCII("good2.crx"); | 1270 path = data_dir_.AppendASCII("good2.crx"); |
| 1282 UpdateExtension(good_crx, path, ENABLED); | 1271 UpdateExtension(good_crx, path, ENABLED); |
| 1283 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); | 1272 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); |
| 1284 extension = service_->GetExtensionById(good_crx, false); | 1273 extension = service_->GetExtensionById(good_crx, false); |
| 1285 ASSERT_TRUE(extension); | 1274 ASSERT_TRUE(extension); |
| 1286 ASSERT_TRUE(extension->from_bookmark()); | 1275 ASSERT_TRUE(extension->from_bookmark()); |
| 1287 | |
| 1288 // Somehow, the "from bookmark pref" gets reset (simulating | |
| 1289 // http://crbug.com/109791). | |
| 1290 SetPrefBool(extension->id(), kPrefFromBookmark, false); | |
| 1291 service_->ReloadExtensions(); | |
| 1292 extension = service_->GetExtensionById(good_crx, false); | |
| 1293 ASSERT_TRUE(extension); | |
| 1294 ASSERT_FALSE(extension->from_bookmark()); | |
| 1295 ValidateBooleanPref(good_crx, kPrefFromBookmark, false); | |
| 1296 | |
| 1297 // If the app gets updated again, we'll reset the "from bookmark" pref if | |
| 1298 // the external extension provider is still serving that extension. | |
| 1299 UpdateExtension(good_crx, path, ENABLED); | |
| 1300 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); | |
| 1301 extension = service_->GetExtensionById(good_crx, false); | |
| 1302 ASSERT_TRUE(extension); | |
| 1303 ASSERT_TRUE(extension->from_bookmark()); | |
| 1304 } | 1276 } |
| 1305 | 1277 |
| 1306 // Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED | 1278 // Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED |
| 1307 TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { | 1279 TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { |
| 1308 InitializeEmptyExtensionService(); | 1280 InitializeEmptyExtensionService(); |
| 1309 | 1281 |
| 1310 FilePath path = data_dir_.AppendASCII("good.crx"); | 1282 FilePath path = data_dir_.AppendASCII("good.crx"); |
| 1311 set_extensions_enabled(true); | 1283 set_extensions_enabled(true); |
| 1312 | 1284 |
| 1313 scoped_ptr<Version> version; | 1285 scoped_ptr<Version> version; |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 EXPECT_TRUE(service_->GetExtensionById(good_crx, false)); | 2867 EXPECT_TRUE(service_->GetExtensionById(good_crx, false)); |
| 2896 } | 2868 } |
| 2897 | 2869 |
| 2898 TEST_F(ExtensionServiceTest, ExternalExtensionAutoAcknowledgement) { | 2870 TEST_F(ExtensionServiceTest, ExternalExtensionAutoAcknowledgement) { |
| 2899 InitializeEmptyExtensionService(); | 2871 InitializeEmptyExtensionService(); |
| 2900 set_extensions_enabled(true); | 2872 set_extensions_enabled(true); |
| 2901 | 2873 |
| 2902 { | 2874 { |
| 2903 // Register and install an external extension. | 2875 // Register and install an external extension. |
| 2904 MockExtensionProvider* provider = | 2876 MockExtensionProvider* provider = |
| 2905 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF, 0); | 2877 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); |
| 2906 AddMockExternalProvider(provider); | 2878 AddMockExternalProvider(provider); |
| 2907 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", | 2879 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", |
| 2908 data_dir_.AppendASCII("good.crx")); | 2880 data_dir_.AppendASCII("good.crx")); |
| 2909 } | 2881 } |
| 2910 { | 2882 { |
| 2911 // Have policy force-install an extension. | 2883 // Have policy force-install an extension. |
| 2912 MockExtensionProvider* provider = | 2884 MockExtensionProvider* provider = |
| 2913 new MockExtensionProvider(service_, | 2885 new MockExtensionProvider(service_, |
| 2914 Extension::EXTERNAL_POLICY_DOWNLOAD); | 2886 Extension::EXTERNAL_POLICY_DOWNLOAD); |
| 2915 AddMockExternalProvider(provider); | 2887 AddMockExternalProvider(provider); |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3777 " \"cccccccccccccccccccccccccccccccc\": {" | 3749 " \"cccccccccccccccccccccccccccccccc\": {" |
| 3778 " \"external_crx\": \"RandomExtension2.crx\"," | 3750 " \"external_crx\": \"RandomExtension2.crx\"," |
| 3779 " \"external_version\": \"3.0\"," | 3751 " \"external_version\": \"3.0\"," |
| 3780 " \"supported_locales\": [ \"en_US\", \"fr\" ]" | 3752 " \"supported_locales\": [ \"en_US\", \"fr\" ]" |
| 3781 " }" | 3753 " }" |
| 3782 "}"; | 3754 "}"; |
| 3783 { | 3755 { |
| 3784 ScopedBrowserLocale guard("en-US"); | 3756 ScopedBrowserLocale guard("en-US"); |
| 3785 EXPECT_EQ(2, visitor.Visit(json_data)); | 3757 EXPECT_EQ(2, visitor.Visit(json_data)); |
| 3786 } | 3758 } |
| 3759 |
| 3760 // Test is_bookmark_app. |
| 3761 MockProviderVisitor from_bookmark_visitor( |
| 3762 base_path, Extension::FROM_BOOKMARK); |
| 3763 json_data = |
| 3764 "{" |
| 3765 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" |
| 3766 " \"external_crx\": \"RandomExtension.crx\"," |
| 3767 " \"external_version\": \"1.0\"," |
| 3768 " \"is_bookmark_app\": true" |
| 3769 " }" |
| 3770 "}"; |
| 3771 EXPECT_EQ(1, from_bookmark_visitor.Visit(json_data)); |
| 3787 } | 3772 } |
| 3788 | 3773 |
| 3789 // Test loading good extensions from the profile directory. | 3774 // Test loading good extensions from the profile directory. |
| 3790 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { | 3775 TEST_F(ExtensionServiceTest, LoadAndRelocalizeExtensions) { |
| 3791 // Initialize the test dir with a good Preferences/extensions. | 3776 // Initialize the test dir with a good Preferences/extensions. |
| 3792 FilePath source_install_dir = data_dir_ | 3777 FilePath source_install_dir = data_dir_ |
| 3793 .AppendASCII("l10n"); | 3778 .AppendASCII("l10n"); |
| 3794 FilePath pref_path = source_install_dir.AppendASCII("Preferences"); | 3779 FilePath pref_path = source_install_dir.AppendASCII("Preferences"); |
| 3795 InitializeInstalledExtensionService(pref_path, source_install_dir); | 3780 InitializeInstalledExtensionService(pref_path, source_install_dir); |
| 3796 | 3781 |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4854 // Now that the extension is installed, sync request should fail | 4839 // Now that the extension is installed, sync request should fail |
| 4855 // because the extension is already installed. | 4840 // because the extension is already installed. |
| 4856 ASSERT_FALSE(AddPendingSyncInstall()); | 4841 ASSERT_FALSE(AddPendingSyncInstall()); |
| 4857 } | 4842 } |
| 4858 | 4843 |
| 4859 TEST_F(ExtensionServiceTest, AlertableExtensionHappyPath) { | 4844 TEST_F(ExtensionServiceTest, AlertableExtensionHappyPath) { |
| 4860 InitializeEmptyExtensionService(); | 4845 InitializeEmptyExtensionService(); |
| 4861 scoped_ptr<ExtensionGlobalError> extension_global_error( | 4846 scoped_ptr<ExtensionGlobalError> extension_global_error( |
| 4862 new ExtensionGlobalError(service_)); | 4847 new ExtensionGlobalError(service_)); |
| 4863 MockExtensionProvider* provider = | 4848 MockExtensionProvider* provider = |
| 4864 new MockExtensionProvider(service_, | 4849 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); |
| 4865 Extension::EXTERNAL_PREF, | |
| 4866 0); | |
| 4867 AddMockExternalProvider(provider); | 4850 AddMockExternalProvider(provider); |
| 4868 | 4851 |
| 4869 // Should return false, meaning there aren't any extensions that the user | 4852 // Should return false, meaning there aren't any extensions that the user |
| 4870 // needs to know about. | 4853 // needs to know about. |
| 4871 ASSERT_FALSE(service_->PopulateExtensionGlobalError( | 4854 ASSERT_FALSE(service_->PopulateExtensionGlobalError( |
| 4872 extension_global_error.get())); | 4855 extension_global_error.get())); |
| 4873 | 4856 |
| 4874 // This is a normal extension, installed normally. | 4857 // This is a normal extension, installed normally. |
| 4875 // This should NOT trigger an alert. | 4858 // This should NOT trigger an alert. |
| 4876 set_extensions_enabled(true); | 4859 set_extensions_enabled(true); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4887 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 4870 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
| 4888 data_dir_.AppendASCII("hosted_app.crx")); | 4871 data_dir_.AppendASCII("hosted_app.crx")); |
| 4889 | 4872 |
| 4890 service_->CheckForExternalUpdates(); | 4873 service_->CheckForExternalUpdates(); |
| 4891 loop_.RunAllPending(); | 4874 loop_.RunAllPending(); |
| 4892 | 4875 |
| 4893 ASSERT_TRUE(service_->PopulateExtensionGlobalError( | 4876 ASSERT_TRUE(service_->PopulateExtensionGlobalError( |
| 4894 extension_global_error.get())); | 4877 extension_global_error.get())); |
| 4895 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); | 4878 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); |
| 4896 } | 4879 } |
| OLD | NEW |