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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 content::Details<UnloadedExtensionInfo>(details)->extension) { | 286 content::Details<UnloadedExtensionInfo>(details)->extension) { |
287 extension_ = NULL; | 287 extension_ = NULL; |
288 } | 288 } |
289 break; | 289 break; |
290 default: | 290 default: |
291 NOTREACHED() << "Unexpected notification sent."; | 291 NOTREACHED() << "Unexpected notification sent."; |
292 break; | 292 break; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 void ExtensionHost::UpdatePreferredSize(WebContents* source, | 296 void ExtensionHost::ResizeDueToAutoResize(WebContents* source, |
297 const gfx::Size& pref_size) { | 297 const gfx::Size& new_size) { |
298 if (view_.get()) | 298 if (view_.get()) |
299 view_->UpdatePreferredSize(pref_size); | 299 view_->ResizeDueToAutoResize(new_size); |
300 } | 300 } |
301 | 301 |
302 void ExtensionHost::RenderViewGone(base::TerminationStatus status) { | 302 void ExtensionHost::RenderViewGone(base::TerminationStatus status) { |
303 // During browser shutdown, we may use sudden termination on an extension | 303 // During browser shutdown, we may use sudden termination on an extension |
304 // process, so it is expected to lose our connection to the render view. | 304 // process, so it is expected to lose our connection to the render view. |
305 // Do nothing. | 305 // Do nothing. |
306 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) | 306 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) |
307 return; | 307 return; |
308 | 308 |
309 // In certain cases, multiple ExtensionHost objects may have pointed to | 309 // In certain cases, multiple ExtensionHost objects may have pointed to |
(...skipping 17 matching lines...) Expand all Loading... |
327 void ExtensionHost::InsertInfobarCSS() { | 327 void ExtensionHost::InsertInfobarCSS() { |
328 DCHECK(!is_background_page()); | 328 DCHECK(!is_background_page()); |
329 | 329 |
330 static const base::StringPiece css( | 330 static const base::StringPiece css( |
331 ResourceBundle::GetSharedInstance().GetRawDataResource( | 331 ResourceBundle::GetSharedInstance().GetRawDataResource( |
332 IDR_EXTENSIONS_INFOBAR_CSS)); | 332 IDR_EXTENSIONS_INFOBAR_CSS)); |
333 | 333 |
334 render_view_host()->InsertCSS(string16(), css.as_string()); | 334 render_view_host()->InsertCSS(string16(), css.as_string()); |
335 } | 335 } |
336 | 336 |
337 void ExtensionHost::DisableScrollbarsForSmallWindows( | |
338 const gfx::Size& size_limit) { | |
339 render_view_host()->DisableScrollbarsForThreshold(size_limit); | |
340 } | |
341 | |
342 void ExtensionHost::DidStopLoading() { | 337 void ExtensionHost::DidStopLoading() { |
343 bool notify = !did_stop_loading_; | 338 bool notify = !did_stop_loading_; |
344 did_stop_loading_ = true; | 339 did_stop_loading_ = true; |
345 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 340 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
346 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || | 341 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || |
347 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || | 342 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || |
348 extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL || | 343 extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL || |
349 extension_host_type_ == chrome::VIEW_TYPE_PANEL) { | 344 extension_host_type_ == chrome::VIEW_TYPE_PANEL) { |
350 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 345 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
351 if (view_.get()) | 346 if (view_.get()) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 473 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
479 extension_function_dispatcher_.Dispatch(params, render_view_host()); | 474 extension_function_dispatcher_.Dispatch(params, render_view_host()); |
480 } | 475 } |
481 | 476 |
482 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 477 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
483 render_view_host_ = render_view_host; | 478 render_view_host_ = render_view_host; |
484 | 479 |
485 if (view_.get()) | 480 if (view_.get()) |
486 view_->RenderViewCreated(); | 481 view_->RenderViewCreated(); |
487 | 482 |
488 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | |
489 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | |
490 render_view_host->EnablePreferredSizeMode(); | |
491 } | |
492 | |
493 // If the host is bound to a browser, then extract its window id. | 483 // If the host is bound to a browser, then extract its window id. |
494 // Extensions hosted in ExternalTabContainer objects may not have | 484 // Extensions hosted in ExternalTabContainer objects may not have |
495 // an associated browser. | 485 // an associated browser. |
496 const Browser* browser = GetBrowser(); | 486 const Browser* browser = GetBrowser(); |
497 if (browser) { | 487 if (browser) { |
498 render_view_host->Send(new ExtensionMsg_UpdateBrowserWindowId( | 488 render_view_host->Send(new ExtensionMsg_UpdateBrowserWindowId( |
499 render_view_host->GetRoutingID(), | 489 render_view_host->GetRoutingID(), |
500 ExtensionTabUtil::GetWindowId(browser))); | 490 ExtensionTabUtil::GetWindowId(browser))); |
501 } | 491 } |
502 } | 492 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 params.user_gesture = user_gesture; | 560 params.user_gesture = user_gesture; |
571 browser::Navigate(¶ms); | 561 browser::Navigate(¶ms); |
572 } | 562 } |
573 | 563 |
574 void ExtensionHost::RenderViewReady() { | 564 void ExtensionHost::RenderViewReady() { |
575 content::NotificationService::current()->Notify( | 565 content::NotificationService::current()->Notify( |
576 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 566 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
577 content::Source<Profile>(profile_), | 567 content::Source<Profile>(profile_), |
578 content::Details<ExtensionHost>(this)); | 568 content::Details<ExtensionHost>(this)); |
579 } | 569 } |
OLD | NEW |