| 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 "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/browser/profiles/profile_io_data.h" | 31 #include "chrome/browser/profiles/profile_io_data.h" |
| 32 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" | 32 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" |
| 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 34 #include "chrome/browser/signin/signin_header_helper.h" | 34 #include "chrome/browser/signin/signin_header_helper.h" |
| 35 #include "chrome/browser/ui/auto_login_prompter.h" | 35 #include "chrome/browser/ui/auto_login_prompter.h" |
| 36 #include "chrome/browser/ui/login/login_prompt.h" | 36 #include "chrome/browser/ui/login/login_prompt.h" |
| 37 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 37 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 38 #include "chrome/common/extensions/extension_constants.h" | 38 #include "chrome/common/extensions/extension_constants.h" |
| 39 #include "chrome/common/extensions/mime_types_handler.h" | 39 #include "chrome/common/extensions/mime_types_handler.h" |
| 40 #include "chrome/common/render_messages.h" | 40 #include "chrome/common/render_messages.h" |
| 41 #include "chrome/common/url_constants.h" | |
| 42 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 43 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 44 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
| 45 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
| 46 #include "content/public/browser/resource_context.h" | 45 #include "content/public/browser/resource_context.h" |
| 47 #include "content/public/browser/resource_dispatcher_host.h" | 46 #include "content/public/browser/resource_dispatcher_host.h" |
| 48 #include "content/public/browser/resource_request_info.h" | 47 #include "content/public/browser/resource_request_info.h" |
| 49 #include "content/public/browser/stream_handle.h" | 48 #include "content/public/browser/stream_handle.h" |
| 50 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/common/resource_response.h" | 50 #include "content/public/common/resource_response.h" |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); | 605 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); |
| 607 if (request->url().DomainIs(webstore_url.host().c_str())) { | 606 if (request->url().DomainIs(webstore_url.host().c_str())) { |
| 608 net::HttpResponseHeaders* response_headers = request->response_headers(); | 607 net::HttpResponseHeaders* response_headers = request->response_headers(); |
| 609 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && | 608 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && |
| 610 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { | 609 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { |
| 611 response_headers->RemoveHeader("x-frame-options"); | 610 response_headers->RemoveHeader("x-frame-options"); |
| 612 response_headers->AddHeader("x-frame-options: sameorigin"); | 611 response_headers->AddHeader("x-frame-options: sameorigin"); |
| 613 } | 612 } |
| 614 } | 613 } |
| 615 | 614 |
| 616 // Ignores x-frame-options for the chrome signin UI. | |
| 617 if (request->first_party_for_cookies().GetOrigin().spec() == | |
| 618 chrome::kChromeUIChromeSigninURL) { | |
| 619 net::HttpResponseHeaders* response_headers = request->response_headers(); | |
| 620 if (response_headers->HasHeader("x-frame-options")) | |
| 621 response_headers->RemoveHeader("x-frame-options"); | |
| 622 } | |
| 623 | |
| 624 prerender::URLRequestResponseStarted(request); | 615 prerender::URLRequestResponseStarted(request); |
| 625 } | 616 } |
| 626 | 617 |
| 627 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 618 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
| 628 const GURL& redirect_url, | 619 const GURL& redirect_url, |
| 629 net::URLRequest* request, | 620 net::URLRequest* request, |
| 630 content::ResourceContext* resource_context, | 621 content::ResourceContext* resource_context, |
| 631 content::ResourceResponse* response) { | 622 content::ResourceResponse* response) { |
| 632 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 623 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 633 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 624 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 url_request->GetTotalReceivedBytes())); | 657 url_request->GetTotalReceivedBytes())); |
| 667 } | 658 } |
| 668 } | 659 } |
| 669 | 660 |
| 670 // static | 661 // static |
| 671 void ChromeResourceDispatcherHostDelegate:: | 662 void ChromeResourceDispatcherHostDelegate:: |
| 672 SetExternalProtocolHandlerDelegateForTesting( | 663 SetExternalProtocolHandlerDelegateForTesting( |
| 673 ExternalProtocolHandler::Delegate* delegate) { | 664 ExternalProtocolHandler::Delegate* delegate) { |
| 674 g_external_protocol_handler_delegate = delegate; | 665 g_external_protocol_handler_delegate = delegate; |
| 675 } | 666 } |
| OLD | NEW |