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 "extensions/browser/extension_web_contents_observer.h" | 5 #include "extensions/browser/extension_web_contents_observer.h" |
6 | 6 |
7 #include "content/public/browser/child_process_security_policy.h" | 7 #include "content/public/browser/child_process_security_policy.h" |
8 #include "content/public/browser/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
15 #include "extensions/browser/extension_api_frame_id_map.h" | 15 #include "extensions/browser/extension_api_frame_id_map.h" |
16 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
17 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extensions_browser_client.h" | 18 #include "extensions/browser/extensions_browser_client.h" |
19 #include "extensions/browser/mojo/service_registration.h" | 19 #include "extensions/browser/mojo/service_registration.h" |
20 #include "extensions/browser/process_manager.h" | 20 #include "extensions/browser/process_manager.h" |
| 21 #include "extensions/browser/renderer_startup_helper.h" |
21 #include "extensions/browser/view_type_utils.h" | 22 #include "extensions/browser/view_type_utils.h" |
22 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
23 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
24 #include "extensions/common/extension_messages.h" | 25 #include "extensions/common/extension_messages.h" |
25 #include "extensions/common/view_type.h" | 26 #include "extensions/common/view_type.h" |
26 | 27 |
27 namespace extensions { | 28 namespace extensions { |
28 | 29 |
29 // static | 30 // static |
30 ExtensionWebContentsObserver* ExtensionWebContentsObserver::GetForWebContents( | 31 ExtensionWebContentsObserver* ExtensionWebContentsObserver::GetForWebContents( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 99 } |
99 | 100 |
100 // Tells the new view that it's hosted in an extension process. | 101 // Tells the new view that it's hosted in an extension process. |
101 // | 102 // |
102 // This will often be a rendant IPC, because activating extensions happens at | 103 // This will often be a rendant IPC, because activating extensions happens at |
103 // the process level, not at the view level. However, without some mild | 104 // the process level, not at the view level. However, without some mild |
104 // refactoring this isn't trivial to do, and this way is simpler. | 105 // refactoring this isn't trivial to do, and this way is simpler. |
105 // | 106 // |
106 // Plus, we can delete the concept of activating an extension once site | 107 // Plus, we can delete the concept of activating an extension once site |
107 // isolation is turned on. | 108 // isolation is turned on. |
108 render_view_host->Send(new ExtensionMsg_ActivateExtension(extension->id())); | 109 RendererStartupHelperFactory::GetForBrowserContext(browser_context_) |
| 110 ->ActivateExtensionInProcess(extension->id(), |
| 111 render_view_host->GetProcess()); |
109 } | 112 } |
110 | 113 |
111 void ExtensionWebContentsObserver::RenderFrameCreated( | 114 void ExtensionWebContentsObserver::RenderFrameCreated( |
112 content::RenderFrameHost* render_frame_host) { | 115 content::RenderFrameHost* render_frame_host) { |
113 InitializeRenderFrame(render_frame_host); | 116 InitializeRenderFrame(render_frame_host); |
114 | 117 |
115 // Optimization: Look up the extension API frame ID to force the mapping to be | 118 // Optimization: Look up the extension API frame ID to force the mapping to be |
116 // cached. This minimizes the number of IO->UI->IO thread hops when the ID is | 119 // cached. This minimizes the number of IO->UI->IO thread hops when the ID is |
117 // looked up again on the IO thread for the webRequest API. | 120 // looked up again on the IO thread for the webRequest API. |
118 ExtensionApiFrameIdMap::Get()->CacheFrameData(render_frame_host); | 121 ExtensionApiFrameIdMap::Get()->CacheFrameData(render_frame_host); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // Since this is called for all existing RenderFrameHosts during the | 283 // Since this is called for all existing RenderFrameHosts during the |
281 // ExtensionWebContentsObserver's creation, it's possible that not all hosts | 284 // ExtensionWebContentsObserver's creation, it's possible that not all hosts |
282 // are ready. | 285 // are ready. |
283 // We only initialize the frame if the renderer counterpart is live; otherwise | 286 // We only initialize the frame if the renderer counterpart is live; otherwise |
284 // we wait for the RenderFrameCreated notification. | 287 // we wait for the RenderFrameCreated notification. |
285 if (render_frame_host->IsRenderFrameLive()) | 288 if (render_frame_host->IsRenderFrameLive()) |
286 InitializeRenderFrame(render_frame_host); | 289 InitializeRenderFrame(render_frame_host); |
287 } | 290 } |
288 | 291 |
289 } // namespace extensions | 292 } // namespace extensions |
OLD | NEW |