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/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" | 14 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" |
| 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 17 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | |
| 18 #include "chrome/browser/ui/views/layout_utils.h" | |
| 17 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/crash_keys.h" | 20 #include "chrome/common/crash_keys.h" |
| 19 #include "chrome/common/logging_chrome.h" | 21 #include "chrome/common/logging_chrome.h" |
| 20 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 21 #include "chrome/grit/theme_resources.h" | 23 #include "chrome/grit/theme_resources.h" |
| 22 #include "components/constrained_window/constrained_window_views.h" | 24 #include "components/constrained_window/constrained_window_views.h" |
| 23 #include "components/favicon/content/content_favicon_driver.h" | 25 #include "components/favicon/content/content_favicon_driver.h" |
| 24 #include "components/web_modal/web_contents_modal_dialog_host.h" | 26 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 25 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/render_widget_host.h" | 29 #include "content/public/browser/render_widget_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/common/result_codes.h" | 31 #include "content/public/common/result_codes.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
| 33 #include "ui/views/controls/button/md_text_button.h" | 35 #include "ui/views/controls/button/md_text_button.h" |
| 34 #include "ui/views/controls/image_view.h" | 36 #include "ui/views/controls/image_view.h" |
| 35 #include "ui/views/controls/label.h" | 37 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/layout/grid_layout.h" | 38 #include "ui/views/layout/grid_layout.h" |
| 37 #include "ui/views/layout/layout_constants.h" | |
| 38 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 39 #include "ui/views/window/client_view.h" | 40 #include "ui/views/window/client_view.h" |
| 40 | 41 |
| 41 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 42 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" | 43 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" |
| 43 #include "chrome/browser/profiles/profile.h" | 44 #include "chrome/browser/profiles/profile.h" |
| 44 #include "chrome/browser/shell_integration_win.h" | 45 #include "chrome/browser/shell_integration_win.h" |
| 45 #include "ui/base/win/shell.h" | 46 #include "ui/base/win/shell.h" |
| 46 #include "ui/views/win/hwnd_util.h" | 47 #include "ui/views/win/hwnd_util.h" |
| 47 #endif | 48 #endif |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 /////////////////////////////////////////////////////////////////////////////// | 170 /////////////////////////////////////////////////////////////////////////////// |
| 170 // HungRendererDialogView | 171 // HungRendererDialogView |
| 171 | 172 |
| 172 // static | 173 // static |
| 173 gfx::ImageSkia* HungRendererDialogView::frozen_icon_ = NULL; | 174 gfx::ImageSkia* HungRendererDialogView::frozen_icon_ = NULL; |
| 174 | 175 |
| 175 // The dimensions of the hung pages list table view, in pixels. | 176 // The dimensions of the hung pages list table view, in pixels. |
| 176 static const int kTableViewWidth = 300; | 177 static const int kTableViewWidth = 300; |
| 177 static const int kTableViewHeight = 100; | 178 static const int kTableViewHeight = 100; |
| 178 | 179 |
| 179 // Padding space in pixels between frozen icon to the info label, hung pages | |
| 180 // list table view and the Kill pages button. | |
| 181 static const int kCentralColumnPadding = | |
| 182 views::kUnrelatedControlLargeHorizontalSpacing; | |
| 183 | |
| 184 /////////////////////////////////////////////////////////////////////////////// | 180 /////////////////////////////////////////////////////////////////////////////// |
| 185 // HungRendererDialogView, public: | 181 // HungRendererDialogView, public: |
| 186 | 182 |
| 187 // static | 183 // static |
| 188 HungRendererDialogView* HungRendererDialogView::Create( | 184 HungRendererDialogView* HungRendererDialogView::Create( |
| 189 gfx::NativeWindow context) { | 185 gfx::NativeWindow context) { |
| 190 if (!g_instance_) { | 186 if (!g_instance_) { |
| 191 g_instance_ = new HungRendererDialogView; | 187 g_instance_ = new HungRendererDialogView; |
| 192 views::DialogDelegate::CreateDialogWidget(g_instance_, context, NULL); | 188 views::DialogDelegate::CreateDialogWidget(g_instance_, context, NULL); |
| 193 } | 189 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 return l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_RENDERER_WAIT); | 339 return l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_RENDERER_WAIT); |
| 344 } | 340 } |
| 345 | 341 |
| 346 views::View* HungRendererDialogView::CreateExtraView() { | 342 views::View* HungRendererDialogView::CreateExtraView() { |
| 347 DCHECK(!kill_button_); | 343 DCHECK(!kill_button_); |
| 348 kill_button_ = views::MdTextButton::CreateSecondaryUiButton(this, | 344 kill_button_ = views::MdTextButton::CreateSecondaryUiButton(this, |
| 349 l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_RENDERER_END)); | 345 l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_RENDERER_END)); |
| 350 return kill_button_; | 346 return kill_button_; |
| 351 } | 347 } |
| 352 | 348 |
| 349 bool HungRendererDialogView::GroupExtraViewWithButtons() const { | |
| 350 // In harmony the kill button looks like a dialog button, but still doesn't | |
| 351 // respond to accelerator keys, so it remains an extra view. | |
| 352 return LayoutDelegate::Get()->IsHarmonyMode(); | |
|
Peter Kasting
2017/02/06 21:44:50
After the previous discussion, I feel like we shou
Bret
2017/02/09 00:49:49
Done. I made the Wait button OK and the Kill butto
| |
| 353 } | |
| 354 | |
| 353 bool HungRendererDialogView::Cancel() { | 355 bool HungRendererDialogView::Cancel() { |
| 354 // Start waiting again for responsiveness. | 356 // Start waiting again for responsiveness. |
| 355 if (!kill_button_clicked_ && | 357 if (!kill_button_clicked_ && |
| 356 hung_pages_table_model_->GetRenderViewHost()) { | 358 hung_pages_table_model_->GetRenderViewHost()) { |
| 357 hung_pages_table_model_->GetRenderViewHost() | 359 hung_pages_table_model_->GetRenderViewHost() |
| 358 ->GetWidget() | 360 ->GetWidget() |
| 359 ->RestartHangMonitorTimeoutIfNecessary(); | 361 ->RestartHangMonitorTimeoutIfNecessary(); |
| 360 } | 362 } |
| 361 return true; | 363 return true; |
| 362 } | 364 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 hung_pages_table_model_.reset(new HungPagesTableModel(this)); | 438 hung_pages_table_model_.reset(new HungPagesTableModel(this)); |
| 437 std::vector<ui::TableColumn> columns; | 439 std::vector<ui::TableColumn> columns; |
| 438 columns.push_back(ui::TableColumn()); | 440 columns.push_back(ui::TableColumn()); |
| 439 hung_pages_table_ = new views::TableView( | 441 hung_pages_table_ = new views::TableView( |
| 440 hung_pages_table_model_.get(), columns, views::ICON_AND_TEXT, true); | 442 hung_pages_table_model_.get(), columns, views::ICON_AND_TEXT, true); |
| 441 hung_pages_table_->SetGrouper(hung_pages_table_model_.get()); | 443 hung_pages_table_->SetGrouper(hung_pages_table_model_.get()); |
| 442 | 444 |
| 443 using views::GridLayout; | 445 using views::GridLayout; |
| 444 using views::ColumnSet; | 446 using views::ColumnSet; |
| 445 | 447 |
| 446 GridLayout* layout = GridLayout::CreatePanel(this); | 448 GridLayout* layout = layout_utils::CreatePanelLayout(this); |
| 447 SetLayoutManager(layout); | 449 LayoutDelegate* delegate = LayoutDelegate::Get(); |
| 448 | 450 |
| 449 const int double_column_set_id = 0; | 451 const int double_column_set_id = 0; |
| 450 ColumnSet* column_set = layout->AddColumnSet(double_column_set_id); | 452 ColumnSet* column_set = layout->AddColumnSet(double_column_set_id); |
| 451 column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, | 453 column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, |
| 452 GridLayout::FIXED, frozen_icon_->width(), 0); | 454 GridLayout::FIXED, frozen_icon_->width(), 0); |
| 453 column_set->AddPaddingColumn(0, kCentralColumnPadding); | 455 column_set->AddPaddingColumn( |
| 456 0, delegate->GetMetric( | |
| 457 LayoutDelegate::Metric:: | |
| 458 UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE)); | |
| 454 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 459 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 455 GridLayout::USE_PREF, 0, 0); | 460 GridLayout::USE_PREF, 0, 0); |
| 456 | 461 |
| 457 layout->StartRow(0, double_column_set_id); | 462 layout->StartRow(0, double_column_set_id); |
| 458 layout->AddView(frozen_icon_view, 1, 3); | 463 layout->AddView(frozen_icon_view, 1, 3); |
| 459 // Add the label with a preferred width of 1, this way it doesn't affect the | 464 // Add the label with a preferred width of 1, this way it doesn't affect the |
| 460 // overall preferred size of the dialog. | 465 // overall preferred size of the dialog. |
| 461 layout->AddView( | 466 layout->AddView( |
| 462 info_label_, 1, 1, GridLayout::FILL, GridLayout::LEADING, 1, 0); | 467 info_label_, 1, 1, GridLayout::FILL, GridLayout::LEADING, 1, 0); |
| 463 | 468 |
| 464 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 469 layout->AddPaddingRow( |
| 470 0, delegate->GetMetric(LayoutDelegate::Metric:: | |
| 471 RELATED_CONTROL_VERTICAL_SPACING)); | |
| 465 | 472 |
| 466 layout->StartRow(0, double_column_set_id); | 473 layout->StartRow(0, double_column_set_id); |
| 467 layout->SkipColumns(1); | 474 layout->SkipColumns(1); |
| 468 layout->AddView(hung_pages_table_->CreateParentIfNecessary(), 1, 1, | 475 layout->AddView(hung_pages_table_->CreateParentIfNecessary(), 1, 1, |
| 469 views::GridLayout::FILL, | 476 views::GridLayout::FILL, |
| 470 views::GridLayout::FILL, kTableViewWidth, kTableViewHeight); | 477 views::GridLayout::FILL, kTableViewWidth, kTableViewHeight); |
| 471 | 478 |
| 472 initialized_ = true; | 479 initialized_ = true; |
| 473 } | 480 } |
| 474 | 481 |
| 475 // static | 482 // static |
| 476 void HungRendererDialogView::InitClass() { | 483 void HungRendererDialogView::InitClass() { |
| 477 static bool initialized = false; | 484 static bool initialized = false; |
| 478 if (!initialized) { | 485 if (!initialized) { |
| 479 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 486 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 480 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); | 487 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); |
| 481 initialized = true; | 488 initialized = true; |
| 482 } | 489 } |
| 483 } | 490 } |
| OLD | NEW |