Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/external_protocol/external_protocol_handler.h" | |
| 12 #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.
| |
| 13 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" | |
| 11 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "components/guest_view/browser/guest_view_manager_delegate.h" | 19 #include "components/guest_view/browser/guest_view_manager_delegate.h" |
| 17 #include "components/guest_view/browser/test_guest_view_manager.h" | 20 #include "components/guest_view/browser/test_guest_view_manager.h" |
| 18 #include "content/public/browser/interstitial_page.h" | 21 #include "content/public/browser/interstitial_page.h" |
| 19 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 test_guest_view_manager()->WaitForSingleGuestCreated(); | 358 test_guest_view_manager()->WaitForSingleGuestCreated(); |
| 356 | 359 |
| 357 // Now detach the frame and observe that the guest is destroyed. | 360 // Now detach the frame and observe that the guest is destroyed. |
| 358 content::WebContentsDestroyedWatcher observer(guest_web_contents); | 361 content::WebContentsDestroyedWatcher observer(guest_web_contents); |
| 359 EXPECT_TRUE(ExecuteScript( | 362 EXPECT_TRUE(ExecuteScript( |
| 360 active_web_contents, | 363 active_web_contents, |
| 361 "document.body.removeChild(document.querySelector('iframe'));")); | 364 "document.body.removeChild(document.querySelector('iframe'));")); |
| 362 observer.Wait(); | 365 observer.Wait(); |
| 363 EXPECT_EQ(0U, test_guest_view_manager()->GetNumGuestsActive()); | 366 EXPECT_EQ(0U, test_guest_view_manager()->GetNumGuestsActive()); |
| 364 } | 367 } |
| 368 | |
| 369 class RunsAtSomePointExternalProtocolHandlerDelegate | |
|
alexmos
2016/12/01 19:21:13
Maybe name this MailtoExternalProtocolHandlerDeleg
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
| |
| 370 : public ExternalProtocolHandler::Delegate { | |
| 371 public: | |
| 372 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.
| |
| 373 void RunExternalProtocolDialog(const GURL& url, | |
| 374 int render_process_host_id, | |
| 375 int routing_id, | |
| 376 ui::PageTransition page_transition, | |
| 377 bool has_user_gesture) override {} | |
| 378 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.
| |
| 379 CreateShellWorker( | |
| 380 const shell_integration::DefaultWebClientWorkerCallback& callback, | |
| 381 const std::string& protocol) override { | |
| 382 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.
| |
| 383 callback, protocol, shell_integration::NOT_DEFAULT); | |
| 384 } | |
| 385 ExternalProtocolHandler::BlockState GetBlockState( | |
| 386 const std::string& scheme) override { | |
| 387 return ExternalProtocolHandler::GetBlockState(scheme); | |
| 388 } | |
| 389 void BlockRequest() override {} | |
| 390 void LaunchUrlWithoutSecurityCheck( | |
| 391 const GURL& url, | |
| 392 content::WebContents* web_contents) override { | |
| 393 if (!web_contents) | |
| 394 return; | |
| 395 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.
| |
| 396 } | |
| 397 void FinishedProcessingCheck() override {} | |
| 398 }; | |
| 399 | |
| 400 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.
| |
| 401 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.
| |
| 402 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.
| |
| 403 new RunsAtSomePointExternalProtocolHandlerDelegate(); | |
| 404 ChromeResourceDispatcherHostDelegate:: | |
| 405 SetExternalProtocolHandlerDelegateForTesting(delegate); | |
| 406 | |
| 407 // Load an ordinary page to cause a new render view | |
| 408 // 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.
| |
| 409 GURL start_url(embedded_test_server()->GetURL( | |
| 410 "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.
| |
| 411 | |
| 412 // TODO(davidsac): this does not appear to return a boolean to check that it | |
| 413 // 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.
| |
| 414 ui_test_utils::NavigateToURL(browser(), start_url); | |
| 415 | |
| 416 // Navigate to a page with a cross-site iframe that triggers a mailto: | |
| 417 // 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.
| |
| 418 GURL mailto_url( | |
| 419 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.
| |
| 420 | |
| 421 // TODO(davidsac): this does not appear to return a boolean to check that it | |
| 422 // 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.
| |
| 423 ui_test_utils::NavigateToURL(browser(), mailto_url); | |
| 424 | |
| 425 EXPECT_TRUE(delegate->has_triggered_external_protocol); | |
| 426 delete delegate; | |
| 427 } | |
|
alexmos
2016/12/01 19:21:13
Since SetExternalProtocolHandlerDelegateForTesting
davidsac (gone - try alexmos)
2016/12/12 19:15:46
Done.
| |
| OLD | NEW |