OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |
| 7 |
| 8 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 9 |
| 10 namespace content { |
| 11 class RenderProcessHost; |
| 12 } |
| 13 |
| 14 class InfoBarService; |
| 15 |
| 16 // A hung renderer infobar is shown when the when the renderer is deemed |
| 17 // unresponsive. The infobar provides the user with a choice of either |
| 18 // waiting for the renderer to regain responsiveness, or killing the |
| 19 // renderer immediately. This class provides the resources necessary to |
| 20 // display such an infobar, also logging the action taken by the user |
| 21 // (if any) for UMA purposes. |
| 22 class HungRendererInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 23 public: |
| 24 // Creates a hung renderer InfoBar, adding it to the provided |
| 25 // |infobar_service|. The |render_process_host| will be used to kill the |
| 26 // renderer process if the user so chooses. |
| 27 static void Create(InfoBarService* infobar_service, |
| 28 content::RenderProcessHost* render_process_host); |
| 29 |
| 30 // Called if the renderer regains responsiveness before the infobar is |
| 31 // dismissed. |
| 32 void OnRendererResponsive(); |
| 33 |
| 34 private: |
| 35 // Keep these values in alignment with their histograms.xml counterparts. |
| 36 enum Event { |
| 37 WAIT_CLICKED = 0, |
| 38 KILL_CLICKED, |
| 39 CLOSE_CLICKED, |
| 40 RENDERER_BECAME_RESPONSIVE, |
| 41 TAB_CLOSED, |
| 42 EVENT_COUNT |
| 43 }; |
| 44 |
| 45 explicit HungRendererInfoBarDelegate( |
| 46 content::RenderProcessHost* render_process_host); |
| 47 ~HungRendererInfoBarDelegate() override; |
| 48 |
| 49 // ConfirmInfoBarDelegate: |
| 50 void InfoBarDismissed() override; |
| 51 HungRendererInfoBarDelegate* AsHungRendererInfoBarDelegate() override; |
| 52 int GetIconId() const override; |
| 53 base::string16 GetMessageText() const override; |
| 54 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 55 bool Accept() override; |
| 56 bool Cancel() override; |
| 57 |
| 58 void LogEvent(Event event); |
| 59 |
| 60 // Used to terminate the renderer process if the user clicks the kill button. |
| 61 content::RenderProcessHost* render_process_host_; |
| 62 |
| 63 bool terminal_event_logged_for_uma_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(HungRendererInfoBarDelegate); |
| 66 }; |
| 67 |
| 68 #endif // CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_ |
OLD | NEW |