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/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "chrome/common/url_constants.h" | 66 #include "chrome/common/url_constants.h" |
67 #include "content/browser/browser_url_handler.h" | 67 #include "content/browser/browser_url_handler.h" |
68 #include "content/browser/child_process_security_policy.h" | 68 #include "content/browser/child_process_security_policy.h" |
69 #include "content/browser/gpu/gpu_data_manager.h" | 69 #include "content/browser/gpu/gpu_data_manager.h" |
70 #include "content/browser/gpu/gpu_process_host.h" | 70 #include "content/browser/gpu/gpu_process_host.h" |
71 #include "content/browser/plugin_process_host.h" | 71 #include "content/browser/plugin_process_host.h" |
72 #include "content/browser/renderer_host/render_view_host.h" | 72 #include "content/browser/renderer_host/render_view_host.h" |
73 #include "content/browser/resource_context.h" | 73 #include "content/browser/resource_context.h" |
74 #include "content/browser/ssl/ssl_cert_error_handler.h" | 74 #include "content/browser/ssl/ssl_cert_error_handler.h" |
75 #include "content/browser/ssl/ssl_client_auth_handler.h" | 75 #include "content/browser/ssl/ssl_client_auth_handler.h" |
76 #include "content/browser/worker_host/worker_process_host.h" | |
77 #include "content/public/browser/browser_main_parts.h" | 76 #include "content/public/browser/browser_main_parts.h" |
78 #include "content/public/browser/render_process_host.h" | 77 #include "content/public/browser/render_process_host.h" |
79 #include "content/public/browser/site_instance.h" | 78 #include "content/public/browser/site_instance.h" |
80 #include "content/public/browser/web_contents.h" | 79 #include "content/public/browser/web_contents.h" |
81 #include "content/public/browser/web_contents_view.h" | 80 #include "content/public/browser/web_contents_view.h" |
82 #include "grit/generated_resources.h" | 81 #include "grit/generated_resources.h" |
83 #include "grit/ui_resources.h" | 82 #include "grit/ui_resources.h" |
84 #include "net/base/cookie_monster.h" | 83 #include "net/base/cookie_monster.h" |
85 #include "net/base/cookie_options.h" | 84 #include "net/base/cookie_options.h" |
86 #include "net/base/network_change_notifier.h" | 85 #include "net/base/network_change_notifier.h" |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 | 774 |
776 bool ChromeContentBrowserClient::AllowSaveLocalState( | 775 bool ChromeContentBrowserClient::AllowSaveLocalState( |
777 const content::ResourceContext& context) { | 776 const content::ResourceContext& context) { |
778 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 777 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
779 ProfileIOData* io_data = | 778 ProfileIOData* io_data = |
780 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); | 779 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
781 return !io_data->clear_local_state_on_exit()->GetValue(); | 780 return !io_data->clear_local_state_on_exit()->GetValue(); |
782 } | 781 } |
783 | 782 |
784 bool ChromeContentBrowserClient::AllowWorkerDatabase( | 783 bool ChromeContentBrowserClient::AllowWorkerDatabase( |
785 int worker_route_id, | |
786 const GURL& url, | 784 const GURL& url, |
787 const string16& name, | 785 const string16& name, |
788 const string16& display_name, | 786 const string16& display_name, |
789 unsigned long estimated_size, | 787 unsigned long estimated_size, |
790 WorkerProcessHost* worker_process_host) { | 788 const content::ResourceContext& context, |
| 789 const std::vector<std::pair<int, int> >& render_views) { |
791 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
792 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( | 791 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
793 worker_process_host->resource_context()->GetUserData(NULL)); | 792 context.GetUserData(NULL)); |
794 CookieSettings* cookie_settings = io_data->GetCookieSettings(); | 793 CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
795 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); | 794 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
796 | 795 |
797 // Record access to database for potential display in UI: Find the worker | 796 // Record access to database for potential display in UI. |
798 // instance and forward the message to all attached documents. | 797 std::vector<std::pair<int, int> >::const_iterator i; |
799 WorkerProcessHost::Instances::const_iterator i; | 798 for (i = render_views.begin(); i != render_views.end(); ++i) { |
800 for (i = worker_process_host->instances().begin(); | 799 BrowserThread::PostTask( |
801 i != worker_process_host->instances().end(); ++i) { | 800 BrowserThread::UI, FROM_HERE, |
802 if (i->worker_route_id() != worker_route_id) | 801 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed, |
803 continue; | 802 i->first, i->second, url, name, display_name, !allow)); |
804 const WorkerDocumentSet::DocumentInfoSet& documents = | |
805 i->worker_document_set()->documents(); | |
806 for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = | |
807 documents.begin(); doc != documents.end(); ++doc) { | |
808 BrowserThread::PostTask( | |
809 BrowserThread::UI, FROM_HERE, | |
810 base::Bind( | |
811 &TabSpecificContentSettings::WebDatabaseAccessed, | |
812 doc->render_process_id(), doc->render_view_id(), | |
813 url, name, display_name, !allow)); | |
814 } | |
815 break; | |
816 } | 803 } |
817 | 804 |
818 return allow; | 805 return allow; |
819 } | 806 } |
820 | 807 |
821 bool ChromeContentBrowserClient::AllowWorkerFileSystem( | 808 bool ChromeContentBrowserClient::AllowWorkerFileSystem( |
822 int worker_route_id, | |
823 const GURL& url, | 809 const GURL& url, |
824 WorkerProcessHost* worker_process_host) { | 810 const content::ResourceContext& context, |
| 811 const std::vector<std::pair<int, int> >& render_views) { |
825 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 812 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
826 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( | 813 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
827 worker_process_host->resource_context()->GetUserData(NULL)); | 814 context.GetUserData(NULL)); |
828 CookieSettings* cookie_settings = io_data->GetCookieSettings(); | 815 CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
829 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); | 816 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
830 | 817 |
831 // Record access to file system for potential display in UI: Find the worker | 818 // Record access to file system for potential display in UI. |
832 // instance and forward the message to all attached documents. | 819 std::vector<std::pair<int, int> >::const_iterator i; |
833 WorkerProcessHost::Instances::const_iterator i; | 820 for (i = render_views.begin(); i != render_views.end(); ++i) { |
834 for (i = worker_process_host->instances().begin(); | 821 BrowserThread::PostTask( |
835 i != worker_process_host->instances().end(); ++i) { | 822 BrowserThread::UI, FROM_HERE, |
836 if (i->worker_route_id() != worker_route_id) | 823 base::Bind(&TabSpecificContentSettings::FileSystemAccessed, |
837 continue; | 824 i->first, i->second, url, !allow)); |
838 const WorkerDocumentSet::DocumentInfoSet& documents = | |
839 i->worker_document_set()->documents(); | |
840 for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = | |
841 documents.begin(); doc != documents.end(); ++doc) { | |
842 BrowserThread::PostTask( | |
843 BrowserThread::UI, FROM_HERE, | |
844 base::Bind( | |
845 &TabSpecificContentSettings::FileSystemAccessed, | |
846 doc->render_process_id(), doc->render_view_id(), url, !allow)); | |
847 } | |
848 break; | |
849 } | 825 } |
850 | 826 |
851 return allow; | 827 return allow; |
852 } | 828 } |
853 | 829 |
854 net::URLRequestContext* | 830 net::URLRequestContext* |
855 ChromeContentBrowserClient::OverrideRequestContextForURL( | 831 ChromeContentBrowserClient::OverrideRequestContextForURL( |
856 const GURL& url, const content::ResourceContext& context) { | 832 const GURL& url, const content::ResourceContext& context) { |
857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 833 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
858 if (url.SchemeIs(chrome::kExtensionScheme)) { | 834 if (url.SchemeIs(chrome::kExtensionScheme)) { |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 #if defined(USE_NSS) | 1452 #if defined(USE_NSS) |
1477 crypto::CryptoModuleBlockingPasswordDelegate* | 1453 crypto::CryptoModuleBlockingPasswordDelegate* |
1478 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1454 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1479 const GURL& url) { | 1455 const GURL& url) { |
1480 return browser::NewCryptoModuleBlockingDialogDelegate( | 1456 return browser::NewCryptoModuleBlockingDialogDelegate( |
1481 browser::kCryptoModulePasswordKeygen, url.host()); | 1457 browser::kCryptoModulePasswordKeygen, url.host()); |
1482 } | 1458 } |
1483 #endif | 1459 #endif |
1484 | 1460 |
1485 } // namespace chrome | 1461 } // namespace chrome |
OLD | NEW |