OLD | NEW |
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/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "chrome/app/breakpad_mac.h" | 9 #include "chrome/app/breakpad_mac.h" |
10 #include "chrome/browser/browser_about_handler.h" | 10 #include "chrome/browser/browser_about_handler.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browsing_data_remover.h" | 12 #include "chrome/browser/browsing_data_remover.h" |
13 #include "chrome/browser/character_encoding.h" | 13 #include "chrome/browser/character_encoding.h" |
14 #include "chrome/browser/chrome_benchmarking_message_filter.h" | 14 #include "chrome/browser/chrome_benchmarking_message_filter.h" |
15 #include "chrome/browser/chrome_plugin_message_filter.h" | 15 #include "chrome/browser/chrome_plugin_message_filter.h" |
16 #include "chrome/browser/chrome_quota_permission_context.h" | 16 #include "chrome/browser/chrome_quota_permission_context.h" |
17 #include "chrome/browser/chrome_worker_message_filter.h" | |
18 #include "chrome/browser/content_settings/cookie_settings.h" | 17 #include "chrome/browser/content_settings/cookie_settings.h" |
19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 18 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
20 #include "chrome/browser/download/download_util.h" | 19 #include "chrome/browser/download/download_util.h" |
21 #include "chrome/browser/extensions/extension_info_map.h" | 20 #include "chrome/browser/extensions/extension_info_map.h" |
22 #include "chrome/browser/extensions/extension_message_handler.h" | 21 #include "chrome/browser/extensions/extension_message_handler.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_web_ui.h" | 23 #include "chrome/browser/extensions/extension_web_ui.h" |
25 #include "chrome/browser/extensions/extension_webrequest_api.h" | 24 #include "chrome/browser/extensions/extension_webrequest_api.h" |
26 #include "chrome/browser/geolocation/chrome_access_token_store.h" | 25 #include "chrome/browser/geolocation/chrome_access_token_store.h" |
27 #include "chrome/browser/google/google_util.h" | 26 #include "chrome/browser/google/google_util.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 320 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
322 map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, "", &settings); | 321 map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, "", &settings); |
323 host->Send(new ChromeViewMsg_SetImageSettingRules(settings)); | 322 host->Send(new ChromeViewMsg_SetImageSettingRules(settings)); |
324 } | 323 } |
325 | 324 |
326 void ChromeContentBrowserClient::PluginProcessHostCreated( | 325 void ChromeContentBrowserClient::PluginProcessHostCreated( |
327 PluginProcessHost* host) { | 326 PluginProcessHost* host) { |
328 host->AddFilter(new ChromePluginMessageFilter(host)); | 327 host->AddFilter(new ChromePluginMessageFilter(host)); |
329 } | 328 } |
330 | 329 |
331 void ChromeContentBrowserClient::WorkerProcessHostCreated( | |
332 WorkerProcessHost* host) { | |
333 host->AddFilter(new ChromeWorkerMessageFilter(host)); | |
334 } | |
335 | |
336 content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() { | 330 content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() { |
337 return ChromeWebUIFactory::GetInstance(); | 331 return ChromeWebUIFactory::GetInstance(); |
338 } | 332 } |
339 | 333 |
340 GURL ChromeContentBrowserClient::GetEffectiveURL( | 334 GURL ChromeContentBrowserClient::GetEffectiveURL( |
341 content::BrowserContext* browser_context, const GURL& url) { | 335 content::BrowserContext* browser_context, const GURL& url) { |
342 Profile* profile = Profile::FromBrowserContext(browser_context); | 336 Profile* profile = Profile::FromBrowserContext(browser_context); |
343 // Get the effective URL for the given actual URL. If the URL is part of an | 337 // Get the effective URL for the given actual URL. If the URL is part of an |
344 // installed app, the effective URL is an extension URL with the ID of that | 338 // installed app, the effective URL is an extension URL with the ID of that |
345 // extension as the host. This has the effect of grouping apps together in | 339 // extension as the host. This has the effect of grouping apps together in |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 } | 706 } |
713 | 707 |
714 bool ChromeContentBrowserClient::AllowSaveLocalState( | 708 bool ChromeContentBrowserClient::AllowSaveLocalState( |
715 const content::ResourceContext& context) { | 709 const content::ResourceContext& context) { |
716 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 710 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
717 ProfileIOData* io_data = | 711 ProfileIOData* io_data = |
718 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); | 712 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
719 return !io_data->clear_local_state_on_exit()->GetValue(); | 713 return !io_data->clear_local_state_on_exit()->GetValue(); |
720 } | 714 } |
721 | 715 |
| 716 bool ChromeContentBrowserClient::AllowWorkerDatabase( |
| 717 int worker_route_id, |
| 718 const GURL& url, |
| 719 const string16& name, |
| 720 const string16& display_name, |
| 721 unsigned long estimated_size, |
| 722 WorkerProcessHost* worker_process_host) { |
| 723 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 724 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 725 worker_process_host->resource_context()->GetUserData(NULL)); |
| 726 CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 727 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 728 |
| 729 // Record access to database for potential display in UI: Find the worker |
| 730 // instance and forward the message to all attached documents. |
| 731 WorkerProcessHost::Instances::const_iterator i; |
| 732 for (i = worker_process_host->instances().begin(); |
| 733 i != worker_process_host->instances().end(); ++i) { |
| 734 if (i->worker_route_id() != worker_route_id) |
| 735 continue; |
| 736 const WorkerDocumentSet::DocumentInfoSet& documents = |
| 737 i->worker_document_set()->documents(); |
| 738 for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = |
| 739 documents.begin(); doc != documents.end(); ++doc) { |
| 740 BrowserThread::PostTask( |
| 741 BrowserThread::UI, FROM_HERE, |
| 742 base::Bind( |
| 743 &TabSpecificContentSettings::WebDatabaseAccessed, |
| 744 doc->render_process_id(), doc->render_view_id(), |
| 745 url, name, display_name, !allow)); |
| 746 } |
| 747 break; |
| 748 } |
| 749 |
| 750 return allow; |
| 751 } |
| 752 |
| 753 bool ChromeContentBrowserClient::AllowWorkerFileSystem( |
| 754 int worker_route_id, |
| 755 const GURL& url, |
| 756 WorkerProcessHost* worker_process_host) { |
| 757 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 758 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 759 worker_process_host->resource_context()->GetUserData(NULL)); |
| 760 CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 761 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 762 |
| 763 // Record access to file system for potential display in UI: Find the worker |
| 764 // instance and forward the message to all attached documents. |
| 765 WorkerProcessHost::Instances::const_iterator i; |
| 766 for (i = worker_process_host->instances().begin(); |
| 767 i != worker_process_host->instances().end(); ++i) { |
| 768 if (i->worker_route_id() != worker_route_id) |
| 769 continue; |
| 770 const WorkerDocumentSet::DocumentInfoSet& documents = |
| 771 i->worker_document_set()->documents(); |
| 772 for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = |
| 773 documents.begin(); doc != documents.end(); ++doc) { |
| 774 BrowserThread::PostTask( |
| 775 BrowserThread::UI, FROM_HERE, |
| 776 base::Bind( |
| 777 &TabSpecificContentSettings::FileSystemAccessed, |
| 778 doc->render_process_id(), doc->render_view_id(), url, !allow)); |
| 779 } |
| 780 break; |
| 781 } |
| 782 |
| 783 return allow; |
| 784 } |
| 785 |
722 net::URLRequestContext* | 786 net::URLRequestContext* |
723 ChromeContentBrowserClient::OverrideRequestContextForURL( | 787 ChromeContentBrowserClient::OverrideRequestContextForURL( |
724 const GURL& url, const content::ResourceContext& context) { | 788 const GURL& url, const content::ResourceContext& context) { |
725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 789 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
726 if (url.SchemeIs(chrome::kExtensionScheme)) { | 790 if (url.SchemeIs(chrome::kExtensionScheme)) { |
727 ProfileIOData* io_data = | 791 ProfileIOData* io_data = |
728 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); | 792 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
729 return io_data->extensions_request_context(); | 793 return io_data->extensions_request_context(); |
730 } | 794 } |
731 | 795 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 #if defined(USE_NSS) | 1125 #if defined(USE_NSS) |
1062 crypto::CryptoModuleBlockingPasswordDelegate* | 1126 crypto::CryptoModuleBlockingPasswordDelegate* |
1063 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1127 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1064 const GURL& url) { | 1128 const GURL& url) { |
1065 return browser::NewCryptoModuleBlockingDialogDelegate( | 1129 return browser::NewCryptoModuleBlockingDialogDelegate( |
1066 browser::kCryptoModulePasswordKeygen, url.host()); | 1130 browser::kCryptoModulePasswordKeygen, url.host()); |
1067 } | 1131 } |
1068 #endif | 1132 #endif |
1069 | 1133 |
1070 } // namespace chrome | 1134 } // namespace chrome |
OLD | NEW |