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/permissions/socket_permission.h" | 5 #include "chrome/common/extensions/permissions/socket_permission.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 std::vector<string16>( | 95 std::vector<string16>( |
96 hostnames.begin(), hostnames.end()), ' ')))); | 96 hostnames.begin(), hostnames.end()), ' ')))); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 bool SocketPermission::Check( | 100 bool SocketPermission::Check( |
101 const APIPermission::CheckParam* param) const { | 101 const APIPermission::CheckParam* param) const { |
102 const CheckParam* socket_param = static_cast<const CheckParam*>(param); | 102 const CheckParam* socket_param = static_cast<const CheckParam*>(param); |
103 std::set<SocketPermissionData>::const_iterator i; | 103 std::set<SocketPermissionData>::const_iterator i; |
104 for (i = data_set_.begin(); i != data_set_.end(); ++i) { | 104 for (i = data_set_.begin(); i != data_set_.end(); ++i) { |
105 if (i->Match(socket_param->type, socket_param->host, socket_param->port)) | 105 if (i->Match(socket_param->request)) |
106 return true; | 106 return true; |
107 } | 107 } |
108 return false; | 108 return false; |
109 } | 109 } |
110 | 110 |
111 bool SocketPermission::Contains(const APIPermission* rhs) const { | 111 bool SocketPermission::Contains(const APIPermission* rhs) const { |
112 CHECK(rhs->info() == info()); | 112 CHECK(rhs->info() == info()); |
113 const SocketPermission* perm = static_cast<const SocketPermission*>(rhs); | 113 const SocketPermission* perm = static_cast<const SocketPermission*>(rhs); |
114 return std::includes(data_set_.begin(), data_set_.end(), | 114 return std::includes(data_set_.begin(), data_set_.end(), |
115 perm->data_set_.begin(), perm->data_set_.end()); | 115 perm->data_set_.begin(), perm->data_set_.end()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bool SocketPermission::Read(const IPC::Message* m, PickleIterator* iter) { | 196 bool SocketPermission::Read(const IPC::Message* m, PickleIterator* iter) { |
197 return IPC::ReadParam(m, iter, &data_set_); | 197 return IPC::ReadParam(m, iter, &data_set_); |
198 } | 198 } |
199 | 199 |
200 void SocketPermission::Log(std::string* log) const { | 200 void SocketPermission::Log(std::string* log) const { |
201 IPC::LogParam(data_set_, log); | 201 IPC::LogParam(data_set_, log); |
202 } | 202 } |
203 | 203 |
204 } // namespace extensions | 204 } // namespace extensions |
205 | 205 |
OLD | NEW |