| OLD | NEW |
| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 void ExtensionHost::DisableScrollbarsForSmallWindows( | 325 void ExtensionHost::DisableScrollbarsForSmallWindows( |
| 326 const gfx::Size& size_limit) { | 326 const gfx::Size& size_limit) { |
| 327 render_view_host()->DisableScrollbarsForThreshold(size_limit); | 327 render_view_host()->DisableScrollbarsForThreshold(size_limit); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void ExtensionHost::DidStopLoading() { | 330 void ExtensionHost::DidStopLoading() { |
| 331 bool notify = !did_stop_loading_; | 331 bool notify = !did_stop_loading_; |
| 332 did_stop_loading_ = true; | 332 did_stop_loading_ = true; |
| 333 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 333 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| 334 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || | 334 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || |
| 335 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 335 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || |
| 336 extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) { |
| 336 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 337 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| 337 if (view_.get()) | 338 if (view_.get()) |
| 338 view_->DidStopLoading(); | 339 view_->DidStopLoading(); |
| 339 #endif | 340 #endif |
| 340 } | 341 } |
| 341 if (notify) { | 342 if (notify) { |
| 342 content::NotificationService::current()->Notify( | 343 content::NotificationService::current()->Notify( |
| 343 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 344 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 344 content::Source<Profile>(profile_), | 345 content::Source<Profile>(profile_), |
| 345 content::Details<ExtensionHost>(this)); | 346 content::Details<ExtensionHost>(this)); |
| 346 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 347 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 347 UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime", | 348 UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime", |
| 348 since_created_.Elapsed()); | 349 since_created_.Elapsed()); |
| 349 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG) { | 350 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG) { |
| 350 UMA_HISTOGRAM_TIMES("Extensions.DialogLoadTime", | 351 UMA_HISTOGRAM_TIMES("Extensions.DialogLoadTime", |
| 351 since_created_.Elapsed()); | 352 since_created_.Elapsed()); |
| 352 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 353 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
| 353 UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime", | 354 UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime", |
| 354 since_created_.Elapsed()); | 355 since_created_.Elapsed()); |
| 355 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 356 } else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { |
| 356 UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime", | 357 UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime", |
| 357 since_created_.Elapsed()); | 358 since_created_.Elapsed()); |
| 359 } else if (extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) { |
| 360 UMA_HISTOGRAM_TIMES("Extensions.ShellLoadTime", since_created_.Elapsed()); |
| 358 } | 361 } |
| 359 } | 362 } |
| 360 } | 363 } |
| 361 | 364 |
| 362 void ExtensionHost::DocumentAvailableInMainFrame() { | 365 void ExtensionHost::DocumentAvailableInMainFrame() { |
| 363 // If the document has already been marked as available for this host, then | 366 // If the document has already been marked as available for this host, then |
| 364 // bail. No need for the redundant setup. http://crbug.com/31170 | 367 // bail. No need for the redundant setup. http://crbug.com/31170 |
| 365 if (document_element_available_) | 368 if (document_element_available_) |
| 366 return; | 369 return; |
| 367 | 370 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 383 content::NotificationService::current()->Notify( | 386 content::NotificationService::current()->Notify( |
| 384 chrome::NOTIFICATION_EXTENSION_HOST_DOM_CONTENT_LOADED, | 387 chrome::NOTIFICATION_EXTENSION_HOST_DOM_CONTENT_LOADED, |
| 385 content::Source<Profile>(profile_), | 388 content::Source<Profile>(profile_), |
| 386 content::Details<ExtensionHost>(this)); | 389 content::Details<ExtensionHost>(this)); |
| 387 } | 390 } |
| 388 | 391 |
| 389 void ExtensionHost::CloseContents(TabContents* contents) { | 392 void ExtensionHost::CloseContents(TabContents* contents) { |
| 390 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 393 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| 391 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || | 394 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG || |
| 392 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 395 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
| 393 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 396 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR || |
| 397 extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) { |
| 394 content::NotificationService::current()->Notify( | 398 content::NotificationService::current()->Notify( |
| 395 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 399 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 396 content::Source<Profile>(profile_), | 400 content::Source<Profile>(profile_), |
| 397 content::Details<ExtensionHost>(this)); | 401 content::Details<ExtensionHost>(this)); |
| 398 } | 402 } |
| 399 } | 403 } |
| 400 | 404 |
| 401 TabContents* ExtensionHost::OpenURLFromTab(TabContents* source, | 405 TabContents* ExtensionHost::OpenURLFromTab(TabContents* source, |
| 402 const OpenURLParams& params) { | 406 const OpenURLParams& params) { |
| 403 // Whitelist the dispositions we will allow to be opened. | 407 // Whitelist the dispositions we will allow to be opened. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 browser::Navigate(¶ms); | 550 browser::Navigate(¶ms); |
| 547 } | 551 } |
| 548 | 552 |
| 549 | 553 |
| 550 void ExtensionHost::RenderViewReady() { | 554 void ExtensionHost::RenderViewReady() { |
| 551 content::NotificationService::current()->Notify( | 555 content::NotificationService::current()->Notify( |
| 552 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 556 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 553 content::Source<Profile>(profile_), | 557 content::Source<Profile>(profile_), |
| 554 content::Details<ExtensionHost>(this)); | 558 content::Details<ExtensionHost>(this)); |
| 555 } | 559 } |
| OLD | NEW |