OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/google/google_url_tracker.h" | 5 #include "components/google/core/browser/google_url_tracker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "chrome/browser/google/google_url_tracker_factory.h" | 13 #include "chrome/browser/google/google_url_tracker_factory.h" |
14 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" | 14 #include "chrome/browser/google/google_util.h" |
15 #include "chrome/browser/google/google_url_tracker_navigation_helper.h" | |
16 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
17 #include "components/google/core/browser/google_pref_names.h" | 16 #include "components/google/core/browser/google_pref_names.h" |
18 #include "components/google/core/browser/google_url_tracker_client.h" | 17 #include "components/google/core/browser/google_url_tracker_client.h" |
| 18 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h" |
| 19 #include "components/google/core/browser/google_url_tracker_navigation_helper.h" |
19 #include "components/infobars/core/infobar.h" | 20 #include "components/infobars/core/infobar.h" |
20 #include "components/infobars/core/infobar_delegate.h" | 21 #include "components/infobars/core/infobar_delegate.h" |
21 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
22 #include "net/url_request/test_url_fetcher_factory.h" | 23 #include "net/url_request/test_url_fetcher_factory.h" |
23 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // TestCallbackListener --------------------------------------------------- | 29 // TestCallbackListener --------------------------------------------------- |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 class TestGoogleURLTrackerClient : public GoogleURLTrackerClient { | 73 class TestGoogleURLTrackerClient : public GoogleURLTrackerClient { |
73 public: | 74 public: |
74 TestGoogleURLTrackerClient(Profile* profile_); | 75 TestGoogleURLTrackerClient(Profile* profile_); |
75 virtual ~TestGoogleURLTrackerClient(); | 76 virtual ~TestGoogleURLTrackerClient(); |
76 | 77 |
77 virtual void SetListeningForNavigationStart(bool listen) OVERRIDE; | 78 virtual void SetListeningForNavigationStart(bool listen) OVERRIDE; |
78 virtual bool IsListeningForNavigationStart() OVERRIDE; | 79 virtual bool IsListeningForNavigationStart() OVERRIDE; |
79 virtual bool IsBackgroundNetworkingEnabled() OVERRIDE; | 80 virtual bool IsBackgroundNetworkingEnabled() OVERRIDE; |
80 virtual PrefService* GetPrefs() OVERRIDE; | 81 virtual PrefService* GetPrefs() OVERRIDE; |
81 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 82 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 83 virtual bool IsGoogleDomainURL(const GURL& url) OVERRIDE; |
| 84 virtual GURL AppendGoogleLocaleParam(const GURL& url) OVERRIDE; |
82 | 85 |
83 private: | 86 private: |
84 Profile* profile_; | 87 Profile* profile_; |
85 bool observe_nav_start_; | 88 bool observe_nav_start_; |
86 | 89 |
87 DISALLOW_COPY_AND_ASSIGN(TestGoogleURLTrackerClient); | 90 DISALLOW_COPY_AND_ASSIGN(TestGoogleURLTrackerClient); |
88 }; | 91 }; |
89 | 92 |
90 TestGoogleURLTrackerClient::TestGoogleURLTrackerClient(Profile* profile) | 93 TestGoogleURLTrackerClient::TestGoogleURLTrackerClient(Profile* profile) |
91 : profile_(profile), | 94 : profile_(profile), |
(...skipping 16 matching lines...) Expand all Loading... |
108 } | 111 } |
109 | 112 |
110 PrefService* TestGoogleURLTrackerClient::GetPrefs() { | 113 PrefService* TestGoogleURLTrackerClient::GetPrefs() { |
111 return profile_->GetPrefs(); | 114 return profile_->GetPrefs(); |
112 } | 115 } |
113 | 116 |
114 net::URLRequestContextGetter* TestGoogleURLTrackerClient::GetRequestContext() { | 117 net::URLRequestContextGetter* TestGoogleURLTrackerClient::GetRequestContext() { |
115 return profile_->GetRequestContext(); | 118 return profile_->GetRequestContext(); |
116 } | 119 } |
117 | 120 |
| 121 bool TestGoogleURLTrackerClient::IsGoogleDomainURL(const GURL& url) { |
| 122 return google_util::IsGoogleDomainUrl( |
| 123 url, |
| 124 google_util::DISALLOW_SUBDOMAIN, |
| 125 google_util::DISALLOW_NON_STANDARD_PORTS); |
| 126 } |
| 127 |
| 128 GURL TestGoogleURLTrackerClient::AppendGoogleLocaleParam(const GURL& url) { |
| 129 return google_util::AppendGoogleLocaleParam(url); |
| 130 } |
| 131 |
| 132 |
118 // TestGoogleURLTrackerNavigationHelper --------------------------------------- | 133 // TestGoogleURLTrackerNavigationHelper --------------------------------------- |
119 | 134 |
120 class TestGoogleURLTrackerNavigationHelper | 135 class TestGoogleURLTrackerNavigationHelper |
121 : public GoogleURLTrackerNavigationHelper { | 136 : public GoogleURLTrackerNavigationHelper { |
122 public: | 137 public: |
123 explicit TestGoogleURLTrackerNavigationHelper(GoogleURLTracker* tracker); | 138 explicit TestGoogleURLTrackerNavigationHelper(GoogleURLTracker* tracker); |
124 virtual ~TestGoogleURLTrackerNavigationHelper(); | 139 virtual ~TestGoogleURLTrackerNavigationHelper(); |
125 | 140 |
126 virtual void SetListeningForNavigationCommit(bool listen) OVERRIDE; | 141 virtual void SetListeningForNavigationCommit(bool listen) OVERRIDE; |
127 virtual bool IsListeningForNavigationCommit() OVERRIDE; | 142 virtual bool IsListeningForNavigationCommit() OVERRIDE; |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 EXPECT_FALSE(GetInfoBarDelegate(&infobar_manager) == NULL); | 1053 EXPECT_FALSE(GetInfoBarDelegate(&infobar_manager) == NULL); |
1039 GoogleURLTrackerInfoBarDelegate* delegate2 = | 1054 GoogleURLTrackerInfoBarDelegate* delegate2 = |
1040 GetInfoBarDelegate(&infobar_manager2); | 1055 GetInfoBarDelegate(&infobar_manager2); |
1041 ASSERT_FALSE(delegate2 == NULL); | 1056 ASSERT_FALSE(delegate2 == NULL); |
1042 SetNavigationPending(&infobar_manager, true); | 1057 SetNavigationPending(&infobar_manager, true); |
1043 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, true)); | 1058 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, true)); |
1044 delegate2->Close(false); | 1059 delegate2->Close(false); |
1045 SetNavigationPending(&infobar_manager, false); | 1060 SetNavigationPending(&infobar_manager, false); |
1046 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, false)); | 1061 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, false)); |
1047 } | 1062 } |
OLD | NEW |