| OLD | NEW |
| 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/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 15 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
| 17 #include "content/public/browser/web_ui_message_handler.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 18 | 19 |
| 19 class HungRendererDialogHandler; | 20 class HungRendererDialogHandler; |
| 20 | 21 |
| 21 class HungRendererDialog : private HtmlDialogUIDelegate { | 22 class HungRendererDialog : private HtmlDialogUIDelegate { |
| 22 public: | 23 public: |
| 23 // Shows a hung renderer dialog. | 24 // Shows a hung renderer dialog. |
| 24 static void ShowHungRendererDialog(content::WebContents* contents); | 25 static void ShowHungRendererDialog(content::WebContents* contents); |
| 25 | 26 |
| 26 // Hides a hung renderer dialog. | 27 // Hides a hung renderer dialog. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 56 void ShowDialog(content::WebContents* contents); | 57 void ShowDialog(content::WebContents* contents); |
| 57 | 58 |
| 58 // Hides the hung renderer dialog. | 59 // Hides the hung renderer dialog. |
| 59 void HideDialog(content::WebContents* contents); | 60 void HideDialog(content::WebContents* contents); |
| 60 | 61 |
| 61 // HtmlDialogUIDelegate methods | 62 // HtmlDialogUIDelegate methods |
| 62 virtual bool IsDialogModal() const OVERRIDE; | 63 virtual bool IsDialogModal() const OVERRIDE; |
| 63 virtual string16 GetDialogTitle() const OVERRIDE; | 64 virtual string16 GetDialogTitle() const OVERRIDE; |
| 64 virtual GURL GetDialogContentURL() const OVERRIDE; | 65 virtual GURL GetDialogContentURL() const OVERRIDE; |
| 65 virtual void GetWebUIMessageHandlers( | 66 virtual void GetWebUIMessageHandlers( |
| 66 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; | 67 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; |
| 67 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 68 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
| 68 virtual std::string GetDialogArgs() const OVERRIDE; | 69 virtual std::string GetDialogArgs() const OVERRIDE; |
| 69 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 70 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
| 70 virtual void OnCloseContents(content::WebContents* source, | 71 virtual void OnCloseContents(content::WebContents* source, |
| 71 bool* out_close_dialog) OVERRIDE; | 72 bool* out_close_dialog) OVERRIDE; |
| 72 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 73 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
| 73 | 74 |
| 74 // The web contents. | 75 // The web contents. |
| 75 content::WebContents* contents_; | 76 content::WebContents* contents_; |
| 76 | 77 |
| 77 // The dialog handler. | 78 // The dialog handler. |
| 78 HungRendererDialogHandler* handler_; | 79 HungRendererDialogHandler* handler_; |
| 79 | 80 |
| 80 // A safety switch that must be enabled to allow actual killing of processes | 81 // A safety switch that must be enabled to allow actual killing of processes |
| 81 // or restarting of the hang timer. This is necessary so that tests can | 82 // or restarting of the hang timer. This is necessary so that tests can |
| 82 // create a disabled version of this dialog that won't kill processes or | 83 // create a disabled version of this dialog that won't kill processes or |
| 83 // restart timers when the dialog closes at the end of the test. | 84 // restart timers when the dialog closes at the end of the test. |
| 84 bool is_enabled_; | 85 bool is_enabled_; |
| 85 | 86 |
| 86 // The dialog window. | 87 // The dialog window. |
| 87 gfx::NativeWindow window_; | 88 gfx::NativeWindow window_; |
| 88 | 89 |
| 89 scoped_ptr<WebContentsObserverImpl> contents_observer_; | 90 scoped_ptr<WebContentsObserverImpl> contents_observer_; |
| 90 | 91 |
| 91 DISALLOW_COPY_AND_ASSIGN(HungRendererDialog); | 92 DISALLOW_COPY_AND_ASSIGN(HungRendererDialog); |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 // Dialog handler that handles calls from the JS WebUI code to get the details | 95 // Dialog handler that handles calls from the JS WebUI code to get the details |
| 95 // of the list of frozen tabs. | 96 // of the list of frozen tabs. |
| 96 class HungRendererDialogHandler : public WebUIMessageHandler { | 97 class HungRendererDialogHandler : public content::WebUIMessageHandler { |
| 97 public: | 98 public: |
| 98 explicit HungRendererDialogHandler(content::WebContents* contents); | 99 explicit HungRendererDialogHandler(content::WebContents* contents); |
| 99 | 100 |
| 100 void CloseDialog(); | 101 void CloseDialog(); |
| 101 | 102 |
| 102 // Overridden from WebUIMessageHandler | 103 // Overridden from WebUIMessageHandler |
| 103 virtual void RegisterMessages() OVERRIDE; | 104 virtual void RegisterMessages() OVERRIDE; |
| 104 | 105 |
| 105 private: | 106 private: |
| 106 void RequestTabContentsList(const base::ListValue* args); | 107 void RequestTabContentsList(const base::ListValue* args); |
| 107 | 108 |
| 108 // The web contents. | 109 // The web contents. |
| 109 content::WebContents* contents_; | 110 content::WebContents* contents_; |
| 110 | 111 |
| 111 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogHandler); | 112 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogHandler); |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 | 115 |
| 115 #endif // CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_ | 116 #endif // CHROME_BROWSER_UI_WEBUI_HUNG_RENDERER_DIALOG_H_ |
| 116 | 117 |
| OLD | NEW |