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

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: Nit 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::kAboutPage);
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return false; 261 return false;
257 } 262 }
258 } 263 }
259 return true; 264 return true;
260 } 265 }
261 266
262 const std::vector<std::string> OptionsPageHandler::Keys() const { 267 const std::vector<std::string> OptionsPageHandler::Keys() const {
263 return SingleKey(keys::kOptionsPage); 268 return SingleKey(keys::kOptionsPage);
264 } 269 }
265 270
271 AboutPageHandler::AboutPageHandler() {
272 }
273
274 AboutPageHandler::~AboutPageHandler() {
275 }
276
277 bool AboutPageHandler::Parse(Extension* extension, base::string16* error) {
278 scoped_ptr<ManifestURL> manifest_url(new ManifestURL);
279 std::string about_str;
280 if (!extension->manifest()->GetString(keys::kAboutPage, &about_str)) {
281 *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
282 return false;
283 }
284
285 GURL absolute(about_str);
286 if (absolute.is_valid()) {
287 *error = base::ASCIIToUTF16(errors::kInvalidAboutPageExpectRelativePath);
288 return false;
289 }
290 manifest_url->url_ = extension->GetResourceURL(about_str);
291 if (!manifest_url->url_.is_valid()) {
292 *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
293 return false;
294 }
295 extension->SetManifestData(keys::kAboutPage, manifest_url.release());
296 return true;
297 }
298
299 bool AboutPageHandler::Validate(const Extension* extension,
300 std::string* error,
301 std::vector<InstallWarning>* warnings) const {
302 // Validate path to the options page.
303 if (!extensions::ManifestURL::GetAboutPage(extension).is_empty()) {
304 const base::FilePath about_path =
305 extensions::file_util::ExtensionURLToRelativeFilePath(
306 extensions::ManifestURL::GetAboutPage(extension));
307 const base::FilePath path =
308 extension->GetResource(about_path).GetFilePath();
309 if (path.empty() || !base::PathExists(path)) {
310 *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ABOUT_PAGE_FAILED,
311 about_path.LossyDisplayName());
312 return false;
313 }
314 }
315 return true;
316 }
317
318 const std::vector<std::string> AboutPageHandler::Keys() const {
319 return SingleKey(keys::kAboutPage);
320 }
321
266 URLOverridesHandler::URLOverridesHandler() { 322 URLOverridesHandler::URLOverridesHandler() {
267 } 323 }
268 324
269 URLOverridesHandler::~URLOverridesHandler() { 325 URLOverridesHandler::~URLOverridesHandler() {
270 } 326 }
271 327
272 bool URLOverridesHandler::Parse(Extension* extension, base::string16* error) { 328 bool URLOverridesHandler::Parse(Extension* extension, base::string16* error) {
273 const base::DictionaryValue* overrides = NULL; 329 const base::DictionaryValue* overrides = NULL;
274 if (!extension->manifest()->GetDictionary(keys::kChromeURLOverrides, 330 if (!extension->manifest()->GetDictionary(keys::kChromeURLOverrides,
275 &overrides)) { 331 &overrides)) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 extension->SetManifestData(keys::kChromeURLOverrides, 380 extension->SetManifestData(keys::kChromeURLOverrides,
325 url_overrides.release()); 381 url_overrides.release());
326 return true; 382 return true;
327 } 383 }
328 384
329 const std::vector<std::string> URLOverridesHandler::Keys() const { 385 const std::vector<std::string> URLOverridesHandler::Keys() const {
330 return SingleKey(keys::kChromeURLOverrides); 386 return SingleKey(keys::kChromeURLOverrides);
331 } 387 }
332 388
333 } // namespace extensions 389 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_url_handler.h ('k') | chrome/test/data/extensions/manifest_tests/shared_module_about.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698