Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2362033002: Showing previews UI for Offline Previews (Closed)
Patch Set: megjablon comments rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/loader/chrome_resource_dispatcher_host_delegate.h" 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 29 matching lines...) Expand all
40 #include "chrome/browser/signin/chrome_signin_helper.h" 40 #include "chrome/browser/signin/chrome_signin_helper.h"
41 #include "chrome/browser/tab_contents/tab_util.h" 41 #include "chrome/browser/tab_contents/tab_util.h"
42 #include "chrome/browser/ui/login/login_handler.h" 42 #include "chrome/browser/ui/login/login_handler.h"
43 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/features.h" 44 #include "chrome/common/features.h"
45 #include "chrome/common/url_constants.h" 45 #include "chrome/common/url_constants.h"
46 #include "components/content_settings/core/browser/host_content_settings_map.h" 46 #include "components/content_settings/core/browser/host_content_settings_map.h"
47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h"
48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" 48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
49 #include "components/google/core/browser/google_util.h" 49 #include "components/google/core/browser/google_util.h"
50 #include "components/offline_pages/loaded_offline_page_info.h"
50 #include "components/policy/core/common/cloud/policy_header_io_helper.h" 51 #include "components/policy/core/common/cloud/policy_header_io_helper.h"
51 #include "components/rappor/rappor_utils.h" 52 #include "components/rappor/rappor_utils.h"
52 #include "components/search_engines/template_url_service.h" 53 #include "components/search_engines/template_url_service.h"
53 #include "components/variations/net/variations_http_headers.h" 54 #include "components/variations/net/variations_http_headers.h"
54 #include "content/public/browser/browser_thread.h" 55 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/navigation_data.h" 56 #include "content/public/browser/navigation_data.h"
56 #include "content/public/browser/notification_service.h" 57 #include "content/public/browser/notification_service.h"
57 #include "content/public/browser/plugin_service.h" 58 #include "content/public/browser/plugin_service.h"
58 #include "content/public/browser/plugin_service_filter.h" 59 #include "content/public/browser/plugin_service_filter.h"
59 #include "content/public/browser/render_frame_host.h" 60 #include "content/public/browser/render_frame_host.h"
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 // static 821 // static
821 void ChromeResourceDispatcherHostDelegate:: 822 void ChromeResourceDispatcherHostDelegate::
822 SetExternalProtocolHandlerDelegateForTesting( 823 SetExternalProtocolHandlerDelegateForTesting(
823 ExternalProtocolHandler::Delegate* delegate) { 824 ExternalProtocolHandler::Delegate* delegate) {
824 g_external_protocol_handler_delegate = delegate; 825 g_external_protocol_handler_delegate = delegate;
825 } 826 }
826 827
827 content::NavigationData* 828 content::NavigationData*
828 ChromeResourceDispatcherHostDelegate::GetNavigationData( 829 ChromeResourceDispatcherHostDelegate::GetNavigationData(
829 net::URLRequest* request) const { 830 net::URLRequest* request) const {
831 if (!request)
832 return nullptr;
830 ChromeNavigationData* data = 833 ChromeNavigationData* data =
831 ChromeNavigationData::GetDataAndCreateIfNecessary(request); 834 ChromeNavigationData::GetDataAndCreateIfNecessary(request);
832 if (!request)
833 return data;
834 835
836 // DeepCopy DataReductionProxyData and LoadedOfflinePageInfo from |request| to
837 // prevent. This copy will be shortlived as it will be deep copied again
838 // when content makes a clone of NavigationData for the UI thread.
835 data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data = 839 data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data =
836 data_reduction_proxy::DataReductionProxyData::GetData(*request); 840 data_reduction_proxy::DataReductionProxyData::GetData(*request);
837 // DeepCopy the DataReductionProxyData from the URLRequest to prevent the
838 // URLRequest and DataReductionProxyData from both having ownership of the
839 // same object. This copy will be shortlived as it will be deep copied again
840 // when content makes a clone of NavigationData for the UI thread.
841 if (data_reduction_proxy_data) 841 if (data_reduction_proxy_data)
842 data->SetDataReductionProxyData(data_reduction_proxy_data->DeepCopy()); 842 data->SetDataReductionProxyData(data_reduction_proxy_data->DeepCopy());
843 offline_pages::LoadedOfflinePageInfo* loaded_offline_page_info =
844 offline_pages::LoadedOfflinePageInfo::GetInfo(*request);
845 if (loaded_offline_page_info)
846 data->SetLoadedOfflinePageInfo(loaded_offline_page_info->DeepCopy());
847
843 return data; 848 return data;
844 } 849 }
845 850
846 std::unique_ptr<net::ClientCertStore> 851 std::unique_ptr<net::ClientCertStore>
847 ChromeResourceDispatcherHostDelegate::CreateClientCertStore( 852 ChromeResourceDispatcherHostDelegate::CreateClientCertStore(
848 content::ResourceContext* resource_context) { 853 content::ResourceContext* resource_context) {
849 return ProfileIOData::FromResourceContext(resource_context)-> 854 return ProfileIOData::FromResourceContext(resource_context)->
850 CreateClientCertStore(); 855 CreateClientCertStore();
851 } 856 }
852 857
853 // Record RAPPOR for aborted main frame loads. Separate into a fast and 858 // Record RAPPOR for aborted main frame loads. Separate into a fast and
854 // slow bucket because a shocking number of aborts happen under 100ms. 859 // slow bucket because a shocking number of aborts happen under 100ms.
855 void ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad( 860 void ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad(
856 const GURL& url, 861 const GURL& url,
857 base::TimeDelta request_loading_time) { 862 base::TimeDelta request_loading_time) {
858 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 863 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
859 BrowserThread::PostTask( 864 BrowserThread::PostTask(
860 BrowserThread::UI, FROM_HERE, 865 BrowserThread::UI, FROM_HERE,
861 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 866 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
862 base::Unretained(this), url, request_loading_time)); 867 base::Unretained(this), url, request_loading_time));
863 return; 868 return;
864 } 869 }
865 870
866 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 871 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
867 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 872 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
868 rappor::SampleDomainAndRegistryFromGURL( 873 rappor::SampleDomainAndRegistryFromGURL(
869 g_browser_process->rappor_service(), metric_name, url); 874 g_browser_process->rappor_service(), metric_name, url);
870 } 875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698