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

Side by Side Diff: chrome/common/extensions/manifest_url_handler.cc

Issue 311193005: Add the about_page key to shared_module manifest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change the dialog Created 6 years, 6 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) 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return false; 78 return false;
79 return extension_urls::IsWebstoreUpdateUrl(GURL(url)); 79 return extension_urls::IsWebstoreUpdateUrl(GURL(url));
80 } 80 }
81 81
82 // static 82 // static
83 const GURL& ManifestURL::GetOptionsPage(const Extension* extension) { 83 const GURL& ManifestURL::GetOptionsPage(const Extension* extension) {
84 return GetManifestURL(extension, keys::kOptionsPage); 84 return GetManifestURL(extension, keys::kOptionsPage);
85 } 85 }
86 86
87 // static 87 // static
88 const GURL& ManifestURL::GetAboutPage(const Extension* extension) {
89 return GetManifestURL(extension, keys::kOptionsPage);
90 }
91
92 // static
88 const GURL ManifestURL::GetDetailsURL(const Extension* extension) { 93 const GURL ManifestURL::GetDetailsURL(const Extension* extension) {
89 return extension->from_webstore() ? 94 return extension->from_webstore() ?
90 GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + extension->id()) : 95 GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + extension->id()) :
91 GURL::EmptyGURL(); 96 GURL::EmptyGURL();
92 } 97 }
93 98
94 URLOverrides::URLOverrides() { 99 URLOverrides::URLOverrides() {
95 } 100 }
96 101
97 URLOverrides::~URLOverrides() { 102 URLOverrides::~URLOverrides() {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return false; 262 return false;
258 } 263 }
259 } 264 }
260 return true; 265 return true;
261 } 266 }
262 267
263 const std::vector<std::string> OptionsPageHandler::Keys() const { 268 const std::vector<std::string> OptionsPageHandler::Keys() const {
264 return SingleKey(keys::kOptionsPage); 269 return SingleKey(keys::kOptionsPage);
265 } 270 }
266 271
272 AboutPageHandler::AboutPageHandler() {
benwells 2014/06/05 03:59:17 This class is so similar to the options page class
sashab 2014/06/10 05:44:13 Not sure if they're _that_ similar. The options_pa
benwells 2014/06/11 00:47:29 I could imagine a URLManifestHandler, which when o
273 }
274
275 AboutPageHandler::~AboutPageHandler() {
276 }
277
278 bool AboutPageHandler::Parse(Extension* extension, base::string16* error) {
279 scoped_ptr<ManifestURL> manifest_url(new ManifestURL);
280 std::string options_str;
benwells 2014/06/05 03:59:17 Nit: options_str -> about_str
sashab 2014/06/10 05:44:13 Done.
281 if (!extension->manifest()->GetString(keys::kAboutPage, &options_str)) {
282 *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
283 return false;
284 }
285
286 GURL absolute(options_str);
287 if (absolute.is_valid()) {
288 *error = base::ASCIIToUTF16(errors::kInvalidAboutPageExpectRelativePath);
289 return false;
290 }
291 manifest_url->url_ = extension->GetResourceURL(options_str);
292 if (!manifest_url->url_.is_valid()) {
293 *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
294 return false;
295 }
296 extension->SetManifestData(keys::kAboutPage, manifest_url.release());
297 return true;
298 }
299
300 bool AboutPageHandler::Validate(const Extension* extension,
301 std::string* error,
302 std::vector<InstallWarning>* warnings) const {
303 // Validate path to the options page.
304 if (!extensions::ManifestURL::GetAboutPage(extension).is_empty()) {
305 const base::FilePath about_path =
306 extensions::file_util::ExtensionURLToRelativeFilePath(
307 extensions::ManifestURL::GetAboutPage(extension));
308 const base::FilePath path =
309 extension->GetResource(about_path).GetFilePath();
310 if (path.empty() || !base::PathExists(path)) {
311 *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ABOUT_PAGE_FAILED,
312 about_path.LossyDisplayName());
313 return false;
314 }
315 }
316 return true;
317 }
318
319 const std::vector<std::string> AboutPageHandler::Keys() const {
320 return SingleKey(keys::kAboutPage);
321 }
322
267 URLOverridesHandler::URLOverridesHandler() { 323 URLOverridesHandler::URLOverridesHandler() {
268 } 324 }
269 325
270 URLOverridesHandler::~URLOverridesHandler() { 326 URLOverridesHandler::~URLOverridesHandler() {
271 } 327 }
272 328
273 bool URLOverridesHandler::Parse(Extension* extension, base::string16* error) { 329 bool URLOverridesHandler::Parse(Extension* extension, base::string16* error) {
274 const base::DictionaryValue* overrides = NULL; 330 const base::DictionaryValue* overrides = NULL;
275 if (!extension->manifest()->GetDictionary(keys::kChromeURLOverrides, 331 if (!extension->manifest()->GetDictionary(keys::kChromeURLOverrides,
276 &overrides)) { 332 &overrides)) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 extension->SetManifestData(keys::kChromeURLOverrides, 381 extension->SetManifestData(keys::kChromeURLOverrides,
326 url_overrides.release()); 382 url_overrides.release());
327 return true; 383 return true;
328 } 384 }
329 385
330 const std::vector<std::string> URLOverridesHandler::Keys() const { 386 const std::vector<std::string> URLOverridesHandler::Keys() const {
331 return SingleKey(keys::kChromeURLOverrides); 387 return SingleKey(keys::kChromeURLOverrides);
332 } 388 }
333 389
334 } // namespace extensions 390 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698