| 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/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/power_monitor/power_monitor.h" | 9 #include "base/power_monitor/power_monitor.h" |
| 10 #include "base/power_monitor/power_monitor_device_source.h" | 10 #include "base/power_monitor/power_monitor_device_source.h" |
| 11 #include "base/test/thread_test_helper.h" | 11 #include "base/test/thread_test_helper.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "chrome/test/base/testing_profile_manager.h" | 15 #include "chrome/test/base/testing_profile_manager.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const events::HistogramValue kHistogramValue = events::FOR_TEST; |
| 28 const char kEventName[] = "event_name"; | 29 const char kEventName[] = "event_name"; |
| 29 const char kExt[] = "extension"; | 30 const char kExt[] = "extension"; |
| 30 | 31 |
| 31 class MockEventRouterForwarder : public EventRouterForwarder { | 32 class MockEventRouterForwarder : public EventRouterForwarder { |
| 32 public: | 33 public: |
| 33 MOCK_METHOD5(CallEventRouter, | 34 MOCK_METHOD6(CallEventRouter, |
| 34 void(Profile*, const std::string&, const std::string&, Profile*, | 35 void(Profile*, |
| 35 const GURL&)); | 36 const std::string&, |
| 37 events::HistogramValue, |
| 38 const std::string&, |
| 39 Profile*, |
| 40 const GURL&)); |
| 36 | 41 |
| 37 virtual void CallEventRouter( | 42 virtual void CallEventRouter(Profile* profile, |
| 38 Profile* profile, const std::string& extension_id, | 43 const std::string& extension_id, |
| 39 const std::string& event_name, scoped_ptr<base::ListValue> event_args, | 44 events::HistogramValue histogram_value, |
| 40 Profile* restrict_to_profile, const GURL& event_url) { | 45 const std::string& event_name, |
| 41 CallEventRouter(profile, extension_id, event_name, | 46 scoped_ptr<base::ListValue> event_args, |
| 42 restrict_to_profile, event_url); | 47 Profile* restrict_to_profile, |
| 48 const GURL& event_url) { |
| 49 CallEventRouter(profile, extension_id, histogram_value, event_name, |
| 50 restrict_to_profile, event_url); |
| 43 } | 51 } |
| 44 | 52 |
| 45 protected: | 53 protected: |
| 46 virtual ~MockEventRouterForwarder() {} | 54 virtual ~MockEventRouterForwarder() {} |
| 47 }; | 55 }; |
| 48 | 56 |
| 49 static void BroadcastEventToRenderers(EventRouterForwarder* event_router, | 57 static void BroadcastEventToRenderers(EventRouterForwarder* event_router, |
| 58 events::HistogramValue histogram_value, |
| 50 const std::string& event_name, | 59 const std::string& event_name, |
| 51 const GURL& url) { | 60 const GURL& url) { |
| 52 scoped_ptr<base::ListValue> args(new base::ListValue()); | 61 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 53 event_router->BroadcastEventToRenderers(event_name, args.Pass(), url); | 62 event_router->BroadcastEventToRenderers(histogram_value, event_name, |
| 63 args.Pass(), url); |
| 54 } | 64 } |
| 55 | 65 |
| 56 static void DispatchEventToRenderers(EventRouterForwarder* event_router, | 66 static void DispatchEventToRenderers(EventRouterForwarder* event_router, |
| 67 events::HistogramValue histogram_value, |
| 57 const std::string& event_name, | 68 const std::string& event_name, |
| 58 void* profile, | 69 void* profile, |
| 59 bool use_profile_to_restrict_events, | 70 bool use_profile_to_restrict_events, |
| 60 const GURL& url) { | 71 const GURL& url) { |
| 61 scoped_ptr<base::ListValue> args(new base::ListValue()); | 72 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 62 event_router->DispatchEventToRenderers(event_name, args.Pass(), profile, | 73 event_router->DispatchEventToRenderers(histogram_value, event_name, |
| 74 args.Pass(), profile, |
| 63 use_profile_to_restrict_events, url); | 75 use_profile_to_restrict_events, url); |
| 64 } | 76 } |
| 65 | 77 |
| 66 static void BroadcastEventToExtension(EventRouterForwarder* event_router, | 78 static void BroadcastEventToExtension(EventRouterForwarder* event_router, |
| 67 const std::string& extension, | 79 const std::string& extension, |
| 80 events::HistogramValue histogram_value, |
| 68 const std::string& event_name, | 81 const std::string& event_name, |
| 69 const GURL& url) { | 82 const GURL& url) { |
| 70 scoped_ptr<base::ListValue> args(new base::ListValue()); | 83 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 71 event_router->BroadcastEventToExtension(extension, event_name, args.Pass(), | 84 event_router->BroadcastEventToExtension(extension, histogram_value, |
| 72 url); | 85 event_name, args.Pass(), url); |
| 73 } | 86 } |
| 74 | 87 |
| 75 static void DispatchEventToExtension(EventRouterForwarder* event_router, | 88 static void DispatchEventToExtension(EventRouterForwarder* event_router, |
| 76 const std::string& extension, | 89 const std::string& extension, |
| 90 events::HistogramValue histogram_value, |
| 77 const std::string& event_name, | 91 const std::string& event_name, |
| 78 void* profile, | 92 void* profile, |
| 79 bool use_profile_to_restrict_events, | 93 bool use_profile_to_restrict_events, |
| 80 const GURL& url) { | 94 const GURL& url) { |
| 81 scoped_ptr<base::ListValue> args(new base::ListValue()); | 95 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 82 event_router->DispatchEventToExtension( | 96 event_router->DispatchEventToExtension(extension, histogram_value, event_name, |
| 83 extension, event_name, args.Pass(), profile, | 97 args.Pass(), profile, |
| 84 use_profile_to_restrict_events, url); | 98 use_profile_to_restrict_events, url); |
| 85 } | 99 } |
| 86 | 100 |
| 87 } // namespace | 101 } // namespace |
| 88 | 102 |
| 89 class EventRouterForwarderTest : public testing::Test { | 103 class EventRouterForwarderTest : public testing::Test { |
| 90 protected: | 104 protected: |
| 91 EventRouterForwarderTest() | 105 EventRouterForwarderTest() |
| 92 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD), | 106 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD), |
| 93 profile_manager_( | 107 profile_manager_( |
| 94 TestingBrowserProcess::GetGlobal()) { | 108 TestingBrowserProcess::GetGlobal()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 114 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|. | 128 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|. |
| 115 TestingProfile* profile1_; | 129 TestingProfile* profile1_; |
| 116 TestingProfile* profile2_; | 130 TestingProfile* profile2_; |
| 117 }; | 131 }; |
| 118 | 132 |
| 119 TEST_F(EventRouterForwarderTest, BroadcastRendererUI) { | 133 TEST_F(EventRouterForwarderTest, BroadcastRendererUI) { |
| 120 scoped_refptr<MockEventRouterForwarder> event_router( | 134 scoped_refptr<MockEventRouterForwarder> event_router( |
| 121 new MockEventRouterForwarder); | 135 new MockEventRouterForwarder); |
| 122 GURL url; | 136 GURL url; |
| 123 EXPECT_CALL(*event_router.get(), | 137 EXPECT_CALL(*event_router.get(), |
| 124 CallEventRouter(profile1_, "", kEventName, profile1_, url)); | 138 CallEventRouter(profile1_, "", kHistogramValue, kEventName, |
| 139 profile1_, url)); |
| 125 EXPECT_CALL(*event_router.get(), | 140 EXPECT_CALL(*event_router.get(), |
| 126 CallEventRouter(profile2_, "", kEventName, profile2_, url)); | 141 CallEventRouter(profile2_, "", kHistogramValue, kEventName, |
| 127 BroadcastEventToRenderers(event_router.get(), kEventName, url); | 142 profile2_, url)); |
| 143 BroadcastEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 144 url); |
| 128 } | 145 } |
| 129 | 146 |
| 130 TEST_F(EventRouterForwarderTest, BroadcastRendererUIIncognito) { | 147 TEST_F(EventRouterForwarderTest, BroadcastRendererUIIncognito) { |
| 131 scoped_refptr<MockEventRouterForwarder> event_router( | 148 scoped_refptr<MockEventRouterForwarder> event_router( |
| 132 new MockEventRouterForwarder); | 149 new MockEventRouterForwarder); |
| 133 using ::testing::_; | 150 using ::testing::_; |
| 134 GURL url; | 151 GURL url; |
| 135 Profile* incognito = profile1_->GetOffTheRecordProfile(); | 152 Profile* incognito = profile1_->GetOffTheRecordProfile(); |
| 136 EXPECT_CALL(*event_router.get(), | 153 EXPECT_CALL(*event_router.get(), |
| 137 CallEventRouter(profile1_, "", kEventName, profile1_, url)); | 154 CallEventRouter(profile1_, "", kHistogramValue, kEventName, |
| 138 EXPECT_CALL(*event_router.get(), CallEventRouter(incognito, _, _, _, _)) | 155 profile1_, url)); |
| 156 EXPECT_CALL(*event_router.get(), CallEventRouter(incognito, _, _, _, _, _)) |
| 139 .Times(0); | 157 .Times(0); |
| 140 EXPECT_CALL(*event_router.get(), | 158 EXPECT_CALL(*event_router.get(), |
| 141 CallEventRouter(profile2_, "", kEventName, profile2_, url)); | 159 CallEventRouter(profile2_, "", kHistogramValue, kEventName, |
| 142 BroadcastEventToRenderers(event_router.get(), kEventName, url); | 160 profile2_, url)); |
| 161 BroadcastEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 162 url); |
| 143 } | 163 } |
| 144 | 164 |
| 145 // This is the canonical test for passing control flow from the IO thread | 165 // This is the canonical test for passing control flow from the IO thread |
| 146 // to the UI thread. Repeating this for all public functions of | 166 // to the UI thread. Repeating this for all public functions of |
| 147 // EventRouterForwarder would not increase coverage. | 167 // EventRouterForwarder would not increase coverage. |
| 148 TEST_F(EventRouterForwarderTest, BroadcastRendererIO) { | 168 TEST_F(EventRouterForwarderTest, BroadcastRendererIO) { |
| 149 scoped_refptr<MockEventRouterForwarder> event_router( | 169 scoped_refptr<MockEventRouterForwarder> event_router( |
| 150 new MockEventRouterForwarder); | 170 new MockEventRouterForwarder); |
| 151 GURL url; | 171 GURL url; |
| 152 EXPECT_CALL(*event_router.get(), | 172 EXPECT_CALL(*event_router.get(), |
| 153 CallEventRouter(profile1_, "", kEventName, profile1_, url)); | 173 CallEventRouter(profile1_, "", kHistogramValue, kEventName, |
| 174 profile1_, url)); |
| 154 EXPECT_CALL(*event_router.get(), | 175 EXPECT_CALL(*event_router.get(), |
| 155 CallEventRouter(profile2_, "", kEventName, profile2_, url)); | 176 CallEventRouter(profile2_, "", kHistogramValue, kEventName, |
| 177 profile2_, url)); |
| 156 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 178 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 157 base::Bind( | 179 base::Bind(&BroadcastEventToRenderers, |
| 158 &BroadcastEventToRenderers, base::Unretained(event_router.get()), | 180 base::Unretained(event_router.get()), |
| 159 kEventName, url)); | 181 kHistogramValue, kEventName, url)); |
| 160 | 182 |
| 161 // Wait for IO thread's message loop to be processed | 183 // Wait for IO thread's message loop to be processed |
| 162 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 184 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 163 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); | 185 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); |
| 164 ASSERT_TRUE(helper->Run()); | 186 ASSERT_TRUE(helper->Run()); |
| 165 | 187 |
| 166 base::MessageLoop::current()->RunUntilIdle(); | 188 base::MessageLoop::current()->RunUntilIdle(); |
| 167 } | 189 } |
| 168 | 190 |
| 169 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestricted) { | 191 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestricted) { |
| 170 scoped_refptr<MockEventRouterForwarder> event_router( | 192 scoped_refptr<MockEventRouterForwarder> event_router( |
| 171 new MockEventRouterForwarder); | 193 new MockEventRouterForwarder); |
| 172 using ::testing::_; | 194 using ::testing::_; |
| 173 GURL url; | 195 GURL url; |
| 174 EXPECT_CALL(*event_router.get(), | 196 EXPECT_CALL(*event_router.get(), |
| 175 CallEventRouter(profile1_, "", kEventName, profile1_, url)); | 197 CallEventRouter(profile1_, "", kHistogramValue, kEventName, |
| 176 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 198 profile1_, url)); |
| 199 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 177 .Times(0); | 200 .Times(0); |
| 178 DispatchEventToRenderers(event_router.get(), kEventName, profile1_, true, | 201 DispatchEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 179 url); | 202 profile1_, true, url); |
| 180 } | 203 } |
| 181 | 204 |
| 182 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestrictedIncognito1) { | 205 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestrictedIncognito1) { |
| 183 scoped_refptr<MockEventRouterForwarder> event_router( | 206 scoped_refptr<MockEventRouterForwarder> event_router( |
| 184 new MockEventRouterForwarder); | 207 new MockEventRouterForwarder); |
| 185 Profile* incognito = profile1_->GetOffTheRecordProfile(); | 208 Profile* incognito = profile1_->GetOffTheRecordProfile(); |
| 186 using ::testing::_; | 209 using ::testing::_; |
| 187 GURL url; | 210 GURL url; |
| 188 EXPECT_CALL(*event_router.get(), | 211 EXPECT_CALL(*event_router.get(), |
| 189 CallEventRouter(profile1_, "", kEventName, profile1_, url)); | 212 CallEventRouter(profile1_, "", kHistogramValue, kEventName, |
| 190 EXPECT_CALL(*event_router.get(), CallEventRouter(incognito, _, _, _, _)) | 213 profile1_, url)); |
| 214 EXPECT_CALL(*event_router.get(), CallEventRouter(incognito, _, _, _, _, _)) |
| 191 .Times(0); | 215 .Times(0); |
| 192 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 216 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 193 .Times(0); | 217 .Times(0); |
| 194 DispatchEventToRenderers(event_router.get(), kEventName, profile1_, true, | 218 DispatchEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 195 url); | 219 profile1_, true, url); |
| 196 } | 220 } |
| 197 | 221 |
| 198 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestrictedIncognito2) { | 222 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestrictedIncognito2) { |
| 199 scoped_refptr<MockEventRouterForwarder> event_router( | 223 scoped_refptr<MockEventRouterForwarder> event_router( |
| 200 new MockEventRouterForwarder); | 224 new MockEventRouterForwarder); |
| 201 Profile* incognito = profile1_->GetOffTheRecordProfile(); | 225 Profile* incognito = profile1_->GetOffTheRecordProfile(); |
| 202 using ::testing::_; | 226 using ::testing::_; |
| 203 GURL url; | 227 GURL url; |
| 204 EXPECT_CALL(*event_router.get(), CallEventRouter(profile1_, _, _, _, _)) | 228 EXPECT_CALL(*event_router.get(), CallEventRouter(profile1_, _, _, _, _, _)) |
| 205 .Times(0); | 229 .Times(0); |
| 206 EXPECT_CALL(*event_router.get(), | 230 EXPECT_CALL(*event_router.get(), |
| 207 CallEventRouter(incognito, "", kEventName, incognito, url)); | 231 CallEventRouter(incognito, "", kHistogramValue, kEventName, |
| 208 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 232 incognito, url)); |
| 233 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 209 .Times(0); | 234 .Times(0); |
| 210 DispatchEventToRenderers(event_router.get(), kEventName, incognito, true, | 235 DispatchEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 211 url); | 236 incognito, true, url); |
| 212 } | 237 } |
| 213 | 238 |
| 214 TEST_F(EventRouterForwarderTest, UnicastRendererUIUnrestricted) { | 239 TEST_F(EventRouterForwarderTest, UnicastRendererUIUnrestricted) { |
| 215 scoped_refptr<MockEventRouterForwarder> event_router( | 240 scoped_refptr<MockEventRouterForwarder> event_router( |
| 216 new MockEventRouterForwarder); | 241 new MockEventRouterForwarder); |
| 217 using ::testing::_; | 242 using ::testing::_; |
| 218 GURL url; | 243 GURL url; |
| 219 EXPECT_CALL(*event_router.get(), | 244 EXPECT_CALL( |
| 220 CallEventRouter(profile1_, "", kEventName, NULL, url)); | 245 *event_router.get(), |
| 221 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 246 CallEventRouter(profile1_, "", kHistogramValue, kEventName, NULL, url)); |
| 247 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 222 .Times(0); | 248 .Times(0); |
| 223 DispatchEventToRenderers(event_router.get(), kEventName, profile1_, false, | 249 DispatchEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 224 url); | 250 profile1_, false, url); |
| 225 } | 251 } |
| 226 | 252 |
| 227 TEST_F(EventRouterForwarderTest, UnicastRendererUIUnrestrictedIncognito) { | 253 TEST_F(EventRouterForwarderTest, UnicastRendererUIUnrestrictedIncognito) { |
| 228 scoped_refptr<MockEventRouterForwarder> event_router( | 254 scoped_refptr<MockEventRouterForwarder> event_router( |
| 229 new MockEventRouterForwarder); | 255 new MockEventRouterForwarder); |
| 230 Profile* incognito = profile1_->GetOffTheRecordProfile(); | 256 Profile* incognito = profile1_->GetOffTheRecordProfile(); |
| 231 using ::testing::_; | 257 using ::testing::_; |
| 232 GURL url; | 258 GURL url; |
| 233 EXPECT_CALL(*event_router.get(), | 259 EXPECT_CALL( |
| 234 CallEventRouter(profile1_, "", kEventName, NULL, url)); | 260 *event_router.get(), |
| 235 EXPECT_CALL(*event_router.get(), CallEventRouter(incognito, _, _, _, _)) | 261 CallEventRouter(profile1_, "", kHistogramValue, kEventName, NULL, url)); |
| 262 EXPECT_CALL(*event_router.get(), CallEventRouter(incognito, _, _, _, _, _)) |
| 236 .Times(0); | 263 .Times(0); |
| 237 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 264 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 238 .Times(0); | 265 .Times(0); |
| 239 DispatchEventToRenderers(event_router.get(), kEventName, profile1_, false, | 266 DispatchEventToRenderers(event_router.get(), kHistogramValue, kEventName, |
| 240 url); | 267 profile1_, false, url); |
| 241 } | 268 } |
| 242 | 269 |
| 243 TEST_F(EventRouterForwarderTest, BroadcastExtensionUI) { | 270 TEST_F(EventRouterForwarderTest, BroadcastExtensionUI) { |
| 244 scoped_refptr<MockEventRouterForwarder> event_router( | 271 scoped_refptr<MockEventRouterForwarder> event_router( |
| 245 new MockEventRouterForwarder); | 272 new MockEventRouterForwarder); |
| 246 GURL url; | 273 GURL url; |
| 247 EXPECT_CALL(*event_router.get(), | 274 EXPECT_CALL(*event_router.get(), |
| 248 CallEventRouter(profile1_, kExt, kEventName, profile1_, url)); | 275 CallEventRouter(profile1_, kExt, kHistogramValue, kEventName, |
| 276 profile1_, url)); |
| 249 EXPECT_CALL(*event_router.get(), | 277 EXPECT_CALL(*event_router.get(), |
| 250 CallEventRouter(profile2_, kExt, kEventName, profile2_, url)); | 278 CallEventRouter(profile2_, kExt, kHistogramValue, kEventName, |
| 251 BroadcastEventToExtension(event_router.get(), kExt, kEventName, url); | 279 profile2_, url)); |
| 280 BroadcastEventToExtension(event_router.get(), kExt, kHistogramValue, |
| 281 kEventName, url); |
| 252 } | 282 } |
| 253 | 283 |
| 254 TEST_F(EventRouterForwarderTest, UnicastExtensionUIRestricted) { | 284 TEST_F(EventRouterForwarderTest, UnicastExtensionUIRestricted) { |
| 255 scoped_refptr<MockEventRouterForwarder> event_router( | 285 scoped_refptr<MockEventRouterForwarder> event_router( |
| 256 new MockEventRouterForwarder); | 286 new MockEventRouterForwarder); |
| 257 using ::testing::_; | 287 using ::testing::_; |
| 258 GURL url; | 288 GURL url; |
| 259 EXPECT_CALL(*event_router.get(), | 289 EXPECT_CALL(*event_router.get(), |
| 260 CallEventRouter(profile1_, kExt, kEventName, profile1_, url)); | 290 CallEventRouter(profile1_, kExt, kHistogramValue, kEventName, |
| 261 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 291 profile1_, url)); |
| 292 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 262 .Times(0); | 293 .Times(0); |
| 263 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_, | 294 DispatchEventToExtension(event_router.get(), kExt, kHistogramValue, |
| 264 true, url); | 295 kEventName, profile1_, true, url); |
| 265 } | 296 } |
| 266 | 297 |
| 267 TEST_F(EventRouterForwarderTest, UnicastExtensionUIUnrestricted) { | 298 TEST_F(EventRouterForwarderTest, UnicastExtensionUIUnrestricted) { |
| 268 scoped_refptr<MockEventRouterForwarder> event_router( | 299 scoped_refptr<MockEventRouterForwarder> event_router( |
| 269 new MockEventRouterForwarder); | 300 new MockEventRouterForwarder); |
| 270 using ::testing::_; | 301 using ::testing::_; |
| 271 GURL url; | 302 GURL url; |
| 272 EXPECT_CALL(*event_router.get(), | 303 EXPECT_CALL( |
| 273 CallEventRouter(profile1_, kExt, kEventName, NULL, url)); | 304 *event_router.get(), |
| 274 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) | 305 CallEventRouter(profile1_, kExt, kHistogramValue, kEventName, NULL, url)); |
| 306 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _, _)) |
| 275 .Times(0); | 307 .Times(0); |
| 276 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_, | 308 DispatchEventToExtension(event_router.get(), kExt, kHistogramValue, |
| 277 false, url); | 309 kEventName, profile1_, false, url); |
| 278 } | 310 } |
| 279 | 311 |
| 280 } // namespace extensions | 312 } // namespace extensions |
| OLD | NEW |