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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const GURL& url, | 101 const GURL& url, |
102 PermittedFeature feature) { | 102 PermittedFeature feature) { |
103 return IsAllowed(extension, url, feature, tab_id()); | 103 return IsAllowed(extension, url, feature, tab_id()); |
104 } | 104 } |
105 | 105 |
106 bool IsAllowed(const scoped_refptr<const Extension>& extension, | 106 bool IsAllowed(const scoped_refptr<const Extension>& extension, |
107 const GURL& url, | 107 const GURL& url, |
108 PermittedFeature feature, | 108 PermittedFeature feature, |
109 int tab_id) { | 109 int tab_id) { |
110 const PermissionsData* permissions_data = extension->permissions_data(); | 110 const PermissionsData* permissions_data = extension->permissions_data(); |
111 bool script = | 111 bool script = permissions_data->CanAccessPage( |
112 permissions_data->CanAccessPage(extension, url, url, tab_id, -1, NULL); | 112 extension.get(), url, url, tab_id, -1, NULL); |
113 bool capture = HasTabsPermission(extension, tab_id) && | 113 bool capture = HasTabsPermission(extension, tab_id) && |
114 permissions_data->CanCaptureVisiblePage(tab_id, NULL); | 114 permissions_data->CanCaptureVisiblePage(tab_id, NULL); |
115 switch (feature) { | 115 switch (feature) { |
116 case PERMITTED_SCRIPT_ONLY: | 116 case PERMITTED_SCRIPT_ONLY: |
117 return script && !capture; | 117 return script && !capture; |
118 case PERMITTED_CAPTURE_ONLY: | 118 case PERMITTED_CAPTURE_ONLY: |
119 return capture && !script; | 119 return capture && !script; |
120 case PERMITTED_BOTH: | 120 case PERMITTED_BOTH: |
121 return script && capture; | 121 return script && capture; |
122 case PERMITTED_NONE: | 122 case PERMITTED_NONE: |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 EXPECT_TRUE(permissions_data->HasAPIPermissionForTab( | 373 EXPECT_TRUE(permissions_data->HasAPIPermissionForTab( |
374 tab_id(), APIPermission::kTabCaptureForTab)); | 374 tab_id(), APIPermission::kTabCaptureForTab)); |
375 | 375 |
376 EXPECT_TRUE(IsBlocked(extension_with_tab_capture, internal, tab_id() + 1)); | 376 EXPECT_TRUE(IsBlocked(extension_with_tab_capture, internal, tab_id() + 1)); |
377 EXPECT_FALSE(permissions_data->HasAPIPermissionForTab( | 377 EXPECT_FALSE(permissions_data->HasAPIPermissionForTab( |
378 tab_id() + 1, APIPermission::kTabCaptureForTab)); | 378 tab_id() + 1, APIPermission::kTabCaptureForTab)); |
379 } | 379 } |
380 | 380 |
381 } // namespace | 381 } // namespace |
382 } // namespace extensions | 382 } // namespace extensions |
OLD | NEW |