Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/ui/views/hung_renderer_view.cc

Issue 2660553005: Harmony - convert hung renderer dialog. (Closed)
Patch Set: comments 1 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 base::string16 HungRendererDialogView::GetDialogButtonLabel( 336 base::string16 HungRendererDialogView::GetDialogButtonLabel(
341 ui::DialogButton button) const { 337 ui::DialogButton button) const {
342 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); 338 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button);
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));
346 LayoutDelegate* delegate = LayoutDelegate::Get();
347 // The kill button doesn't look like a normal dialog button pre-harmony.
Peter Kasting 2017/02/02 00:32:30 Oh? It looks like one in my build. Say more? Wh
Bret 2017/02/03 01:47:17 I meant that it's an extra view, off to the left,
348 if (delegate->IsHarmonyMode())
349 kill_button_->SetMinSize(
350 gfx::Size(delegate->GetDialogButtonMinimumWidth(), 0));
350 return kill_button_; 351 return kill_button_;
351 } 352 }
352 353
354 bool HungRendererDialogView::GroupExtraViewWithButtons() const {
355 // In harmony the kill button looks like a dialog button, but still doesn't
356 // respond to accelerator keys, so it remains an extra view.
Peter Kasting 2017/02/02 00:32:30 Why doesn't it respond to accelerator keys? Are w
Bret 2017/02/03 01:47:17 I dunno, that's the only reason I can think of tha
357 return LayoutDelegate::Get()->IsHarmonyMode();
358 }
359
353 bool HungRendererDialogView::Cancel() { 360 bool HungRendererDialogView::Cancel() {
354 // Start waiting again for responsiveness. 361 // Start waiting again for responsiveness.
355 if (!kill_button_clicked_ && 362 if (!kill_button_clicked_ &&
356 hung_pages_table_model_->GetRenderViewHost()) { 363 hung_pages_table_model_->GetRenderViewHost()) {
357 hung_pages_table_model_->GetRenderViewHost() 364 hung_pages_table_model_->GetRenderViewHost()
358 ->GetWidget() 365 ->GetWidget()
359 ->RestartHangMonitorTimeoutIfNecessary(); 366 ->RestartHangMonitorTimeoutIfNecessary();
360 } 367 }
361 return true; 368 return true;
362 } 369 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 hung_pages_table_model_.reset(new HungPagesTableModel(this)); 443 hung_pages_table_model_.reset(new HungPagesTableModel(this));
437 std::vector<ui::TableColumn> columns; 444 std::vector<ui::TableColumn> columns;
438 columns.push_back(ui::TableColumn()); 445 columns.push_back(ui::TableColumn());
439 hung_pages_table_ = new views::TableView( 446 hung_pages_table_ = new views::TableView(
440 hung_pages_table_model_.get(), columns, views::ICON_AND_TEXT, true); 447 hung_pages_table_model_.get(), columns, views::ICON_AND_TEXT, true);
441 hung_pages_table_->SetGrouper(hung_pages_table_model_.get()); 448 hung_pages_table_->SetGrouper(hung_pages_table_model_.get());
442 449
443 using views::GridLayout; 450 using views::GridLayout;
444 using views::ColumnSet; 451 using views::ColumnSet;
445 452
446 GridLayout* layout = GridLayout::CreatePanel(this); 453 GridLayout* layout = layout_utils::CreatePanelLayout(this);
447 SetLayoutManager(layout); 454 LayoutDelegate* delegate = LayoutDelegate::Get();
448 455
449 const int double_column_set_id = 0; 456 const int double_column_set_id = 0;
450 ColumnSet* column_set = layout->AddColumnSet(double_column_set_id); 457 ColumnSet* column_set = layout->AddColumnSet(double_column_set_id);
451 column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, 458 column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
452 GridLayout::FIXED, frozen_icon_->width(), 0); 459 GridLayout::FIXED, frozen_icon_->width(), 0);
453 column_set->AddPaddingColumn(0, kCentralColumnPadding); 460 column_set->AddPaddingColumn(
461 0, delegate->GetLayoutDistance(
462 LayoutDelegate::LayoutDistanceType::
463 UNRELATED_CONTROL_LARGE_HORIZONTAL_SPACING));
454 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 464 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
455 GridLayout::USE_PREF, 0, 0); 465 GridLayout::USE_PREF, 0, 0);
456 466
457 layout->StartRow(0, double_column_set_id); 467 layout->StartRow(0, double_column_set_id);
458 layout->AddView(frozen_icon_view, 1, 3); 468 layout->AddView(frozen_icon_view, 1, 3);
459 // Add the label with a preferred width of 1, this way it doesn't affect the 469 // Add the label with a preferred width of 1, this way it doesn't affect the
460 // overall preferred size of the dialog. 470 // overall preferred size of the dialog.
461 layout->AddView( 471 layout->AddView(
462 info_label_, 1, 1, GridLayout::FILL, GridLayout::LEADING, 1, 0); 472 info_label_, 1, 1, GridLayout::FILL, GridLayout::LEADING, 1, 0);
463 473
464 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 474 layout->AddPaddingRow(
475 0, delegate->GetLayoutDistance(LayoutDelegate::LayoutDistanceType::
476 RELATED_CONTROL_VERTICAL_SPACING));
465 477
466 layout->StartRow(0, double_column_set_id); 478 layout->StartRow(0, double_column_set_id);
467 layout->SkipColumns(1); 479 layout->SkipColumns(1);
468 layout->AddView(hung_pages_table_->CreateParentIfNecessary(), 1, 1, 480 layout->AddView(hung_pages_table_->CreateParentIfNecessary(), 1, 1,
469 views::GridLayout::FILL, 481 views::GridLayout::FILL,
470 views::GridLayout::FILL, kTableViewWidth, kTableViewHeight); 482 views::GridLayout::FILL, kTableViewWidth, kTableViewHeight);
471 483
472 initialized_ = true; 484 initialized_ = true;
473 } 485 }
474 486
475 // static 487 // static
476 void HungRendererDialogView::InitClass() { 488 void HungRendererDialogView::InitClass() {
477 static bool initialized = false; 489 static bool initialized = false;
478 if (!initialized) { 490 if (!initialized) {
479 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 491 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
480 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); 492 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON);
481 initialized = true; 493 initialized = true;
482 } 494 }
483 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698