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

Unified Diff: chrome/common/extensions/api/url_parser/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: Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/api/url_parser/homepage_url_handler.cc
diff --git a/chrome/common/extensions/api/url_parser/homepage_url_handler.cc b/chrome/common/extensions/api/url_parser/homepage_url_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c5bf7c507f83cecfd3bd7e7254c419da10486159
--- /dev/null
+++ b/chrome/common/extensions/api/url_parser/homepage_url_handler.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/extensions/api/url_parser/homepage_url_handler.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/common/extensions/api/url_parser/url_info.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "extensions/common/error_utils.h"
+
+namespace keys = extension_manifest_keys;
+namespace errors = extension_manifest_errors;
+
+namespace extensions {
+
+HomepageURLHandler::HomepageURLHandler() {
+}
+
+HomepageURLHandler::~HomepageURLHandler() {
+}
+
+bool HomepageURLHandler::Parse(const base::Value* value,
+ Extension* extension,
+ string16* error) {
+ scoped_ptr<URLInfo> info(new URLInfo);
+ std::string homepage_url_str;
+ if (!value->GetAsString(&homepage_url_str)) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidHomepageURL, "");
+ return false;
+ }
+ info->url_ = GURL(homepage_url_str);
+ if (!info->url_.is_valid() ||
+ (!info->url_.SchemeIs("http") &&
+ !info->url_.SchemeIs("https"))) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidHomepageURL, homepage_url_str);
+ return false;
+ }
+ extension->SetManifestData(keys::kHomepageURL, info.release());
+ return true;
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698