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

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

Issue 8734018: Fix regression with extension popup bubbles on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 9 years 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) 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // ExtensionHost 113 // ExtensionHost
114 114
115 ExtensionHost::ExtensionHost(const Extension* extension, 115 ExtensionHost::ExtensionHost(const Extension* extension,
116 SiteInstance* site_instance, 116 SiteInstance* site_instance,
117 const GURL& url, 117 const GURL& url,
118 content::ViewType host_type) 118 content::ViewType host_type)
119 : extension_(extension), 119 : extension_(extension),
120 extension_id_(extension->id()), 120 extension_id_(extension->id()),
121 profile_(Profile::FromBrowserContext( 121 profile_(Profile::FromBrowserContext(
122 site_instance->browsing_instance()->browser_context())), 122 site_instance->browsing_instance()->browser_context())),
123 render_view_host_(NULL),
123 did_stop_loading_(false), 124 did_stop_loading_(false),
124 document_element_available_(false), 125 document_element_available_(false),
125 initial_url_(url), 126 initial_url_(url),
126 ALLOW_THIS_IN_INITIALIZER_LIST( 127 ALLOW_THIS_IN_INITIALIZER_LIST(
127 extension_function_dispatcher_(profile_, this)), 128 extension_function_dispatcher_(profile_, this)),
128 extension_host_type_(host_type), 129 extension_host_type_(host_type),
129 associated_tab_contents_(NULL) { 130 associated_tab_contents_(NULL) {
130 host_contents_.reset(new TabContents( 131 host_contents_.reset(new TabContents(
131 profile_, site_instance, MSG_ROUTING_NONE, NULL, NULL)); 132 profile_, site_instance, MSG_ROUTING_NONE, NULL, NULL));
132 TabContentsObserver::Observe(host_contents_.get()); 133 TabContentsObserver::Observe(host_contents_.get());
133 host_contents_->set_delegate(this); 134 host_contents_->set_delegate(this);
134 host_contents_->set_view_type(host_type); 135 host_contents_->set_view_type(host_type);
135 136
137 render_view_host_ = host_contents_->render_view_host();
138
136 // Listen for when an extension is unloaded from the same profile, as it may 139 // Listen for when an extension is unloaded from the same profile, as it may
137 // be the same extension that this points to. 140 // be the same extension that this points to.
138 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 141 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
139 content::Source<Profile>(profile_)); 142 content::Source<Profile>(profile_));
140 } 143 }
141 144
142 // This "mock" constructor should only be used by unit tests. 145 // This "mock" constructor should only be used by unit tests.
143 ExtensionHost::ExtensionHost(const Extension* extension, 146 ExtensionHost::ExtensionHost(const Extension* extension,
144 content::ViewType host_type) 147 content::ViewType host_type)
145 : extension_(extension), 148 : extension_(extension),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // TODO(port) 181 // TODO(port)
179 NOTREACHED(); 182 NOTREACHED();
180 #endif 183 #endif
181 } 184 }
182 185
183 TabContents* ExtensionHost::GetAssociatedTabContents() const { 186 TabContents* ExtensionHost::GetAssociatedTabContents() const {
184 return associated_tab_contents_; 187 return associated_tab_contents_;
185 } 188 }
186 189
187 content::RenderProcessHost* ExtensionHost::render_process_host() const { 190 content::RenderProcessHost* ExtensionHost::render_process_host() const {
188 return host_contents()->GetRenderProcessHost(); 191 return render_view_host()->process();
189 } 192 }
190 193
191 RenderViewHost* ExtensionHost::render_view_host() const { 194 RenderViewHost* ExtensionHost::render_view_host() const {
192 // TODO(mpcomplete): This can be NULL. How do we handle that? 195 // TODO(mpcomplete): This can be NULL. How do we handle that?
193 return host_contents()->render_view_host(); 196 return render_view_host_;
194 } 197 }
195 198
196 bool ExtensionHost::IsRenderViewLive() const { 199 bool ExtensionHost::IsRenderViewLive() const {
197 return render_view_host()->IsRenderViewLive(); 200 return render_view_host()->IsRenderViewLive();
198 } 201 }
199 202
200 void ExtensionHost::CreateRenderViewSoon() { 203 void ExtensionHost::CreateRenderViewSoon() {
201 if (render_process_host()->HasConnection()) { 204 if (render_process_host() && render_process_host()->HasConnection()) {
202 // If the process is already started, go ahead and initialize the RenderView 205 // If the process is already started, go ahead and initialize the RenderView
203 // synchronously. The process creation is the real meaty part that we want 206 // synchronously. The process creation is the real meaty part that we want
204 // to defer. 207 // to defer.
205 CreateRenderViewNow(); 208 CreateRenderViewNow();
206 } else { 209 } else {
207 ProcessCreationQueue::GetInstance()->CreateSoon(this); 210 ProcessCreationQueue::GetInstance()->CreateSoon(this);
208 } 211 }
209 } 212 }
210 213
211 void ExtensionHost::CreateRenderViewNow() { 214 void ExtensionHost::CreateRenderViewNow() {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 IPC_MESSAGE_UNHANDLED(handled = false) 415 IPC_MESSAGE_UNHANDLED(handled = false)
413 IPC_END_MESSAGE_MAP() 416 IPC_END_MESSAGE_MAP()
414 return handled; 417 return handled;
415 } 418 }
416 419
417 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { 420 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) {
418 extension_function_dispatcher_.Dispatch(params, render_view_host()); 421 extension_function_dispatcher_.Dispatch(params, render_view_host());
419 } 422 }
420 423
421 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { 424 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
425 render_view_host_ = render_view_host;
426
422 if (view_.get()) 427 if (view_.get())
423 view_->RenderViewCreated(); 428 view_->RenderViewCreated();
424 429
425 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || 430 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP ||
426 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { 431 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) {
427 render_view_host->EnablePreferredSizeMode(); 432 render_view_host->EnablePreferredSizeMode();
428 } 433 }
429 434
430 // If the host is bound to a browser, then extract its window id. 435 // If the host is bound to a browser, then extract its window id.
431 // Extensions hosted in ExternalTabContainer objects may not have 436 // Extensions hosted in ExternalTabContainer objects may not have
432 // an associated browser. 437 // an associated browser.
433 const Browser* browser = GetBrowser(); 438 const Browser* browser = GetBrowser();
434 if (browser) { 439 if (browser) {
435 render_view_host->Send(new ExtensionMsg_UpdateBrowserWindowId( 440 render_view_host->Send(new ExtensionMsg_UpdateBrowserWindowId(
436 render_view_host->routing_id(), 441 render_view_host->routing_id(),
437 ExtensionTabUtil::GetWindowId(browser))); 442 ExtensionTabUtil::GetWindowId(browser)));
438 } 443 }
439 } 444 }
440 445
446 void ExtensionHost::RenderViewDeleted(RenderViewHost* render_view_host) {
447 // If our RenderViewHost is deleted, fall back to the host_contents' current
448 // RVH. There is sometimes a small gap between the pending RVH being deleted
449 // and RenderViewCreated being called, so we update it here.
450 if (render_view_host == render_view_host_)
451 render_view_host_ = host_contents_->render_view_host();
452 }
453
441 content::JavaScriptDialogCreator* ExtensionHost::GetJavaScriptDialogCreator() { 454 content::JavaScriptDialogCreator* ExtensionHost::GetJavaScriptDialogCreator() {
442 return GetJavaScriptDialogCreatorInstance(); 455 return GetJavaScriptDialogCreatorInstance();
443 } 456 }
444 457
445 void ExtensionHost::AddNewContents(TabContents* source, 458 void ExtensionHost::AddNewContents(TabContents* source,
446 TabContents* new_contents, 459 TabContents* new_contents,
447 WindowOpenDisposition disposition, 460 WindowOpenDisposition disposition,
448 const gfx::Rect& initial_pos, 461 const gfx::Rect& initial_pos,
449 bool user_gesture) { 462 bool user_gesture) {
450 // TODO(mpcomplete): is all this necessary? Maybe we can just call the 463 // TODO(mpcomplete): is all this necessary? Maybe we can just call the
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 browser->AddTabContents(contents, disposition, initial_pos, user_gesture); 516 browser->AddTabContents(contents, disposition, initial_pos, user_gesture);
504 } 517 }
505 518
506 519
507 void ExtensionHost::RenderViewReady() { 520 void ExtensionHost::RenderViewReady() {
508 content::NotificationService::current()->Notify( 521 content::NotificationService::current()->Notify(
509 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 522 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
510 content::Source<Profile>(profile_), 523 content::Source<Profile>(profile_),
511 content::Details<ExtensionHost>(this)); 524 content::Details<ExtensionHost>(this));
512 } 525 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/ui/cocoa/extensions/extension_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698