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

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

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: additional cleanup Created 6 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/unpacked_installer.h" 5 #include "chrome/browser/extensions/unpacked_installer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
14 #include "chrome/browser/extensions/extension_install_ui.h" 14 #include "chrome/browser/extensions/extension_install_ui.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/permissions_updater.h" 16 #include "chrome/browser/extensions/permissions_updater.h"
17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 18 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
18 #include "chrome/common/extensions/extension_file_util.h" 19 #include "chrome/common/extensions/extension_file_util.h"
19 #include "chrome/common/extensions/extension_l10n_util.h" 20 #include "chrome/common/extensions/extension_l10n_util.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "extensions/browser/extension_prefs.h" 22 #include "extensions/browser/extension_prefs.h"
23 #include "extensions/browser/extension_registry.h"
22 #include "extensions/common/extension.h" 24 #include "extensions/common/extension.h"
23 #include "extensions/common/id_util.h" 25 #include "extensions/common/id_util.h"
24 #include "extensions/common/manifest.h" 26 #include "extensions/common/manifest.h"
25 #include "sync/api/string_ordinal.h" 27 #include "sync/api/string_ordinal.h"
26 28
27 using content::BrowserThread; 29 using content::BrowserThread;
28 using extensions::Extension; 30 using extensions::Extension;
29 31
30 namespace { 32 namespace {
31 33
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 152
151 *extension_id = installer_.extension()->id(); 153 *extension_id = installer_.extension()->id();
152 return true; 154 return true;
153 } 155 }
154 156
155 void UnpackedInstaller::ShowInstallPrompt() { 157 void UnpackedInstaller::ShowInstallPrompt() {
156 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
157 if (!service_weak_.get()) 159 if (!service_weak_.get())
158 return; 160 return;
159 161
160 const ExtensionSet* disabled_extensions = 162 const ExtensionSet& disabled_extensions =
161 service_weak_->disabled_extensions(); 163 ExtensionRegistry::Get(service_weak_->profile())->disabled_extensions();
162 if (service_weak_->show_extensions_prompts() && prompt_for_plugins_ && 164 if (service_weak_->show_extensions_prompts() && prompt_for_plugins_ &&
163 PluginInfo::HasPlugins(installer_.extension().get()) && 165 PluginInfo::HasPlugins(installer_.extension().get()) &&
164 !disabled_extensions->Contains(installer_.extension()->id())) { 166 !disabled_extensions.Contains(installer_.extension()->id())) {
165 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( 167 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
166 installer_.extension().get(), 168 installer_.extension().get(),
167 installer_.profile(), 169 installer_.profile(),
168 base::Bind(&UnpackedInstaller::CallCheckRequirements, this)); 170 base::Bind(&UnpackedInstaller::CallCheckRequirements, this));
169 prompt->ShowPrompt(); 171 prompt->ShowPrompt();
170 return; 172 return;
171 } 173 }
172 CallCheckRequirements(); 174 CallCheckRequirements();
173 } 175 }
174 176
(...skipping 11 matching lines...) Expand all
186 return; 188 return;
187 } 189 }
188 190
189 ConfirmInstall(); 191 ConfirmInstall();
190 } 192 }
191 193
192 int UnpackedInstaller::GetFlags() { 194 int UnpackedInstaller::GetFlags() {
193 std::string id = id_util::GenerateIdForPath(extension_path_); 195 std::string id = id_util::GenerateIdForPath(extension_path_);
194 bool allow_file_access = 196 bool allow_file_access =
195 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED); 197 Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED);
196 ExtensionPrefs* prefs = service_weak_->extension_prefs(); 198 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile());
197 if (prefs->HasAllowFileAccessSetting(id)) 199 if (prefs->HasAllowFileAccessSetting(id))
198 allow_file_access = prefs->AllowFileAccess(id); 200 allow_file_access = prefs->AllowFileAccess(id);
199 201
200 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE; 202 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE;
201 if (allow_file_access) 203 if (allow_file_access)
202 result |= Extension::ALLOW_FILE_ACCESS; 204 result |= Extension::ALLOW_FILE_ACCESS;
203 if (require_modern_manifest_version_) 205 if (require_modern_manifest_version_)
204 result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION; 206 result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION;
205 207
206 return result; 208 return result;
207 } 209 }
208 210
209 bool UnpackedInstaller::IsLoadingUnpackedAllowed() const { 211 bool UnpackedInstaller::IsLoadingUnpackedAllowed() const {
210 if (!service_weak_.get()) 212 if (!service_weak_.get())
211 return true; 213 return true;
212 // If there is a "*" in the extension blacklist, then no extensions should be 214 // If there is a "*" in the extension blacklist, then no extensions should be
213 // allowed at all (except explicitly whitelisted extensions). 215 // allowed at all (except explicitly whitelisted extensions).
214 ExtensionPrefs* prefs = service_weak_->extension_prefs(); 216 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile());
215 return !prefs->ExtensionsBlacklistedByDefault(); 217 return !prefs->ExtensionsBlacklistedByDefault();
216 } 218 }
217 219
218 void UnpackedInstaller::GetAbsolutePath() { 220 void UnpackedInstaller::GetAbsolutePath() {
219 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 221 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
220 222
221 extension_path_ = base::MakeAbsoluteFilePath(extension_path_); 223 extension_path_ = base::MakeAbsoluteFilePath(extension_path_);
222 224
223 std::string error; 225 std::string error;
224 if (!extension_file_util::CheckForIllegalFilenames(extension_path_, 226 if (!extension_file_util::CheckForIllegalFilenames(extension_path_,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 297
296 service_weak_->OnExtensionInstalled( 298 service_weak_->OnExtensionInstalled(
297 installer_.extension().get(), 299 installer_.extension().get(),
298 syncer::StringOrdinal(), 300 syncer::StringOrdinal(),
299 false /* no requirement errors */, 301 false /* no requirement errors */,
300 NOT_BLACKLISTED, 302 NOT_BLACKLISTED,
301 false /* don't wait for idle */); 303 false /* don't wait for idle */);
302 } 304 }
303 305
304 } // namespace extensions 306 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698