Chromium Code Reviews| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/app/breakpad_mac.h" | 8 #include "chrome/app/breakpad_mac.h" |
| 9 #include "chrome/browser/browser_about_handler.h" | 9 #include "chrome/browser/browser_about_handler.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "chrome/browser/ssl/ssl_add_cert_handler.h" | 38 #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
| 39 #include "chrome/browser/ssl/ssl_blocking_page.h" | 39 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 40 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 40 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
| 41 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" | 41 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 42 #include "chrome/browser/tab_contents/tab_util.h" | 42 #include "chrome/browser/tab_contents/tab_util.h" |
| 43 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 43 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 44 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" | 44 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
| 45 #include "chrome/common/child_process_logging.h" | 45 #include "chrome/common/child_process_logging.h" |
| 46 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/extensions/extension.h" | 47 #include "chrome/common/extensions/extension.h" |
| 48 #include "chrome/common/extensions/extension_messages.h" | |
| 49 #include "chrome/common/logging_chrome.h" | 48 #include "chrome/common/logging_chrome.h" |
| 50 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 51 #include "chrome/common/render_messages.h" | 50 #include "chrome/common/render_messages.h" |
| 52 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 53 #include "content/browser/browser_url_handler.h" | 52 #include "content/browser/browser_url_handler.h" |
| 54 #include "content/browser/browsing_instance.h" | 53 #include "content/browser/browsing_instance.h" |
| 55 #include "content/browser/child_process_security_policy.h" | |
| 56 #include "content/browser/debugger/devtools_handler.h" | 54 #include "content/browser/debugger/devtools_handler.h" |
| 57 #include "content/browser/plugin_process_host.h" | 55 #include "content/browser/plugin_process_host.h" |
| 58 #include "content/browser/renderer_host/browser_render_process_host.h" | 56 #include "content/browser/renderer_host/browser_render_process_host.h" |
| 59 #include "content/browser/renderer_host/render_view_host.h" | 57 #include "content/browser/renderer_host/render_view_host.h" |
| 60 #include "content/browser/resource_context.h" | 58 #include "content/browser/resource_context.h" |
| 61 #include "content/browser/site_instance.h" | 59 #include "content/browser/site_instance.h" |
| 62 #include "content/browser/ssl/ssl_cert_error_handler.h" | 60 #include "content/browser/ssl/ssl_cert_error_handler.h" |
| 63 #include "content/browser/ssl/ssl_client_auth_handler.h" | 61 #include "content/browser/ssl/ssl_client_auth_handler.h" |
| 64 #include "content/browser/tab_contents/tab_contents.h" | 62 #include "content/browser/tab_contents/tab_contents.h" |
| 65 #include "content/browser/worker_host/worker_process_host.h" | 63 #include "content/browser/worker_host/worker_process_host.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 | 96 |
| 99 ExtensionProcessManager* process_manager = | 97 ExtensionProcessManager* process_manager = |
| 100 profile->GetExtensionProcessManager(); | 98 profile->GetExtensionProcessManager(); |
| 101 CHECK(process_manager); | 99 CHECK(process_manager); |
| 102 | 100 |
| 103 // This can happen if somebody typos a chrome-extension:// URL. | 101 // This can happen if somebody typos a chrome-extension:// URL. |
| 104 const Extension* extension = service->GetExtensionByURL(site); | 102 const Extension* extension = service->GetExtensionByURL(site); |
| 105 if (!extension) | 103 if (!extension) |
| 106 return; | 104 return; |
| 107 | 105 |
| 108 site_instance->GetProcess()->mark_is_extension_process(); | 106 site_instance->GetProcess()->mark_is_extension_process(); |
|
Charlie Reis
2011/08/11 19:10:55
Ah yes, this only needs to be done once, because t
| |
| 109 | 107 |
| 110 // Register the association between extension and SiteInstance with | 108 // Register the association between extension and SiteInstance with |
| 111 // ExtensionProcessManager. | 109 // ExtensionProcessManager. |
| 112 // TODO(creis): Use this to replace SetInstalledAppForRenderer below. | 110 // TODO(creis): Use this to replace SetInstalledAppForRenderer in |
| 111 // ChromeRenderViewHostObserver::InitRenderViewHostForExtensions. | |
| 113 process_manager->RegisterExtensionSiteInstance(site_instance->id(), | 112 process_manager->RegisterExtensionSiteInstance(site_instance->id(), |
| 114 extension->id()); | 113 extension->id()); |
| 115 | 114 |
| 116 RenderProcessHost* process = render_view_host->process(); | |
| 117 | |
| 118 if (extension->is_app()) { | |
| 119 render_view_host->Send( | |
| 120 new ExtensionMsg_ActivateApplication(extension->id())); | |
| 121 // Record which, if any, installed app is associated with this process. | |
| 122 // TODO(aa): Totally lame to store this state in a global map in extension | |
| 123 // service. Can we get it from EPM instead? | |
| 124 service->SetInstalledAppForRenderer(process->id(), extension); | |
| 125 } | |
| 126 | |
| 127 // Some extensions use chrome:// URLs. | |
| 128 Extension::Type type = extension->GetType(); | |
| 129 if (type == Extension::TYPE_EXTENSION || | |
| 130 type == Extension::TYPE_PACKAGED_APP) { | |
| 131 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | |
| 132 process->id(), chrome::kChromeUIScheme); | |
| 133 } | |
| 134 | |
| 135 // Enable extension bindings for the renderer. Currently only extensions, | 115 // Enable extension bindings for the renderer. Currently only extensions, |
| 136 // packaged apps, and hosted component apps use extension bindings. | 116 // packaged apps, and hosted component apps use extension bindings. |
| 117 Extension::Type type = extension->GetType(); | |
| 137 if (type == Extension::TYPE_EXTENSION || | 118 if (type == Extension::TYPE_EXTENSION || |
| 138 type == Extension::TYPE_USER_SCRIPT || | 119 type == Extension::TYPE_USER_SCRIPT || |
| 139 type == Extension::TYPE_PACKAGED_APP || | 120 type == Extension::TYPE_PACKAGED_APP || |
| 140 (type == Extension::TYPE_HOSTED_APP && | 121 (type == Extension::TYPE_HOSTED_APP && |
| 141 extension->location() == Extension::COMPONENT)) { | 122 extension->location() == Extension::COMPONENT)) { |
| 142 render_view_host->Send(new ExtensionMsg_ActivateExtension(extension->id())); | |
| 143 render_view_host->AllowBindings(BindingsPolicy::EXTENSION); | 123 render_view_host->AllowBindings(BindingsPolicy::EXTENSION); |
| 144 } | 124 } |
| 145 } | 125 } |
| 146 | 126 |
| 147 // Handles rewriting Web UI URLs. | 127 // Handles rewriting Web UI URLs. |
| 148 static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { | 128 static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
| 149 if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) | 129 if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) |
| 150 return false; | 130 return false; |
| 151 | 131 |
| 152 // Special case the new tab page. In older versions of Chrome, the new tab | 132 // Special case the new tab page. In older versions of Chrome, the new tab |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 #if defined(USE_NSS) | 765 #if defined(USE_NSS) |
| 786 crypto::CryptoModuleBlockingPasswordDelegate* | 766 crypto::CryptoModuleBlockingPasswordDelegate* |
| 787 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 767 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 788 const GURL& url) { | 768 const GURL& url) { |
| 789 return browser::NewCryptoModuleBlockingDialogDelegate( | 769 return browser::NewCryptoModuleBlockingDialogDelegate( |
| 790 browser::kCryptoModulePasswordKeygen, url.host()); | 770 browser::kCryptoModulePasswordKeygen, url.host()); |
| 791 } | 771 } |
| 792 #endif | 772 #endif |
| 793 | 773 |
| 794 } // namespace chrome | 774 } // namespace chrome |
| OLD | NEW |