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

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

Issue 11624036: Move the parsing of homepage_url" and "devtools_page" out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments addressed Created 7 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/extensions/homepage_url_handler.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h"
9 #include "chrome/common/extensions/extension_manifest_constants.h"
10 #include "chrome/common/extensions/manifest_url_info.h"
11 #include "extensions/common/error_utils.h"
12
13 namespace keys = extension_manifest_keys;
14 namespace errors = extension_manifest_errors;
15
16 namespace extensions {
17
18 HomepageURLHandler::HomepageURLHandler() {
19 }
20
21 HomepageURLHandler::~HomepageURLHandler() {
22 }
23
24 bool HomepageURLHandler::Parse(const base::Value* value,
25 Extension* extension,
26 string16* error) {
27 scoped_ptr<ManifestURLInfo> info(new ManifestURLInfo);
28 std::string homepage_url_str;
29 if (!value->GetAsString(&homepage_url_str)) {
30 *error = ErrorUtils::FormatErrorMessageUTF16(
31 errors::kInvalidHomepageURL, "");
32 return false;
33 }
34 info->url_ = GURL(homepage_url_str);
35 if (!info->url_.is_valid() ||
36 (!info->url_.SchemeIs("http") &&
37 !info->url_.SchemeIs("https"))) {
38 *error = ErrorUtils::FormatErrorMessageUTF16(
39 errors::kInvalidHomepageURL, homepage_url_str);
40 return false;
41 }
42 extension->SetManifestData(keys::kHomepageURL, info.release());
43 return true;
44 }
45
46 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698