Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/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/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 18 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 18 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/content_settings/content_settings_details.h" | 20 #include "chrome/browser/content_settings/content_settings_details.h" |
| 21 #include "chrome/browser/content_settings/content_settings_utils.h" | 21 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 22 #include "chrome/browser/content_settings/cookie_settings.h" | |
| 22 #include "chrome/browser/content_settings/host_content_settings_map.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 23 #include "chrome/browser/prerender/prerender_manager.h" | 24 #include "chrome/browser/prerender/prerender_manager.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/navigation_controller.h" | 29 #include "content/public/browser/navigation_controller.h" |
| 29 #include "content/public/browser/navigation_details.h" | 30 #include "content/public/browser/navigation_details.h" |
| 30 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
| 31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 } | 337 } |
| 337 | 338 |
| 338 if (access_changed) { | 339 if (access_changed) { |
| 339 content::NotificationService::current()->Notify( | 340 content::NotificationService::current()->Notify( |
| 340 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 341 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 341 content::Source<WebContents>(web_contents()), | 342 content::Source<WebContents>(web_contents()), |
| 342 content::NotificationService::NoDetails()); | 343 content::NotificationService::NoDetails()); |
| 343 } | 344 } |
| 344 } | 345 } |
| 345 | 346 |
| 347 void TabSpecificContentSettings::OnRequestFileSystemAccess( | |
| 348 const IPC::Message& message) { | |
| 349 ChromeViewHostMsg_RequestFileSystemAccess::Param param; | |
| 350 if (!ChromeViewHostMsg_RequestFileSystemAccess::Read(&message, ¶m)) | |
|
kinuko
2014/03/05 08:35:44
nit: I think you could directly read out params li
Fady Samuel
2014/03/06 18:38:25
Done.
| |
| 351 return; | |
| 352 | |
| 353 Profile* profile = | |
| 354 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | |
| 355 scoped_refptr<CookieSettings> cookie_settings( | |
| 356 CookieSettings::Factory::GetForProfile(profile)); | |
| 357 int request_id = param.a; | |
| 358 const GURL& origin_url = param.b; | |
| 359 const GURL& top_origin_url = param.c; | |
| 360 bool allowed = | |
| 361 cookie_settings->IsSettingCookieAllowed(origin_url, top_origin_url); | |
| 362 OnFileSystemAccessed(origin_url, !allowed); | |
| 363 Send(new ChromeViewMsg_RequestFileSystemAccess_ACK( | |
| 364 message.routing_id(), request_id, allowed)); | |
| 365 } | |
| 366 | |
| 346 void TabSpecificContentSettings::OnCookiesRead( | 367 void TabSpecificContentSettings::OnCookiesRead( |
| 347 const GURL& url, | 368 const GURL& url, |
| 348 const GURL& frame_url, | 369 const GURL& frame_url, |
| 349 const net::CookieList& cookie_list, | 370 const net::CookieList& cookie_list, |
| 350 bool blocked_by_policy) { | 371 bool blocked_by_policy) { |
| 351 if (cookie_list.empty()) | 372 if (cookie_list.empty()) |
| 352 return; | 373 return; |
| 353 if (blocked_by_policy) { | 374 if (blocked_by_policy) { |
| 354 blocked_local_shared_objects_.cookies()->AddReadCookies( | 375 blocked_local_shared_objects_.cookies()->AddReadCookies( |
| 355 frame_url, url, cookie_list); | 376 frame_url, url, cookie_list); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 // page. | 654 // page. |
| 634 render_frame_host->Send(new ChromeViewMsg_SetAsInterstitial( | 655 render_frame_host->Send(new ChromeViewMsg_SetAsInterstitial( |
| 635 render_frame_host->GetRoutingID())); | 656 render_frame_host->GetRoutingID())); |
| 636 } | 657 } |
| 637 | 658 |
| 638 bool TabSpecificContentSettings::OnMessageReceived( | 659 bool TabSpecificContentSettings::OnMessageReceived( |
| 639 const IPC::Message& message) { | 660 const IPC::Message& message) { |
| 640 bool handled = true; | 661 bool handled = true; |
| 641 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) | 662 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) |
| 642 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) | 663 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) |
| 664 IPC_MESSAGE_HANDLER_GENERIC(ChromeViewHostMsg_RequestFileSystemAccess, | |
| 665 OnRequestFileSystemAccess(message)) | |
| 643 IPC_MESSAGE_UNHANDLED(handled = false) | 666 IPC_MESSAGE_UNHANDLED(handled = false) |
| 644 IPC_END_MESSAGE_MAP() | 667 IPC_END_MESSAGE_MAP() |
| 645 return handled; | 668 return handled; |
| 646 } | 669 } |
| 647 | 670 |
| 648 void TabSpecificContentSettings::DidNavigateMainFrame( | 671 void TabSpecificContentSettings::DidNavigateMainFrame( |
| 649 const content::LoadCommittedDetails& details, | 672 const content::LoadCommittedDetails& details, |
| 650 const content::FrameNavigateParams& params) { | 673 const content::FrameNavigateParams& params) { |
| 651 if (!details.is_in_page) { | 674 if (!details.is_in_page) { |
| 652 // Clear "blocked" flags. | 675 // Clear "blocked" flags. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 } | 742 } |
| 720 | 743 |
| 721 void TabSpecificContentSettings::RemoveSiteDataObserver( | 744 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 722 SiteDataObserver* observer) { | 745 SiteDataObserver* observer) { |
| 723 observer_list_.RemoveObserver(observer); | 746 observer_list_.RemoveObserver(observer); |
| 724 } | 747 } |
| 725 | 748 |
| 726 void TabSpecificContentSettings::NotifySiteDataObservers() { | 749 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 727 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 750 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 728 } | 751 } |
| OLD | NEW |