| 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" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 12 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 13 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sessions/session_id.h" | 15 #include "chrome/browser/sessions/session_id.h" |
| 16 #include "chrome/common/extensions/features/feature_channel.h" | 16 #include "chrome/common/extensions/features/feature_channel.h" |
| 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/common/frame_navigate_params.h" | 24 #include "content/public/common/frame_navigate_params.h" |
| 25 #include "content/public/common/page_transition_types.h" | 25 #include "content/public/common/page_transition_types.h" |
| 26 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 27 #include "extensions/browser/extension_registry.h" |
| 27 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 28 #include "extensions/common/extension_builder.h" | 29 #include "extensions/common/extension_builder.h" |
| 29 #include "extensions/common/features/feature.h" | 30 #include "extensions/common/features/feature.h" |
| 30 #include "extensions/common/permissions/permissions_data.h" | 31 #include "extensions/common/permissions/permissions_data.h" |
| 31 #include "extensions/common/value_builder.h" | 32 #include "extensions/common/value_builder.h" |
| 32 | 33 |
| 33 using base::DictionaryValue; | 34 using base::DictionaryValue; |
| 34 using base::ListValue; | 35 using base::ListValue; |
| 35 using content::BrowserThread; | 36 using content::BrowserThread; |
| 36 using content::NavigationController; | 37 using content::NavigationController; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Some semi-arbitrary setup. | 284 // Some semi-arbitrary setup. |
| 284 GURL google("http://www.google.com"); | 285 GURL google("http://www.google.com"); |
| 285 NavigateAndCommit(google); | 286 NavigateAndCommit(google); |
| 286 | 287 |
| 287 active_tab_permission_granter()->GrantIfRequested(extension.get()); | 288 active_tab_permission_granter()->GrantIfRequested(extension.get()); |
| 288 | 289 |
| 289 EXPECT_TRUE(IsGrantedForTab(extension.get(), web_contents())); | 290 EXPECT_TRUE(IsGrantedForTab(extension.get(), web_contents())); |
| 290 EXPECT_TRUE(IsAllowed(extension, google)); | 291 EXPECT_TRUE(IsAllowed(extension, google)); |
| 291 | 292 |
| 292 // Uninstalling the extension should clear its tab permissions. | 293 // Uninstalling the extension should clear its tab permissions. |
| 293 UnloadedExtensionInfo details(extension.get(), | 294 ExtensionRegistry* registry = |
| 294 UnloadedExtensionInfo::REASON_DISABLE); | 295 ExtensionRegistry::Get(web_contents()->GetBrowserContext()); |
| 295 content::NotificationService::current()->Notify( | 296 registry->TriggerOnUnloaded(extension.get(), |
| 296 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 297 UnloadedExtensionInfo::REASON_DISABLE); |
| 297 content::Source<Profile>(Profile::FromBrowserContext( | |
| 298 web_contents()->GetBrowserContext())), | |
| 299 content::Details<UnloadedExtensionInfo>(&details)); | |
| 300 | 298 |
| 301 // Note: can't EXPECT_FALSE(IsAllowed) here because uninstalled extensions | 299 // Note: can't EXPECT_FALSE(IsAllowed) here because uninstalled extensions |
| 302 // are just that... considered to be uninstalled, and the manager might | 300 // are just that... considered to be uninstalled, and the manager might |
| 303 // just ignore them from here on. | 301 // just ignore them from here on. |
| 304 | 302 |
| 305 // Granting the extension again should give them back. | 303 // Granting the extension again should give them back. |
| 306 active_tab_permission_granter()->GrantIfRequested(extension.get()); | 304 active_tab_permission_granter()->GrantIfRequested(extension.get()); |
| 307 | 305 |
| 308 EXPECT_TRUE(IsGrantedForTab(extension.get(), web_contents())); | 306 EXPECT_TRUE(IsGrantedForTab(extension.get(), web_contents())); |
| 309 EXPECT_TRUE(IsAllowed(extension, google)); | 307 EXPECT_TRUE(IsAllowed(extension, google)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 376 |
| 379 EXPECT_TRUE(IsBlocked(extension_with_tab_capture, internal, tab_id() + 1)); | 377 EXPECT_TRUE(IsBlocked(extension_with_tab_capture, internal, tab_id() + 1)); |
| 380 EXPECT_FALSE(PermissionsData::HasAPIPermissionForTab( | 378 EXPECT_FALSE(PermissionsData::HasAPIPermissionForTab( |
| 381 extension_with_tab_capture.get(), | 379 extension_with_tab_capture.get(), |
| 382 tab_id() + 1, | 380 tab_id() + 1, |
| 383 APIPermission::kTabCaptureForTab)); | 381 APIPermission::kTabCaptureForTab)); |
| 384 } | 382 } |
| 385 | 383 |
| 386 } // namespace | 384 } // namespace |
| 387 } // namespace extensions | 385 } // namespace extensions |
| OLD | NEW |