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

Side by Side Diff: chrome/browser/content_settings/tab_specific_content_settings.cc

Issue 8538004: Take script URLs into account when applying script content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/content_settings/tab_specific_content_settings.h" 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browsing_data_appcache_helper.h" 12 #include "chrome/browser/browsing_data_appcache_helper.h"
13 #include "chrome/browser/browsing_data_cookie_helper.h" 13 #include "chrome/browser/browsing_data_cookie_helper.h"
14 #include "chrome/browser/browsing_data_database_helper.h" 14 #include "chrome/browser/browsing_data_database_helper.h"
15 #include "chrome/browser/browsing_data_file_system_helper.h" 15 #include "chrome/browser/browsing_data_file_system_helper.h"
16 #include "chrome/browser/browsing_data_indexed_db_helper.h" 16 #include "chrome/browser/browsing_data_indexed_db_helper.h"
17 #include "chrome/browser/browsing_data_local_storage_helper.h" 17 #include "chrome/browser/browsing_data_local_storage_helper.h"
18 #include "chrome/browser/content_settings/content_settings_details.h" 18 #include "chrome/browser/content_settings/content_settings_details.h"
19 #include "chrome/browser/content_settings/content_settings_utils.h"
19 #include "chrome/browser/content_settings/host_content_settings_map.h" 20 #include "chrome/browser/content_settings/host_content_settings_map.h"
20 #include "chrome/browser/cookies_tree_model.h" 21 #include "chrome/browser/cookies_tree_model.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
25 #include "content/browser/renderer_host/render_view_host.h" 26 #include "content/browser/renderer_host/render_view_host.h"
26 #include "content/browser/tab_contents/navigation_details.h" 27 #include "content/browser/tab_contents/navigation_details.h"
27 #include "content/browser/tab_contents/tab_contents.h" 28 #include "content/browser/tab_contents/tab_contents.h"
28 #include "content/browser/tab_contents/tab_contents_delegate.h" 29 #include "content/browser/tab_contents/tab_contents_delegate.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 void TabSpecificContentSettings::DidNavigateMainFrame( 424 void TabSpecificContentSettings::DidNavigateMainFrame(
424 const content::LoadCommittedDetails& details, 425 const content::LoadCommittedDetails& details,
425 const ViewHostMsg_FrameNavigate_Params& params) { 426 const ViewHostMsg_FrameNavigate_Params& params) {
426 if (!details.is_in_page) { 427 if (!details.is_in_page) {
427 // Clear "blocked" flags. 428 // Clear "blocked" flags.
428 ClearBlockedContentSettingsExceptForCookies(); 429 ClearBlockedContentSettingsExceptForCookies();
429 GeolocationDidNavigate(details); 430 GeolocationDidNavigate(details);
430 } 431 }
431 } 432 }
432 433
433 void TabSpecificContentSettings::RenderViewCreated(
434 RenderViewHost* render_view_host) {
435 Profile* profile =
436 Profile::FromBrowserContext(tab_contents()->browser_context());
437 HostContentSettingsMap* map = profile->GetHostContentSettingsMap();
438 render_view_host->Send(new ChromeViewMsg_SetDefaultContentSettings(
439 map->GetDefaultContentSettings()));
440 }
441
442 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( 434 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame(
443 int64 frame_id, 435 int64 frame_id,
444 bool is_main_frame, 436 bool is_main_frame,
445 const GURL& validated_url, 437 const GURL& validated_url,
446 bool is_error_page, 438 bool is_error_page,
447 RenderViewHost* render_view_host) { 439 RenderViewHost* render_view_host) {
448 if (!is_main_frame) 440 if (!is_main_frame)
449 return; 441 return;
450 442
451 // If we're displaying a network error page do not reset the content 443 // If we're displaying a network error page do not reset the content
(...skipping 26 matching lines...) Expand all
478 NavigationEntry* entry = controller.GetActiveEntry(); 470 NavigationEntry* entry = controller.GetActiveEntry();
479 GURL entry_url; 471 GURL entry_url;
480 if (entry) 472 if (entry)
481 entry_url = entry->url(); 473 entry_url = entry->url();
482 if (settings_details.ptr()->update_all() || 474 if (settings_details.ptr()->update_all() ||
483 // The active NavigationEntry is the URL in the URL field of a tab. 475 // The active NavigationEntry is the URL in the URL field of a tab.
484 // Currently this should be matched by the |primary_pattern|. 476 // Currently this should be matched by the |primary_pattern|.
485 settings_details.ptr()->primary_pattern().Matches(entry_url)) { 477 settings_details.ptr()->primary_pattern().Matches(entry_url)) {
486 Profile* profile = 478 Profile* profile =
487 Profile::FromBrowserContext(tab_contents()->browser_context()); 479 Profile::FromBrowserContext(tab_contents()->browser_context());
488 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); 480 RendererContentSettingRules rules;
489 Send(new ChromeViewMsg_SetDefaultContentSettings( 481 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(),
490 map->GetDefaultContentSettings())); 482 &rules);
491 Send(new ChromeViewMsg_SetContentSettingsForCurrentURL( 483 Send(new ChromeViewMsg_SetContentSettingRules(rules));
492 entry_url, map->GetContentSettings(entry_url)));
493 ContentSettingsForOneType settings;
494 map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, "", &settings);
495 Send(new ChromeViewMsg_SetImageSettingRules(settings));
496 } 484 }
497 } 485 }
498 486
499 TabSpecificContentSettings::LocalSharedObjectsContainer:: 487 TabSpecificContentSettings::LocalSharedObjectsContainer::
500 LocalSharedObjectsContainer(Profile* profile) 488 LocalSharedObjectsContainer(Profile* profile)
501 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), 489 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
502 cookies_(new CannedBrowsingDataCookieHelper(profile)), 490 cookies_(new CannedBrowsingDataCookieHelper(profile)),
503 databases_(new CannedBrowsingDataDatabaseHelper(profile)), 491 databases_(new CannedBrowsingDataDatabaseHelper(profile)),
504 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)), 492 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)),
505 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper()), 493 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper()),
(...skipping 20 matching lines...) Expand all
526 return new CookiesTreeModel(cookies_->Clone(), 514 return new CookiesTreeModel(cookies_->Clone(),
527 databases_->Clone(), 515 databases_->Clone(),
528 local_storages_->Clone(), 516 local_storages_->Clone(),
529 session_storages_->Clone(), 517 session_storages_->Clone(),
530 appcaches_->Clone(), 518 appcaches_->Clone(),
531 indexed_dbs_->Clone(), 519 indexed_dbs_->Clone(),
532 file_systems_->Clone(), 520 file_systems_->Clone(),
533 NULL, 521 NULL,
534 true); 522 true);
535 } 523 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698