1 // Copyright (c) 2014 Intel Corporation. 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.
5 #include "xwalk/application/common/manifest_handlers/navigation_handler.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "xwalk/application/common/application_manifest_constants.h"
12 namespace keys = application_widget_keys;
14 namespace application {
16 const char navigation_separator = ' ';
19 NavigationInfo::NavigationInfo(const std::string& allowed_domains) {
20 base::SplitString(allowed_domains, navigation_separator, &allowed_domains_);
23 NavigationInfo::~NavigationInfo() {
26 NavigationHandler::NavigationHandler() {
29 NavigationHandler::~NavigationHandler() {
32 bool NavigationHandler::Parse(scoped_refptr<ApplicationData> application_data,
33 base::string16* error) {
34 if (!application_data->GetManifest()->HasPath(keys::kAllowNavigationKey))
36 std::string allowed_domains;
37 if (!application_data->GetManifest()->GetString(keys::kAllowNavigationKey,
39 *error = base::ASCIIToUTF16("Invalid value of allow-navigation.");
42 if (allowed_domains.empty())
45 application_data->SetManifestData(keys::kAllowNavigationKey,
46 new NavigationInfo(allowed_domains));
51 std::vector<std::string> NavigationHandler::Keys() const {
52 return std::vector<std::string>(1, keys::kAllowNavigationKey);
55 } // namespace application