OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_event_router.h" | 6 #include "chrome/browser/extensions/extension_event_router.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/common/chrome_notification_types.h" |
8 #include "content/common/notification_registrar.h" | 9 #include "content/common/notification_registrar.h" |
9 #include "content/common/notification_service.h" | 10 #include "content/common/notification_service.h" |
10 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 class MessageSender : public NotificationObserver { | 15 class MessageSender : public NotificationObserver { |
15 public: | 16 public: |
16 MessageSender() { | 17 MessageSender() { |
17 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 18 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
18 NotificationService::AllSources()); | 19 NotificationService::AllSources()); |
19 } | 20 } |
20 | 21 |
21 private: | 22 private: |
22 virtual void Observe(NotificationType type, | 23 virtual void Observe(int type, |
23 const NotificationSource& source, | 24 const NotificationSource& source, |
24 const NotificationDetails& details) { | 25 const NotificationDetails& details) { |
25 ExtensionEventRouter* event_router = | 26 ExtensionEventRouter* event_router = |
26 Source<Profile>(source).ptr()->GetExtensionEventRouter(); | 27 Source<Profile>(source).ptr()->GetExtensionEventRouter(); |
27 | 28 |
28 // Sends four messages to the extension. All but the third message sent | 29 // Sends four messages to the extension. All but the third message sent |
29 // from the origin http://b.com/ are supposed to arrive. | 30 // from the origin http://b.com/ are supposed to arrive. |
30 event_router->DispatchEventToRenderers("test.onMessage", | 31 event_router->DispatchEventToRenderers("test.onMessage", |
31 "[{\"lastMessage\":false,\"data\":\"no restriction\"}]", | 32 "[{\"lastMessage\":false,\"data\":\"no restriction\"}]", |
32 Source<Profile>(source).ptr(), | 33 Source<Profile>(source).ptr(), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 67 |
67 ASSERT_TRUE(RunExtensionTest("messaging/connect_external")) << message_; | 68 ASSERT_TRUE(RunExtensionTest("messaging/connect_external")) << message_; |
68 } | 69 } |
69 | 70 |
70 // Tests that messages with event_urls are only passed to extensions with | 71 // Tests that messages with event_urls are only passed to extensions with |
71 // appropriate permissions. | 72 // appropriate permissions. |
72 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { | 73 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { |
73 MessageSender sender; | 74 MessageSender sender; |
74 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; | 75 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; |
75 } | 76 } |
OLD | NEW |