| 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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool IsAllowed(const scoped_refptr<const Extension>& extension, | 74 bool IsAllowed(const scoped_refptr<const Extension>& extension, |
| 75 const GURL& url) { | 75 const GURL& url) { |
| 76 return IsAllowed(extension, url, tab_id()); | 76 return IsAllowed(extension, url, tab_id()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool IsAllowed(const scoped_refptr<const Extension>& extension, | 79 bool IsAllowed(const scoped_refptr<const Extension>& extension, |
| 80 const GURL& url, | 80 const GURL& url, |
| 81 int tab_id) { | 81 int tab_id) { |
| 82 return extension->CanExecuteScriptOnPage(url, tab_id, NULL, NULL) && | 82 return extension->CanExecuteScriptOnPage(url, url, tab_id, NULL, NULL) && |
| 83 extension->CanCaptureVisiblePage(url, tab_id, NULL) && | 83 extension->CanCaptureVisiblePage(url, tab_id, NULL) && |
| 84 HasTabsPermission(extension, tab_id); | 84 HasTabsPermission(extension, tab_id); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool IsBlocked(const scoped_refptr<const Extension>& extension, | 87 bool IsBlocked(const scoped_refptr<const Extension>& extension, |
| 88 const GURL& url) { | 88 const GURL& url) { |
| 89 return IsBlocked(extension, url, tab_id()); | 89 return IsBlocked(extension, url, tab_id()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool IsBlocked(const scoped_refptr<const Extension>& extension, | 92 bool IsBlocked(const scoped_refptr<const Extension>& extension, |
| 93 const GURL& url, | 93 const GURL& url, |
| 94 int tab_id) { | 94 int tab_id) { |
| 95 // Note: can't check HasTabsPermission because it isn't URL specific. | 95 // Note: can't check HasTabsPermission because it isn't URL specific. |
| 96 return !extension->CanExecuteScriptOnPage(url, tab_id, NULL, NULL) && | 96 return !extension->CanExecuteScriptOnPage(url, url, tab_id, NULL, NULL) && |
| 97 !extension->CanCaptureVisiblePage(url, tab_id, NULL); | 97 !extension->CanCaptureVisiblePage(url, tab_id, NULL); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool HasTabsPermission(const scoped_refptr<const Extension>& extension) { | 100 bool HasTabsPermission(const scoped_refptr<const Extension>& extension) { |
| 101 return HasTabsPermission(extension, tab_id()); | 101 return HasTabsPermission(extension, tab_id()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool HasTabsPermission(const scoped_refptr<const Extension>& extension, | 104 bool HasTabsPermission(const scoped_refptr<const Extension>& extension, |
| 105 int tab_id) { | 105 int tab_id) { |
| 106 return extension->HasAPIPermissionForTab(tab_id, APIPermission::kTab); | 106 return extension->HasAPIPermissionForTab(tab_id, APIPermission::kTab); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 Reload(); | 314 Reload(); |
| 315 | 315 |
| 316 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); | 316 EXPECT_FALSE(IsAllowed(extension, google, tab_id())); |
| 317 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); | 317 EXPECT_FALSE(IsAllowed(extension, google_h1, tab_id())); |
| 318 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); | 318 EXPECT_FALSE(IsAllowed(extension, chromium, tab_id())); |
| 319 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); | 319 EXPECT_FALSE(IsAllowed(extension, chromium_h1, tab_id())); |
| 320 } | 320 } |
| 321 | 321 |
| 322 } // namespace | 322 } // namespace |
| 323 } // namespace extensions | 323 } // namespace extensions |
| OLD | NEW |