Index: chrome/browser/chrome_site_per_process_browsertest.cc |
diff --git a/chrome/browser/chrome_site_per_process_browsertest.cc b/chrome/browser/chrome_site_per_process_browsertest.cc |
index e385c9ef3c642142343c7b2e1b041f800d99cfc4..d10a4877ab7a7c072b883d2fa2c0785c48494ebb 100644 |
--- a/chrome/browser/chrome_site_per_process_browsertest.cc |
+++ b/chrome/browser/chrome_site_per_process_browsertest.cc |
@@ -8,6 +8,9 @@ |
#include "base/path_service.h" |
#include "base/strings/stringprintf.h" |
#include "chrome/browser/chrome_notification_types.h" |
+#include "chrome/browser/external_protocol/external_protocol_handler.h" |
+#include "chrome/browser/external_protocol/external_protocol_handler_unittest.cc" |
alexmos
2016/12/01 19:21:13
Why do you need this? Is this for FakeExternalPro
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+#include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
@@ -362,3 +365,63 @@ IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessPDFTest, |
observer.Wait(); |
EXPECT_EQ(0U, test_guest_view_manager()->GetNumGuestsActive()); |
} |
+ |
+class RunsAtSomePointExternalProtocolHandlerDelegate |
alexmos
2016/12/01 19:21:13
Maybe name this MailtoExternalProtocolHandlerDeleg
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ : public ExternalProtocolHandler::Delegate { |
+ public: |
+ bool has_triggered_external_protocol = false; |
alexmos
2016/12/01 19:21:13
Usually, this would go under private:, and the nam
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ void RunExternalProtocolDialog(const GURL& url, |
+ int render_process_host_id, |
+ int routing_id, |
+ ui::PageTransition page_transition, |
+ bool has_user_gesture) override {} |
+ scoped_refptr<shell_integration::DefaultProtocolClientWorker> |
alexmos
2016/12/01 19:21:13
Let's separate out individual functions with blank
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ CreateShellWorker( |
+ const shell_integration::DefaultWebClientWorkerCallback& callback, |
+ const std::string& protocol) override { |
+ return new FakeExternalProtocolHandlerWorker( |
alexmos
2016/12/01 19:21:13
Instead of this, can you just return "new shell_in
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ callback, protocol, shell_integration::NOT_DEFAULT); |
+ } |
+ ExternalProtocolHandler::BlockState GetBlockState( |
+ const std::string& scheme) override { |
+ return ExternalProtocolHandler::GetBlockState(scheme); |
+ } |
+ void BlockRequest() override {} |
+ void LaunchUrlWithoutSecurityCheck( |
+ const GURL& url, |
+ content::WebContents* web_contents) override { |
+ if (!web_contents) |
+ return; |
+ has_triggered_external_protocol = true; |
alexmos
2016/12/01 19:21:14
Perhaps we should also save the |url| and |web_con
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ } |
+ void FinishedProcessingCheck() override {} |
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest, |
alexmos
2016/12/01 19:21:14
It's a good idea to describe the test in a comment
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ ExternalProtocolCrossSiteNavigation) { |
alexmos
2016/12/01 19:21:13
I think the test name should convey that an extern
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ RunsAtSomePointExternalProtocolHandlerDelegate* delegate = |
alexmos
2016/12/01 19:21:13
No need to use new/delete; this can just be a stac
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ new RunsAtSomePointExternalProtocolHandlerDelegate(); |
+ ChromeResourceDispatcherHostDelegate:: |
+ SetExternalProtocolHandlerDelegateForTesting(delegate); |
+ |
+ // Load an ordinary page to cause a new render view |
+ // host to be created for the WebContents. |
alexmos
2016/12/01 19:21:13
I don't think these details are important to the t
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ GURL start_url(embedded_test_server()->GetURL( |
+ "a.com", "//cross_site_iframe_factory.html?a()")); |
alexmos
2016/12/01 19:21:13
No need to use cross_site_iframe_factory here, sin
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ |
+ // TODO(davidsac): this does not appear to return a boolean to check that it |
+ // works??? |
alexmos
2016/12/01 19:21:14
Yes, this is a known issue that I've been hoping t
davidsac (gone - try alexmos)
2016/12/12 19:15:47
Done.
|
+ ui_test_utils::NavigateToURL(browser(), start_url); |
+ |
+ // Navigate to a page with a cross-site iframe that triggers a mailto: |
+ // external protocol request. |
alexmos
2016/12/01 19:21:13
I'd make this comment more about why you couldn't
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ GURL mailto_url( |
+ embedded_test_server()->GetURL("c.com", "/auto_mailto_main_frame.html")); |
alexmos
2016/12/01 19:21:13
You could avoid adding this new file by using an e
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ |
+ // TODO(davidsac): this does not appear to return a boolean to check that it |
+ // works??? |
alexmos
2016/12/01 19:21:13
Same comment as for NavigateToURL above.
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|
+ ui_test_utils::NavigateToURL(browser(), mailto_url); |
+ |
+ EXPECT_TRUE(delegate->has_triggered_external_protocol); |
+ delete delegate; |
+} |
alexmos
2016/12/01 19:21:13
Since SetExternalProtocolHandlerDelegateForTesting
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
|