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" |
11 #include "chrome/browser/extensions/active_tab_permission_manager.h" | 11 #include "chrome/browser/extensions/active_tab_permission_manager.h" |
12 #include "chrome/browser/extensions/extension_tab_helper.h" | 12 #include "chrome/browser/extensions/extension_tab_helper.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
14 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | 14 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/extensions/features/feature.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/page_transition_types.h" | 22 #include "content/public/common/page_transition_types.h" |
22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
23 | 24 |
24 using base::DictionaryValue; | 25 using base::DictionaryValue; |
25 using base::ListValue; | 26 using base::ListValue; |
26 using content::BrowserThread; | 27 using content::BrowserThread; |
(...skipping 28 matching lines...) Expand all Loading... |
55 return extension; | 56 return extension; |
56 } | 57 } |
57 | 58 |
58 class ActiveTabTest : public TabContentsTestHarness { | 59 class ActiveTabTest : public TabContentsTestHarness { |
59 public: | 60 public: |
60 ActiveTabTest() | 61 ActiveTabTest() |
61 : extension(CreateTestExtension("extension", true)), | 62 : extension(CreateTestExtension("extension", true)), |
62 another_extension(CreateTestExtension("another", true)), | 63 another_extension(CreateTestExtension("another", true)), |
63 extension_without_active_tab( | 64 extension_without_active_tab( |
64 CreateTestExtension("without activeTab", false)), | 65 CreateTestExtension("without activeTab", false)), |
65 ui_thread_(BrowserThread::UI, MessageLoop::current()) {} | 66 ui_thread_(BrowserThread::UI, MessageLoop::current()) { |
| 67 Feature::SetChannelForTesting(chrome::VersionInfo::CHANNEL_UNKNOWN); |
| 68 } |
66 | 69 |
67 protected: | 70 protected: |
68 int tab_id() { | 71 int tab_id() { |
69 return tab_contents()->extension_tab_helper()->tab_id(); | 72 return tab_contents()->extension_tab_helper()->tab_id(); |
70 } | 73 } |
71 | 74 |
72 ActiveTabPermissionManager* active_tab_permission_manager() { | 75 ActiveTabPermissionManager* active_tab_permission_manager() { |
73 return tab_contents()->extension_tab_helper()-> | 76 return tab_contents()->extension_tab_helper()-> |
74 active_tab_permission_manager(); | 77 active_tab_permission_manager(); |
75 } | 78 } |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 NavigateAndCommit(google); | 418 NavigateAndCommit(google); |
416 | 419 |
417 active_tab_permission_manager()->GrantIfRequested(extension); | 420 active_tab_permission_manager()->GrantIfRequested(extension); |
418 | 421 |
419 EXPECT_TRUE(IsAllowed(extension, google, tab_id())); | 422 EXPECT_TRUE(IsAllowed(extension, google, tab_id())); |
420 EXPECT_TRUE(IsBlocked(extension, google, tab_id() + 1)); | 423 EXPECT_TRUE(IsBlocked(extension, google, tab_id() + 1)); |
421 } | 424 } |
422 | 425 |
423 } // namespace | 426 } // namespace |
424 } // namespace extensions | 427 } // namespace extensions |
OLD | NEW |