| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/chrome_content_browser_client_extensions_par
t.h" | 5 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par
t.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 11 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" | 12 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_web_ui.h" | 14 #include "chrome/browser/extensions/extension_web_ui.h" |
| 14 #include "chrome/browser/extensions/extension_webkit_preferences.h" | 15 #include "chrome/browser/extensions/extension_webkit_preferences.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_io_data.h" | 18 #include "chrome/browser/profiles/profile_io_data.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/renderer_host/chrome_extension_message_filter.h" |
| 21 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 18 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chrome/common/extensions/extension_process_policy.h" | 24 #include "chrome/common/extensions/extension_process_policy.h" |
| 21 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 25 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
| 22 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/browser_url_handler.h" | 27 #include "content/public/browser/browser_url_handler.h" |
| 24 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/render_view_host.h" | 29 #include "content/public/browser/render_view_host.h" |
| 26 #include "content/public/browser/site_instance.h" | 30 #include "content/public/browser/site_instance.h" |
| 27 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 28 #include "extensions/browser/extension_host.h" | 32 #include "extensions/browser/extension_host.h" |
| 33 #include "extensions/browser/extension_message_filter.h" |
| 29 #include "extensions/browser/extension_registry.h" | 34 #include "extensions/browser/extension_registry.h" |
| 30 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
| 31 #include "extensions/browser/info_map.h" | 36 #include "extensions/browser/info_map.h" |
| 32 #include "extensions/browser/view_type_utils.h" | 37 #include "extensions/browser/view_type_utils.h" |
| 33 #include "extensions/common/constants.h" | 38 #include "extensions/common/constants.h" |
| 34 #include "extensions/common/manifest_handlers/background_info.h" | 39 #include "extensions/common/manifest_handlers/background_info.h" |
| 35 #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" | 40 #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" |
| 36 #include "extensions/common/switches.h" | 41 #include "extensions/common/switches.h" |
| 37 | 42 |
| 38 // TODO(thestig): Remove ifdefs when extensions no longer build on mobile. | |
| 39 #if defined(ENABLE_EXTENSIONS) | |
| 40 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | |
| 41 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | |
| 42 #include "chrome/browser/renderer_host/chrome_extension_message_filter.h" | |
| 43 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | |
| 44 #include "extensions/browser/extension_message_filter.h" | |
| 45 #endif | |
| 46 | |
| 47 using content::BrowserThread; | 43 using content::BrowserThread; |
| 48 using content::BrowserURLHandler; | 44 using content::BrowserURLHandler; |
| 49 using content::RenderViewHost; | 45 using content::RenderViewHost; |
| 50 using content::SiteInstance; | 46 using content::SiteInstance; |
| 51 using content::WebContents; | 47 using content::WebContents; |
| 52 using content::WebPreferences; | 48 using content::WebPreferences; |
| 53 | 49 |
| 54 namespace extensions { | 50 namespace extensions { |
| 55 | 51 |
| 56 namespace { | 52 namespace { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 BrowserThread::PostTask( | 397 BrowserThread::PostTask( |
| 402 BrowserThread::IO, | 398 BrowserThread::IO, |
| 403 FROM_HERE, | 399 FROM_HERE, |
| 404 base::Bind(&InfoMap::SetSigninProcess, | 400 base::Bind(&InfoMap::SetSigninProcess, |
| 405 ExtensionSystem::Get(profile)->info_map(), | 401 ExtensionSystem::Get(profile)->info_map(), |
| 406 site_instance->GetProcess()->GetID())); | 402 site_instance->GetProcess()->GetID())); |
| 407 } | 403 } |
| 408 | 404 |
| 409 void ChromeContentBrowserClientExtensionsPart::RenderProcessWillLaunch( | 405 void ChromeContentBrowserClientExtensionsPart::RenderProcessWillLaunch( |
| 410 content::RenderProcessHost* host) { | 406 content::RenderProcessHost* host) { |
| 411 #if defined(ENABLE_EXTENSIONS) | |
| 412 int id = host->GetID(); | 407 int id = host->GetID(); |
| 413 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | 408 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
| 414 | 409 |
| 415 host->AddFilter(new ChromeExtensionMessageFilter(id, profile)); | 410 host->AddFilter(new ChromeExtensionMessageFilter(id, profile)); |
| 416 host->AddFilter(new ExtensionMessageFilter(id, profile)); | 411 host->AddFilter(new ExtensionMessageFilter(id, profile)); |
| 417 SendExtensionWebRequestStatusToHost(host); | 412 SendExtensionWebRequestStatusToHost(host); |
| 418 #endif | |
| 419 } | 413 } |
| 420 | 414 |
| 421 void ChromeContentBrowserClientExtensionsPart::SiteInstanceGotProcess( | 415 void ChromeContentBrowserClientExtensionsPart::SiteInstanceGotProcess( |
| 422 SiteInstance* site_instance) { | 416 SiteInstance* site_instance) { |
| 423 Profile* profile = Profile::FromBrowserContext( | 417 Profile* profile = Profile::FromBrowserContext( |
| 424 site_instance->GetProcess()->GetBrowserContext()); | 418 site_instance->GetProcess()->GetBrowserContext()); |
| 425 ExtensionService* service = | 419 ExtensionService* service = |
| 426 ExtensionSystem::Get(profile)->extension_service(); | 420 ExtensionSystem::Get(profile)->extension_service(); |
| 427 if (!service) | 421 if (!service) |
| 428 return; | 422 return; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } | 531 } |
| 538 | 532 |
| 539 void ChromeContentBrowserClientExtensionsPart:: | 533 void ChromeContentBrowserClientExtensionsPart:: |
| 540 GetAdditionalAllowedSchemesForFileSystem( | 534 GetAdditionalAllowedSchemesForFileSystem( |
| 541 std::vector<std::string>* additional_allowed_schemes) { | 535 std::vector<std::string>* additional_allowed_schemes) { |
| 542 additional_allowed_schemes->push_back(kExtensionScheme); | 536 additional_allowed_schemes->push_back(kExtensionScheme); |
| 543 } | 537 } |
| 544 | 538 |
| 545 void ChromeContentBrowserClientExtensionsPart::GetURLRequestAutoMountHandlers( | 539 void ChromeContentBrowserClientExtensionsPart::GetURLRequestAutoMountHandlers( |
| 546 std::vector<fileapi::URLRequestAutoMountHandler>* handlers) { | 540 std::vector<fileapi::URLRequestAutoMountHandler>* handlers) { |
| 547 #if defined(ENABLE_EXTENSIONS) | |
| 548 handlers->push_back( | 541 handlers->push_back( |
| 549 base::Bind(MediaFileSystemBackend::AttemptAutoMountForURLRequest)); | 542 base::Bind(MediaFileSystemBackend::AttemptAutoMountForURLRequest)); |
| 550 #endif | |
| 551 } | 543 } |
| 552 | 544 |
| 553 void ChromeContentBrowserClientExtensionsPart::GetAdditionalFileSystemBackends( | 545 void ChromeContentBrowserClientExtensionsPart::GetAdditionalFileSystemBackends( |
| 554 content::BrowserContext* browser_context, | 546 content::BrowserContext* browser_context, |
| 555 const base::FilePath& storage_partition_path, | 547 const base::FilePath& storage_partition_path, |
| 556 ScopedVector<fileapi::FileSystemBackend>* additional_backends) { | 548 ScopedVector<fileapi::FileSystemBackend>* additional_backends) { |
| 557 #if defined(ENABLE_EXTENSIONS) | |
| 558 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); | 549 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
| 559 additional_backends->push_back(new MediaFileSystemBackend( | 550 additional_backends->push_back(new MediaFileSystemBackend( |
| 560 storage_partition_path, | 551 storage_partition_path, |
| 561 pool->GetSequencedTaskRunner( | 552 pool->GetSequencedTaskRunner( |
| 562 pool->GetNamedSequenceToken( | 553 pool->GetNamedSequenceToken( |
| 563 MediaFileSystemBackend::kMediaTaskRunnerName)).get())); | 554 MediaFileSystemBackend::kMediaTaskRunnerName)).get())); |
| 564 | 555 |
| 565 additional_backends->push_back(new sync_file_system::SyncFileSystemBackend( | 556 additional_backends->push_back(new sync_file_system::SyncFileSystemBackend( |
| 566 Profile::FromBrowserContext(browser_context))); | 557 Profile::FromBrowserContext(browser_context))); |
| 567 #endif | |
| 568 } | 558 } |
| 569 | 559 |
| 570 void ChromeContentBrowserClientExtensionsPart:: | 560 void ChromeContentBrowserClientExtensionsPart:: |
| 571 AppendExtraRendererCommandLineSwitches(base::CommandLine* command_line, | 561 AppendExtraRendererCommandLineSwitches(base::CommandLine* command_line, |
| 572 content::RenderProcessHost* process, | 562 content::RenderProcessHost* process, |
| 573 Profile* profile) { | 563 Profile* profile) { |
| 574 if (!process) | 564 if (!process) |
| 575 return; | 565 return; |
| 576 DCHECK(profile); | 566 DCHECK(profile); |
| 577 if (ProcessMap::Get(profile)->Contains(process->GetID())) | 567 if (ProcessMap::Get(profile)->Contains(process->GetID())) |
| 578 command_line->AppendSwitch(switches::kExtensionProcess); | 568 command_line->AppendSwitch(switches::kExtensionProcess); |
| 579 } | 569 } |
| 580 | 570 |
| 581 } // namespace extensions | 571 } // namespace extensions |
| OLD | NEW |