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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/browser/download/download_manager_impl.h" | 9 #include "content/browser/download/download_manager_impl.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/resource_dispatcher_host.h" | |
14 #include "content/public/browser/resource_dispatcher_host_delegate.h" | |
15 #include "content/public/browser/resource_request_info.h" | |
13 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
15 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
16 #include "content/public/test/content_browser_test.h" | 19 #include "content/public/test/content_browser_test.h" |
17 #include "content/public/test/content_browser_test_utils.h" | 20 #include "content/public/test/content_browser_test_utils.h" |
18 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
19 #include "content/shell/browser/shell.h" | 22 #include "content/shell/browser/shell.h" |
20 #include "content/shell/browser/shell_content_browser_client.h" | 23 #include "content/shell/browser/shell_content_browser_client.h" |
21 #include "content/shell/browser/shell_network_delegate.h" | 24 #include "content/shell/browser/shell_network_delegate.h" |
22 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 std::string set_cookie_url(base::StringPrintf( | 468 std::string set_cookie_url(base::StringPrintf( |
466 "http://localhost:%d/set_cookie.html", embedded_test_server()->port())); | 469 "http://localhost:%d/set_cookie.html", embedded_test_server()->port())); |
467 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url)); | 470 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url)); |
468 | 471 |
469 ShellContentBrowserClient::SetSwapProcessesForRedirect(true); | 472 ShellContentBrowserClient::SetSwapProcessesForRedirect(true); |
470 ShellNetworkDelegate::SetAcceptAllCookies(false); | 473 ShellNetworkDelegate::SetAcceptAllCookies(false); |
471 | 474 |
472 CheckTitleTest(url, "cookie set"); | 475 CheckTitleTest(url, "cookie set"); |
473 } | 476 } |
474 | 477 |
478 class PageTransitionResourceDispatcherHostDelegate | |
479 : public ResourceDispatcherHostDelegate { | |
480 public: | |
481 PageTransitionResourceDispatcherHostDelegate(GURL watch) : watch_(watch) {} | |
482 | |
483 // ResourceDispatcherHostDelegate implementation: | |
484 | |
Charlie Reis
2014/11/13 00:49:35
nit: No blank line.
| |
485 void RequestBeginning(net::URLRequest* request, | |
486 ResourceContext* resource_context, | |
487 AppCacheService* appcache_service, | |
488 ResourceType resource_type, | |
489 ScopedVector<ResourceThrottle>* throttles) override { | |
490 if (request->url() == watch_) { | |
491 const ResourceRequestInfo* info = | |
492 ResourceRequestInfo::ForRequest(request); | |
493 page_transition_ = info->GetPageTransition(); | |
494 } | |
495 } | |
496 | |
497 ui::PageTransition page_transition() { return page_transition_; } | |
498 | |
499 private: | |
500 GURL watch_; | |
Charlie Reis
2014/11/13 00:49:35
nit: watch_url_
| |
501 ui::PageTransition page_transition_; | |
502 }; | |
503 | |
504 // Test that ui::PAGE_TRANSITION_CLIENT_REDIRECT is correctly set | |
505 // when encountering a meta refresh tag. | |
506 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | |
507 PageTransitionClientRedirect) { | |
508 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
509 | |
510 PageTransitionResourceDispatcherHostDelegate delegate( | |
511 embedded_test_server()->GetURL("/some_page.html")); | |
512 ResourceDispatcherHost::Get()->SetDelegate(&delegate); | |
513 | |
514 NavigateToURL(shell(), | |
515 embedded_test_server()->GetURL("/client_redirect.html")); | |
516 | |
517 EXPECT_TRUE( | |
518 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); | |
519 } | |
520 | |
475 } // namespace content | 521 } // namespace content |
OLD | NEW |