Move view-source handling to the //content layer.
This CL moves most of handling of view-source into the //content layer,
exposing it through a single public API:
void RenderFrameHost::ViewSource()
This move helps to
- Avoid passing PageState to the //chrome layer (e.g. via
content::CustomContextMenuContext).
- Create browser tests that can simulate triggerring a view-source
from the code (e.g. without having to simulate mouse clicks).
- Ensure that the right navigation entries are used - preventing
incorrect reusing of main frame's site instance for showing
a subframe's view-source (https://crbug.com/770946)
This CL adds regression tests for https://crbug.com/523 that ensure that
view-source for HTTP POST works fine in case of main frame and subframe.
Works fine = no new network requests are issued (verified by a response
nonce added to the /echoall default handler in the embedded http test
server).
Bug: 770487, 770946, 774691, 699493
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: Ic0afeed898b4f0900f3f8ad47a903f83f2c589d3
Reviewed-on: https://chromium-review.googlesource.com/695913
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: Ćukasz Anforowicz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#512625}diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 268ebf5..3372c99 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -48,6 +48,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/service_manager_connection.h"
@@ -437,7 +438,10 @@
BookmarkAllTabs(browser_);
break;
case IDC_VIEW_SOURCE:
- ViewSelectedSource(browser_);
+ browser_->tab_strip_model()
+ ->GetActiveWebContents()
+ ->GetMainFrame()
+ ->ViewSource();
break;
case IDC_EMAIL_PAGE_LOCATION:
EmailPageLocation(browser_);