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 #include <iterator> | 6 #include <iterator> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/favicon/favicon_service.h" | 15 #include "chrome/browser/favicon/favicon_service.h" |
15 #include "chrome/browser/intents/default_web_intent_service.h" | 16 #include "chrome/browser/intents/default_web_intent_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_tabstrip.h" | 19 #include "chrome/browser/ui/browser_tabstrip.h" |
19 #include "chrome/browser/ui/intents/web_intent_picker.h" | 20 #include "chrome/browser/ui/intents/web_intent_picker.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 "}\\n" | 73 "}\\n" |
73 "}\\n" | 74 "}\\n" |
74 "}\\n\"," | 75 "}\\n\"," |
75 "\"family_safe\":true," | 76 "\"family_safe\":true," |
76 "\"icon_url\": \"%s\"}]}"; | 77 "\"icon_url\": \"%s\"}]}"; |
77 | 78 |
78 const char kCWSFakeIconURLFormat[] = "http://example.com/%s/icon.png"; | 79 const char kCWSFakeIconURLFormat[] = "http://example.com/%s/icon.png"; |
79 | 80 |
80 class DummyURLFetcherFactory : public net::URLFetcherFactory { | 81 class DummyURLFetcherFactory : public net::URLFetcherFactory { |
81 public: | 82 public: |
82 DummyURLFetcherFactory() {} | 83 DummyURLFetcherFactory() {} |
83 virtual ~DummyURLFetcherFactory() {} | 84 virtual ~DummyURLFetcherFactory() {} |
84 | 85 |
85 virtual net::URLFetcher* CreateURLFetcher( | 86 virtual net::URLFetcher* CreateURLFetcher( |
86 int id, | 87 int id, |
87 const GURL& url, | 88 const GURL& url, |
88 net::URLFetcher::RequestType request_type, | 89 net::URLFetcher::RequestType request_type, |
89 net::URLFetcherDelegate* d) OVERRIDE { | 90 net::URLFetcherDelegate* d) OVERRIDE { |
90 return new net::TestURLFetcher(id, url, d); | 91 return new net::TestURLFetcher(id, url, d); |
91 } | 92 } |
92 }; | 93 }; |
93 | 94 |
94 } // namespace | 95 } // namespace |
95 | 96 |
96 class WebIntentPickerMock : public WebIntentPicker, | 97 class WebIntentPickerMock : public WebIntentPicker, |
97 public WebIntentPickerModelObserver { | 98 public WebIntentPickerModelObserver { |
98 public: | 99 public: |
99 WebIntentPickerMock() | 100 WebIntentPickerMock() |
100 : num_installed_services_(0), | 101 : num_installed_services_(0), |
101 num_icons_changed_(0), | 102 num_icons_changed_(0), |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 EXPECT_EQ(GURL(kServiceURL1), | 425 EXPECT_EQ(GURL(kServiceURL1), |
425 chrome::GetActiveWebContents(browser())->GetURL()); | 426 chrome::GetActiveWebContents(browser())->GetURL()); |
426 | 427 |
427 EXPECT_TRUE(dispatcher.dispatched_); | 428 EXPECT_TRUE(dispatcher.dispatched_); |
428 | 429 |
429 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); | 430 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); |
430 ASSERT_EQ(2, browser()->tab_count()); | 431 ASSERT_EQ(2, browser()->tab_count()); |
431 EXPECT_EQ(original, chrome::GetActiveWebContents(browser())->GetURL()); | 432 EXPECT_EQ(original, chrome::GetActiveWebContents(browser())->GetURL()); |
432 } | 433 } |
433 | 434 |
434 class WebIntentPickerControllerIncognitoBrowserTest : | 435 class WebIntentPickerControllerIncognitoBrowserTest |
435 public WebIntentPickerControllerBrowserTest { | 436 : public WebIntentPickerControllerBrowserTest { |
436 public: | 437 public: |
437 WebIntentPickerControllerIncognitoBrowserTest() {} | 438 WebIntentPickerControllerIncognitoBrowserTest() {} |
438 | 439 |
439 virtual void SetUpOnMainThread() OVERRIDE { | 440 virtual void SetUpOnMainThread() OVERRIDE { |
440 incognito_browser_ = CreateIncognitoBrowser(); | 441 incognito_browser_ = CreateIncognitoBrowser(); |
441 WebIntentPickerControllerBrowserTest::SetUpOnMainThread(); | 442 WebIntentPickerControllerBrowserTest::SetUpOnMainThread(); |
442 } | 443 } |
443 | 444 |
444 virtual Browser* GetBrowser() OVERRIDE { return incognito_browser_; } | 445 virtual Browser* GetBrowser() OVERRIDE { return incognito_browser_; } |
445 | 446 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 635 |
635 EXPECT_EQ(2, picker_.num_installed_services_); | 636 EXPECT_EQ(2, picker_.num_installed_services_); |
636 | 637 |
637 // The tab is shown immediately without needing to call OnServiceChosen. | 638 // The tab is shown immediately without needing to call OnServiceChosen. |
638 ASSERT_EQ(2, browser()->tab_count()); | 639 ASSERT_EQ(2, browser()->tab_count()); |
639 EXPECT_EQ(GURL(kServiceURL1), | 640 EXPECT_EQ(GURL(kServiceURL1), |
640 chrome::GetActiveWebContents(browser())->GetURL()); | 641 chrome::GetActiveWebContents(browser())->GetURL()); |
641 | 642 |
642 EXPECT_TRUE(dispatcher.dispatched_); | 643 EXPECT_TRUE(dispatcher.dispatched_); |
643 } | 644 } |
OLD | NEW |