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

Side by Side Diff: chrome/browser/tab_contents/navigation_metrics_recorder.cc

Issue 2787123005: Block data URL navigations with RenderFrameImpl::DecidePolicyForNavigation (Closed)
Patch Set: Attempt another fix Created 3 years, 8 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/tab_contents/navigation_metrics_recorder.h" 5 #include "chrome/browser/tab_contents/navigation_metrics_recorder.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/tab_contents/origins_seen_service_factory.h" 10 #include "chrome/browser/tab_contents/origins_seen_service_factory.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 last_committed_entry->GetVirtualURL(), 88 last_committed_entry->GetVirtualURL(),
89 navigation_handle->IsSameDocument(), context->IsOffTheRecord(), 89 navigation_handle->IsSameDocument(), context->IsOffTheRecord(),
90 have_already_seen_origin); 90 have_already_seen_origin);
91 91
92 // Record the domain and registry of the URL that resulted in a navigation to 92 // Record the domain and registry of the URL that resulted in a navigation to
93 // a |data:| URL, either by redirects or user clicking a link. 93 // a |data:| URL, either by redirects or user clicking a link.
94 if (last_committed_entry->GetVirtualURL().SchemeIs(url::kDataScheme) && 94 if (last_committed_entry->GetVirtualURL().SchemeIs(url::kDataScheme) &&
95 !ui::PageTransitionCoreTypeIs(navigation_handle->GetPageTransition(), 95 !ui::PageTransitionCoreTypeIs(navigation_handle->GetPageTransition(),
96 ui::PAGE_TRANSITION_TYPED)) { 96 ui::PAGE_TRANSITION_TYPED)) {
97 if (!navigation_handle->GetPreviousURL().is_empty()) { 97 if (!navigation_handle->GetPreviousURL().is_empty()) {
98 // TODO(meacer): Remove once data URL navigations are blocked.
98 rappor::SampleDomainAndRegistryFromGURL( 99 rappor::SampleDomainAndRegistryFromGURL(
99 rappor_service_, "Navigation.Scheme.Data", 100 rappor_service_, "Navigation.Scheme.Data",
100 navigation_handle->GetPreviousURL()); 101 navigation_handle->GetPreviousURL());
101 } 102 }
102 103
103 // Also record the mime type of the data: URL. 104 // Also record the mime type of the data: URL.
104 std::string mime_type; 105 std::string mime_type;
105 std::string charset; 106 std::string charset;
107 // TODO(meacer): Remove once data URL navigations are blocked.
106 if (net::DataURL::Parse(last_committed_entry->GetVirtualURL(), &mime_type, 108 if (net::DataURL::Parse(last_committed_entry->GetVirtualURL(), &mime_type,
107 &charset, nullptr)) { 109 &charset, nullptr)) {
108 RecordDataURLMimeType(mime_type); 110 RecordDataURLMimeType(mime_type);
109 } 111 }
110 } 112 }
111 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698