| 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
|
|
|