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

Side by Side Diff: extensions/common/manifest_url_handlers.cc

Issue 1908953003: Convert //extensions/{common,shell} from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? 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
« no previous file with comments | « extensions/common/manifest_test.cc ('k') | extensions/common/message_bundle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/common/manifest_url_handlers.h" 5 #include "extensions/common/manifest_url_handlers.h"
6 6
7 #include <memory>
8
7 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "extensions/common/error_utils.h" 14 #include "extensions/common/error_utils.h"
14 #include "extensions/common/extension_urls.h" 15 #include "extensions/common/extension_urls.h"
15 #include "extensions/common/file_util.h" 16 #include "extensions/common/file_util.h"
16 #include "extensions/common/manifest.h" 17 #include "extensions/common/manifest.h"
17 #include "extensions/common/manifest_constants.h" 18 #include "extensions/common/manifest_constants.h"
18 #include "extensions/common/manifest_handlers/shared_module_info.h" 19 #include "extensions/common/manifest_handlers/shared_module_info.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 GURL::EmptyGURL(); 81 GURL::EmptyGURL();
81 } 82 }
82 83
83 HomepageURLHandler::HomepageURLHandler() { 84 HomepageURLHandler::HomepageURLHandler() {
84 } 85 }
85 86
86 HomepageURLHandler::~HomepageURLHandler() { 87 HomepageURLHandler::~HomepageURLHandler() {
87 } 88 }
88 89
89 bool HomepageURLHandler::Parse(Extension* extension, base::string16* error) { 90 bool HomepageURLHandler::Parse(Extension* extension, base::string16* error) {
90 scoped_ptr<ManifestURL> manifest_url(new ManifestURL); 91 std::unique_ptr<ManifestURL> manifest_url(new ManifestURL);
91 std::string homepage_url_str; 92 std::string homepage_url_str;
92 if (!extension->manifest()->GetString(keys::kHomepageURL, 93 if (!extension->manifest()->GetString(keys::kHomepageURL,
93 &homepage_url_str)) { 94 &homepage_url_str)) {
94 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidHomepageURL, 95 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidHomepageURL,
95 std::string()); 96 std::string());
96 return false; 97 return false;
97 } 98 }
98 manifest_url->url_ = GURL(homepage_url_str); 99 manifest_url->url_ = GURL(homepage_url_str);
99 if (!manifest_url->url_.is_valid() || 100 if (!manifest_url->url_.is_valid() ||
100 !manifest_url->url_.SchemeIsHTTPOrHTTPS()) { 101 !manifest_url->url_.SchemeIsHTTPOrHTTPS()) {
101 *error = ErrorUtils::FormatErrorMessageUTF16( 102 *error = ErrorUtils::FormatErrorMessageUTF16(
102 errors::kInvalidHomepageURL, homepage_url_str); 103 errors::kInvalidHomepageURL, homepage_url_str);
103 return false; 104 return false;
104 } 105 }
105 extension->SetManifestData(keys::kHomepageURL, manifest_url.release()); 106 extension->SetManifestData(keys::kHomepageURL, manifest_url.release());
106 return true; 107 return true;
107 } 108 }
108 109
109 const std::vector<std::string> HomepageURLHandler::Keys() const { 110 const std::vector<std::string> HomepageURLHandler::Keys() const {
110 return SingleKey(keys::kHomepageURL); 111 return SingleKey(keys::kHomepageURL);
111 } 112 }
112 113
113 UpdateURLHandler::UpdateURLHandler() { 114 UpdateURLHandler::UpdateURLHandler() {
114 } 115 }
115 116
116 UpdateURLHandler::~UpdateURLHandler() { 117 UpdateURLHandler::~UpdateURLHandler() {
117 } 118 }
118 119
119 bool UpdateURLHandler::Parse(Extension* extension, base::string16* error) { 120 bool UpdateURLHandler::Parse(Extension* extension, base::string16* error) {
120 scoped_ptr<ManifestURL> manifest_url(new ManifestURL); 121 std::unique_ptr<ManifestURL> manifest_url(new ManifestURL);
121 std::string tmp_update_url; 122 std::string tmp_update_url;
122 123
123 if (!extension->manifest()->GetString(keys::kUpdateURL, &tmp_update_url)) { 124 if (!extension->manifest()->GetString(keys::kUpdateURL, &tmp_update_url)) {
124 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidUpdateURL, 125 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidUpdateURL,
125 std::string()); 126 std::string());
126 return false; 127 return false;
127 } 128 }
128 129
129 manifest_url->url_ = GURL(tmp_update_url); 130 manifest_url->url_ = GURL(tmp_update_url);
130 if (!manifest_url->url_.is_valid() || 131 if (!manifest_url->url_.is_valid() ||
(...skipping 11 matching lines...) Expand all
142 return SingleKey(keys::kUpdateURL); 143 return SingleKey(keys::kUpdateURL);
143 } 144 }
144 145
145 AboutPageHandler::AboutPageHandler() { 146 AboutPageHandler::AboutPageHandler() {
146 } 147 }
147 148
148 AboutPageHandler::~AboutPageHandler() { 149 AboutPageHandler::~AboutPageHandler() {
149 } 150 }
150 151
151 bool AboutPageHandler::Parse(Extension* extension, base::string16* error) { 152 bool AboutPageHandler::Parse(Extension* extension, base::string16* error) {
152 scoped_ptr<ManifestURL> manifest_url(new ManifestURL); 153 std::unique_ptr<ManifestURL> manifest_url(new ManifestURL);
153 std::string about_str; 154 std::string about_str;
154 if (!extension->manifest()->GetString(keys::kAboutPage, &about_str)) { 155 if (!extension->manifest()->GetString(keys::kAboutPage, &about_str)) {
155 *error = base::ASCIIToUTF16(errors::kInvalidAboutPage); 156 *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
156 return false; 157 return false;
157 } 158 }
158 159
159 GURL absolute(about_str); 160 GURL absolute(about_str);
160 if (absolute.is_valid()) { 161 if (absolute.is_valid()) {
161 *error = base::ASCIIToUTF16(errors::kInvalidAboutPageExpectRelativePath); 162 *error = base::ASCIIToUTF16(errors::kInvalidAboutPageExpectRelativePath);
162 return false; 163 return false;
(...skipping 24 matching lines...) Expand all
187 } 188 }
188 } 189 }
189 return true; 190 return true;
190 } 191 }
191 192
192 const std::vector<std::string> AboutPageHandler::Keys() const { 193 const std::vector<std::string> AboutPageHandler::Keys() const {
193 return SingleKey(keys::kAboutPage); 194 return SingleKey(keys::kAboutPage);
194 } 195 }
195 196
196 } // namespace extensions 197 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_test.cc ('k') | extensions/common/message_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698