Upstream version 11.39.244.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / manifest_handlers / tizen_navigation_handler.cc
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.
4
5 #include "xwalk/application/common/manifest_handlers/tizen_navigation_handler.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "xwalk/application/common/application_manifest_constants.h"
9
10 namespace xwalk {
11
12 namespace keys = application_widget_keys;
13
14 namespace application {
15 namespace {
16
17 const char navigation_separator = ' ';
18
19 }  // namespace
20
21 TizenNavigationInfo::TizenNavigationInfo(const std::string& allowed_domains) {
22   base::SplitString(allowed_domains, navigation_separator, &allowed_domains_);
23 }
24
25 TizenNavigationInfo::~TizenNavigationInfo() {
26 }
27
28 TizenNavigationHandler::TizenNavigationHandler() {
29 }
30
31 TizenNavigationHandler::~TizenNavigationHandler() {
32 }
33
34 bool TizenNavigationHandler::Parse(
35     scoped_refptr<ApplicationData> application_data,
36     base::string16* error) {
37   if (!application_data->GetManifest()->HasPath(keys::kAllowNavigationKey))
38     return true;
39   std::string allowed_domains;
40   if (!application_data->GetManifest()->GetString(keys::kAllowNavigationKey,
41                                                   &allowed_domains)) {
42     *error = base::ASCIIToUTF16("Invalid value of allow-navigation.");
43     return false;
44   }
45   if (allowed_domains.empty())
46     return true;
47
48   application_data->SetManifestData(keys::kAllowNavigationKey,
49                                     new TizenNavigationInfo(allowed_domains));
50
51   return true;
52 }
53
54 std::vector<std::string> TizenNavigationHandler::Keys() const {
55   return std::vector<std::string>(1, keys::kAllowNavigationKey);
56 }
57
58 }  // namespace application
59 }  // namespace xwalk