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 "base/values.h" | 5 #include "base/values.h" |
6 #include "chrome/browser/extensions/event_router.h" | 6 #include "chrome/browser/extensions/event_router.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 GURL event_url) { | 39 GURL event_url) { |
40 scoped_ptr<extensions::Event> event(new extensions::Event( | 40 scoped_ptr<extensions::Event> event(new extensions::Event( |
41 "test.onMessage", event_args.Pass())); | 41 "test.onMessage", event_args.Pass())); |
42 event->restrict_to_profile = profile; | 42 event->restrict_to_profile = profile; |
43 event->event_url = event_url; | 43 event->event_url = event_url; |
44 return event.Pass(); | 44 return event.Pass(); |
45 } | 45 } |
46 | 46 |
47 virtual void Observe(int type, | 47 virtual void Observe(int type, |
48 const content::NotificationSource& source, | 48 const content::NotificationSource& source, |
49 const content::NotificationDetails& details) { | 49 const content::NotificationDetails& details) OVERRIDE { |
50 extensions::EventRouter* event_router = | 50 extensions::EventRouter* event_router = |
51 extensions::ExtensionSystem::Get( | 51 extensions::ExtensionSystem::Get( |
52 content::Source<Profile>(source).ptr())->event_router(); | 52 content::Source<Profile>(source).ptr())->event_router(); |
53 | 53 |
54 // Sends four messages to the extension. All but the third message sent | 54 // Sends four messages to the extension. All but the third message sent |
55 // from the origin http://b.com/ are supposed to arrive. | 55 // from the origin http://b.com/ are supposed to arrive. |
56 event_router->BroadcastEvent(BuildEvent( | 56 event_router->BroadcastEvent(BuildEvent( |
57 BuildEventArguments(false, "no restriction"), | 57 BuildEventArguments(false, "no restriction"), |
58 content::Source<Profile>(source).ptr(), | 58 content::Source<Profile>(source).ptr(), |
59 GURL())); | 59 GURL())); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 // Tests that messages with event_urls are only passed to extensions with | 96 // Tests that messages with event_urls are only passed to extensions with |
97 // appropriate permissions. | 97 // appropriate permissions. |
98 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { | 98 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { |
99 MessageSender sender; | 99 MessageSender sender; |
100 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; | 100 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; |
101 } | 101 } |
102 | 102 |
103 // Tests connecting from a panel to its extension. | 103 // Tests connecting from a panel to its extension. |
104 class PanelMessagingTest : public ExtensionApiTest { | 104 class PanelMessagingTest : public ExtensionApiTest { |
105 virtual void SetUpCommandLine(CommandLine* command_line) { | 105 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
106 ExtensionApiTest::SetUpCommandLine(command_line); | 106 ExtensionApiTest::SetUpCommandLine(command_line); |
107 command_line->AppendSwitch(switches::kEnablePanels); | 107 command_line->AppendSwitch(switches::kEnablePanels); |
108 } | 108 } |
109 }; | 109 }; |
110 | 110 |
111 IN_PROC_BROWSER_TEST_F(PanelMessagingTest, MessagingPanel) { | 111 IN_PROC_BROWSER_TEST_F(PanelMessagingTest, MessagingPanel) { |
112 ASSERT_TRUE(RunExtensionTest("messaging/connect_panel")) << message_; | 112 ASSERT_TRUE(RunExtensionTest("messaging/connect_panel")) << message_; |
113 } | 113 } |
OLD | NEW |