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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 class MessageSender : public content::NotificationObserver { | 18 class MessageSender : public content::NotificationObserver { |
(...skipping 11 matching lines...) Expand all Loading... |
29 event->SetString("data", data); | 30 event->SetString("data", data); |
30 scoped_ptr<ListValue> arguments(new ListValue()); | 31 scoped_ptr<ListValue> arguments(new ListValue()); |
31 arguments->Append(event); | 32 arguments->Append(event); |
32 return arguments.Pass(); | 33 return arguments.Pass(); |
33 } | 34 } |
34 | 35 |
35 virtual void Observe(int type, | 36 virtual void Observe(int type, |
36 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
37 const content::NotificationDetails& details) { | 38 const content::NotificationDetails& details) { |
38 extensions::EventRouter* event_router = | 39 extensions::EventRouter* event_router = |
39 content::Source<Profile>(source).ptr()->GetExtensionEventRouter(); | 40 extensions::ExtensionSystem::Get( |
| 41 content::Source<Profile>(source).ptr())->event_router(); |
40 | 42 |
41 // Sends four messages to the extension. All but the third message sent | 43 // Sends four messages to the extension. All but the third message sent |
42 // from the origin http://b.com/ are supposed to arrive. | 44 // from the origin http://b.com/ are supposed to arrive. |
43 event_router->DispatchEventToRenderers("test.onMessage", | 45 event_router->DispatchEventToRenderers("test.onMessage", |
44 BuildEventArguments(false, "no restriction"), | 46 BuildEventArguments(false, "no restriction"), |
45 content::Source<Profile>(source).ptr(), | 47 content::Source<Profile>(source).ptr(), |
46 GURL(), | 48 GURL(), |
47 extensions::EventFilteringInfo()); | 49 extensions::EventFilteringInfo()); |
48 event_router->DispatchEventToRenderers("test.onMessage", | 50 event_router->DispatchEventToRenderers("test.onMessage", |
49 BuildEventArguments(false, "http://a.com/"), | 51 BuildEventArguments(false, "http://a.com/"), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 class PanelMessagingTest : public ExtensionApiTest { | 98 class PanelMessagingTest : public ExtensionApiTest { |
97 virtual void SetUpCommandLine(CommandLine* command_line) { | 99 virtual void SetUpCommandLine(CommandLine* command_line) { |
98 ExtensionApiTest::SetUpCommandLine(command_line); | 100 ExtensionApiTest::SetUpCommandLine(command_line); |
99 command_line->AppendSwitch(switches::kEnablePanels); | 101 command_line->AppendSwitch(switches::kEnablePanels); |
100 } | 102 } |
101 }; | 103 }; |
102 | 104 |
103 IN_PROC_BROWSER_TEST_F(PanelMessagingTest, MessagingPanel) { | 105 IN_PROC_BROWSER_TEST_F(PanelMessagingTest, MessagingPanel) { |
104 ASSERT_TRUE(RunExtensionTest("messaging/connect_panel")) << message_; | 106 ASSERT_TRUE(RunExtensionTest("messaging/connect_panel")) << message_; |
105 } | 107 } |
OLD | NEW |