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

Unified Diff: chrome/browser/ui/webui/hung_renderer_dialog.cc

Issue 7824039: Implement function that hides the WebUI Hung Renderer Dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed timeout behaviour. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/hung_renderer_dialog.cc
diff --git a/chrome/browser/ui/webui/hung_renderer_dialog.cc b/chrome/browser/ui/webui/hung_renderer_dialog.cc
index cf5050e0998c0030e59455faad35b81f145386eb..2177b98ee16f6854190ebadd46187a00f4da6fe1 100644
--- a/chrome/browser/ui/webui/hung_renderer_dialog.cc
+++ b/chrome/browser/ui/webui/hung_renderer_dialog.cc
@@ -19,6 +19,7 @@
#include "content/common/result_codes.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+#include "views/widget/widget.h"
namespace {
HungRendererDialog* g_instance = NULL;
@@ -41,10 +42,8 @@ void ShowHungRendererDialog(TabContents* contents) {
}
void HideHungRendererDialog(TabContents* contents) {
- if (!logging::DialogsAreSuppressed() && g_instance) {
- // TODO(wyck): Hide the webui hung renderer dialog.
- NOTIMPLEMENTED() << " TODO: Hide the webui hung renderer dialog.";
- }
+ if (!logging::DialogsAreSuppressed() && g_instance)
+ g_instance->HideDialog(contents);
}
} // namespace browser
@@ -53,7 +52,8 @@ void HideHungRendererDialog(TabContents* contents) {
// HungRendererDialog methods
HungRendererDialog::HungRendererDialog()
- : contents_(NULL) {
+ : contents_(NULL),
+ window_(NULL) {
}
void HungRendererDialog::ShowDialog(gfx::NativeWindow owning_window,
@@ -62,7 +62,15 @@ void HungRendererDialog::ShowDialog(gfx::NativeWindow owning_window,
contents_ = contents;
Browser* browser = BrowserList::GetLastActive();
DCHECK(browser);
- browser->BrowserShowHtmlDialog(this, owning_window);
+ window_ = browser->BrowserShowHtmlDialog(this, owning_window);
+}
+
+void HungRendererDialog::HideDialog(TabContents* contents) {
flackr 2011/09/03 17:51:31 You should check that (contents_->GetRenderProcess
wyck 2011/09/06 18:07:35 Done.
+ // Settings |contents_| to NULL prevents the hang monitor from restarting.
+ contents_ = NULL;
+ views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window_);
+ DCHECK(widget);
+ widget->Close();
}
bool HungRendererDialog::IsDialogModal() const {
@@ -94,13 +102,12 @@ void HungRendererDialog::OnDialogClosed(const std::string& json_retval) {
// Figure out what the response was.
scoped_ptr<Value> root(base::JSONReader::Read(json_retval, false));
bool response = false;
- ListValue* list;
- if (!root.get() || !root->GetAsList(&list) || !list ||
- !list->GetBoolean(0, &response)) {
- NOTREACHED() << "json does not describe a valid result";
- }
-
- if (response) {
+ ListValue* list = NULL;
wyck 2011/09/02 19:18:43 Decided to initialize this too.
+ // If the dialog closes because of a button click then the json is a list
+ // containing a single bool. If the dialog closes some other way, then we
+ // assume it means no permission was given to kill tabs.
+ if (root.get() && root->GetAsList(&list) && list &&
wyck 2011/09/02 19:18:43 Folded into one statement.
+ list->GetBoolean(0, &response) && response) {
flackr 2011/09/03 17:51:31 Why not use the result from list->GetBoolean to kn
wyck 2011/09/06 18:07:35 Because if you click the X on the dialog, it close
// The user indicated that it is OK to kill the renderer process.
if (contents_ && contents_->GetRenderProcessHost()) {
base::KillProcess(contents_->GetRenderProcessHost()->GetHandle(),
@@ -112,7 +119,6 @@ void HungRendererDialog::OnDialogClosed(const std::string& json_retval) {
if (contents_ && contents_->render_view_host())
contents_->render_view_host()->RestartHangMonitorTimeout();
}
-
g_instance = NULL;
delete this;
}
@@ -160,4 +166,3 @@ void HungRendererDialogHandler::RequestTabContentsList(
web_ui_->CallJavascriptFunction("hungRendererDialog.setTabContentsList",
tab_contents_list);
}
-

Powered by Google App Engine
This is Rietveld 408576698