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 <deque> | 5 #include <deque> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/scoped_observer.h" | |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/test/histogram_tester.h" | 21 #include "base/test/histogram_tester.h" |
21 #include "base/test/test_timeouts.h" | 22 #include "base/test/test_timeouts.h" |
22 #include "base/values.h" | 23 #include "base/values.h" |
23 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 24 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
24 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 25 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
25 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 26 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
26 #include "chrome/browser/chrome_content_browser_client.h" | 27 #include "chrome/browser/chrome_content_browser_client.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 60 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
60 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 61 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
61 #include "chrome/common/chrome_paths.h" | 62 #include "chrome/common/chrome_paths.h" |
62 #include "chrome/common/chrome_switches.h" | 63 #include "chrome/common/chrome_switches.h" |
63 #include "chrome/common/pref_names.h" | 64 #include "chrome/common/pref_names.h" |
64 #include "chrome/grit/generated_resources.h" | 65 #include "chrome/grit/generated_resources.h" |
65 #include "chrome/test/base/in_process_browser_test.h" | 66 #include "chrome/test/base/in_process_browser_test.h" |
66 #include "chrome/test/base/test_switches.h" | 67 #include "chrome/test/base/test_switches.h" |
67 #include "chrome/test/base/ui_test_utils.h" | 68 #include "chrome/test/base/ui_test_utils.h" |
68 #include "components/content_settings/core/browser/host_content_settings_map.h" | 69 #include "components/content_settings/core/browser/host_content_settings_map.h" |
70 #include "components/favicon/core/favicon_driver_observer.h" | |
69 #include "components/variations/entropy_provider.h" | 71 #include "components/variations/entropy_provider.h" |
70 #include "components/variations/variations_associated_data.h" | 72 #include "components/variations/variations_associated_data.h" |
71 #include "content/public/browser/browser_message_filter.h" | 73 #include "content/public/browser/browser_message_filter.h" |
72 #include "content/public/browser/devtools_agent_host.h" | 74 #include "content/public/browser/devtools_agent_host.h" |
73 #include "content/public/browser/navigation_controller.h" | 75 #include "content/public/browser/navigation_controller.h" |
74 #include "content/public/browser/navigation_entry.h" | 76 #include "content/public/browser/navigation_entry.h" |
75 #include "content/public/browser/notification_service.h" | 77 #include "content/public/browser/notification_service.h" |
76 #include "content/public/browser/render_frame_host.h" | 78 #include "content/public/browser/render_frame_host.h" |
77 #include "content/public/browser/render_process_host.h" | 79 #include "content/public/browser/render_process_host.h" |
78 #include "content/public/browser/render_view_host.h" | 80 #include "content/public/browser/render_view_host.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 // the page behaves as expected when prerendered. | 126 // the page behaves as expected when prerendered. |
125 // | 127 // |
126 // The prerendered page is then displayed on a tab. The Javascript function | 128 // The prerendered page is then displayed on a tab. The Javascript function |
127 // DidDisplayPass() is called, and returns true if the page behaved as it | 129 // DidDisplayPass() is called, and returns true if the page behaved as it |
128 // should while being displayed. | 130 // should while being displayed. |
129 | 131 |
130 namespace prerender { | 132 namespace prerender { |
131 | 133 |
132 namespace { | 134 namespace { |
133 | 135 |
136 class FaviconUpdateWatcher : public favicon::FaviconDriverObserver { | |
137 public: | |
138 explicit FaviconUpdateWatcher(content::WebContents* web_contents) | |
139 : seen_(false), running_(false), scoped_observer_(this) { | |
140 scoped_observer_.Add(FaviconTabHelper::FromWebContents(web_contents)); | |
141 } | |
142 | |
143 void Wait() { | |
144 if (seen_) | |
145 return; | |
146 | |
147 running_ = true; | |
148 message_loop_runner_ = new content::MessageLoopRunner; | |
149 message_loop_runner_->Run(); | |
150 } | |
151 | |
152 private: | |
153 void OnFaviconAvailable(const gfx::Image& image) override {} | |
154 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, | |
155 bool icon_url_changed) override { | |
156 seen_ = true; | |
157 if (!running_) | |
158 return; | |
159 | |
160 message_loop_runner_->Quit(); | |
161 running_ = false; | |
162 } | |
163 | |
164 bool seen_; | |
165 bool running_; | |
166 ScopedObserver<FaviconTabHelper, FaviconUpdateWatcher> scoped_observer_; | |
167 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
168 }; | |
jochen (gone - plz use gerrit)
2015/04/07 19:03:25
nit. DISALLOW_COPY_AND_ASSIGN()
| |
169 | |
134 class MockNetworkChangeNotifierWIFI : public NetworkChangeNotifier { | 170 class MockNetworkChangeNotifierWIFI : public NetworkChangeNotifier { |
135 public: | 171 public: |
136 ConnectionType GetCurrentConnectionType() const override { | 172 ConnectionType GetCurrentConnectionType() const override { |
137 return NetworkChangeNotifier::CONNECTION_WIFI; | 173 return NetworkChangeNotifier::CONNECTION_WIFI; |
138 } | 174 } |
139 }; | 175 }; |
140 | 176 |
141 class MockNetworkChangeNotifier4G : public NetworkChangeNotifier { | 177 class MockNetworkChangeNotifier4G : public NetworkChangeNotifier { |
142 public: | 178 public: |
143 ConnectionType GetCurrentConnectionType() const override { | 179 ConnectionType GetCurrentConnectionType() const override { |
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3139 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) { | 3175 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) { |
3140 scoped_ptr<TestPrerender> prerender = | 3176 scoped_ptr<TestPrerender> prerender = |
3141 PrerenderTestURL("files/prerender/prerender_favicon.html", | 3177 PrerenderTestURL("files/prerender/prerender_favicon.html", |
3142 FINAL_STATUS_USED, | 3178 FINAL_STATUS_USED, |
3143 1); | 3179 1); |
3144 NavigateToDestURL(); | 3180 NavigateToDestURL(); |
3145 | 3181 |
3146 if (!FaviconTabHelper::FromWebContents( | 3182 if (!FaviconTabHelper::FromWebContents( |
3147 GetActiveWebContents())->FaviconIsValid()) { | 3183 GetActiveWebContents())->FaviconIsValid()) { |
3148 // If the favicon has not been set yet, wait for it to be. | 3184 // If the favicon has not been set yet, wait for it to be. |
3149 content::WindowedNotificationObserver favicon_update_watcher( | 3185 FaviconUpdateWatcher favicon_update_watcher(GetActiveWebContents()); |
3150 chrome::NOTIFICATION_FAVICON_UPDATED, | |
3151 content::Source<WebContents>(GetActiveWebContents())); | |
3152 favicon_update_watcher.Wait(); | 3186 favicon_update_watcher.Wait(); |
3153 } | 3187 } |
3154 EXPECT_TRUE(FaviconTabHelper::FromWebContents( | 3188 EXPECT_TRUE(FaviconTabHelper::FromWebContents( |
3155 GetActiveWebContents())->FaviconIsValid()); | 3189 GetActiveWebContents())->FaviconIsValid()); |
3156 } | 3190 } |
3157 | 3191 |
3158 // Checks that when a prerendered page is swapped in to a referring page, the | 3192 // Checks that when a prerendered page is swapped in to a referring page, the |
3159 // unload handlers on the referring page are executed. | 3193 // unload handlers on the referring page are executed. |
3160 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) { | 3194 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) { |
3161 // Matches URL in prerender_loader_with_unload.html. | 3195 // Matches URL in prerender_loader_with_unload.html. |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4114 TestShouldDisableLocalPredictorPreferenceNetworkMatrix( | 4148 TestShouldDisableLocalPredictorPreferenceNetworkMatrix( |
4115 false /*preference_wifi_network_wifi*/, | 4149 false /*preference_wifi_network_wifi*/, |
4116 false /*preference_wifi_network_4g*/, | 4150 false /*preference_wifi_network_4g*/, |
4117 false /*preference_always_network_wifi*/, | 4151 false /*preference_always_network_wifi*/, |
4118 false /*preference_always_network_4g*/, | 4152 false /*preference_always_network_4g*/, |
4119 false /*preference_never_network_wifi*/, | 4153 false /*preference_never_network_wifi*/, |
4120 false /*preference_never_network_4g*/); | 4154 false /*preference_never_network_4g*/); |
4121 } | 4155 } |
4122 | 4156 |
4123 } // namespace prerender | 4157 } // namespace prerender |
OLD | NEW |