OLD | NEW |
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/manifest_url_handler.h" | 5 #include "chrome/common/extensions/manifest_url_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_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 scoped_ptr<ManifestURL> manifest_url(new ManifestURL); | 135 scoped_ptr<ManifestURL> manifest_url(new ManifestURL); |
136 std::string homepage_url_str; | 136 std::string homepage_url_str; |
137 if (!extension->manifest()->GetString(keys::kHomepageURL, | 137 if (!extension->manifest()->GetString(keys::kHomepageURL, |
138 &homepage_url_str)) { | 138 &homepage_url_str)) { |
139 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidHomepageURL, | 139 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidHomepageURL, |
140 std::string()); | 140 std::string()); |
141 return false; | 141 return false; |
142 } | 142 } |
143 manifest_url->url_ = GURL(homepage_url_str); | 143 manifest_url->url_ = GURL(homepage_url_str); |
144 if (!manifest_url->url_.is_valid() || | 144 if (!manifest_url->url_.is_valid() || |
145 (!manifest_url->url_.SchemeIs("http") && | 145 !manifest_url->url_.SchemeIsHTTPOrHTTPS()) { |
146 !manifest_url->url_.SchemeIs("https"))) { | |
147 *error = ErrorUtils::FormatErrorMessageUTF16( | 146 *error = ErrorUtils::FormatErrorMessageUTF16( |
148 errors::kInvalidHomepageURL, homepage_url_str); | 147 errors::kInvalidHomepageURL, homepage_url_str); |
149 return false; | 148 return false; |
150 } | 149 } |
151 extension->SetManifestData(keys::kHomepageURL, manifest_url.release()); | 150 extension->SetManifestData(keys::kHomepageURL, manifest_url.release()); |
152 return true; | 151 return true; |
153 } | 152 } |
154 | 153 |
155 const std::vector<std::string> HomepageURLHandler::Keys() const { | 154 const std::vector<std::string> HomepageURLHandler::Keys() const { |
156 return SingleKey(keys::kHomepageURL); | 155 return SingleKey(keys::kHomepageURL); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 std::string options_str; | 198 std::string options_str; |
200 if (!extension->manifest()->GetString(keys::kOptionsPage, &options_str)) { | 199 if (!extension->manifest()->GetString(keys::kOptionsPage, &options_str)) { |
201 *error = ASCIIToUTF16(errors::kInvalidOptionsPage); | 200 *error = ASCIIToUTF16(errors::kInvalidOptionsPage); |
202 return false; | 201 return false; |
203 } | 202 } |
204 | 203 |
205 if (extension->is_hosted_app()) { | 204 if (extension->is_hosted_app()) { |
206 // hosted apps require an absolute URL. | 205 // hosted apps require an absolute URL. |
207 GURL options_url(options_str); | 206 GURL options_url(options_str); |
208 if (!options_url.is_valid() || | 207 if (!options_url.is_valid() || |
209 !(options_url.SchemeIs("http") || options_url.SchemeIs("https"))) { | 208 !options_url.SchemeIsHTTPOrHTTPS()) { |
210 *error = ASCIIToUTF16(errors::kInvalidOptionsPageInHostedApp); | 209 *error = ASCIIToUTF16(errors::kInvalidOptionsPageInHostedApp); |
211 return false; | 210 return false; |
212 } | 211 } |
213 manifest_url->url_ = options_url; | 212 manifest_url->url_ = options_url; |
214 } else { | 213 } else { |
215 GURL absolute(options_str); | 214 GURL absolute(options_str); |
216 if (absolute.is_valid()) { | 215 if (absolute.is_valid()) { |
217 *error = ASCIIToUTF16(errors::kInvalidOptionsPageExpectUrlInPackage); | 216 *error = ASCIIToUTF16(errors::kInvalidOptionsPageExpectUrlInPackage); |
218 return false; | 217 return false; |
219 } | 218 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 extension->SetManifestData(keys::kChromeURLOverrides, | 320 extension->SetManifestData(keys::kChromeURLOverrides, |
322 url_overrides.release()); | 321 url_overrides.release()); |
323 return true; | 322 return true; |
324 } | 323 } |
325 | 324 |
326 const std::vector<std::string> URLOverridesHandler::Keys() const { | 325 const std::vector<std::string> URLOverridesHandler::Keys() const { |
327 return SingleKey(keys::kChromeURLOverrides); | 326 return SingleKey(keys::kChromeURLOverrides); |
328 } | 327 } |
329 | 328 |
330 } // namespace extensions | 329 } // namespace extensions |
OLD | NEW |