| 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/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 |
| OLD | NEW |