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 "components/google/core/browser/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_util.h" | |
15 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
16 #include "components/google/core/browser/google_pref_names.h" | 15 #include "components/google/core/browser/google_pref_names.h" |
17 #include "components/google/core/browser/google_url_tracker_client.h" | 16 #include "components/google/core/browser/google_url_tracker_client.h" |
18 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h" | 17 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h" |
19 #include "components/google/core/browser/google_url_tracker_navigation_helper.h" | 18 #include "components/google/core/browser/google_url_tracker_navigation_helper.h" |
20 #include "components/infobars/core/infobar.h" | 19 #include "components/infobars/core/infobar.h" |
21 #include "components/infobars/core/infobar_delegate.h" | 20 #include "components/infobars/core/infobar_delegate.h" |
22 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
23 #include "net/url_request/test_url_fetcher_factory.h" | 22 #include "net/url_request/test_url_fetcher_factory.h" |
24 #include "net/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class TestGoogleURLTrackerClient : public GoogleURLTrackerClient { | 72 class TestGoogleURLTrackerClient : public GoogleURLTrackerClient { |
74 public: | 73 public: |
75 TestGoogleURLTrackerClient(Profile* profile_); | 74 TestGoogleURLTrackerClient(Profile* profile_); |
76 virtual ~TestGoogleURLTrackerClient(); | 75 virtual ~TestGoogleURLTrackerClient(); |
77 | 76 |
78 virtual void SetListeningForNavigationStart(bool listen) OVERRIDE; | 77 virtual void SetListeningForNavigationStart(bool listen) OVERRIDE; |
79 virtual bool IsListeningForNavigationStart() OVERRIDE; | 78 virtual bool IsListeningForNavigationStart() OVERRIDE; |
80 virtual bool IsBackgroundNetworkingEnabled() OVERRIDE; | 79 virtual bool IsBackgroundNetworkingEnabled() OVERRIDE; |
81 virtual PrefService* GetPrefs() OVERRIDE; | 80 virtual PrefService* GetPrefs() OVERRIDE; |
82 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 81 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
83 virtual bool IsGoogleDomainURL(const GURL& url) OVERRIDE; | |
84 | 82 |
85 private: | 83 private: |
86 Profile* profile_; | 84 Profile* profile_; |
87 bool observe_nav_start_; | 85 bool observe_nav_start_; |
88 | 86 |
89 DISALLOW_COPY_AND_ASSIGN(TestGoogleURLTrackerClient); | 87 DISALLOW_COPY_AND_ASSIGN(TestGoogleURLTrackerClient); |
90 }; | 88 }; |
91 | 89 |
92 TestGoogleURLTrackerClient::TestGoogleURLTrackerClient(Profile* profile) | 90 TestGoogleURLTrackerClient::TestGoogleURLTrackerClient(Profile* profile) |
93 : profile_(profile), | 91 : profile_(profile), |
(...skipping 16 matching lines...) Expand all Loading... |
110 } | 108 } |
111 | 109 |
112 PrefService* TestGoogleURLTrackerClient::GetPrefs() { | 110 PrefService* TestGoogleURLTrackerClient::GetPrefs() { |
113 return profile_->GetPrefs(); | 111 return profile_->GetPrefs(); |
114 } | 112 } |
115 | 113 |
116 net::URLRequestContextGetter* TestGoogleURLTrackerClient::GetRequestContext() { | 114 net::URLRequestContextGetter* TestGoogleURLTrackerClient::GetRequestContext() { |
117 return profile_->GetRequestContext(); | 115 return profile_->GetRequestContext(); |
118 } | 116 } |
119 | 117 |
120 bool TestGoogleURLTrackerClient::IsGoogleDomainURL(const GURL& url) { | |
121 return google_util::IsGoogleDomainUrl( | |
122 url, | |
123 google_util::DISALLOW_SUBDOMAIN, | |
124 google_util::DISALLOW_NON_STANDARD_PORTS); | |
125 } | |
126 | |
127 | 118 |
128 // TestGoogleURLTrackerNavigationHelper --------------------------------------- | 119 // TestGoogleURLTrackerNavigationHelper --------------------------------------- |
129 | 120 |
130 class TestGoogleURLTrackerNavigationHelper | 121 class TestGoogleURLTrackerNavigationHelper |
131 : public GoogleURLTrackerNavigationHelper { | 122 : public GoogleURLTrackerNavigationHelper { |
132 public: | 123 public: |
133 explicit TestGoogleURLTrackerNavigationHelper(GoogleURLTracker* tracker); | 124 explicit TestGoogleURLTrackerNavigationHelper(GoogleURLTracker* tracker); |
134 virtual ~TestGoogleURLTrackerNavigationHelper(); | 125 virtual ~TestGoogleURLTrackerNavigationHelper(); |
135 | 126 |
136 virtual void SetListeningForNavigationCommit(bool listen) OVERRIDE; | 127 virtual void SetListeningForNavigationCommit(bool listen) OVERRIDE; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 EXPECT_FALSE(GetInfoBarDelegate(&infobar_manager) == NULL); | 1039 EXPECT_FALSE(GetInfoBarDelegate(&infobar_manager) == NULL); |
1049 GoogleURLTrackerInfoBarDelegate* delegate2 = | 1040 GoogleURLTrackerInfoBarDelegate* delegate2 = |
1050 GetInfoBarDelegate(&infobar_manager2); | 1041 GetInfoBarDelegate(&infobar_manager2); |
1051 ASSERT_FALSE(delegate2 == NULL); | 1042 ASSERT_FALSE(delegate2 == NULL); |
1052 SetNavigationPending(&infobar_manager, true); | 1043 SetNavigationPending(&infobar_manager, true); |
1053 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, true)); | 1044 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, true)); |
1054 delegate2->Close(false); | 1045 delegate2->Close(false); |
1055 SetNavigationPending(&infobar_manager, false); | 1046 SetNavigationPending(&infobar_manager, false); |
1056 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, false)); | 1047 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, false)); |
1057 } | 1048 } |
OLD | NEW |