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

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

Issue 2362033002: Showing previews UI for Offline Previews (Closed)
Patch Set: typo 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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 // static 823 // static
823 void ChromeResourceDispatcherHostDelegate:: 824 void ChromeResourceDispatcherHostDelegate::
824 SetExternalProtocolHandlerDelegateForTesting( 825 SetExternalProtocolHandlerDelegateForTesting(
825 ExternalProtocolHandler::Delegate* delegate) { 826 ExternalProtocolHandler::Delegate* delegate) {
826 g_external_protocol_handler_delegate = delegate; 827 g_external_protocol_handler_delegate = delegate;
827 } 828 }
828 829
829 content::NavigationData* 830 content::NavigationData*
830 ChromeResourceDispatcherHostDelegate::GetNavigationData( 831 ChromeResourceDispatcherHostDelegate::GetNavigationData(
831 net::URLRequest* request) const { 832 net::URLRequest* request) const {
833 if (!request)
834 return nullptr;
832 ChromeNavigationData* data = 835 ChromeNavigationData* data =
833 ChromeNavigationData::GetDataAndCreateIfNecessary(request); 836 ChromeNavigationData::GetDataAndCreateIfNecessary(request);
834 if (!request)
835 return data;
836 837
838 // DeepCopy DataReductionProxyData and LoadedOfflinePageInfo from |request| to
839 // prevent. This copy will be shortlived as it will be deep copied again
840 // when content makes a clone of NavigationData for the UI thread.
837 data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data = 841 data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data =
838 data_reduction_proxy::DataReductionProxyData::GetData(*request); 842 data_reduction_proxy::DataReductionProxyData::GetData(*request);
839 // DeepCopy the DataReductionProxyData from the URLRequest to prevent the
840 // URLRequest and DataReductionProxyData from both having ownership of the
841 // same object. This copy will be shortlived as it will be deep copied again
842 // when content makes a clone of NavigationData for the UI thread.
843 if (data_reduction_proxy_data) 843 if (data_reduction_proxy_data)
844 data->SetDataReductionProxyData(data_reduction_proxy_data->DeepCopy()); 844 data->SetDataReductionProxyData(data_reduction_proxy_data->DeepCopy());
845 offline_pages::LoadedOfflinePageInfo* loaded_offline_page_info =
846 offline_pages::LoadedOfflinePageInfo::GetInfo(*request);
847 if (loaded_offline_page_info)
848 data->SetLoadedOfflinePageInfo(loaded_offline_page_info->DeepCopy());
849
845 return data; 850 return data;
846 } 851 }
847 852
848 std::unique_ptr<net::ClientCertStore> 853 std::unique_ptr<net::ClientCertStore>
849 ChromeResourceDispatcherHostDelegate::CreateClientCertStore( 854 ChromeResourceDispatcherHostDelegate::CreateClientCertStore(
850 content::ResourceContext* resource_context) { 855 content::ResourceContext* resource_context) {
851 return ProfileIOData::FromResourceContext(resource_context)-> 856 return ProfileIOData::FromResourceContext(resource_context)->
852 CreateClientCertStore(); 857 CreateClientCertStore();
853 } 858 }
854 859
855 // Record RAPPOR for aborted main frame loads. Separate into a fast and 860 // Record RAPPOR for aborted main frame loads. Separate into a fast and
856 // slow bucket because a shocking number of aborts happen under 100ms. 861 // slow bucket because a shocking number of aborts happen under 100ms.
857 void ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad( 862 void ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad(
858 const GURL& url, 863 const GURL& url,
859 base::TimeDelta request_loading_time) { 864 base::TimeDelta request_loading_time) {
860 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 865 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
861 BrowserThread::PostTask( 866 BrowserThread::PostTask(
862 BrowserThread::UI, FROM_HERE, 867 BrowserThread::UI, FROM_HERE,
863 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 868 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
864 base::Unretained(this), url, request_loading_time)); 869 base::Unretained(this), url, request_loading_time));
865 return; 870 return;
866 } 871 }
867 872
868 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 873 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
869 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 874 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
870 rappor::SampleDomainAndRegistryFromGURL( 875 rappor::SampleDomainAndRegistryFromGURL(
871 g_browser_process->rappor_service(), metric_name, url); 876 g_browser_process->rappor_service(), metric_name, url);
872 } 877 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698