| OLD | NEW |
| 1 // Copyright (c) 2011 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 view_->Init(); | 182 view_->Init(); |
| 183 #elif defined(TOOLKIT_USES_GTK) | 183 #elif defined(TOOLKIT_USES_GTK) |
| 184 view_.reset(new ExtensionViewGtk(this, browser)); | 184 view_.reset(new ExtensionViewGtk(this, browser)); |
| 185 view_->Init(); | 185 view_->Init(); |
| 186 #else | 186 #else |
| 187 // TODO(port) | 187 // TODO(port) |
| 188 NOTREACHED(); | 188 NOTREACHED(); |
| 189 #endif | 189 #endif |
| 190 } | 190 } |
| 191 | 191 |
| 192 void ExtensionHost::CreateViewWithoutBrowser() { |
| 193 CreateView(NULL); |
| 194 } |
| 195 |
| 192 WebContents* ExtensionHost::GetAssociatedWebContents() const { | 196 WebContents* ExtensionHost::GetAssociatedWebContents() const { |
| 193 return associated_web_contents_; | 197 return associated_web_contents_; |
| 194 } | 198 } |
| 195 | 199 |
| 196 content::RenderProcessHost* ExtensionHost::render_process_host() const { | 200 content::RenderProcessHost* ExtensionHost::render_process_host() const { |
| 197 return render_view_host()->process(); | 201 return render_view_host()->process(); |
| 198 } | 202 } |
| 199 | 203 |
| 200 RenderViewHost* ExtensionHost::render_view_host() const { | 204 RenderViewHost* ExtensionHost::render_view_host() const { |
| 201 // TODO(mpcomplete): This can be NULL. How do we handle that? | 205 // TODO(mpcomplete): This can be NULL. How do we handle that? |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void ExtensionHost::DisableScrollbarsForSmallWindows( | 328 void ExtensionHost::DisableScrollbarsForSmallWindows( |
| 325 const gfx::Size& size_limit) { | 329 const gfx::Size& size_limit) { |
| 326 render_view_host()->DisableScrollbarsForThreshold(size_limit); | 330 render_view_host()->DisableScrollbarsForThreshold(size_limit); |
| 327 } | 331 } |
| 328 | 332 |
| 329 void ExtensionHost::DidStopLoading() { | 333 void ExtensionHost::DidStopLoading() { |
| 330 bool notify = !did_stop_loading_; | 334 bool notify = !did_stop_loading_; |
| 331 did_stop_loading_ = true; | 335 did_stop_loading_ = true; |
| 332 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 336 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| 333 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || | 337 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || |
| 334 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 338 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || |
| 339 extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) { |
| 335 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 340 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| 336 if (view_.get()) | 341 if (view_.get()) |
| 337 view_->DidStopLoading(); | 342 view_->DidStopLoading(); |
| 338 #endif | 343 #endif |
| 339 } | 344 } |
| 340 if (notify) { | 345 if (notify) { |
| 341 content::NotificationService::current()->Notify( | 346 content::NotificationService::current()->Notify( |
| 342 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 347 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 343 content::Source<Profile>(profile_), | 348 content::Source<Profile>(profile_), |
| 344 content::Details<ExtensionHost>(this)); | 349 content::Details<ExtensionHost>(this)); |
| 345 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 350 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 346 UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime", | 351 UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime", |
| 347 since_created_.Elapsed()); | 352 since_created_.Elapsed()); |
| 348 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG) { | 353 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG) { |
| 349 UMA_HISTOGRAM_TIMES("Extensions.DialogLoadTime", | 354 UMA_HISTOGRAM_TIMES("Extensions.DialogLoadTime", |
| 350 since_created_.Elapsed()); | 355 since_created_.Elapsed()); |
| 351 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 356 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
| 352 UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime", | 357 UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime", |
| 353 since_created_.Elapsed()); | 358 since_created_.Elapsed()); |
| 354 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 359 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { |
| 355 UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime", | 360 UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime", |
| 356 since_created_.Elapsed()); | 361 since_created_.Elapsed()); |
| 362 } else if (extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) { |
| 363 UMA_HISTOGRAM_TIMES("Extensions.ShellLoadTime", since_created_.Elapsed()); |
| 357 } | 364 } |
| 358 } | 365 } |
| 359 } | 366 } |
| 360 | 367 |
| 361 void ExtensionHost::DocumentAvailableInMainFrame() { | 368 void ExtensionHost::DocumentAvailableInMainFrame() { |
| 362 // If the document has already been marked as available for this host, then | 369 // If the document has already been marked as available for this host, then |
| 363 // bail. No need for the redundant setup. http://crbug.com/31170 | 370 // bail. No need for the redundant setup. http://crbug.com/31170 |
| 364 if (document_element_available_) | 371 if (document_element_available_) |
| 365 return; | 372 return; |
| 366 | 373 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 382 content::NotificationService::current()->Notify( | 389 content::NotificationService::current()->Notify( |
| 383 chrome::NOTIFICATION_EXTENSION_HOST_DOM_CONTENT_LOADED, | 390 chrome::NOTIFICATION_EXTENSION_HOST_DOM_CONTENT_LOADED, |
| 384 content::Source<Profile>(profile_), | 391 content::Source<Profile>(profile_), |
| 385 content::Details<ExtensionHost>(this)); | 392 content::Details<ExtensionHost>(this)); |
| 386 } | 393 } |
| 387 | 394 |
| 388 void ExtensionHost::CloseContents(WebContents* contents) { | 395 void ExtensionHost::CloseContents(WebContents* contents) { |
| 389 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 396 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| 390 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || | 397 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || |
| 391 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 398 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
| 392 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 399 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || |
| 400 extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) { |
| 393 content::NotificationService::current()->Notify( | 401 content::NotificationService::current()->Notify( |
| 394 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 402 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 395 content::Source<Profile>(profile_), | 403 content::Source<Profile>(profile_), |
| 396 content::Details<ExtensionHost>(this)); | 404 content::Details<ExtensionHost>(this)); |
| 397 } | 405 } |
| 398 } | 406 } |
| 399 | 407 |
| 400 WebContents* ExtensionHost::OpenURLFromTab(WebContents* source, | 408 WebContents* ExtensionHost::OpenURLFromTab(WebContents* source, |
| 401 const OpenURLParams& params) { | 409 const OpenURLParams& params) { |
| 402 // Whitelist the dispositions we will allow to be opened. | 410 // Whitelist the dispositions we will allow to be opened. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 browser::Navigate(¶ms); | 553 browser::Navigate(¶ms); |
| 546 } | 554 } |
| 547 | 555 |
| 548 | 556 |
| 549 void ExtensionHost::RenderViewReady() { | 557 void ExtensionHost::RenderViewReady() { |
| 550 content::NotificationService::current()->Notify( | 558 content::NotificationService::current()->Notify( |
| 551 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 559 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 552 content::Source<Profile>(profile_), | 560 content::Source<Profile>(profile_), |
| 553 content::Details<ExtensionHost>(this)); | 561 content::Details<ExtensionHost>(this)); |
| 554 } | 562 } |
| OLD | NEW |