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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2946113002: Use FrameIsAd to decide whether to isolate a frame in TopDocumentIsolation mode. (Closed)
Patch Set: Use FOR_EACH_TDI_MODE(V) macro. Created 3 years, 5 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/scoped_file.h" 16 #include "base/files/scoped_file.h"
17 #include "base/i18n/character_encoding.h" 17 #include "base/i18n/character_encoding.h"
18 #include "base/json/json_reader.h" 18 #include "base/json/json_reader.h"
19 #include "base/lazy_instance.h" 19 #include "base/lazy_instance.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/metrics/field_trial_params.h"
22 #include "base/metrics/histogram_macros.h" 23 #include "base/metrics/histogram_macros.h"
23 #include "base/path_service.h" 24 #include "base/path_service.h"
24 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
25 #include "base/strings/string_split.h" 26 #include "base/strings/string_split.h"
26 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
27 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 29 #include "base/strings/utf_string_conversions.h"
29 #include "base/threading/sequenced_worker_pool.h" 30 #include "base/threading/sequenced_worker_pool.h"
30 #include "base/threading/thread_task_runner_handle.h" 31 #include "base/threading/thread_task_runner_handle.h"
31 #include "build/build_config.h" 32 #include "build/build_config.h"
(...skipping 18 matching lines...) Expand all
50 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" 51 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
51 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp l.h" 52 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp l.h"
52 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 53 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
53 #include "chrome/browser/memory/chrome_memory_coordinator_delegate.h" 54 #include "chrome/browser/memory/chrome_memory_coordinator_delegate.h"
54 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" 55 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
55 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 56 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
56 #include "chrome/browser/net_benchmarking.h" 57 #include "chrome/browser/net_benchmarking.h"
57 #include "chrome/browser/notifications/platform_notification_service_impl.h" 58 #include "chrome/browser/notifications/platform_notification_service_impl.h"
58 #include "chrome/browser/page_load_metrics/experiments/delay_navigation_throttle .h" 59 #include "chrome/browser/page_load_metrics/experiments/delay_navigation_throttle .h"
59 #include "chrome/browser/page_load_metrics/metrics_navigation_throttle.h" 60 #include "chrome/browser/page_load_metrics/metrics_navigation_throttle.h"
61 #include "chrome/browser/page_load_metrics/observers/ads_detection.h"
60 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 62 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
61 #include "chrome/browser/permissions/permission_context_base.h" 63 #include "chrome/browser/permissions/permission_context_base.h"
62 #include "chrome/browser/platform_util.h" 64 #include "chrome/browser/platform_util.h"
63 #include "chrome/browser/prefs/active_profile_pref_service.h" 65 #include "chrome/browser/prefs/active_profile_pref_service.h"
64 #include "chrome/browser/prerender/prerender_final_status.h" 66 #include "chrome/browser/prerender/prerender_final_status.h"
65 #include "chrome/browser/prerender/prerender_manager.h" 67 #include "chrome/browser/prerender/prerender_manager.h"
66 #include "chrome/browser/prerender/prerender_manager_factory.h" 68 #include "chrome/browser/prerender/prerender_manager_factory.h"
67 #include "chrome/browser/prerender/prerender_message_filter.h" 69 #include "chrome/browser/prerender/prerender_message_filter.h"
68 #include "chrome/browser/printing/printing_message_filter.h" 70 #include "chrome/browser/printing/printing_message_filter.h"
69 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" 71 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 *is_renderer_initiated = false; 1333 *is_renderer_initiated = false;
1332 *referrer = content::Referrer(); 1334 *referrer = content::Referrer();
1333 } 1335 }
1334 1336
1335 #if BUILDFLAG(ENABLE_EXTENSIONS) 1337 #if BUILDFLAG(ENABLE_EXTENSIONS)
1336 ChromeContentBrowserClientExtensionsPart::OverrideNavigationParams( 1338 ChromeContentBrowserClientExtensionsPart::OverrideNavigationParams(
1337 site_instance, transition, is_renderer_initiated, referrer); 1339 site_instance, transition, is_renderer_initiated, referrer);
1338 #endif 1340 #endif
1339 } 1341 }
1340 1342
1341 bool ChromeContentBrowserClient:: 1343 bool ChromeContentBrowserClient::ShouldIsolateFrameFromMainContent(
1342 ShouldFrameShareParentSiteInstanceDespiteTopDocumentIsolation( 1344 content::RenderFrameHost* frame,
1343 const GURL& url, 1345 const GURL& dest_url,
1344 content::SiteInstance* parent_site_instance) { 1346 content::SiteInstance* main_frame_site_instance) {
1345 if (IsNTPSiteInstance(parent_site_instance)) 1347 if (IsNTPSiteInstance(main_frame_site_instance))
1346 return true; 1348 return false;
1347 1349
1348 #if BUILDFLAG(ENABLE_EXTENSIONS) 1350 #if BUILDFLAG(ENABLE_EXTENSIONS)
1349 return ChromeContentBrowserClientExtensionsPart:: 1351 if (ChromeContentBrowserClientExtensionsPart::
1350 ShouldFrameShareParentSiteInstanceDespiteTopDocumentIsolation( 1352 IsMainFrameSiteInstanceExcludedFromTopDocumentIsolation(
1351 url, parent_site_instance); 1353 main_frame_site_instance))
1352 #else 1354 return false;
1355 #endif
1356
1357 features::TopDocumentIsolationMode tdiMode =
1358 static_cast<features::TopDocumentIsolationMode>(
1359 base::GetFieldTrialParamByFeatureAsInt(
1360 ::features::kTopDocumentIsolation,
1361 ::features::kTopDocumentIsolationModeParam,
1362 static_cast<int>(features::TopDocumentIsolationMode::Default)));
1363 switch (tdiMode) {
1364 case features::TopDocumentIsolationMode::Default:
Charlie Reis 2017/06/30 23:28:45 I thought "Default" meant disabled? Shouldn't we
Łukasz Anforowicz 2017/07/01 00:10:53 TDI state has 2 parts: part1: is the feature enabl
Charlie Reis 2017/07/06 20:02:29 Thanks, I understand now. Yes, we should try to m
1365 case features::TopDocumentIsolationMode::Ads:
1366 return IsAdFrame(frame->GetFrameName(), dest_url);
1367
1368 case features::TopDocumentIsolationMode::Xsite:
1369 return true;
1370 }
1371 NOTREACHED();
1353 return false; 1372 return false;
1354 #endif
1355 } 1373 }
1356 1374
1357 bool ChromeContentBrowserClient::IsSuitableHost( 1375 bool ChromeContentBrowserClient::IsSuitableHost(
1358 content::RenderProcessHost* process_host, 1376 content::RenderProcessHost* process_host,
1359 const GURL& site_url) { 1377 const GURL& site_url) {
1360 Profile* profile = 1378 Profile* profile =
1361 Profile::FromBrowserContext(process_host->GetBrowserContext()); 1379 Profile::FromBrowserContext(process_host->GetBrowserContext());
1362 // This may be NULL during tests. In that case, just assume any site can 1380 // This may be NULL during tests. In that case, just assume any site can
1363 // share any host. 1381 // share any host.
1364 if (!profile) 1382 if (!profile)
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 // displayed URL when rewriting chrome://help to chrome://settings/help. 3488 // displayed URL when rewriting chrome://help to chrome://settings/help.
3471 return url->SchemeIs(content::kChromeUIScheme) && 3489 return url->SchemeIs(content::kChromeUIScheme) &&
3472 url->host() == chrome::kChromeUISettingsHost; 3490 url->host() == chrome::kChromeUISettingsHost;
3473 } 3491 }
3474 3492
3475 // static 3493 // static
3476 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( 3494 void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting(
3477 const storage::QuotaSettings* settings) { 3495 const storage::QuotaSettings* settings) {
3478 g_default_quota_settings = settings; 3496 g_default_quota_settings = settings;
3479 } 3497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698