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

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

Issue 236213002: Move most of extension_file_util.cc into extensions/common/file_util.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (file-util) Created 6 years, 8 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "chrome/browser/extensions/extension_install_prompt.h" 14 #include "chrome/browser/extensions/extension_install_prompt.h"
15 #include "chrome/browser/extensions/extension_install_ui.h" 15 #include "chrome/browser/extensions/extension_install_ui.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/permissions_updater.h" 17 #include "chrome/browser/extensions/permissions_updater.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 20 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
21 #include "chrome/common/extensions/extension_file_util.h"
22 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
23 #include "extensions/browser/extension_prefs.h" 22 #include "extensions/browser/extension_prefs.h"
24 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
25 #include "extensions/common/extension.h" 24 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_l10n_util.h" 25 #include "extensions/common/extension_l10n_util.h"
26 #include "extensions/common/file_util.h"
27 #include "extensions/common/id_util.h" 27 #include "extensions/common/id_util.h"
28 #include "extensions/common/manifest.h" 28 #include "extensions/common/manifest.h"
29 #include "sync/api/string_ordinal.h" 29 #include "sync/api/string_ordinal.h"
30 30
31 using content::BrowserThread; 31 using content::BrowserThread;
32 using extensions::Extension; 32 using extensions::Extension;
33 33
34 namespace { 34 namespace {
35 35
36 const char kUnpackedExtensionsBlacklistedError[] = 36 const char kUnpackedExtensionsBlacklistedError[] =
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::ThreadRestrictions::ScopedAllowIO allow_io; 142 base::ThreadRestrictions::ScopedAllowIO allow_io;
143 143
144 extension_path_ = base::MakeAbsoluteFilePath(path_in); 144 extension_path_ = base::MakeAbsoluteFilePath(path_in);
145 145
146 if (!IsLoadingUnpackedAllowed()) { 146 if (!IsLoadingUnpackedAllowed()) {
147 ReportExtensionLoadError(kUnpackedExtensionsBlacklistedError); 147 ReportExtensionLoadError(kUnpackedExtensionsBlacklistedError);
148 return false; 148 return false;
149 } 149 }
150 150
151 std::string error; 151 std::string error;
152 installer_.set_extension(extension_file_util::LoadExtension( 152 installer_.set_extension(
153 extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get()); 153 file_util::LoadExtension(
154 extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get());
154 155
155 if (!installer_.extension().get() || 156 if (!installer_.extension().get() ||
156 !extension_l10n_util::ValidateExtensionLocales( 157 !extension_l10n_util::ValidateExtensionLocales(
157 extension_path_, 158 extension_path_,
158 installer_.extension()->manifest()->value(), 159 installer_.extension()->manifest()->value(),
159 &error)) { 160 &error)) {
160 ReportExtensionLoadError(error); 161 ReportExtensionLoadError(error);
161 return false; 162 return false;
162 } 163 }
163 164
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile()); 230 ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile());
230 return !prefs->ExtensionsBlacklistedByDefault(); 231 return !prefs->ExtensionsBlacklistedByDefault();
231 } 232 }
232 233
233 void UnpackedInstaller::GetAbsolutePath() { 234 void UnpackedInstaller::GetAbsolutePath() {
234 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 235 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
235 236
236 extension_path_ = base::MakeAbsoluteFilePath(extension_path_); 237 extension_path_ = base::MakeAbsoluteFilePath(extension_path_);
237 238
238 std::string error; 239 std::string error;
239 if (!extension_file_util::CheckForIllegalFilenames(extension_path_, 240 if (!file_util::CheckForIllegalFilenames(extension_path_, &error)) {
240 &error)) {
241 BrowserThread::PostTask( 241 BrowserThread::PostTask(
242 BrowserThread::UI, 242 BrowserThread::UI,
243 FROM_HERE, 243 FROM_HERE,
244 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error)); 244 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error));
245 return; 245 return;
246 } 246 }
247 BrowserThread::PostTask( 247 BrowserThread::PostTask(
248 BrowserThread::UI, FROM_HERE, 248 BrowserThread::UI, FROM_HERE,
249 base::Bind(&UnpackedInstaller::CheckExtensionFileAccess, this)); 249 base::Bind(&UnpackedInstaller::CheckExtensionFileAccess, this));
250 } 250 }
(...skipping 11 matching lines...) Expand all
262 BrowserThread::PostTask( 262 BrowserThread::PostTask(
263 BrowserThread::FILE, 263 BrowserThread::FILE,
264 FROM_HERE, 264 FROM_HERE,
265 base::Bind(&UnpackedInstaller::LoadWithFileAccess, this, GetFlags())); 265 base::Bind(&UnpackedInstaller::LoadWithFileAccess, this, GetFlags()));
266 } 266 }
267 267
268 void UnpackedInstaller::LoadWithFileAccess(int flags) { 268 void UnpackedInstaller::LoadWithFileAccess(int flags) {
269 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 269 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
270 270
271 std::string error; 271 std::string error;
272 installer_.set_extension(extension_file_util::LoadExtension( 272 installer_.set_extension(
273 extension_path_, Manifest::UNPACKED, flags, &error).get()); 273 file_util::LoadExtension(
274 extension_path_, Manifest::UNPACKED, flags, &error).get());
274 275
275 if (!installer_.extension().get() || 276 if (!installer_.extension().get() ||
276 !extension_l10n_util::ValidateExtensionLocales( 277 !extension_l10n_util::ValidateExtensionLocales(
277 extension_path_, 278 extension_path_,
278 installer_.extension()->manifest()->value(), 279 installer_.extension()->manifest()->value(),
279 &error)) { 280 &error)) {
280 BrowserThread::PostTask( 281 BrowserThread::PostTask(
281 BrowserThread::UI, 282 BrowserThread::UI,
282 FROM_HERE, 283 FROM_HERE,
283 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error)); 284 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 326
326 service_weak_->OnExtensionInstalled( 327 service_weak_->OnExtensionInstalled(
327 installer_.extension().get(), 328 installer_.extension().get(),
328 syncer::StringOrdinal(), 329 syncer::StringOrdinal(),
329 false /* no requirement errors */, 330 false /* no requirement errors */,
330 NOT_BLACKLISTED, 331 NOT_BLACKLISTED,
331 false /* don't wait for idle */); 332 false /* don't wait for idle */);
332 } 333 }
333 334
334 } // namespace extensions 335 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698