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

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

Issue 5784004: Add DCHECKs to StatefulExternalExtensionProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/stateful_external_extension_provider.h" 5 #include "chrome/browser/extensions/stateful_external_extension_provider.h"
6 6
7 #include "app/app_paths.h" 7 #include "app/app_paths.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 16 matching lines...) Expand all
27 Extension::Location download_location) 27 Extension::Location download_location)
28 : crx_location_(crx_location), 28 : crx_location_(crx_location),
29 download_location_(download_location) { 29 download_location_(download_location) {
30 } 30 }
31 31
32 StatefulExternalExtensionProvider::~StatefulExternalExtensionProvider() { 32 StatefulExternalExtensionProvider::~StatefulExternalExtensionProvider() {
33 } 33 }
34 34
35 void StatefulExternalExtensionProvider::VisitRegisteredExtension( 35 void StatefulExternalExtensionProvider::VisitRegisteredExtension(
36 Visitor* visitor) const { 36 Visitor* visitor) const {
37 DCHECK(prefs_.get());
37 for (DictionaryValue::key_iterator i = prefs_->begin_keys(); 38 for (DictionaryValue::key_iterator i = prefs_->begin_keys();
38 i != prefs_->end_keys(); ++i) { 39 i != prefs_->end_keys(); ++i) {
39 const std::string& extension_id = *i; 40 const std::string& extension_id = *i;
40 DictionaryValue* extension; 41 DictionaryValue* extension;
41 if (!prefs_->GetDictionaryWithoutPathExpansion(extension_id, &extension)) 42 if (!prefs_->GetDictionaryWithoutPathExpansion(extension_id, &extension))
42 continue; 43 continue;
43 44
44 FilePath::StringType external_crx; 45 FilePath::StringType external_crx;
45 std::string external_version; 46 std::string external_version;
46 std::string external_update_url; 47 std::string external_update_url;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 continue; 114 continue;
114 } 115 }
115 visitor->OnExternalExtensionUpdateUrlFound( 116 visitor->OnExternalExtensionUpdateUrlFound(
116 extension_id, update_url, download_location_); 117 extension_id, update_url, download_location_);
117 } 118 }
118 } 119 }
119 } 120 }
120 121
121 bool StatefulExternalExtensionProvider::HasExtension( 122 bool StatefulExternalExtensionProvider::HasExtension(
122 const std::string& id) const { 123 const std::string& id) const {
124 DCHECK(prefs_.get());
123 return prefs_->HasKey(id); 125 return prefs_->HasKey(id);
124 } 126 }
125 127
126 bool StatefulExternalExtensionProvider::GetExtensionDetails( 128 bool StatefulExternalExtensionProvider::GetExtensionDetails(
127 const std::string& id, Extension::Location* location, 129 const std::string& id, Extension::Location* location,
128 scoped_ptr<Version>* version) const { 130 scoped_ptr<Version>* version) const {
131 DCHECK(prefs_.get());
129 DictionaryValue* extension = NULL; 132 DictionaryValue* extension = NULL;
130 if (!prefs_->GetDictionary(id, &extension)) 133 if (!prefs_->GetDictionary(id, &extension))
131 return false; 134 return false;
132 135
133 Extension::Location loc = Extension::INVALID; 136 Extension::Location loc = Extension::INVALID;
134 if (extension->HasKey(kExternalUpdateUrl)) { 137 if (extension->HasKey(kExternalUpdateUrl)) {
135 loc = download_location_; 138 loc = download_location_;
136 139
137 } else if (extension->HasKey(kExternalCrx)) { 140 } else if (extension->HasKey(kExternalCrx)) {
138 loc = crx_location_; 141 loc = crx_location_;
139 142
140 std::string external_version; 143 std::string external_version;
141 if (!extension->GetString(kExternalVersion, &external_version)) 144 if (!extension->GetString(kExternalVersion, &external_version))
142 return false; 145 return false;
143 146
144 if (version) 147 if (version)
145 version->reset(Version::GetVersionFromString(external_version)); 148 version->reset(Version::GetVersionFromString(external_version));
146 149
147 } else { 150 } else {
148 NOTREACHED(); // Chrome should not allow prefs to get into this state. 151 NOTREACHED(); // Chrome should not allow prefs to get into this state.
149 return false; 152 return false;
150 } 153 }
151 154
152 if (location) 155 if (location)
153 *location = loc; 156 *location = loc;
154 157
155 return true; 158 return true;
156 } 159 }
160
161 void StatefulExternalExtensionProvider::set_prefs(DictionaryValue* prefs) {
162 prefs_.reset(prefs);
163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698