diff options
author | carlosk <carlosk@chromium.org> | 2015-12-16 06:40:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-16 14:41:34 +0000 |
commit | d80262f530419ce91eedddff4347949875b5db92 (patch) | |
tree | b31001bd84cfb3cfb83fc8aadccfa3d29e78dab9 /content/test | |
parent | 7624161daedad7c0639635f92cae95ce267d7ce1 (diff) | |
download | chromium_src-d80262f530419ce91eedddff4347949875b5db92.zip chromium_src-d80262f530419ce91eedddff4347949875b5db92.tar.gz chromium_src-d80262f530419ce91eedddff4347949875b5db92.tar.bz2 |
PlzNavigate: Add helper method for checking if PlzNavigate is enabled.
In the interest of simplifying the code for checking if browser side
navigation is enabled this change creates a new helper method and
replaces all current occurrences of the "extended" form.
BUG=368813
TBR=mmenke@chromium.org
Review URL: https://codereview.chromium.org/1517643002
Cr-Commit-Position: refs/heads/master@{#365527}
Diffstat (limited to 'content/test')
-rw-r--r-- | content/test/test_render_frame.cc | 6 | ||||
-rw-r--r-- | content/test/test_render_frame_host.cc | 25 | ||||
-rw-r--r-- | content/test/test_web_contents.cc | 16 |
3 files changed, 15 insertions, 32 deletions
diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc index 1544c2a..f63a0c8 100644 --- a/content/test/test_render_frame.cc +++ b/content/test/test_render_frame.cc @@ -4,9 +4,8 @@ #include "content/test/test_render_frame.h" -#include "base/command_line.h" #include "content/common/navigation_params.h" -#include "content/public/common/content_switches.h" +#include "content/public/common/browser_side_navigation_policy.h" #include "content/public/common/resource_response.h" namespace content { @@ -28,8 +27,7 @@ void TestRenderFrame::Navigate(const CommonNavigationParams& common_params, const StartNavigationParams& start_params, const RequestNavigationParams& request_params) { // PlzNavigate - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { OnCommitNavigation(ResourceResponseHead(), GURL(), common_params, request_params); } else { diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc index 78e960c..68ab1c6 100644 --- a/content/test/test_render_frame_host.cc +++ b/content/test/test_render_frame_host.cc @@ -4,7 +4,6 @@ #include "content/test/test_render_frame_host.h" -#include "base/command_line.h" #include "content/browser/frame_host/frame_tree.h" #include "content/browser/frame_host/navigation_handle_impl.h" #include "content/browser/frame_host/navigation_request.h" @@ -14,7 +13,7 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/frame_messages.h" #include "content/public/browser/stream_handle.h" -#include "content/public/common/content_switches.h" +#include "content/public/common/browser_side_navigation_policy.h" #include "content/public/common/url_constants.h" #include "content/test/browser_side_navigation_test_utils.h" #include "content/test/test_navigation_url_loader.h" @@ -92,8 +91,7 @@ TestRenderFrameHost* TestRenderFrameHost::AppendChild( } void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { SendRendererInitiatedNavigationRequest(url, false); return; } @@ -103,8 +101,7 @@ void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) { } void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { NavigationRequest* request = frame_tree_node_->navigation_request(); TestNavigationURLLoader* url_loader = static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); @@ -151,8 +148,7 @@ void TestRenderFrameHost::SimulateNavigationCommit(const GURL& url) { void TestRenderFrameHost::SimulateNavigationError(const GURL& url, int error_code) { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { NavigationRequest* request = frame_tree_node_->navigation_request(); CHECK(request); // Simulate a beforeUnload ACK from the renderer if the browser is waiting @@ -195,8 +191,7 @@ void TestRenderFrameHost::SimulateNavigationErrorPageCommit() { void TestRenderFrameHost::SimulateNavigationStop() { if (is_loading()) { OnDidStopLoading(); - } else if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + } else if (IsBrowserSideNavigationEnabled()) { // Even if the RenderFrameHost is not loading, there may still be an // ongoing navigation in the FrameTreeNode. Cancel this one as well. frame_tree_node()->ResetNavigationRequest(false); @@ -323,9 +318,7 @@ void TestRenderFrameHost::NavigateAndCommitRendererInitiated( // stack commit. if (frame_tree_node()->navigation_request()) PrepareForCommit(); - bool browser_side_navigation = - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation); + bool browser_side_navigation = IsBrowserSideNavigationEnabled(); CHECK(!browser_side_navigation || is_loading()); CHECK(!browser_side_navigation || !frame_tree_node()->navigation_request()); SendNavigate(page_id, 0, did_create_new_entry, url); @@ -338,8 +331,7 @@ void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( // initialized. Do it if it hasn't happened yet. InitializeRenderFrameIfNeeded(); - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, has_user_gesture, false, REQUEST_CONTEXT_TYPE_HYPERLINK); @@ -362,8 +354,7 @@ void TestRenderFrameHost::PrepareForCommit() { void TestRenderFrameHost::PrepareForCommitWithServerRedirect( const GURL& redirect_url) { - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (!IsBrowserSideNavigationEnabled()) { // Non PlzNavigate if (is_waiting_for_beforeunload_ack()) SendBeforeUnloadACK(true); diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc index 788081a..c1ca5ea 100644 --- a/content/test/test_web_contents.cc +++ b/content/test/test_web_contents.cc @@ -6,7 +6,6 @@ #include <utility> -#include "base/command_line.h" #include "content/browser/browser_url_handler_impl.h" #include "content/browser/frame_host/cross_process_frame_connector.h" #include "content/browser/frame_host/navigation_entry_impl.h" @@ -19,7 +18,7 @@ #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" -#include "content/public/common/content_switches.h" +#include "content/public/common/browser_side_navigation_policy.h" #include "content/public/common/page_state.h" #include "content/public/test/mock_render_process_host.h" #include "content/test/test_render_view_host.h" @@ -55,8 +54,7 @@ TestRenderViewHost* TestWebContents::GetRenderViewHost() const { } TestRenderFrameHost* TestWebContents::GetPendingMainFrame() const { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { return static_cast<TestRenderFrameHost*>( GetRenderManager()->speculative_render_frame_host_.get()); } @@ -74,8 +72,7 @@ void TestWebContents::StartNavigation(const GURL& url) { // This will simulate receiving the DidStartProvisionalLoad IPC from the // renderer. - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (!IsBrowserSideNavigationEnabled()) { if (GetMainFrame()->is_waiting_for_beforeunload_ack()) GetMainFrame()->SendBeforeUnloadACK(true); TestRenderFrameHost* rfh = @@ -150,8 +147,7 @@ const std::string& TestWebContents::GetSaveFrameHeaders() { } bool TestWebContents::CrossProcessNavigationPending() { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation)) { + if (IsBrowserSideNavigationEnabled()) { return GetRenderManager()->speculative_render_frame_host_ && static_cast<TestRenderFrameHost*>( GetRenderManager()->speculative_render_frame_host_.get()) @@ -215,9 +211,7 @@ void TestWebContents::CommitPendingNavigation() { // Note that for some synchronous navigations (about:blank, javascript // urls, etc.) there will be no NavigationRequest, and no simulation of the // network stack is required. - bool browser_side_navigation = - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableBrowserSideNavigation); + bool browser_side_navigation = IsBrowserSideNavigationEnabled(); if (!browser_side_navigation || GetMainFrame()->frame_tree_node()->navigation_request()) { GetMainFrame()->PrepareForCommit(); |