Chromium Code Reviews| 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/ui/views/hung_renderer_view.h" | 5 #include "chrome/browser/ui/views/hung_renderer_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/favicon/favicon_tab_helper.h" | 10 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 11 #include "chrome/browser/platform_util.h" | 11 #include "chrome/browser/platform_util.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" | 13 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" |
| 14 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 14 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 15 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/logging_chrome.h" | 17 #include "chrome/common/logging_chrome.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/constrained_window/constrained_window_views.h" | 19 #include "components/constrained_window/constrained_window_views.h" |
| 20 #include "components/web_modal/web_contents_modal_dialog_host.h" | 20 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/user_metrics.h" | |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/common/result_codes.h" | 25 #include "content/public/common/result_codes.h" |
| 25 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
| 26 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 30 #include "ui/views/controls/button/label_button.h" | 31 #include "ui/views/controls/button/label_button.h" |
| 31 #include "ui/views/controls/image_view.h" | 32 #include "ui/views/controls/image_view.h" |
| 32 #include "ui/views/controls/label.h" | 33 #include "ui/views/controls/label.h" |
| 33 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
| 34 #include "ui/views/layout/layout_constants.h" | 35 #include "ui/views/layout/layout_constants.h" |
| 35 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 36 #include "ui/views/window/client_view.h" | 37 #include "ui/views/window/client_view.h" |
| 37 | 38 |
| 38 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 39 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" | 40 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" |
| 40 #include "chrome/browser/profiles/profile.h" | 41 #include "chrome/browser/profiles/profile.h" |
| 41 #include "chrome/browser/shell_integration.h" | 42 #include "chrome/browser/shell_integration.h" |
| 42 #include "ui/base/win/shell.h" | 43 #include "ui/base/win/shell.h" |
| 43 #include "ui/views/win/hwnd_util.h" | 44 #include "ui/views/win/hwnd_util.h" |
| 44 #endif | 45 #endif |
| 45 | 46 |
| 47 using base::UserMetricsAction; | |
| 46 using content::WebContents; | 48 using content::WebContents; |
| 47 | 49 |
| 48 HungRendererDialogView* HungRendererDialogView::g_instance_ = NULL; | 50 HungRendererDialogView* HungRendererDialogView::g_instance_ = NULL; |
| 49 | 51 |
| 50 /////////////////////////////////////////////////////////////////////////////// | 52 /////////////////////////////////////////////////////////////////////////////// |
| 51 // HungPagesTableModel, public: | 53 // HungPagesTableModel, public: |
| 52 | 54 |
| 53 HungPagesTableModel::HungPagesTableModel(Delegate* delegate) | 55 HungPagesTableModel::HungPagesTableModel(Delegate* delegate) |
| 54 : observer_(NULL), | 56 : observer_(NULL), |
| 55 delegate_(delegate) { | 57 delegate_(delegate) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 #endif | 278 #endif |
| 277 | 279 |
| 278 // We only do this if the window isn't active (i.e. hasn't been shown yet, | 280 // We only do this if the window isn't active (i.e. hasn't been shown yet, |
| 279 // or is currently shown but deactivated for another WebContents). This is | 281 // or is currently shown but deactivated for another WebContents). This is |
| 280 // because this window is a singleton, and it's possible another active | 282 // because this window is a singleton, and it's possible another active |
| 281 // renderer may hang while this one is showing, and we don't want to reset | 283 // renderer may hang while this one is showing, and we don't want to reset |
| 282 // the list of hung pages for a potentially unrelated renderer while this | 284 // the list of hung pages for a potentially unrelated renderer while this |
| 283 // one is showing. | 285 // one is showing. |
| 284 hung_pages_table_model_->InitForWebContents(contents); | 286 hung_pages_table_model_->InitForWebContents(contents); |
| 285 GetWidget()->Show(); | 287 GetWidget()->Show(); |
| 288 content::RecordAction(UserMetricsAction("HungRendererDialogView.Shown")); | |
|
msw
2015/01/02 22:58:35
Should this be outside of the active Widget check?
| |
| 286 } | 289 } |
| 287 } | 290 } |
| 288 | 291 |
| 289 void HungRendererDialogView::EndForWebContents(WebContents* contents) { | 292 void HungRendererDialogView::EndForWebContents(WebContents* contents) { |
| 290 DCHECK(contents); | 293 DCHECK(contents); |
| 291 if (hung_pages_table_model_->RowCount() == 0 || | 294 if (hung_pages_table_model_->RowCount() == 0 || |
| 292 hung_pages_table_model_->GetRenderProcessHost() == | 295 hung_pages_table_model_->GetRenderProcessHost() == |
| 293 contents->GetRenderProcessHost()) { | 296 contents->GetRenderProcessHost()) { |
| 294 GetWidget()->Close(); | 297 GetWidget()->Close(); |
| 298 content::RecordAction(UserMetricsAction("HungRendererDialogView.Closed")); | |
|
msw
2015/01/02 22:58:35
Should this also be recorded in HungRendererDialog
| |
| 295 // Close is async, make sure we drop our references to the tab immediately | 299 // Close is async, make sure we drop our references to the tab immediately |
| 296 // (it may be going away). | 300 // (it may be going away). |
| 297 hung_pages_table_model_->InitForWebContents(NULL); | 301 hung_pages_table_model_->InitForWebContents(NULL); |
| 298 } | 302 } |
| 299 } | 303 } |
| 300 | 304 |
| 301 /////////////////////////////////////////////////////////////////////////////// | 305 /////////////////////////////////////////////////////////////////////////////// |
| 302 // HungRendererDialogView, views::DialogDelegate implementation: | 306 // HungRendererDialogView, views::DialogDelegate implementation: |
| 303 | 307 |
| 304 base::string16 HungRendererDialogView::GetWindowTitle() const { | 308 base::string16 HungRendererDialogView::GetWindowTitle() const { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 331 DCHECK(!kill_button_); | 335 DCHECK(!kill_button_); |
| 332 kill_button_ = new views::LabelButton(this, | 336 kill_button_ = new views::LabelButton(this, |
| 333 l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_RENDERER_END)); | 337 l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_RENDERER_END)); |
| 334 kill_button_->SetStyle(views::Button::STYLE_BUTTON); | 338 kill_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 335 return kill_button_; | 339 return kill_button_; |
| 336 } | 340 } |
| 337 | 341 |
| 338 bool HungRendererDialogView::Accept(bool window_closing) { | 342 bool HungRendererDialogView::Accept(bool window_closing) { |
| 339 // Don't do anything if we're being called only because the dialog is being | 343 // Don't do anything if we're being called only because the dialog is being |
| 340 // destroyed and we don't supply a Cancel function... | 344 // destroyed and we don't supply a Cancel function... |
| 341 if (window_closing) | 345 if (window_closing) { |
| 346 content::RecordAction( | |
| 347 UserMetricsAction("HungRendererDialogView.CloseButton")); | |
| 342 return true; | 348 return true; |
| 349 } | |
| 343 | 350 |
| 344 // Start waiting again for responsiveness. | 351 // Start waiting again for responsiveness. |
| 345 if (hung_pages_table_model_->GetRenderViewHost()) | 352 if (hung_pages_table_model_->GetRenderViewHost()) { |
| 353 content::RecordAction( | |
| 354 UserMetricsAction("HungRendererDialogView.WaitButton")); | |
| 346 hung_pages_table_model_->GetRenderViewHost()->RestartHangMonitorTimeout(); | 355 hung_pages_table_model_->GetRenderViewHost()->RestartHangMonitorTimeout(); |
| 356 } | |
| 347 return true; | 357 return true; |
| 348 } | 358 } |
| 349 | 359 |
| 350 | 360 |
| 351 bool HungRendererDialogView::UseNewStyleForThisDialog() const { | 361 bool HungRendererDialogView::UseNewStyleForThisDialog() const { |
| 352 #if defined(OS_WIN) | 362 #if defined(OS_WIN) |
| 353 // Use the old dialog style without Aero glass, otherwise the dialog will be | 363 // Use the old dialog style without Aero glass, otherwise the dialog will be |
| 354 // visually constrained to browser window bounds. See http://crbug.com/323278 | 364 // visually constrained to browser window bounds. See http://crbug.com/323278 |
| 355 return ui::win::IsAeroGlassEnabled(); | 365 return ui::win::IsAeroGlassEnabled(); |
| 356 #else | 366 #else |
| 357 return views::DialogDelegateView::UseNewStyleForThisDialog(); | 367 return views::DialogDelegateView::UseNewStyleForThisDialog(); |
| 358 #endif | 368 #endif |
| 359 } | 369 } |
| 360 | 370 |
| 361 /////////////////////////////////////////////////////////////////////////////// | 371 /////////////////////////////////////////////////////////////////////////////// |
| 362 // HungRendererDialogView, views::ButtonListener implementation: | 372 // HungRendererDialogView, views::ButtonListener implementation: |
| 363 | 373 |
| 364 void HungRendererDialogView::ButtonPressed( | 374 void HungRendererDialogView::ButtonPressed( |
| 365 views::Button* sender, const ui::Event& event) { | 375 views::Button* sender, const ui::Event& event) { |
| 366 if (sender == kill_button_ && | 376 if (sender == kill_button_ && |
| 367 hung_pages_table_model_->GetRenderProcessHost()) { | 377 hung_pages_table_model_->GetRenderProcessHost()) { |
| 378 content::RecordAction( | |
| 379 UserMetricsAction("HungRendererDialogView.KillButton")); | |
| 368 KillRendererProcess(hung_pages_table_model_->GetRenderProcessHost()); | 380 KillRendererProcess(hung_pages_table_model_->GetRenderProcessHost()); |
| 369 } | 381 } |
| 370 } | 382 } |
| 371 | 383 |
| 372 /////////////////////////////////////////////////////////////////////////////// | 384 /////////////////////////////////////////////////////////////////////////////// |
| 373 // HungRendererDialogView, HungPagesTableModel::Delegate overrides: | 385 // HungRendererDialogView, HungPagesTableModel::Delegate overrides: |
| 374 | 386 |
| 375 void HungRendererDialogView::TabDestroyed() { | 387 void HungRendererDialogView::TabDestroyed() { |
| 376 GetWidget()->Close(); | 388 GetWidget()->Close(); |
| 377 } | 389 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 451 |
| 440 // static | 452 // static |
| 441 void HungRendererDialogView::InitClass() { | 453 void HungRendererDialogView::InitClass() { |
| 442 static bool initialized = false; | 454 static bool initialized = false; |
| 443 if (!initialized) { | 455 if (!initialized) { |
| 444 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 456 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 445 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); | 457 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); |
| 446 initialized = true; | 458 initialized = true; |
| 447 } | 459 } |
| 448 } | 460 } |
| OLD | NEW |