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

Side by Side Diff: extensions/common/manifest_handlers/externally_connectable.cc

Issue 309533007: Refactor PermissionsData pt1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master Created 6 years, 6 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/manifest_handlers/externally_connectable.h" 5 #include "extensions/common/manifest_handlers/externally_connectable.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "extensions/common/api/extensions_manifest_types.h" 11 #include "extensions/common/api/extensions_manifest_types.h"
12 #include "extensions/common/error_utils.h" 12 #include "extensions/common/error_utils.h"
13 #include "extensions/common/manifest_constants.h" 13 #include "extensions/common/manifest_constants.h"
14 #include "extensions/common/manifest_handlers/permissions_parser.h"
14 #include "extensions/common/permissions/api_permission_set.h" 15 #include "extensions/common/permissions/api_permission_set.h"
15 #include "extensions/common/permissions/permissions_data.h"
16 #include "extensions/common/url_pattern.h" 16 #include "extensions/common/url_pattern.h"
17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace rcd = net::registry_controlled_domains; 20 namespace rcd = net::registry_controlled_domains;
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 namespace externally_connectable_errors { 24 namespace externally_connectable_errors {
25 const char kErrorInvalidMatchPattern[] = "Invalid match pattern '*'"; 25 const char kErrorInvalidMatchPattern[] = "Invalid match pattern '*'";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 CHECK(extension->manifest()->Get(keys::kExternallyConnectable, 63 CHECK(extension->manifest()->Get(keys::kExternallyConnectable,
64 &externally_connectable)); 64 &externally_connectable));
65 std::vector<InstallWarning> install_warnings; 65 std::vector<InstallWarning> install_warnings;
66 scoped_ptr<ExternallyConnectableInfo> info = 66 scoped_ptr<ExternallyConnectableInfo> info =
67 ExternallyConnectableInfo::FromValue(*externally_connectable, 67 ExternallyConnectableInfo::FromValue(*externally_connectable,
68 &install_warnings, 68 &install_warnings,
69 error); 69 error);
70 if (!info) 70 if (!info)
71 return false; 71 return false;
72 if (!info->matches.is_empty()) { 72 if (!info->matches.is_empty()) {
73 PermissionsData::GetInitialAPIPermissions(extension) 73 PermissionsParser::AddAPIPermission(extension,
74 ->insert(APIPermission::kWebConnectable); 74 APIPermission::kWebConnectable);
75 } 75 }
76 extension->AddInstallWarnings(install_warnings); 76 extension->AddInstallWarnings(install_warnings);
77 extension->SetManifestData(keys::kExternallyConnectable, info.release()); 77 extension->SetManifestData(keys::kExternallyConnectable, info.release());
78 return true; 78 return true;
79 } 79 }
80 80
81 const std::vector<std::string> ExternallyConnectableHandler::Keys() const { 81 const std::vector<std::string> ExternallyConnectableHandler::Keys() const {
82 return SingleKey(keys::kExternallyConnectable); 82 return SingleKey(keys::kExternallyConnectable);
83 } 83 }
84 84
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { 211 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) {
212 if (all_ids) 212 if (all_ids)
213 return true; 213 return true;
214 DCHECK(base::STLIsSorted(ids)); 214 DCHECK(base::STLIsSorted(ids));
215 return std::binary_search(ids.begin(), ids.end(), id); 215 return std::binary_search(ids.begin(), ids.end(), id);
216 } 216 }
217 217
218 } // namespace extensions 218 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_handlers/background_info.cc ('k') | extensions/common/manifest_handlers/offline_enabled_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698