Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/active_script_controller.h" | 8 #include "chrome/browser/extensions/active_script_controller.h" |
| 9 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 9 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 10 #include "chrome/browser/extensions/extension_util.h" | 10 #include "chrome/browser/extensions/extension_util.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 ->active_tab_permission_granter(); | 273 ->active_tab_permission_granter(); |
| 274 ASSERT_TRUE(active_tab_permission_granter); | 274 ASSERT_TRUE(active_tab_permission_granter); |
| 275 // Grant the extension active tab permissions. This normally happens, e.g., | 275 // Grant the extension active tab permissions. This normally happens, e.g., |
| 276 // if the user clicks on a browser action. | 276 // if the user clicks on a browser action. |
| 277 active_tab_permission_granter->GrantIfRequested(extension); | 277 active_tab_permission_granter->GrantIfRequested(extension); |
| 278 | 278 |
| 279 // Since we have active tab permissions, we shouldn't need user consent | 279 // Since we have active tab permissions, we shouldn't need user consent |
| 280 // anymore. | 280 // anymore. |
| 281 EXPECT_FALSE(RequiresUserConsent(extension)); | 281 EXPECT_FALSE(RequiresUserConsent(extension)); |
| 282 | 282 |
| 283 // Also test that granting active tab runs any pending tasks. | 283 // Also test that granting active tab runs any pending tasks. |
|
Devlin
2014/08/15 21:24:00
this comment was somewhat misplaced before, and is
not at google - send to devlin
2014/08/15 21:38:29
Done.
| |
| 284 Reload(); | 284 Reload(); |
| 285 // Navigating should mean we need permission again. | 285 // Reloading and other same-origin navigations maintain the permission to |
| 286 // execute. | |
| 287 EXPECT_FALSE(RequiresUserConsent(extension)); | |
| 288 NavigateAndCommit(GURL("https://www.google.com/some-page")); | |
| 289 EXPECT_FALSE(RequiresUserConsent(extension)); | |
| 290 | |
| 291 // Navigating to a different origin will require user consent again. | |
| 292 NavigateAndCommit(GURL("https://yahoo.com")); | |
| 293 EXPECT_TRUE(RequiresUserConsent(extension)); | |
| 294 | |
| 295 // Back to the original origin should also re-require constent. | |
| 296 NavigateAndCommit(GURL("https://www.google.com")); | |
| 286 EXPECT_TRUE(RequiresUserConsent(extension)); | 297 EXPECT_TRUE(RequiresUserConsent(extension)); |
| 287 | 298 |
| 288 RequestInjection(extension); | 299 RequestInjection(extension); |
| 289 EXPECT_TRUE(controller()->GetActionForExtension(extension)); | 300 EXPECT_TRUE(controller()->GetActionForExtension(extension)); |
| 290 EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id())); | 301 EXPECT_EQ(0u, GetExecutionCountForExtension(extension->id())); |
| 291 | 302 |
| 292 // Grant active tab. | 303 // Grant active tab. |
| 293 active_tab_permission_granter->GrantIfRequested(extension); | 304 active_tab_permission_granter->GrantIfRequested(extension); |
| 294 | 305 |
| 295 // The pending injections should have run since active tab permission was | 306 // The pending injections should have run since active tab permission was |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 316 // Turning off the preference should have instant effect. | 327 // Turning off the preference should have instant effect. |
| 317 util::SetAllowedScriptingOnAllUrls(extension->id(), profile(), false); | 328 util::SetAllowedScriptingOnAllUrls(extension->id(), profile(), false); |
| 318 EXPECT_TRUE(RequiresUserConsent(extension)); | 329 EXPECT_TRUE(RequiresUserConsent(extension)); |
| 319 | 330 |
| 320 // And should also persist across navigations and websites. | 331 // And should also persist across navigations and websites. |
| 321 NavigateAndCommit(GURL("http://www.bar.com")); | 332 NavigateAndCommit(GURL("http://www.bar.com")); |
| 322 EXPECT_TRUE(RequiresUserConsent(extension)); | 333 EXPECT_TRUE(RequiresUserConsent(extension)); |
| 323 } | 334 } |
| 324 | 335 |
| 325 } // namespace extensions | 336 } // namespace extensions |
| OLD | NEW |