| 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 #if defined(OS_WIN) && !defined(USE_AURA) | 7 #if defined(OS_WIN) && !defined(USE_AURA) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 16 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 17 #include "chrome/browser/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/logging_chrome.h" | 21 #include "chrome/common/logging_chrome.h" |
| 22 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/browser/web_contents_view.h" |
| 25 #include "content/public/common/result_codes.h" | 26 #include "content/public/common/result_codes.h" |
| 26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 28 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/gfx/canvas.h" | 32 #include "ui/gfx/canvas.h" |
| 32 #include "ui/views/controls/button/text_button.h" | 33 #include "ui/views/controls/button/text_button.h" |
| 33 #include "ui/views/controls/image_view.h" | 34 #include "ui/views/controls/image_view.h" |
| 34 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 200 } |
| 200 | 201 |
| 201 // static | 202 // static |
| 202 HungRendererDialogView* HungRendererDialogView::GetInstance() { | 203 HungRendererDialogView* HungRendererDialogView::GetInstance() { |
| 203 return g_instance_; | 204 return g_instance_; |
| 204 } | 205 } |
| 205 | 206 |
| 206 // static | 207 // static |
| 207 bool HungRendererDialogView::IsFrameActive(WebContents* contents) { | 208 bool HungRendererDialogView::IsFrameActive(WebContents* contents) { |
| 208 gfx::NativeView frame_view = | 209 gfx::NativeView frame_view = |
| 209 platform_util::GetTopLevel(contents->GetNativeView()); | 210 platform_util::GetTopLevel(contents->GetView()->GetNativeView()); |
| 210 return platform_util::IsWindowActive(frame_view); | 211 return platform_util::IsWindowActive(frame_view); |
| 211 } | 212 } |
| 212 | 213 |
| 213 #if !defined(OS_WIN) | 214 #if !defined(OS_WIN) |
| 214 // static | 215 // static |
| 215 void HungRendererDialogView::KillRendererProcess( | 216 void HungRendererDialogView::KillRendererProcess( |
| 216 base::ProcessHandle process_handle) { | 217 base::ProcessHandle process_handle) { |
| 217 base::KillProcess(process_handle, content::RESULT_CODE_HUNG, false); | 218 base::KillProcess(process_handle, content::RESULT_CODE_HUNG, false); |
| 218 } | 219 } |
| 219 #endif // OS_WIN | 220 #endif // OS_WIN |
| (...skipping 17 matching lines...) Expand all Loading... |
| 237 // window (but still invisible). If the user has another window or | 238 // window (but still invisible). If the user has another window or |
| 238 // application selected, activating ourselves is rude. | 239 // application selected, activating ourselves is rude. |
| 239 if (!IsFrameActive(contents) && | 240 if (!IsFrameActive(contents) && |
| 240 !platform_util::IsWindowActive(GetWidget()->GetNativeWindow())) | 241 !platform_util::IsWindowActive(GetWidget()->GetNativeWindow())) |
| 241 return; | 242 return; |
| 242 | 243 |
| 243 if (!GetWidget()->IsActive()) { | 244 if (!GetWidget()->IsActive()) { |
| 244 gfx::Rect bounds = GetDisplayBounds(contents); | 245 gfx::Rect bounds = GetDisplayBounds(contents); |
| 245 | 246 |
| 246 gfx::NativeView frame_view = | 247 gfx::NativeView frame_view = |
| 247 platform_util::GetTopLevel(contents->GetNativeView()); | 248 platform_util::GetTopLevel(contents->GetView()->GetNativeView()); |
| 248 | 249 |
| 249 views::Widget* insert_after = | 250 views::Widget* insert_after = |
| 250 views::Widget::GetWidgetForNativeView(frame_view); | 251 views::Widget::GetWidgetForNativeView(frame_view); |
| 251 GetWidget()->SetBoundsConstrained(bounds); | 252 GetWidget()->SetBoundsConstrained(bounds); |
| 252 if (insert_after) | 253 if (insert_after) |
| 253 GetWidget()->StackAboveWidget(insert_after); | 254 GetWidget()->StackAboveWidget(insert_after); |
| 254 | 255 |
| 255 // We only do this if the window isn't active (i.e. hasn't been shown yet, | 256 // We only do this if the window isn't active (i.e. hasn't been shown yet, |
| 256 // or is currently shown but deactivated for another WebContents). This is | 257 // or is currently shown but deactivated for another WebContents). This is |
| 257 // because this window is a singleton, and it's possible another active | 258 // because this window is a singleton, and it's possible another active |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 layout->AddView(hung_pages_table_->CreateParentIfNecessary(), 1, 1, | 404 layout->AddView(hung_pages_table_->CreateParentIfNecessary(), 1, 1, |
| 404 views::GridLayout::FILL, | 405 views::GridLayout::FILL, |
| 405 views::GridLayout::FILL, kTableViewWidth, kTableViewHeight); | 406 views::GridLayout::FILL, kTableViewWidth, kTableViewHeight); |
| 406 | 407 |
| 407 initialized_ = true; | 408 initialized_ = true; |
| 408 } | 409 } |
| 409 | 410 |
| 410 gfx::Rect HungRendererDialogView::GetDisplayBounds( | 411 gfx::Rect HungRendererDialogView::GetDisplayBounds( |
| 411 WebContents* contents) { | 412 WebContents* contents) { |
| 412 #if defined(USE_AURA) | 413 #if defined(USE_AURA) |
| 413 gfx::Rect contents_bounds(contents->GetNativeView()->GetBoundsInRootWindow()); | 414 gfx::Rect contents_bounds( |
| 415 contents->GetView()->GetNativeView()->GetBoundsInRootWindow()); |
| 414 #elif defined(OS_WIN) | 416 #elif defined(OS_WIN) |
| 415 HWND contents_hwnd = contents->GetNativeView(); | 417 HWND contents_hwnd = contents->GetView()->GetNativeView(); |
| 416 RECT contents_bounds_rect; | 418 RECT contents_bounds_rect; |
| 417 GetWindowRect(contents_hwnd, &contents_bounds_rect); | 419 GetWindowRect(contents_hwnd, &contents_bounds_rect); |
| 418 gfx::Rect contents_bounds(contents_bounds_rect); | 420 gfx::Rect contents_bounds(contents_bounds_rect); |
| 419 #endif | 421 #endif |
| 420 gfx::Rect window_bounds = GetWidget()->GetWindowBoundsInScreen(); | 422 gfx::Rect window_bounds = GetWidget()->GetWindowBoundsInScreen(); |
| 421 | 423 |
| 422 int window_x = contents_bounds.x() + | 424 int window_x = contents_bounds.x() + |
| 423 (contents_bounds.width() - window_bounds.width()) / 2; | 425 (contents_bounds.width() - window_bounds.width()) / 2; |
| 424 int window_y = contents_bounds.y() + kOverlayContentsOffsetY; | 426 int window_y = contents_bounds.y() + kOverlayContentsOffsetY; |
| 425 return gfx::Rect(window_x, window_y, window_bounds.width(), | 427 return gfx::Rect(window_x, window_y, window_bounds.width(), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 447 } | 449 } |
| 448 | 450 |
| 449 void HideHungRendererDialog(WebContents* contents) { | 451 void HideHungRendererDialog(WebContents* contents) { |
| 450 if (!logging::DialogsAreSuppressed() && | 452 if (!logging::DialogsAreSuppressed() && |
| 451 !PlatformHideCustomHungRendererDialog(contents) && | 453 !PlatformHideCustomHungRendererDialog(contents) && |
| 452 HungRendererDialogView::GetInstance()) | 454 HungRendererDialogView::GetInstance()) |
| 453 HungRendererDialogView::GetInstance()->EndForWebContents(contents); | 455 HungRendererDialogView::GetInstance()->EndForWebContents(contents); |
| 454 } | 456 } |
| 455 | 457 |
| 456 } // namespace chrome | 458 } // namespace chrome |
| OLD | NEW |