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

Side by Side Diff: chrome/browser/ui/webui/hung_renderer_dialog.h

Issue 8462015: Tests for WebUI Hung Renderer Dialog (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: TabContentsObserver Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_
6 #define CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_ 6 #define CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h"
12 #include "base/string16.h" 13 #include "base/string16.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/ui/webui/html_dialog_ui.h" 15 #include "chrome/browser/ui/webui/html_dialog_ui.h"
16 #include "content/browser/tab_contents/tab_contents_observer.h"
15 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
16 18
17 class TabContents; 19 class TabContents;
18 class HungRendererDialogHandler; 20 class HungRendererDialogHandler;
19 21
20 class HungRendererDialog : private HtmlDialogUIDelegate { 22 class HungRendererDialog : private HtmlDialogUIDelegate {
21 public: 23 public:
22 // Shows a hung renderer dialog. 24 // Shows a hung renderer dialog.
23 static void ShowHungRendererDialog(TabContents* contents); 25 static void ShowHungRendererDialog(TabContents* contents);
24 26
25 // Hides a hung renderer dialog. 27 // Hides a hung renderer dialog.
26 static void HideHungRendererDialog(TabContents* contents); 28 static void HideHungRendererDialog(TabContents* contents);
27 29
28 private: 30 private:
29 HungRendererDialog(); 31 class TabContentsObserverImpl : public TabContentsObserver {
32 public:
33 TabContentsObserverImpl(HungRendererDialog* dialog,
34 TabContents* contents)
35 : TabContentsObserver(contents),
36 contents_(contents),
37 dialog_(dialog) {
38 }
39
40 // TabContentsObserver overrides:
41 virtual void RenderViewGone() OVERRIDE {
42 dialog_->HideDialog(contents_);
43 }
44 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE {
45 dialog_->HideDialog(contents_);
46 }
47
48 private:
49 TabContents* contents_; // weak
50 HungRendererDialog* dialog_; // weak
51
52 DISALLOW_COPY_AND_ASSIGN(TabContentsObserverImpl);
53 };
flackr 2011/11/14 15:48:24 Move function bodies to the .cc file. The general
wyck 2011/11/14 18:08:38 Done.
54
55 friend class HungRendererDialogUITest;
56
57 // Shows a hung renderer dialog that, if not enabled, won't kill processes
58 // or restart hang timers.
59 static void ShowHungRendererDialogInternal(TabContents* contents,
60 bool is_enabled);
61
62 explicit HungRendererDialog(bool is_enabled);
63 ~HungRendererDialog();
30 64
31 // Shows the hung renderer dialog. 65 // Shows the hung renderer dialog.
32 void ShowDialog(TabContents* contents); 66 void ShowDialog(TabContents* contents);
33 67
34 // Hides the hung renderer dialog. 68 // Hides the hung renderer dialog.
35 void HideDialog(TabContents* contents); 69 void HideDialog(TabContents* contents);
36 70
37 // HtmlDialogUIDelegate methods 71 // HtmlDialogUIDelegate methods
38 virtual bool IsDialogModal() const OVERRIDE; 72 virtual bool IsDialogModal() const OVERRIDE;
39 virtual string16 GetDialogTitle() const OVERRIDE; 73 virtual string16 GetDialogTitle() const OVERRIDE;
40 virtual GURL GetDialogContentURL() const OVERRIDE; 74 virtual GURL GetDialogContentURL() const OVERRIDE;
41 virtual void GetWebUIMessageHandlers( 75 virtual void GetWebUIMessageHandlers(
42 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; 76 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE;
43 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; 77 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
44 virtual std::string GetDialogArgs() const OVERRIDE; 78 virtual std::string GetDialogArgs() const OVERRIDE;
45 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; 79 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
46 virtual void OnCloseContents(TabContents* source, 80 virtual void OnCloseContents(TabContents* source,
47 bool* out_close_dialog) OVERRIDE; 81 bool* out_close_dialog) OVERRIDE;
48 virtual bool ShouldShowDialogTitle() const OVERRIDE; 82 virtual bool ShouldShowDialogTitle() const OVERRIDE;
49 83
50 // The tab contents. 84 // The tab contents.
51 TabContents* contents_; 85 TabContents* contents_;
52 86
53 // The dialog handler. 87 // The dialog handler.
54 HungRendererDialogHandler* handler_; 88 HungRendererDialogHandler* handler_;
55 89
90 // A safety switch that must be enabled to allow actual killing of processes
91 // or restarting of the hang timer. This is necessary so that tests can
92 // create a disabled version of this dialog that won't kill processes or
93 // restart timers when the dialog closes at the end of the test.
94 bool is_enabled_;
95
56 // The dialog window. 96 // The dialog window.
57 gfx::NativeWindow window_; 97 gfx::NativeWindow window_;
58 98
99 scoped_ptr<TabContentsObserverImpl> contents_observer_;
100
59 DISALLOW_COPY_AND_ASSIGN(HungRendererDialog); 101 DISALLOW_COPY_AND_ASSIGN(HungRendererDialog);
60 }; 102 };
61 103
62 // Dialog handler that handles calls from the JS WebUI code to get the details 104 // Dialog handler that handles calls from the JS WebUI code to get the details
63 // of the list of frozen tabs. 105 // of the list of frozen tabs.
64 class HungRendererDialogHandler : public WebUIMessageHandler { 106 class HungRendererDialogHandler : public WebUIMessageHandler {
65 public: 107 public:
66 explicit HungRendererDialogHandler(TabContents* contents); 108 explicit HungRendererDialogHandler(TabContents* contents);
67 109
68 void CloseDialog(); 110 void CloseDialog();
69 111
70 // Overridden from WebUIMessageHandler 112 // Overridden from WebUIMessageHandler
71 virtual void RegisterMessages(); 113 virtual void RegisterMessages();
72 114
73 private: 115 private:
74 void RequestTabContentsList(const base::ListValue* args); 116 void RequestTabContentsList(const base::ListValue* args);
75 117
76 // The tab contents. 118 // The tab contents.
77 TabContents* contents_; 119 TabContents* contents_;
78 120
79 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogHandler); 121 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogHandler);
80 }; 122 };
81 123
82 124
83 #endif // CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_ 125 #endif // CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_
84 126
OLDNEW
« no previous file with comments | « chrome/browser/resources/hung_renderer_dialog.js ('k') | chrome/browser/ui/webui/hung_renderer_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698