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

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

Issue 1880143002: Convert chrome/common to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
19 #include "extensions/common/error_utils.h" 20 #include "extensions/common/error_utils.h"
20 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
21 #include "extensions/common/extension_resource.h" 22 #include "extensions/common/extension_resource.h"
22 #include "extensions/common/host_id.h" 23 #include "extensions/common/host_id.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 383 }
383 384
384 const std::vector<std::string> ContentScriptsHandler::Keys() const { 385 const std::vector<std::string> ContentScriptsHandler::Keys() const {
385 static const char* const keys[] = { 386 static const char* const keys[] = {
386 keys::kContentScripts 387 keys::kContentScripts
387 }; 388 };
388 return std::vector<std::string>(keys, keys + arraysize(keys)); 389 return std::vector<std::string>(keys, keys + arraysize(keys));
389 } 390 }
390 391
391 bool ContentScriptsHandler::Parse(Extension* extension, base::string16* error) { 392 bool ContentScriptsHandler::Parse(Extension* extension, base::string16* error) {
392 scoped_ptr<ContentScriptsInfo> content_scripts_info(new ContentScriptsInfo); 393 std::unique_ptr<ContentScriptsInfo> content_scripts_info(
394 new ContentScriptsInfo);
393 const base::ListValue* scripts_list = NULL; 395 const base::ListValue* scripts_list = NULL;
394 if (!extension->manifest()->GetList(keys::kContentScripts, &scripts_list)) { 396 if (!extension->manifest()->GetList(keys::kContentScripts, &scripts_list)) {
395 *error = base::ASCIIToUTF16(errors::kInvalidContentScriptsList); 397 *error = base::ASCIIToUTF16(errors::kInvalidContentScriptsList);
396 return false; 398 return false;
397 } 399 }
398 400
399 for (size_t i = 0; i < scripts_list->GetSize(); ++i) { 401 for (size_t i = 0; i < scripts_list->GetSize(); ++i) {
400 const base::DictionaryValue* script_dict = NULL; 402 const base::DictionaryValue* script_dict = NULL;
401 if (!scripts_list->GetDictionary(i, &script_dict)) { 403 if (!scripts_list->GetDictionary(i, &script_dict)) {
402 *error = ErrorUtils::FormatErrorMessageUTF16( 404 *error = ErrorUtils::FormatErrorMessageUTF16(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (!IsScriptValid(path, css_script.relative_path(), 468 if (!IsScriptValid(path, css_script.relative_path(),
467 IDS_EXTENSION_LOAD_CSS_FAILED, error)) 469 IDS_EXTENSION_LOAD_CSS_FAILED, error))
468 return false; 470 return false;
469 } 471 }
470 } 472 }
471 473
472 return true; 474 return true;
473 } 475 }
474 476
475 } // namespace extensions 477 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698