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

Side by Side Diff: chrome/browser/ui/gtk/sad_tab_gtk.cc

Issue 11775012: Add Histogram record to SadTabGtk (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" 5 #include "chrome/browser/ui/gtk/sad_tab_gtk.h"
6 6
7 #include "base/metrics/histogram.h"
7 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 9 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
9 #include "chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_g tk.h" 10 #include "chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_g tk.h"
10 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "grit/locale_settings.h" 14 #include "grit/locale_settings.h"
14 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
15 #include "ui/base/gtk/gtk_hig_constants.h" 16 #include "ui/base/gtk/gtk_hig_constants.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return label; 51 return label;
51 } 52 }
52 53
53 } // namespace 54 } // namespace
54 55
55 SadTabGtk::SadTabGtk(WebContents* web_contents, chrome::SadTabKind kind) 56 SadTabGtk::SadTabGtk(WebContents* web_contents, chrome::SadTabKind kind)
56 : web_contents_(web_contents), 57 : web_contents_(web_contents),
57 kind_(kind) { 58 kind_(kind) {
58 DCHECK(web_contents_); 59 DCHECK(web_contents_);
59 60
61 switch (kind_) {
62 case chrome::SAD_TAB_KIND_CRASHED: {
63 static int crashed = 0;
64 UMA_HISTOGRAM_CUSTOM_COUNTS(
65 "Tabs.SadTab.CrashCreated", ++crashed, 1, 1000, 50);
66 break;
67 }
68 case chrome::SAD_TAB_KIND_KILLED: {
69 static int killed = 0;
70 UMA_HISTOGRAM_CUSTOM_COUNTS(
71 "Tabs.SadTab.KilledCreated", ++killed, 1, 1000, 50);
72 break;
73 }
74 default:
75 NOTREACHED();
76 }
77
60 // Use an event box to get the background painting correctly. 78 // Use an event box to get the background painting correctly.
61 event_box_.Own(gtk_event_box_new()); 79 event_box_.Own(gtk_event_box_new());
62 gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL, 80 gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL,
63 (kind == chrome::SAD_TAB_KIND_CRASHED) ? 81 (kind == chrome::SAD_TAB_KIND_CRASHED) ?
64 &kCrashedBackgroundColor : &kKilledBackgroundColor); 82 &kCrashedBackgroundColor : &kKilledBackgroundColor);
65 // Allow ourselves to be resized arbitrarily small. 83 // Allow ourselves to be resized arbitrarily small.
66 gtk_widget_set_size_request(event_box_.get(), 0, 0); 84 gtk_widget_set_size_request(event_box_.get(), 0, 0);
67 85
68 GtkWidget* centering = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); 86 GtkWidget* centering = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
69 gtk_container_add(GTK_CONTAINER(event_box_.get()), centering); 87 gtk_container_add(GTK_CONTAINER(event_box_.get()), centering);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 167 }
150 168
151 gtk_widget_show_all(event_box_.get()); 169 gtk_widget_show_all(event_box_.get());
152 } 170 }
153 171
154 SadTabGtk::~SadTabGtk() { 172 SadTabGtk::~SadTabGtk() {
155 event_box_.Destroy(); 173 event_box_.Destroy();
156 } 174 }
157 175
158 void SadTabGtk::Show() { 176 void SadTabGtk::Show() {
177 switch (kind_) {
178 case chrome::SAD_TAB_KIND_CRASHED: {
179 static int crashed = 0;
180 UMA_HISTOGRAM_CUSTOM_COUNTS(
181 "Tabs.SadTab.CrashDisplayed", ++crashed, 1, 1000, 50);
182 break;
183 }
184 case chrome::SAD_TAB_KIND_KILLED: {
185 static int killed = 0;
186 UMA_HISTOGRAM_CUSTOM_COUNTS(
187 "Tabs.SadTab.KilledDisplayed", ++killed, 1, 1000, 50);
188 break;
189 }
190 default:
191 NOTREACHED();
192 }
193
159 GtkWidget* expanded_container = 194 GtkWidget* expanded_container =
160 ChromeWebContentsViewDelegateGtk::GetFor(web_contents_)-> 195 ChromeWebContentsViewDelegateGtk::GetFor(web_contents_)->
161 expanded_container(); 196 expanded_container();
162 gtk_container_add(GTK_CONTAINER(expanded_container), event_box_.get()); 197 gtk_container_add(GTK_CONTAINER(expanded_container), event_box_.get());
163 gtk_widget_show(event_box_.get()); 198 gtk_widget_show(event_box_.get());
164 } 199 }
165 200
166 void SadTabGtk::Close() { 201 void SadTabGtk::Close() {
167 GtkWidget* expanded_container = 202 GtkWidget* expanded_container =
168 ChromeWebContentsViewDelegateGtk::GetFor(web_contents_)-> 203 ChromeWebContentsViewDelegateGtk::GetFor(web_contents_)->
(...skipping 11 matching lines...) Expand all
180 } 215 }
181 } 216 }
182 217
183 namespace chrome { 218 namespace chrome {
184 219
185 SadTab* SadTab::Create(content::WebContents* web_contents, SadTabKind kind) { 220 SadTab* SadTab::Create(content::WebContents* web_contents, SadTabKind kind) {
186 return new SadTabGtk(web_contents, kind); 221 return new SadTabGtk(web_contents, kind);
187 } 222 }
188 223
189 } // namespace chrome 224 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698