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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 virtual void OnFaviconChanged( | 119 virtual void OnFaviconChanged( |
120 WebIntentPickerModel* model, size_t index) OVERRIDE { | 120 WebIntentPickerModel* model, size_t index) OVERRIDE { |
121 num_icons_changed_++; | 121 num_icons_changed_++; |
122 } | 122 } |
123 | 123 |
124 virtual void OnExtensionIconChanged( | 124 virtual void OnExtensionIconChanged( |
125 WebIntentPickerModel* model, const string16& extension_id) OVERRIDE { | 125 WebIntentPickerModel* model, const string16& extension_id) OVERRIDE { |
126 num_extension_icons_changed_++; | 126 num_extension_icons_changed_++; |
127 } | 127 } |
128 | 128 |
129 virtual void OnInlineDisposition(WebIntentPickerModel* model) OVERRIDE {} | 129 virtual void OnInlineDisposition( |
| 130 WebIntentPickerModel* model, const GURL& url) OVERRIDE {} |
130 virtual void Close() OVERRIDE {} | 131 virtual void Close() OVERRIDE {} |
131 | 132 |
132 virtual void OnPendingAsyncCompleted() OVERRIDE { | 133 virtual void OnPendingAsyncCompleted() OVERRIDE { |
133 pending_async_completed_ = true; | 134 pending_async_completed_ = true; |
134 | 135 |
135 if (message_loop_started_) | 136 if (message_loop_started_) |
136 MessageLoop::current()->Quit(); | 137 MessageLoop::current()->Quit(); |
137 } | 138 } |
138 | 139 |
139 void WaitForPendingAsync() { | 140 void WaitForPendingAsync() { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 234 |
234 fake_url_fetcher_factory_->SetFakeResponse(icon_url, icon_response_, | 235 fake_url_fetcher_factory_->SetFakeResponse(icon_url, icon_response_, |
235 true); | 236 true); |
236 } | 237 } |
237 | 238 |
238 void OnSendReturnMessage( | 239 void OnSendReturnMessage( |
239 webkit_glue::WebIntentReplyType reply_type) { | 240 webkit_glue::WebIntentReplyType reply_type) { |
240 controller_->OnSendReturnMessage(reply_type); | 241 controller_->OnSendReturnMessage(reply_type); |
241 } | 242 } |
242 | 243 |
243 void OnServiceChosen(size_t index, Disposition disposition) { | 244 void OnServiceChosen(const GURL& url, Disposition disposition) { |
244 controller_->OnServiceChosen(index, disposition); | 245 controller_->OnServiceChosen(url, disposition); |
245 } | 246 } |
246 | 247 |
247 void OnCancelled() { | 248 void OnCancelled() { |
248 controller_->OnCancelled(); | 249 controller_->OnCancelled(); |
249 } | 250 } |
250 | 251 |
251 void CreateFakeIcon() { | 252 void CreateFakeIcon() { |
252 gfx::Image image(gfx::test::CreateImage()); | 253 gfx::Image image(gfx::test::CreateImage()); |
253 std::vector<unsigned char> image_data; | 254 std::vector<unsigned char> image_data; |
254 bool result = gfx::PNGEncodedDataFromImage(image, &image_data); | 255 bool result = gfx::PNGEncodedDataFromImage(image, &image_data); |
(...skipping 21 matching lines...) Expand all Loading... |
276 picker_.WaitForPendingAsync(); | 277 picker_.WaitForPendingAsync(); |
277 EXPECT_EQ(2, picker_.num_installed_services_); | 278 EXPECT_EQ(2, picker_.num_installed_services_); |
278 EXPECT_EQ(0, picker_.num_icons_changed_); | 279 EXPECT_EQ(0, picker_.num_icons_changed_); |
279 | 280 |
280 webkit_glue::WebIntentData intent; | 281 webkit_glue::WebIntentData intent; |
281 intent.action = ASCIIToUTF16("a"); | 282 intent.action = ASCIIToUTF16("a"); |
282 intent.type = ASCIIToUTF16("b"); | 283 intent.type = ASCIIToUTF16("b"); |
283 IntentsDispatcherMock dispatcher(intent); | 284 IntentsDispatcherMock dispatcher(intent); |
284 controller_->SetIntentsDispatcher(&dispatcher); | 285 controller_->SetIntentsDispatcher(&dispatcher); |
285 | 286 |
286 OnServiceChosen(1, WebIntentPickerModel::DISPOSITION_WINDOW); | 287 OnServiceChosen(kServiceURL2, WebIntentPickerModel::DISPOSITION_WINDOW); |
287 ASSERT_EQ(2, browser()->tab_count()); | 288 ASSERT_EQ(2, browser()->tab_count()); |
288 EXPECT_EQ(GURL(kServiceURL2), | 289 EXPECT_EQ(GURL(kServiceURL2), |
289 browser()->GetSelectedWebContents()->GetURL()); | 290 browser()->GetSelectedWebContents()->GetURL()); |
290 | 291 |
291 EXPECT_TRUE(dispatcher.dispatched_); | 292 EXPECT_TRUE(dispatcher.dispatched_); |
292 | 293 |
293 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); | 294 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); |
294 ASSERT_EQ(1, browser()->tab_count()); | 295 ASSERT_EQ(1, browser()->tab_count()); |
295 } | 296 } |
296 | 297 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 controller_->ShowDialog(browser(), kAction1, kType); | 338 controller_->ShowDialog(browser(), kAction1, kType); |
338 picker_.WaitForPendingAsync(); | 339 picker_.WaitForPendingAsync(); |
339 EXPECT_EQ(1, picker_.num_installed_services_); | 340 EXPECT_EQ(1, picker_.num_installed_services_); |
340 | 341 |
341 webkit_glue::WebIntentData intent; | 342 webkit_glue::WebIntentData intent; |
342 intent.action = ASCIIToUTF16("a"); | 343 intent.action = ASCIIToUTF16("a"); |
343 intent.type = ASCIIToUTF16("b"); | 344 intent.type = ASCIIToUTF16("b"); |
344 IntentsDispatcherMock dispatcher(intent); | 345 IntentsDispatcherMock dispatcher(intent); |
345 controller_->SetIntentsDispatcher(&dispatcher); | 346 controller_->SetIntentsDispatcher(&dispatcher); |
346 | 347 |
347 OnServiceChosen(0, WebIntentPickerModel::DISPOSITION_WINDOW); | 348 OnServiceChosen(kServiceURL1, WebIntentPickerModel::DISPOSITION_WINDOW); |
348 ASSERT_EQ(3, browser()->tab_count()); | 349 ASSERT_EQ(3, browser()->tab_count()); |
349 EXPECT_EQ(GURL(kServiceURL1), | 350 EXPECT_EQ(GURL(kServiceURL1), |
350 browser()->GetSelectedWebContents()->GetURL()); | 351 browser()->GetSelectedWebContents()->GetURL()); |
351 | 352 |
352 EXPECT_TRUE(dispatcher.dispatched_); | 353 EXPECT_TRUE(dispatcher.dispatched_); |
353 | 354 |
354 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); | 355 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); |
355 ASSERT_EQ(2, browser()->tab_count()); | 356 ASSERT_EQ(2, browser()->tab_count()); |
356 EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL()); | 357 EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL()); |
357 } | 358 } |
OLD | NEW |