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

Side by Side Diff: content/renderer/manifest/manifest_parser.cc

Issue 1851933002: Convert //url to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU fixup 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/manifest/manifest_parser.h" 5 #include "content/renderer/manifest/manifest_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/strings/nullable_string16.h" 11 #include "base/strings/nullable_string16.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "content/public/common/manifest.h" 17 #include "content/public/common/manifest.h"
17 #include "content/renderer/manifest/manifest_uma_util.h" 18 #include "content/renderer/manifest/manifest_uma_util.h"
18 #include "third_party/WebKit/public/platform/WebColor.h" 19 #include "third_party/WebKit/public/platform/WebColor.h"
19 #include "third_party/WebKit/public/platform/WebString.h" 20 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 failed_(false) { 102 failed_(false) {
102 } 103 }
103 104
104 ManifestParser::~ManifestParser() { 105 ManifestParser::~ManifestParser() {
105 } 106 }
106 107
107 void ManifestParser::Parse() { 108 void ManifestParser::Parse() {
108 std::string error_msg; 109 std::string error_msg;
109 int error_line = 0; 110 int error_line = 0;
110 int error_column = 0; 111 int error_column = 0;
111 scoped_ptr<base::Value> value = base::JSONReader::ReadAndReturnError( 112 std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
112 data_, base::JSON_PARSE_RFC, nullptr, &error_msg, &error_line, 113 data_, base::JSON_PARSE_RFC, nullptr, &error_msg, &error_line,
113 &error_column); 114 &error_column);
114 115
115 if (!value) { 116 if (!value) {
116 AddErrorInfo(GetErrorPrefix() + error_msg, error_line, error_column); 117 AddErrorInfo(GetErrorPrefix() + error_msg, error_line, error_column);
117 ManifestUmaUtil::ParseFailed(); 118 ManifestUmaUtil::ParseFailed();
118 failed_ = true; 119 failed_ = true;
119 return; 120 return;
120 } 121 }
121 122
(...skipping 20 matching lines...) Expand all
142 manifest_.background_color = ParseBackgroundColor(*dictionary); 143 manifest_.background_color = ParseBackgroundColor(*dictionary);
143 manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary); 144 manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary);
144 145
145 ManifestUmaUtil::ParseSucceeded(manifest_); 146 ManifestUmaUtil::ParseSucceeded(manifest_);
146 } 147 }
147 148
148 const Manifest& ManifestParser::manifest() const { 149 const Manifest& ManifestParser::manifest() const {
149 return manifest_; 150 return manifest_;
150 } 151 }
151 152
152 const std::vector<scoped_ptr<ManifestParser::ErrorInfo>>& 153 const std::vector<std::unique_ptr<ManifestParser::ErrorInfo>>&
153 ManifestParser::errors() const { 154 ManifestParser::errors() const {
154 return errors_; 155 return errors_;
155 } 156 }
156 157
157 bool ManifestParser::failed() const { 158 bool ManifestParser::failed() const {
158 return failed_; 159 return failed_;
159 } 160 }
160 161
161 bool ManifestParser::ParseBoolean(const base::DictionaryValue& dictionary, 162 bool ManifestParser::ParseBoolean(const base::DictionaryValue& dictionary,
162 const std::string& key, 163 const std::string& key,
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 454
454 base::NullableString16 ManifestParser::ParseGCMSenderID( 455 base::NullableString16 ManifestParser::ParseGCMSenderID(
455 const base::DictionaryValue& dictionary) { 456 const base::DictionaryValue& dictionary) {
456 return ParseString(dictionary, "gcm_sender_id", Trim); 457 return ParseString(dictionary, "gcm_sender_id", Trim);
457 } 458 }
458 459
459 void ManifestParser::AddErrorInfo(const std::string& error_msg, 460 void ManifestParser::AddErrorInfo(const std::string& error_msg,
460 int error_line, 461 int error_line,
461 int error_column) { 462 int error_column) {
462 errors_.push_back( 463 errors_.push_back(
463 make_scoped_ptr(new ErrorInfo(error_msg, error_line, error_column))); 464 base::WrapUnique(new ErrorInfo(error_msg, error_line, error_column)));
464 } 465 }
465 } // namespace content 466 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_parser.h ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698