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..109dcc544c5b4bc37e20cb6d20f4585f006570a3 |
--- /dev/null |
+++ b/chrome/browser/android/hung_renderer_infobar_delegate.h |
@@ -0,0 +1,62 @@ |
+// 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 WebContents; |
+} |
+ |
+// A hung renderer infobar is shown when the when the renderer is deemed |
+// unresponsive. The infobar provides the user with a choice of either |
+// waiting for the renderer to regain responsiveness, or killing the |
+// renderer immediately. This class provides the resources necessary to |
+// display such an infobar, also logging the action taken by the user |
+// (if any) for UMA purposes. |
+class HungRendererInfoBarDelegate : public ConfirmInfoBarDelegate { |
+ public: |
+ // Creates a hung renderer InfoBar, adding it to the InfoBarService |
+ // associated with the provided |web_contents|. |
+ static void Create(content::WebContents* web_contents); |
+ |
+ // Called if the renderer regains responsiveness before the infobar is |
+ // dismissed. |
+ void OnRendererResponsive(); |
+ |
+ private: |
+ // Keep these values in alignment with their histograms.xml counterparts. |
+ enum Event { |
+ WAIT_CLICKED = 0, |
+ KILL_CLICKED, |
+ CLOSE_CLICKED, |
+ RENDERER_BECAME_RESPONSIVE, |
+ INFOBAR_SHUTDOWN, |
+ EVENT_COUNT |
+ }; |
+ |
+ explicit HungRendererInfoBarDelegate(content::WebContents* web_contents); |
+ ~HungRendererInfoBarDelegate() override; |
+ |
+ // ConfirmInfoBarDelegate: |
+ void InfoBarDismissed() override; |
+ HungRendererInfoBarDelegate* AsHungRendererInfoBarDelegate() override; |
+ int GetIconID() const override; |
+ base::string16 GetMessageText() const override; |
+ base::string16 GetButtonLabel(InfoBarButton button) const override; |
+ bool Accept() override; |
+ bool Cancel() override; |
+ |
+ void LogEvent(Event event); |
+ |
+ content::WebContents* web_contents_; |
+ |
+ bool terminal_event_logged_for_uma_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HungRendererInfoBarDelegate); |
+}; |
+ |
+#endif // CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |