Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 397031: Launch processes asynchronously so as not to block the UI thread. For now, re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: return 0 instead of -1 if zygote couldn't launch renderer Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 : extension_(extension), 117 : extension_(extension),
118 profile_(site_instance->browsing_instance()->profile()), 118 profile_(site_instance->browsing_instance()->profile()),
119 did_stop_loading_(false), 119 did_stop_loading_(false),
120 document_element_available_(false), 120 document_element_available_(false),
121 url_(url), 121 url_(url),
122 extension_host_type_(host_type) { 122 extension_host_type_(host_type) {
123 render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE); 123 render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE);
124 render_view_host_->AllowBindings(BindingsPolicy::EXTENSION); 124 render_view_host_->AllowBindings(BindingsPolicy::EXTENSION);
125 if (enable_dom_automation_) 125 if (enable_dom_automation_)
126 render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION); 126 render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION);
127
128 // Listen for when the render process' handle is available so we can add it
129 // to the task manager then.
130 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CREATED,
131 Source<RenderProcessHost>(render_process_host()));
127 } 132 }
128 133
129 ExtensionHost::~ExtensionHost() { 134 ExtensionHost::~ExtensionHost() {
130 NotificationService::current()->Notify( 135 NotificationService::current()->Notify(
131 NotificationType::EXTENSION_HOST_DESTROYED, 136 NotificationType::EXTENSION_HOST_DESTROYED,
132 Source<Profile>(profile_), 137 Source<Profile>(profile_),
133 Details<ExtensionHost>(this)); 138 Details<ExtensionHost>(this));
134 ProcessCreationQueue::get()->Remove(this); 139 ProcessCreationQueue::get()->Remove(this);
135 render_view_host_->Shutdown(); // deletes render_view_host 140 render_view_host_->Shutdown(); // deletes render_view_host
136 } 141 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) { 173 void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) {
169 LOG(INFO) << "Creating RenderView for " + extension_->name(); 174 LOG(INFO) << "Creating RenderView for " + extension_->name();
170 render_view_host_->set_view(host_view); 175 render_view_host_->set_view(host_view);
171 ProcessCreationQueue::get()->CreateSoon(this); 176 ProcessCreationQueue::get()->CreateSoon(this);
172 } 177 }
173 178
174 void ExtensionHost::CreateRenderViewNow() { 179 void ExtensionHost::CreateRenderViewNow() {
175 render_view_host_->CreateRenderView(profile_->GetRequestContext()); 180 render_view_host_->CreateRenderView(profile_->GetRequestContext());
176 NavigateToURL(url_); 181 NavigateToURL(url_);
177 DCHECK(IsRenderViewLive()); 182 DCHECK(IsRenderViewLive());
178 LOG(INFO) << "Sending EXTENSION_PROCESS_CREATED";
179 NotificationService::current()->Notify(
180 NotificationType::EXTENSION_PROCESS_CREATED,
181 Source<Profile>(profile_),
182 Details<ExtensionHost>(this));
183 } 183 }
184 184
185 void ExtensionHost::NavigateToURL(const GURL& url) { 185 void ExtensionHost::NavigateToURL(const GURL& url) {
186 LOG(INFO) << "Request to NavigateToURL " << url.spec() << " for " 186 LOG(INFO) << "Request to NavigateToURL " << url.spec() << " for "
187 << extension_->name(); 187 << extension_->name();
188 // Prevent explicit navigation to another extension id's pages. 188 // Prevent explicit navigation to another extension id's pages.
189 // This method is only called by some APIs, so we still need to protect 189 // This method is only called by some APIs, so we still need to protect
190 // DidNavigate below (location = ""). 190 // DidNavigate below (location = "").
191 if (url.SchemeIs(chrome::kExtensionScheme) && 191 if (url.SchemeIs(chrome::kExtensionScheme) &&
192 url.host() != extension_->id()) { 192 url.host() != extension_->id()) {
(...skipping 16 matching lines...) Expand all
209 } 209 }
210 210
211 void ExtensionHost::Observe(NotificationType type, 211 void ExtensionHost::Observe(NotificationType type,
212 const NotificationSource& source, 212 const NotificationSource& source,
213 const NotificationDetails& details) { 213 const NotificationDetails& details) {
214 if (type == NotificationType::EXTENSION_BACKGROUND_PAGE_READY) { 214 if (type == NotificationType::EXTENSION_BACKGROUND_PAGE_READY) {
215 DCHECK(extension_->GetBackgroundPageReady()); 215 DCHECK(extension_->GetBackgroundPageReady());
216 NavigateToURL(url_); 216 NavigateToURL(url_);
217 } else if (type == NotificationType::BROWSER_THEME_CHANGED) { 217 } else if (type == NotificationType::BROWSER_THEME_CHANGED) {
218 InsertThemeCSS(); 218 InsertThemeCSS();
219 } else if (type == NotificationType::RENDERER_PROCESS_CREATED) {
220 LOG(INFO) << "Sending EXTENSION_PROCESS_CREATED";
221 NotificationService::current()->Notify(
222 NotificationType::EXTENSION_PROCESS_CREATED,
223 Source<Profile>(profile_),
224 Details<ExtensionHost>(this));
219 } else { 225 } else {
220 NOTREACHED(); 226 NOTREACHED();
221 } 227 }
222 } 228 }
223 229
224 void ExtensionHost::UpdatePreferredSize(const gfx::Size& new_size) { 230 void ExtensionHost::UpdatePreferredSize(const gfx::Size& new_size) {
225 if (view_.get()) 231 if (view_.get())
226 view_->UpdatePreferredSize(new_size); 232 view_->UpdatePreferredSize(new_size);
227 } 233 }
228 234
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 window_id = ExtensionTabUtil::GetWindowId( 571 window_id = ExtensionTabUtil::GetWindowId(
566 const_cast<ExtensionHost* >(this)->GetBrowser()); 572 const_cast<ExtensionHost* >(this)->GetBrowser());
567 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { 573 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) {
568 // Background page is not attached to any browser window, so pass -1. 574 // Background page is not attached to any browser window, so pass -1.
569 window_id = -1; 575 window_id = -1;
570 } else { 576 } else {
571 NOTREACHED(); 577 NOTREACHED();
572 } 578 }
573 return window_id; 579 return window_id;
574 } 580 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/renderer_host/browser_render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698