Index: chrome/browser/android/hung_renderer_infobar_delegate.h |
diff --git a/chrome/browser/android/hung_renderer_infobar_delegate.h b/chrome/browser/android/hung_renderer_infobar_delegate.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..27b8d29c4370e5b02feb2f76168220998369c520 |
--- /dev/null |
+++ b/chrome/browser/android/hung_renderer_infobar_delegate.h |
@@ -0,0 +1,52 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |
+#define CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |
+ |
+#include "components/infobars/core/confirm_infobar_delegate.h" |
+ |
+namespace content { |
+class WebContent; |
+} |
+ |
+// This class is responsible for customizing a hung renderer infobar. |
+// If the "kill" dialog is clicked, the renderer of the corresponding |
+// WebContents will be shutdown. |
+class HungRendererInfoBarDelegate : public ConfirmInfoBarDelegate { |
+ public: |
+ // The caller must ensure that |web_contents| outlives the delegate. |
+ // This will naturally occur if the associated InfoBar is managed by the |
+ // InfoBarService. |
+ explicit HungRendererInfoBarDelegate(content::WebContents* web_contents); |
+ ~HungRendererInfoBarDelegate() override; |
+ |
+ // InfoBarDelegate: |
+ void InfoBarDismissed() override; |
+ HungRendererInfoBarDelegate* AsHungRendererInfoBarDelegate() override; |
+ |
+ // ConfirmInfoBarDelegate: |
+ int GetIconID() const override; |
+ base::string16 GetMessageText() const override; |
+ base::string16 GetButtonLabel(InfoBarButton button) const override; |
+ bool Accept() override; |
+ bool Cancel() override; |
+ |
+ // Called when the renderer regains responsiveness before the dialog is |
+ // dismissed. |
+ void OnRendererResponsive(); |
+ |
+ private: |
+ // Keep these values in alignment with their histograms.xml counterparts. |
+ enum Action { WAIT = 0, KILL, DISMISS, RESPONSIVE, REMOVE, ACTION_COUNT }; |
+ void LogAction(Action action); |
+ |
+ content::WebContents* web_contents_; |
+ |
+ bool action_logged_for_uma_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HungRendererInfoBarDelegate); |
+}; |
+ |
+#endif // CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |