| OLD | NEW |
| (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/api/url_parser/homepage_url_handler.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/values.h" |
| 10 #include "chrome/common/extensions/api/url_parser/url_info.h" |
| 11 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 12 #include "extensions/common/error_utils.h" |
| 13 |
| 14 namespace keys = extension_manifest_keys; |
| 15 namespace errors = extension_manifest_errors; |
| 16 |
| 17 namespace extensions { |
| 18 |
| 19 HomepageURLHandler::HomepageURLHandler() { |
| 20 } |
| 21 |
| 22 HomepageURLHandler::~HomepageURLHandler() { |
| 23 } |
| 24 |
| 25 bool HomepageURLHandler::Parse(const base::Value* value, |
| 26 Extension* extension, |
| 27 string16* error) { |
| 28 scoped_ptr<URLInfo> info(new URLInfo); |
| 29 std::string homepage_url_str; |
| 30 if (!value->GetAsString(&homepage_url_str)) { |
| 31 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 32 errors::kInvalidHomepageURL, ""); |
| 33 return false; |
| 34 } |
| 35 info->url_ = GURL(homepage_url_str); |
| 36 if (!info->url_.is_valid() || |
| 37 (!info->url_.SchemeIs("http") && |
| 38 !info->url_.SchemeIs("https"))) { |
| 39 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 40 errors::kInvalidHomepageURL, homepage_url_str); |
| 41 return false; |
| 42 } |
| 43 extension->SetManifestData(keys::kHomepageURL, info.release()); |
| 44 return true; |
| 45 } |
| 46 |
| 47 } // namespace extensions |
| OLD | NEW |