OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 typedef std::list<ExtensionHost*> Queue; | 117 typedef std::list<ExtensionHost*> Queue; |
118 Queue queue_; | 118 Queue queue_; |
119 bool pending_create_; | 119 bool pending_create_; |
120 base::WeakPtrFactory<ProcessCreationQueue> ptr_factory_; | 120 base::WeakPtrFactory<ProcessCreationQueue> ptr_factory_; |
121 }; | 121 }; |
122 | 122 |
123 //////////////// | 123 //////////////// |
124 // ExtensionHost | 124 // ExtensionHost |
125 | 125 |
126 ExtensionHost::ExtensionHost(const Extension* extension, | 126 ExtensionHost::ExtensionHost(const extensions::Extension* extension, |
127 SiteInstance* site_instance, | 127 SiteInstance* site_instance, |
128 const GURL& url, | 128 const GURL& url, |
129 content::ViewType host_type) | 129 content::ViewType host_type) |
130 : extension_(extension), | 130 : extension_(extension), |
131 extension_id_(extension->id()), | 131 extension_id_(extension->id()), |
132 profile_(Profile::FromBrowserContext( | 132 profile_(Profile::FromBrowserContext( |
133 site_instance->GetBrowserContext())), | 133 site_instance->GetBrowserContext())), |
134 render_view_host_(NULL), | 134 render_view_host_(NULL), |
135 did_stop_loading_(false), | 135 did_stop_loading_(false), |
136 document_element_available_(false), | 136 document_element_available_(false), |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 const GURL& ExtensionHost::GetURL() const { | 239 const GURL& ExtensionHost::GetURL() const { |
240 return host_contents()->GetURL(); | 240 return host_contents()->GetURL(); |
241 } | 241 } |
242 | 242 |
243 void ExtensionHost::LoadInitialURL() { | 243 void ExtensionHost::LoadInitialURL() { |
244 if (!is_background_page() && | 244 if (!is_background_page() && |
245 !profile_->GetExtensionService()->IsBackgroundPageReady(extension_)) { | 245 !profile_->GetExtensionService()->IsBackgroundPageReady(extension_)) { |
246 // Make sure the background page loads before any others. | 246 // Make sure the background page loads before any others. |
247 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 247 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
248 content::Source<Extension>(extension_)); | 248 content::Source<extensions::Extension>(extension_)); |
249 return; | 249 return; |
250 } | 250 } |
251 | 251 |
252 host_contents_->GetController().LoadURL( | 252 host_contents_->GetController().LoadURL( |
253 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, | 253 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, |
254 std::string()); | 254 std::string()); |
255 } | 255 } |
256 | 256 |
257 void ExtensionHost::Close() { | 257 void ExtensionHost::Close() { |
258 content::NotificationService::current()->Notify( | 258 content::NotificationService::current()->Notify( |
(...skipping 10 matching lines...) Expand all Loading... |
269 DCHECK(profile_->GetExtensionService()-> | 269 DCHECK(profile_->GetExtensionService()-> |
270 IsBackgroundPageReady(extension_)); | 270 IsBackgroundPageReady(extension_)); |
271 LoadInitialURL(); | 271 LoadInitialURL(); |
272 break; | 272 break; |
273 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 273 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
274 // The extension object will be deleted after this notification has been | 274 // The extension object will be deleted after this notification has been |
275 // sent. NULL it out so that dirty pointer issues don't arise in cases | 275 // sent. NULL it out so that dirty pointer issues don't arise in cases |
276 // when multiple ExtensionHost objects pointing to the same Extension are | 276 // when multiple ExtensionHost objects pointing to the same Extension are |
277 // present. | 277 // present. |
278 if (extension_ == | 278 if (extension_ == |
279 content::Details<UnloadedExtensionInfo>(details)->extension) { | 279 content::Details<extensions::UnloadedExtensionInfo>( |
| 280 details)->extension) { |
280 extension_ = NULL; | 281 extension_ = NULL; |
281 } | 282 } |
282 break; | 283 break; |
283 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: | 284 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
284 if (content::Source<WebContents>(source).ptr() == | 285 if (content::Source<WebContents>(source).ptr() == |
285 associated_web_contents_) { | 286 associated_web_contents_) { |
286 associated_web_contents_ = NULL; | 287 associated_web_contents_ = NULL; |
287 } | 288 } |
288 break; | 289 break; |
289 default: | 290 default: |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 params.user_gesture = user_gesture; | 588 params.user_gesture = user_gesture; |
588 browser::Navigate(¶ms); | 589 browser::Navigate(¶ms); |
589 } | 590 } |
590 | 591 |
591 void ExtensionHost::RenderViewReady() { | 592 void ExtensionHost::RenderViewReady() { |
592 content::NotificationService::current()->Notify( | 593 content::NotificationService::current()->Notify( |
593 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 594 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
594 content::Source<Profile>(profile_), | 595 content::Source<Profile>(profile_), |
595 content::Details<ExtensionHost>(this)); | 596 content::Details<ExtensionHost>(this)); |
596 } | 597 } |
OLD | NEW |