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

Side by Side Diff: extensions/common/features/permission_feature.cc

Issue 2241203003: Pass user session type to extension feature checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out some stuff Created 4 years, 4 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
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/features/permission_feature.h" 5 #include "extensions/common/features/permission_feature.h"
6 6
7 #include "extensions/common/permissions/permission_set.h" 7 #include "extensions/common/permissions/permission_set.h"
8 #include "extensions/common/permissions/permissions_data.h" 8 #include "extensions/common/permissions/permissions_data.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 PermissionFeature::PermissionFeature() { 12 PermissionFeature::PermissionFeature() {
13 } 13 }
14 14
15 PermissionFeature::~PermissionFeature() { 15 PermissionFeature::~PermissionFeature() {
16 } 16 }
17 17
18 Feature::Availability PermissionFeature::IsAvailableToContext( 18 Feature::Availability PermissionFeature::IsAvailableToContext(
19 const Extension* extension, 19 const Extension* extension,
20 Feature::Context context, 20 Feature::Context context,
21 Feature::SessionType session_type,
21 const GURL& url, 22 const GURL& url,
22 Feature::Platform platform) const { 23 Feature::Platform platform) const {
23 Availability availability = SimpleFeature::IsAvailableToContext(extension, 24 Availability availability = SimpleFeature::IsAvailableToContext(
24 context, 25 extension, context, session_type, url, platform);
25 url,
26 platform);
27 if (!availability.is_available()) 26 if (!availability.is_available())
28 return availability; 27 return availability;
29 28
30 if (extension && !extension->permissions_data()->HasAPIPermission(name())) 29 if (extension && !extension->permissions_data()->HasAPIPermission(name()))
31 return CreateAvailability(NOT_PRESENT, extension->GetType()); 30 return CreateAvailability(NOT_PRESENT, extension->GetType());
32 31
33 return CreateAvailability(IS_AVAILABLE); 32 return CreateAvailability(IS_AVAILABLE);
34 } 33 }
35 34
36 bool PermissionFeature::Validate(std::string* error) { 35 bool PermissionFeature::Validate(std::string* error) {
37 if (!SimpleFeature::Validate(error)) 36 if (!SimpleFeature::Validate(error))
38 return false; 37 return false;
39 38
40 if (extension_types().empty()) { 39 if (extension_types().empty()) {
41 *error = name() + ": Permission features must specify at least one " + 40 *error = name() + ": Permission features must specify at least one " +
42 "value for extension_types."; 41 "value for extension_types.";
43 return false; 42 return false;
44 } 43 }
45 44
46 if (!contexts().empty()) { 45 if (!contexts().empty()) {
47 *error = name() + ": Permission features do not support contexts."; 46 *error = name() + ": Permission features do not support contexts.";
48 return false; 47 return false;
49 } 48 }
50 49
51 return true; 50 return true;
52 } 51 }
53 52
54 } // namespace extensions 53 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698