| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <deque> | 6 #include <deque> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/test/scoped_feature_list.h" | 27 #include "base/test/scoped_feature_list.h" |
| 28 #include "base/test/simple_test_tick_clock.h" | 28 #include "base/test/simple_test_tick_clock.h" |
| 29 #include "base/test/test_timeouts.h" | 29 #include "base/test/test_timeouts.h" |
| 30 #include "base/values.h" | 30 #include "base/values.h" |
| 31 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 32 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 32 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 33 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 33 |
| 34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | |
| 35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | |
| 36 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 34 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 37 #include "chrome/browser/chrome_content_browser_client.h" | 35 #include "chrome/browser/chrome_content_browser_client.h" |
| 38 #include "chrome/browser/chrome_notification_types.h" | 36 #include "chrome/browser/chrome_notification_types.h" |
| 39 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 37 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 40 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 38 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
| 41 #include "chrome/browser/extensions/extension_apitest.h" | 39 #include "chrome/browser/extensions/extension_apitest.h" |
| 42 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 40 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 43 #include "chrome/browser/net/prediction_options.h" | 41 #include "chrome/browser/net/prediction_options.h" |
| 44 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.h" | 42 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.h" |
| 45 #include "chrome/browser/page_load_metrics/observers/prerender_page_load_metrics
_observer.h" | 43 #include "chrome/browser/page_load_metrics/observers/prerender_page_load_metrics
_observer.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #include "components/omnibox/browser/omnibox_popup_model.h" | 78 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 81 #include "components/omnibox/browser/omnibox_view.h" | 79 #include "components/omnibox/browser/omnibox_view.h" |
| 82 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 80 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| 83 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 81 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 84 #include "components/password_manager/core/browser/test_password_store.h" | 82 #include "components/password_manager/core/browser/test_password_store.h" |
| 85 #include "components/safe_browsing_db/database_manager.h" | 83 #include "components/safe_browsing_db/database_manager.h" |
| 86 #include "components/safe_browsing_db/util.h" | 84 #include "components/safe_browsing_db/util.h" |
| 87 #include "components/variations/entropy_provider.h" | 85 #include "components/variations/entropy_provider.h" |
| 88 #include "components/variations/variations_associated_data.h" | 86 #include "components/variations/variations_associated_data.h" |
| 89 #include "content/public/browser/browser_message_filter.h" | 87 #include "content/public/browser/browser_message_filter.h" |
| 88 #include "content/public/browser/browsing_data_remover.h" |
| 90 #include "content/public/browser/devtools_agent_host.h" | 89 #include "content/public/browser/devtools_agent_host.h" |
| 91 #include "content/public/browser/navigation_controller.h" | 90 #include "content/public/browser/navigation_controller.h" |
| 92 #include "content/public/browser/navigation_entry.h" | 91 #include "content/public/browser/navigation_entry.h" |
| 93 #include "content/public/browser/notification_service.h" | 92 #include "content/public/browser/notification_service.h" |
| 94 #include "content/public/browser/render_frame_host.h" | 93 #include "content/public/browser/render_frame_host.h" |
| 95 #include "content/public/browser/render_process_host.h" | 94 #include "content/public/browser/render_process_host.h" |
| 96 #include "content/public/browser/render_view_host.h" | 95 #include "content/public/browser/render_view_host.h" |
| 97 #include "content/public/browser/site_instance.h" | 96 #include "content/public/browser/site_instance.h" |
| 98 #include "content/public/browser/web_contents.h" | 97 #include "content/public/browser/web_contents.h" |
| 99 #include "content/public/browser/web_contents_observer.h" | 98 #include "content/public/browser/web_contents_observer.h" |
| 100 #include "content/public/common/browser_side_navigation_policy.h" | 99 #include "content/public/common/browser_side_navigation_policy.h" |
| 101 #include "content/public/common/content_switches.h" | 100 #include "content/public/common/content_switches.h" |
| 102 #include "content/public/common/resource_request_body.h" | 101 #include "content/public/common/resource_request_body.h" |
| 103 #include "content/public/common/url_constants.h" | 102 #include "content/public/common/url_constants.h" |
| 104 #include "content/public/test/browser_test_utils.h" | 103 #include "content/public/test/browser_test_utils.h" |
| 104 #include "content/public/test/browsing_data_remover_test_util.h" |
| 105 #include "content/public/test/ppapi_test_utils.h" | 105 #include "content/public/test/ppapi_test_utils.h" |
| 106 #include "content/public/test/test_navigation_observer.h" | 106 #include "content/public/test/test_navigation_observer.h" |
| 107 #include "content/public/test/test_utils.h" | 107 #include "content/public/test/test_utils.h" |
| 108 #include "extensions/common/constants.h" | 108 #include "extensions/common/constants.h" |
| 109 #include "extensions/common/extension_urls.h" | 109 #include "extensions/common/extension_urls.h" |
| 110 #include "extensions/common/manifest_handlers/mime_types_handler.h" | 110 #include "extensions/common/manifest_handlers/mime_types_handler.h" |
| 111 #include "extensions/common/switches.h" | 111 #include "extensions/common/switches.h" |
| 112 #include "extensions/test/result_catcher.h" | 112 #include "extensions/test/result_catcher.h" |
| 113 #include "net/base/escape.h" | 113 #include "net/base/escape.h" |
| 114 #include "net/cert/x509_certificate.h" | 114 #include "net/cert/x509_certificate.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return kClientRedirectBase + net::EscapeQueryParamValue(dest_url, false); | 230 return kClientRedirectBase + net::EscapeQueryParamValue(dest_url, false); |
| 231 } | 231 } |
| 232 | 232 |
| 233 std::string CreateServerRedirect(const std::string& dest_url) { | 233 std::string CreateServerRedirect(const std::string& dest_url) { |
| 234 const char* const kServerRedirectBase = "/server-redirect?"; | 234 const char* const kServerRedirectBase = "/server-redirect?"; |
| 235 return kServerRedirectBase + net::EscapeQueryParamValue(dest_url, false); | 235 return kServerRedirectBase + net::EscapeQueryParamValue(dest_url, false); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Clears the specified data using BrowsingDataRemover. | 238 // Clears the specified data using BrowsingDataRemover. |
| 239 void ClearBrowsingData(Browser* browser, int remove_mask) { | 239 void ClearBrowsingData(Browser* browser, int remove_mask) { |
| 240 BrowsingDataRemover* remover = | 240 content::BrowsingDataRemover* remover = |
| 241 BrowsingDataRemoverFactory::GetForBrowserContext(browser->profile()); | 241 content::BrowserContext::GetBrowsingDataRemover(browser->profile()); |
| 242 BrowsingDataRemoverCompletionObserver observer(remover); | 242 content::BrowsingDataRemoverCompletionObserver observer(remover); |
| 243 remover->RemoveAndReply(base::Time(), base::Time::Max(), remove_mask, | 243 remover->RemoveAndReply( |
| 244 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, | 244 base::Time(), base::Time::Max(), remove_mask, |
| 245 &observer); | 245 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, &observer); |
| 246 observer.BlockUntilCompletion(); | 246 observer.BlockUntilCompletion(); |
| 247 // BrowsingDataRemover deletes itself. | 247 // BrowsingDataRemover deletes itself. |
| 248 } | 248 } |
| 249 | 249 |
| 250 // Returns true if the prerender is expected to abort on its own, before | 250 // Returns true if the prerender is expected to abort on its own, before |
| 251 // attempting to swap it. | 251 // attempting to swap it. |
| 252 bool ShouldAbortPrerenderBeforeSwap(FinalStatus status) { | 252 bool ShouldAbortPrerenderBeforeSwap(FinalStatus status) { |
| 253 switch (status) { | 253 switch (status) { |
| 254 case FINAL_STATUS_USED: | 254 case FINAL_STATUS_USED: |
| 255 case FINAL_STATUS_WINDOW_OPENER: | 255 case FINAL_STATUS_WINDOW_OPENER: |
| (...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 EXPECT_EQ(0U, GetHistoryLength()); | 2526 EXPECT_EQ(0U, GetHistoryLength()); |
| 2527 } | 2527 } |
| 2528 | 2528 |
| 2529 // Checks that when the cache is cleared, prerenders are cancelled but | 2529 // Checks that when the cache is cleared, prerenders are cancelled but |
| 2530 // prerendering history is not cleared. | 2530 // prerendering history is not cleared. |
| 2531 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClearCache) { | 2531 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClearCache) { |
| 2532 std::unique_ptr<TestPrerender> prerender = | 2532 std::unique_ptr<TestPrerender> prerender = |
| 2533 PrerenderTestURL("/prerender/prerender_page.html", | 2533 PrerenderTestURL("/prerender/prerender_page.html", |
| 2534 FINAL_STATUS_CACHE_OR_HISTORY_CLEARED, 1); | 2534 FINAL_STATUS_CACHE_OR_HISTORY_CLEARED, 1); |
| 2535 | 2535 |
| 2536 ClearBrowsingData(current_browser(), BrowsingDataRemover::DATA_TYPE_CACHE); | 2536 ClearBrowsingData(current_browser(), |
| 2537 content::BrowsingDataRemover::DATA_TYPE_CACHE); |
| 2537 prerender->WaitForStop(); | 2538 prerender->WaitForStop(); |
| 2538 | 2539 |
| 2539 // Make sure prerender history was not cleared. Not a vital behavior, but | 2540 // Make sure prerender history was not cleared. Not a vital behavior, but |
| 2540 // used to compare with PrerenderClearHistory test. | 2541 // used to compare with PrerenderClearHistory test. |
| 2541 EXPECT_EQ(1U, GetHistoryLength()); | 2542 EXPECT_EQ(1U, GetHistoryLength()); |
| 2542 } | 2543 } |
| 2543 | 2544 |
| 2544 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { | 2545 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { |
| 2545 std::unique_ptr<TestPrerender> prerender = PrerenderTestURL( | 2546 std::unique_ptr<TestPrerender> prerender = PrerenderTestURL( |
| 2546 "/prerender/prerender_page.html", FINAL_STATUS_CANCELLED, 1); | 2547 "/prerender/prerender_page.html", FINAL_STATUS_CANCELLED, 1); |
| (...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3915 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, | 3916 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, |
| 3916 "DidDisplayReallyPass()", | 3917 "DidDisplayReallyPass()", |
| 3917 &display_test_result)); | 3918 &display_test_result)); |
| 3918 ASSERT_TRUE(display_test_result); | 3919 ASSERT_TRUE(display_test_result); |
| 3919 } | 3920 } |
| 3920 #endif // !defined(DISABLE_NACL) | 3921 #endif // !defined(DISABLE_NACL) |
| 3921 | 3922 |
| 3922 } // namespace prerender | 3923 } // namespace prerender |
| 3923 | 3924 |
| 3924 #endif // !defined(OS_MACOSX) || !defined(ADDRESS_SANITIZER) | 3925 #endif // !defined(OS_MACOSX) || !defined(ADDRESS_SANITIZER) |
| OLD | NEW |