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

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

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/extensions/external_provider_impl.h" 5 #include "chrome/browser/extensions/external_provider_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 ExternalProviderImpl::~ExternalProviderImpl() { 83 ExternalProviderImpl::~ExternalProviderImpl() {
84 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 84 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
85 loader_->OwnerShutdown(); 85 loader_->OwnerShutdown();
86 } 86 }
87 87
88 void ExternalProviderImpl::VisitRegisteredExtension() { 88 void ExternalProviderImpl::VisitRegisteredExtension() {
89 // The loader will call back to SetPrefs. 89 // The loader will call back to SetPrefs.
90 loader_->StartLoading(); 90 loader_->StartLoading();
91 } 91 }
92 92
93 void ExternalProviderImpl::SetPrefs(DictionaryValue* prefs) { 93 void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
94 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 94 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
95 95
96 // Check if the service is still alive. It is possible that it went 96 // Check if the service is still alive. It is possible that it went
97 // away while |loader_| was working on the FILE thread. 97 // away while |loader_| was working on the FILE thread.
98 if (!service_) return; 98 if (!service_) return;
99 99
100 prefs_.reset(prefs); 100 prefs_.reset(prefs);
101 ready_ = true; // Queries for extensions are allowed from this point. 101 ready_ = true; // Queries for extensions are allowed from this point.
102 102
103 // Set of unsupported extensions that need to be deleted from prefs_. 103 // Set of unsupported extensions that need to be deleted from prefs_.
104 std::set<std::string> unsupported_extensions; 104 std::set<std::string> unsupported_extensions;
105 105
106 // Notify ExtensionService about all the extensions this provider has. 106 // Notify ExtensionService about all the extensions this provider has.
107 for (DictionaryValue::Iterator i(*prefs_); !i.IsAtEnd(); i.Advance()) { 107 for (base::DictionaryValue::Iterator i(*prefs_); !i.IsAtEnd(); i.Advance()) {
108 const std::string& extension_id = i.key(); 108 const std::string& extension_id = i.key();
109 const DictionaryValue* extension = NULL; 109 const base::DictionaryValue* extension = NULL;
110 110
111 if (!Extension::IdIsValid(extension_id)) { 111 if (!Extension::IdIsValid(extension_id)) {
112 LOG(WARNING) << "Malformed extension dictionary: key " 112 LOG(WARNING) << "Malformed extension dictionary: key "
113 << extension_id.c_str() << " is not a valid id."; 113 << extension_id.c_str() << " is not a valid id.";
114 continue; 114 continue;
115 } 115 }
116 116
117 if (!i.value().GetAsDictionary(&extension)) { 117 if (!i.value().GetAsDictionary(&extension)) {
118 LOG(WARNING) << "Malformed extension dictionary: key " 118 LOG(WARNING) << "Malformed extension dictionary: key "
119 << extension_id.c_str() 119 << extension_id.c_str()
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 if (has_external_crx == has_external_update_url) { 153 if (has_external_crx == has_external_update_url) {
154 LOG(WARNING) << "Malformed extension dictionary for extension: " 154 LOG(WARNING) << "Malformed extension dictionary for extension: "
155 << extension_id.c_str() << ". Exactly one of the " 155 << extension_id.c_str() << ". Exactly one of the "
156 << "followng keys should be used: " << kExternalCrx 156 << "followng keys should be used: " << kExternalCrx
157 << ", " << kExternalUpdateUrl << "."; 157 << ", " << kExternalUpdateUrl << ".";
158 continue; 158 continue;
159 } 159 }
160 160
161 // Check that extension supports current browser locale. 161 // Check that extension supports current browser locale.
162 const ListValue* supported_locales = NULL; 162 const base::ListValue* supported_locales = NULL;
163 if (extension->GetList(kSupportedLocales, &supported_locales)) { 163 if (extension->GetList(kSupportedLocales, &supported_locales)) {
164 std::vector<std::string> browser_locales; 164 std::vector<std::string> browser_locales;
165 l10n_util::GetParentLocales(g_browser_process->GetApplicationLocale(), 165 l10n_util::GetParentLocales(g_browser_process->GetApplicationLocale(),
166 &browser_locales); 166 &browser_locales);
167 167
168 size_t num_locales = supported_locales->GetSize(); 168 size_t num_locales = supported_locales->GetSize();
169 bool locale_supported = false; 169 bool locale_supported = false;
170 for (size_t j = 0; j < num_locales; j++) { 170 for (size_t j = 0; j < num_locales; j++) {
171 std::string current_locale; 171 std::string current_locale;
172 if (supported_locales->GetString(j, &current_locale) && 172 if (supported_locales->GetString(j, &current_locale) &&
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 CHECK(ready_); 300 CHECK(ready_);
301 return prefs_->HasKey(id); 301 return prefs_->HasKey(id);
302 } 302 }
303 303
304 bool ExternalProviderImpl::GetExtensionDetails( 304 bool ExternalProviderImpl::GetExtensionDetails(
305 const std::string& id, Manifest::Location* location, 305 const std::string& id, Manifest::Location* location,
306 scoped_ptr<Version>* version) const { 306 scoped_ptr<Version>* version) const {
307 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 307 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
308 CHECK(prefs_.get()); 308 CHECK(prefs_.get());
309 CHECK(ready_); 309 CHECK(ready_);
310 DictionaryValue* extension = NULL; 310 base::DictionaryValue* extension = NULL;
311 if (!prefs_->GetDictionary(id, &extension)) 311 if (!prefs_->GetDictionary(id, &extension))
312 return false; 312 return false;
313 313
314 Manifest::Location loc = Manifest::INVALID_LOCATION; 314 Manifest::Location loc = Manifest::INVALID_LOCATION;
315 if (extension->HasKey(kExternalUpdateUrl)) { 315 if (extension->HasKey(kExternalUpdateUrl)) {
316 loc = download_location_; 316 loc = download_location_;
317 317
318 } else if (extension->HasKey(kExternalCrx)) { 318 } else if (extension->HasKey(kExternalCrx)) {
319 loc = crx_location_; 319 loc = crx_location_;
320 320
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 new ExternalProviderImpl( 488 new ExternalProviderImpl(
489 service, 489 service,
490 new ExternalComponentLoader(), 490 new ExternalComponentLoader(),
491 profile, 491 profile,
492 Manifest::INVALID_LOCATION, 492 Manifest::INVALID_LOCATION,
493 Manifest::EXTERNAL_POLICY_DOWNLOAD, 493 Manifest::EXTERNAL_POLICY_DOWNLOAD,
494 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); 494 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
495 } 495 }
496 496
497 } // namespace extensions 497 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698