| 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 "chrome/common/chrome_notification_types.h" |
| 9 #include "content/public/browser/notification_registrar.h" | 9 #include "content/public/browser/notification_registrar.h" |
| 10 #include "content/common/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class MessageSender : public content::NotificationObserver { | 15 class MessageSender : public content::NotificationObserver { |
| 16 public: | 16 public: |
| 17 MessageSender() { | 17 MessageSender() { |
| 18 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 18 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 19 NotificationService::AllSources()); | 19 content::NotificationService::AllSources()); |
| 20 } | 20 } |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 virtual void Observe(int type, | 23 virtual void Observe(int type, |
| 24 const content::NotificationSource& source, | 24 const content::NotificationSource& source, |
| 25 const content::NotificationDetails& details) { | 25 const content::NotificationDetails& details) { |
| 26 ExtensionEventRouter* event_router = | 26 ExtensionEventRouter* event_router = |
| 27 content::Source<Profile>(source).ptr()->GetExtensionEventRouter(); | 27 content::Source<Profile>(source).ptr()->GetExtensionEventRouter(); |
| 28 | 28 |
| 29 // 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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 ASSERT_TRUE(RunExtensionTest("messaging/connect_external")) << message_; | 69 ASSERT_TRUE(RunExtensionTest("messaging/connect_external")) << message_; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Tests that messages with event_urls are only passed to extensions with | 72 // Tests that messages with event_urls are only passed to extensions with |
| 73 // appropriate permissions. | 73 // appropriate permissions. |
| 74 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { | 74 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingEventURL) { |
| 75 MessageSender sender; | 75 MessageSender sender; |
| 76 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; | 76 ASSERT_TRUE(RunExtensionTest("messaging/event_url")) << message_; |
| 77 } | 77 } |
| OLD | NEW |