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.
5 #ifndef CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_
8 #include "components/infobars/core/confirm_infobar_delegate.h"
11 class RenderProcessHost
;
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
{
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
);
30 // Called if the renderer regains responsiveness before the infobar is
32 void OnRendererResponsive();
35 // Keep these values in alignment with their histograms.xml counterparts.
40 RENDERER_BECAME_RESPONSIVE
,
45 explicit HungRendererInfoBarDelegate(
46 content::RenderProcessHost
* render_process_host
);
47 ~HungRendererInfoBarDelegate() override
;
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
;
58 void LogEvent(Event event
);
60 // Used to terminate the renderer process if the user clicks the kill button.
61 content::RenderProcessHost
* render_process_host_
;
63 bool terminal_event_logged_for_uma_
;
65 DISALLOW_COPY_AND_ASSIGN(HungRendererInfoBarDelegate
);
68 #endif // CHROME_BROWSER_ANDROID_HUNG_RENDERER_INFOBAR_DELEGATE_H_