Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/common/extensions/api/extension_api.cc

Issue 8806025: Whitelist experimental.storage as an unprivileged extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/api/extension_api.h" 5 #include "chrome/common/extensions/api/extension_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 25 matching lines...) Expand all
36 CHECK(temp_value->IsType(base::Value::TYPE_LIST)) 36 CHECK(temp_value->IsType(base::Value::TYPE_LIST))
37 << "Top-level node in extension API is not dictionary"; 37 << "Top-level node in extension API is not dictionary";
38 38
39 value_.reset(static_cast<base::ListValue*>(temp_value.release())); 39 value_.reset(static_cast<base::ListValue*>(temp_value.release()));
40 } 40 }
41 41
42 ExtensionAPI::~ExtensionAPI() { 42 ExtensionAPI::~ExtensionAPI() {
43 } 43 }
44 44
45 bool ExtensionAPI::IsPrivileged(const std::string& full_name) const { 45 bool ExtensionAPI::IsPrivileged(const std::string& full_name) const {
46 std::vector<std::string> name_space; 46 std::vector<std::string> split_full_name;
47 base::SplitString(full_name, '.', &name_space); 47 base::SplitString(full_name, '.', &split_full_name);
48 std::string name = name_space.back(); 48 std::string name = split_full_name.back();
49 name_space.pop_back(); 49 split_full_name.pop_back();
50 std::string name_space = JoinString(split_full_name, '.');
51
52 // HACK(kalman): explicitly mark all Storage API methods as unprivileged.
53 // TODO(kalman): solve this in a more general way; the problem is that
54 // functions-on-properties are not found with the following algorithm.
55 if (name_space == "experimental.storage")
56 return false;
50 57
51 base::DictionaryValue* name_space_node = 58 base::DictionaryValue* name_space_node =
52 FindListItem(value_.get(), "namespace", JoinString(name_space, '.')); 59 FindListItem(value_.get(), "namespace", name_space);
53 if (!name_space_node) 60 if (!name_space_node)
54 return true; 61 return true;
55 62
56 if (!IsChildNamePrivileged(name_space_node, "functions", name) || 63 if (!IsChildNamePrivileged(name_space_node, "functions", name) ||
57 !IsChildNamePrivileged(name_space_node, "events", name)) { 64 !IsChildNamePrivileged(name_space_node, "events", name)) {
58 return false; 65 return false;
59 } 66 }
60 67
61 return true; 68 return true;
62 } 69 }
(...skipping 23 matching lines...) Expand all
86 93
87 bool unprivileged = false; 94 bool unprivileged = false;
88 DictionaryValue* child = FindListItem(child_list, "name", child_name); 95 DictionaryValue* child = FindListItem(child_list, "name", child_name);
89 if (!child || !child->GetBoolean("unprivileged", &unprivileged)) 96 if (!child || !child->GetBoolean("unprivileged", &unprivileged))
90 return true; 97 return true;
91 98
92 return !unprivileged; 99 return !unprivileged;
93 } 100 }
94 101
95 } 102 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698