| 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 "chrome/browser/extensions/event_router_forwarder.h" | 5 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/power_monitor/power_monitor.h" | 9 #include "base/power_monitor/power_monitor.h" |
| 10 #include "base/test/thread_test_helper.h" | 10 #include "base/test/thread_test_helper.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 restrict_to_profile, event_url); | 40 restrict_to_profile, event_url); |
| 41 } | 41 } |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 virtual ~MockEventRouterForwarder() {} | 44 virtual ~MockEventRouterForwarder() {} |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 static void BroadcastEventToRenderers(EventRouterForwarder* event_router, | 47 static void BroadcastEventToRenderers(EventRouterForwarder* event_router, |
| 48 const std::string& event_name, | 48 const std::string& event_name, |
| 49 const GURL& url) { | 49 const GURL& url) { |
| 50 scoped_ptr<ListValue> args(new ListValue()); | 50 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 51 event_router->BroadcastEventToRenderers(event_name, args.Pass(), url); | 51 event_router->BroadcastEventToRenderers(event_name, args.Pass(), url); |
| 52 } | 52 } |
| 53 | 53 |
| 54 static void DispatchEventToRenderers(EventRouterForwarder* event_router, | 54 static void DispatchEventToRenderers(EventRouterForwarder* event_router, |
| 55 const std::string& event_name, | 55 const std::string& event_name, |
| 56 void* profile, | 56 void* profile, |
| 57 bool use_profile_to_restrict_events, | 57 bool use_profile_to_restrict_events, |
| 58 const GURL& url) { | 58 const GURL& url) { |
| 59 scoped_ptr<ListValue> args(new ListValue()); | 59 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 60 event_router->DispatchEventToRenderers(event_name, args.Pass(), profile, | 60 event_router->DispatchEventToRenderers(event_name, args.Pass(), profile, |
| 61 use_profile_to_restrict_events, url); | 61 use_profile_to_restrict_events, url); |
| 62 } | 62 } |
| 63 | 63 |
| 64 static void BroadcastEventToExtension(EventRouterForwarder* event_router, | 64 static void BroadcastEventToExtension(EventRouterForwarder* event_router, |
| 65 const std::string& extension, | 65 const std::string& extension, |
| 66 const std::string& event_name, | 66 const std::string& event_name, |
| 67 const GURL& url) { | 67 const GURL& url) { |
| 68 scoped_ptr<ListValue> args(new ListValue()); | 68 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 69 event_router->BroadcastEventToExtension(extension, event_name, args.Pass(), | 69 event_router->BroadcastEventToExtension(extension, event_name, args.Pass(), |
| 70 url); | 70 url); |
| 71 } | 71 } |
| 72 | 72 |
| 73 static void DispatchEventToExtension(EventRouterForwarder* event_router, | 73 static void DispatchEventToExtension(EventRouterForwarder* event_router, |
| 74 const std::string& extension, | 74 const std::string& extension, |
| 75 const std::string& event_name, | 75 const std::string& event_name, |
| 76 void* profile, | 76 void* profile, |
| 77 bool use_profile_to_restrict_events, | 77 bool use_profile_to_restrict_events, |
| 78 const GURL& url) { | 78 const GURL& url) { |
| 79 scoped_ptr<ListValue> args(new ListValue()); | 79 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 80 event_router->DispatchEventToExtension( | 80 event_router->DispatchEventToExtension( |
| 81 extension, event_name, args.Pass(), profile, | 81 extension, event_name, args.Pass(), profile, |
| 82 use_profile_to_restrict_events, url); | 82 use_profile_to_restrict_events, url); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 class EventRouterForwarderTest : public testing::Test { | 87 class EventRouterForwarderTest : public testing::Test { |
| 88 protected: | 88 protected: |
| 89 EventRouterForwarderTest() | 89 EventRouterForwarderTest() |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 GURL url; | 279 GURL url; |
| 280 EXPECT_CALL(*event_router.get(), | 280 EXPECT_CALL(*event_router.get(), |
| 281 CallEventRouter(profile1_, kExt, kEventName, NULL, url)); | 281 CallEventRouter(profile1_, kExt, kEventName, NULL, url)); |
| 282 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 282 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) |
| 283 .Times(0); | 283 .Times(0); |
| 284 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_, | 284 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_, |
| 285 false, url); | 285 false, url); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace extensions | 288 } // namespace extensions |
| OLD | NEW |