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

Side by Side Diff: chrome/common/extensions/extension_file_util.cc

Issue 9150008: Introduce background.scripts feature for extension manifests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready to land Created 8 years, 11 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/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (!path.empty() && 281 if (!path.empty() &&
282 !file_util::PathExists(extension->GetResource(path).GetFilePath())) { 282 !file_util::PathExists(extension->GetResource(path).GetFilePath())) {
283 *error = 283 *error =
284 l10n_util::GetStringFUTF8( 284 l10n_util::GetStringFUTF8(
285 IDS_EXTENSION_LOAD_ICON_FOR_BROWSER_ACTION_FAILED, 285 IDS_EXTENSION_LOAD_ICON_FOR_BROWSER_ACTION_FAILED,
286 UTF8ToUTF16(path)); 286 UTF8ToUTF16(path));
287 return false; 287 return false;
288 } 288 }
289 } 289 }
290 290
291 // Validate that background scripts exist.
292 for (size_t i = 0; i < extension->background_scripts().size(); ++i) {
293 if (!file_util::PathExists(
294 extension->GetResource(
295 extension->background_scripts()[i]).GetFilePath())) {
296 *error = l10n_util::GetStringFUTF8(
297 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
298 UTF8ToUTF16(extension->background_scripts()[i]));
299 return false;
300 }
301 }
302
291 // Validate background page location, except for hosted apps, which should use 303 // Validate background page location, except for hosted apps, which should use
292 // an external URL. Background page for hosted apps are verified when the 304 // an external URL. Background page for hosted apps are verified when the
293 // extension is created (in Extension::InitFromValue) 305 // extension is created (in Extension::InitFromValue)
294 if (!extension->background_url().is_empty() && !extension->is_hosted_app()) { 306 if (extension->has_background_page() &&
307 !extension->is_hosted_app() &&
308 extension->background_scripts().empty()) {
295 FilePath page_path = ExtensionURLToRelativeFilePath( 309 FilePath page_path = ExtensionURLToRelativeFilePath(
296 extension->background_url()); 310 extension->GetBackgroundURL());
297 const FilePath path = extension->GetResource(page_path).GetFilePath(); 311 const FilePath path = extension->GetResource(page_path).GetFilePath();
298 if (path.empty() || !file_util::PathExists(path)) { 312 if (path.empty() || !file_util::PathExists(path)) {
299 *error = 313 *error =
300 l10n_util::GetStringFUTF8( 314 l10n_util::GetStringFUTF8(
301 IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, 315 IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED,
302 page_path.LossyDisplayName()); 316 page_path.LossyDisplayName());
303 return false; 317 return false;
304 } 318 }
305 } 319 }
306 320
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 return temp_path; 679 return temp_path;
666 680
667 return FilePath(); 681 return FilePath();
668 } 682 }
669 683
670 void DeleteFile(const FilePath& path, bool recursive) { 684 void DeleteFile(const FilePath& path, bool recursive) {
671 file_util::Delete(path, recursive); 685 file_util::Delete(path, recursive);
672 } 686 }
673 687
674 } // namespace extension_file_util 688 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698