| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/extensions/homepage_url_handler.h" | 5 #include "chrome/common/extensions/update_url_handler.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 9 #include "base/values.h" |
| 9 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 10 #include "chrome/common/extensions/manifest_url_info.h" | 11 #include "chrome/common/extensions/manifest_url_info.h" |
| 11 #include "extensions/common/error_utils.h" | 12 #include "extensions/common/error_utils.h" |
| 12 | 13 |
| 13 namespace keys = extension_manifest_keys; | 14 namespace keys = extension_manifest_keys; |
| 14 namespace errors = extension_manifest_errors; | 15 namespace errors = extension_manifest_errors; |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 HomepageURLHandler::HomepageURLHandler() { | 19 UpdateURLHandler::UpdateURLHandler() { |
| 19 } | 20 } |
| 20 | 21 |
| 21 HomepageURLHandler::~HomepageURLHandler() { | 22 UpdateURLHandler::~UpdateURLHandler() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 bool HomepageURLHandler::Parse(const base::Value* value, | 25 bool UpdateURLHandler::Parse(const base::Value* value, |
| 25 Extension* extension, | 26 Extension* extension, |
| 26 string16* error) { | 27 string16* error) { |
| 27 scoped_ptr<ManifestURLInfo> info(new ManifestURLInfo); | 28 scoped_ptr<ManifestURLInfo> info(new ManifestURLInfo); |
| 28 std::string homepage_url_str; | 29 std::string tmp_update_url; |
| 29 if (!value->GetAsString(&homepage_url_str)) { | 30 |
| 31 if (!value->GetAsString(&tmp_update_url)) { |
| 30 *error = ErrorUtils::FormatErrorMessageUTF16( | 32 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 31 errors::kInvalidHomepageURL, ""); | 33 errors::kInvalidUpdateURL, ""); |
| 32 return false; | 34 return false; |
| 33 } | 35 } |
| 34 info->url_ = GURL(homepage_url_str); | 36 |
| 37 info->url_ = GURL(tmp_update_url); |
| 35 if (!info->url_.is_valid() || | 38 if (!info->url_.is_valid() || |
| 36 (!info->url_.SchemeIs("http") && | 39 info->url_.has_ref()) { |
| 37 !info->url_.SchemeIs("https"))) { | |
| 38 *error = ErrorUtils::FormatErrorMessageUTF16( | 40 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 39 errors::kInvalidHomepageURL, homepage_url_str); | 41 errors::kInvalidUpdateURL, tmp_update_url); |
| 40 return false; | 42 return false; |
| 41 } | 43 } |
| 42 extension->SetManifestData(keys::kHomepageURL, info.release()); | 44 |
| 45 extension->SetManifestData(keys::kUpdateURL, info.release()); |
| 43 return true; | 46 return true; |
| 44 } | 47 } |
| 45 | 48 |
| 46 } // namespace extensions | 49 } // namespace extensions |
| OLD | NEW |