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

Side by Side Diff: chrome/common/extensions/manifest_handlers/content_scripts_handler.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/common/extensions/manifest_handlers/content_scripts_handler.h" 5 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 291
292 // Returns false and sets the error if script file can't be loaded, 292 // Returns false and sets the error if script file can't be loaded,
293 // or if it's not UTF-8 encoded. 293 // or if it's not UTF-8 encoded.
294 static bool IsScriptValid(const base::FilePath& path, 294 static bool IsScriptValid(const base::FilePath& path,
295 const base::FilePath& relative_path, 295 const base::FilePath& relative_path,
296 int message_id, 296 int message_id,
297 std::string* error) { 297 std::string* error) {
298 std::string content; 298 std::string content;
299 if (!base::PathExists(path) || 299 if (!base::PathExists(path) ||
300 !file_util::ReadFileToString(path, &content)) { 300 !base::ReadFileToString(path, &content)) {
301 *error = l10n_util::GetStringFUTF8( 301 *error = l10n_util::GetStringFUTF8(
302 message_id, 302 message_id,
303 relative_path.LossyDisplayName()); 303 relative_path.LossyDisplayName());
304 return false; 304 return false;
305 } 305 }
306 306
307 if (!IsStringUTF8(content)) { 307 if (!IsStringUTF8(content)) {
308 *error = l10n_util::GetStringFUTF8( 308 *error = l10n_util::GetStringFUTF8(
309 IDS_EXTENSION_BAD_FILE_ENCODING, 309 IDS_EXTENSION_BAD_FILE_ENCODING,
310 relative_path.LossyDisplayName()); 310 relative_path.LossyDisplayName());
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (!IsScriptValid(path, css_script.relative_path(), 459 if (!IsScriptValid(path, css_script.relative_path(),
460 IDS_EXTENSION_LOAD_CSS_FAILED, error)) 460 IDS_EXTENSION_LOAD_CSS_FAILED, error))
461 return false; 461 return false;
462 } 462 }
463 } 463 }
464 464
465 return true; 465 return true;
466 } 466 }
467 467
468 } // namespace extensions 468 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_unittest.cc ('k') | chrome/common/importer/firefox_importer_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698