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/extensions/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 url_(url), | 141 url_(url), |
142 ALLOW_THIS_IN_INITIALIZER_LIST( | 142 ALLOW_THIS_IN_INITIALIZER_LIST( |
143 extension_function_dispatcher_(profile_, this)), | 143 extension_function_dispatcher_(profile_, this)), |
144 extension_host_type_(host_type), | 144 extension_host_type_(host_type), |
145 associated_tab_contents_(NULL) { | 145 associated_tab_contents_(NULL) { |
146 render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE, | 146 render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE, |
147 NULL); | 147 NULL); |
148 if (enable_dom_automation_) | 148 if (enable_dom_automation_) |
149 render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); | 149 render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); |
150 | 150 |
151 // Listen for when the render process' handle is available so we can add it | |
152 // to the task manager then. | |
153 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | |
154 content::Source<RenderProcessHost>(render_process_host())); | |
155 // Listen for when an extension is unloaded from the same profile, as it may | 151 // Listen for when an extension is unloaded from the same profile, as it may |
156 // be the same extension that this points to. | 152 // be the same extension that this points to. |
157 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 153 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
158 content::Source<Profile>(profile_)); | 154 content::Source<Profile>(profile_)); |
159 } | 155 } |
160 | 156 |
161 // This "mock" constructor should only be used by unit tests. | 157 // This "mock" constructor should only be used by unit tests. |
162 ExtensionHost::ExtensionHost(const Extension* extension, | 158 ExtensionHost::ExtensionHost(const Extension* extension, |
163 content::ViewType host_type) | 159 content::ViewType host_type) |
164 : extension_(extension), | 160 : extension_(extension), |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 286 |
291 void ExtensionHost::Observe(int type, | 287 void ExtensionHost::Observe(int type, |
292 const content::NotificationSource& source, | 288 const content::NotificationSource& source, |
293 const content::NotificationDetails& details) { | 289 const content::NotificationDetails& details) { |
294 switch (type) { | 290 switch (type) { |
295 case chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY: | 291 case chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY: |
296 DCHECK(profile_->GetExtensionService()-> | 292 DCHECK(profile_->GetExtensionService()-> |
297 IsBackgroundPageReady(extension_)); | 293 IsBackgroundPageReady(extension_)); |
298 NavigateToURL(url_); | 294 NavigateToURL(url_); |
299 break; | 295 break; |
300 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: | |
301 content::NotificationService::current()->Notify( | |
302 chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, | |
303 content::Source<Profile>(profile_), | |
304 content::Details<ExtensionHost>(this)); | |
305 break; | |
306 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 296 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
307 // The extension object will be deleted after this notification has been | 297 // The extension object will be deleted after this notification has been |
308 // sent. NULL it out so that dirty pointer issues don't arise in cases | 298 // sent. NULL it out so that dirty pointer issues don't arise in cases |
309 // when multiple ExtensionHost objects pointing to the same Extension are | 299 // when multiple ExtensionHost objects pointing to the same Extension are |
310 // present. | 300 // present. |
311 if (extension_ == | 301 if (extension_ == |
312 content::Details<UnloadedExtensionInfo>(details)->extension) { | 302 content::Details<UnloadedExtensionInfo>(details)->extension) { |
313 extension_ = NULL; | 303 extension_ = NULL; |
314 } | 304 } |
315 break; | 305 break; |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 792 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
803 if (view_.get()) | 793 if (view_.get()) |
804 view_->RenderViewCreated(); | 794 view_->RenderViewCreated(); |
805 | 795 |
806 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 796 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
807 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 797 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { |
808 render_view_host->EnablePreferredSizeMode( | 798 render_view_host->EnablePreferredSizeMode( |
809 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); | 799 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
810 } | 800 } |
811 } | 801 } |
| 802 |
| 803 void ExtensionHost::RenderViewReady(RenderViewHost* render_view_host) { |
| 804 content::NotificationService::current()->Notify( |
| 805 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 806 content::Source<Profile>(profile_), |
| 807 content::Details<ExtensionHost>(this)); |
| 808 } |
OLD | NEW |