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/base64.h" | 5 #include "base/base64.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 Profile* profile, | 67 Profile* profile, |
68 GURL event_url) { | 68 GURL event_url) { |
69 scoped_ptr<Event> event(new Event("test.onMessage", event_args.Pass())); | 69 scoped_ptr<Event> event(new Event("test.onMessage", event_args.Pass())); |
70 event->restrict_to_browser_context = profile; | 70 event->restrict_to_browser_context = profile; |
71 event->event_url = event_url; | 71 event->event_url = event_url; |
72 return event.Pass(); | 72 return event.Pass(); |
73 } | 73 } |
74 | 74 |
75 virtual void Observe(int type, | 75 virtual void Observe(int type, |
76 const content::NotificationSource& source, | 76 const content::NotificationSource& source, |
77 const content::NotificationDetails& details) OVERRIDE { | 77 const content::NotificationDetails& details) override { |
78 EventRouter* event_router = | 78 EventRouter* event_router = |
79 EventRouter::Get(content::Source<Profile>(source).ptr()); | 79 EventRouter::Get(content::Source<Profile>(source).ptr()); |
80 | 80 |
81 // Sends four messages to the extension. All but the third message sent | 81 // Sends four messages to the extension. All but the third message sent |
82 // from the origin http://b.com/ are supposed to arrive. | 82 // from the origin http://b.com/ are supposed to arrive. |
83 event_router->BroadcastEvent(BuildEvent( | 83 event_router->BroadcastEvent(BuildEvent( |
84 BuildEventArguments(false, "no restriction"), | 84 BuildEventArguments(false, "no restriction"), |
85 content::Source<Profile>(source).ptr(), | 85 content::Source<Profile>(source).ptr(), |
86 GURL())); | 86 GURL())); |
87 event_router->BroadcastEvent(BuildEvent( | 87 event_router->BroadcastEvent(BuildEvent( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 // Tests that messages with event_urls are only passed to extensions with | 121 // Tests that messages with event_urls are only passed to extensions with |
122 // appropriate permissions. | 122 // appropriate permissions. |
123 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { | 123 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { |
124 MessageSender sender; | 124 MessageSender sender; |
125 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; | 125 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; |
126 } | 126 } |
127 | 127 |
128 // Tests connecting from a panel to its extension. | 128 // Tests connecting from a panel to its extension. |
129 class PanelMessagingTest : public ExtensionApiTest { | 129 class PanelMessagingTest : public ExtensionApiTest { |
130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 130 virtual void SetUpCommandLine(CommandLine* command_line) override { |
131 ExtensionApiTest::SetUpCommandLine(command_line); | 131 ExtensionApiTest::SetUpCommandLine(command_line); |
132 command_line->AppendSwitch(switches::kEnablePanels); | 132 command_line->AppendSwitch(switches::kEnablePanels); |
133 } | 133 } |
134 }; | 134 }; |
135 | 135 |
136 IN_PROC_BROWSER_TEST_F(PanelMessagingTest, MessagingPanel) { | 136 IN_PROC_BROWSER_TEST_F(PanelMessagingTest, MessagingPanel) { |
137 ASSERT_TRUE(RunExtensionTest("messaging/connect_panel")) << message_; | 137 ASSERT_TRUE(RunExtensionTest("messaging/connect_panel")) << message_; |
138 } | 138 } |
139 | 139 |
140 // XXX(kalman): All web messaging tests disabled on windows due to extreme | 140 // XXX(kalman): All web messaging tests disabled on windows due to extreme |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); | 1081 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); |
1082 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, | 1082 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, |
1083 CanConnectAndSendMessagesToMainFrame(invalid.get())); | 1083 CanConnectAndSendMessagesToMainFrame(invalid.get())); |
1084 } | 1084 } |
1085 | 1085 |
1086 #endif // !defined(OS_WIN) - http://crbug.com/350517. | 1086 #endif // !defined(OS_WIN) - http://crbug.com/350517. |
1087 | 1087 |
1088 } // namespace | 1088 } // namespace |
1089 | 1089 |
1090 }; // namespace extensions | 1090 }; // namespace extensions |
OLD | NEW |