Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Side by Side Diff: chrome/browser/android/hung_renderer_infobar_delegate.cc

Issue 1299513002: [Android] Add support for a hung renderer dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/android/hung_renderer_infobar_delegate.h"
6
7 #include "base/callback.h"
8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "components/infobars/core/infobar.h"
12 #include "content/public/browser/render_process_host.h"
13 #include "content/public/common/result_codes.h"
14 #include "grit/theme_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
16
17 // static
18 void HungRendererInfoBarDelegate::Create(
19 InfoBarService* infobar_service,
20 content::RenderProcessHost* render_process_host) {
21 DCHECK(render_process_host);
22 infobar_service->AddInfoBar(
23 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
24 new HungRendererInfoBarDelegate(render_process_host))));
25 }
26
27 void HungRendererInfoBarDelegate::OnRendererResponsive() {
28 LogEvent(RENDERER_BECAME_RESPONSIVE);
29 }
30
31 HungRendererInfoBarDelegate::HungRendererInfoBarDelegate(
32 content::RenderProcessHost* render_process_host)
33 : render_process_host_(render_process_host),
34 terminal_event_logged_for_uma_(false) {}
35
36 HungRendererInfoBarDelegate::~HungRendererInfoBarDelegate() {
37 if (!terminal_event_logged_for_uma_)
38 LogEvent(TAB_CLOSED);
39 }
40
41 void HungRendererInfoBarDelegate::InfoBarDismissed() {
42 LogEvent(CLOSE_CLICKED);
43 }
44
45 HungRendererInfoBarDelegate*
46 HungRendererInfoBarDelegate::AsHungRendererInfoBarDelegate() {
47 return this;
48 }
49
50 int HungRendererInfoBarDelegate::GetIconId() const {
51 return IDR_INFOBAR_FROZEN_TAB;
52 }
53
54 base::string16 HungRendererInfoBarDelegate::GetMessageText() const {
55 return l10n_util::GetPluralStringFUTF16(IDS_BROWSER_HANGMONITOR_RENDERER, 1);
56 }
57
58 base::string16 HungRendererInfoBarDelegate::GetButtonLabel(
59 InfoBarButton button) const {
60 return l10n_util::GetStringUTF16((button == BUTTON_OK)
61 ? IDS_BROWSER_HANGMONITOR_RENDERER_END
62 : IDS_BROWSER_HANGMONITOR_RENDERER_WAIT);
63 }
64
65 bool HungRendererInfoBarDelegate::Accept() {
66 LogEvent(KILL_CLICKED);
67 render_process_host_->Shutdown(content::RESULT_CODE_HUNG, false);
68 return true;
69 }
70
71 bool HungRendererInfoBarDelegate::Cancel() {
72 LogEvent(WAIT_CLICKED);
73 return true;
74 }
75
76 void HungRendererInfoBarDelegate::LogEvent(Event event) {
77 DCHECK(!terminal_event_logged_for_uma_);
78 terminal_event_logged_for_uma_ = true;
79 UMA_HISTOGRAM_ENUMERATION("Renderer.Hung.MobileInfoBar.UserEvent", event,
80 EVENT_COUNT);
81 }
OLDNEW
« no previous file with comments | « chrome/browser/android/hung_renderer_infobar_delegate.h ('k') | chrome/browser/android/resource_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698