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

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

Issue 14946003: Record first run startup metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 7 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 | Annotate | Revision Log
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/first_run_dialog.h" 5 #include "chrome/browser/ui/gtk/first_run_dialog.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 g_value_set_int(&value, y); 61 g_value_set_int(&value, y);
62 gtk_container_child_set_property(GTK_CONTAINER(container), 62 gtk_container_child_set_property(GTK_CONTAINER(container),
63 label, "y", &value); 63 label, "y", &value);
64 g_value_unset(&value); 64 g_value_unset(&value);
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 namespace first_run { 69 namespace first_run {
70 70
71 void ShowFirstRunDialog(Profile* profile) { 71 bool ShowFirstRunDialog(Profile* profile) {
72 FirstRunDialog::Show(); 72 return FirstRunDialog::Show();
73 } 73 }
74 74
75 } // namespace first_run 75 } // namespace first_run
76 76
77 // static 77 // static
78 bool FirstRunDialog::Show() { 78 bool FirstRunDialog::Show() {
79 #if !defined(GOOGLE_CHROME_BUILD) 79 bool dialog_shown = false;
80 return true; // Nothing to do 80 #if defined(GOOGLE_CHROME_BUILD)
81 #else
82 // If the metrics reporting is managed, we won't ask. 81 // If the metrics reporting is managed, we won't ask.
83 const PrefService::Preference* metrics_reporting_pref = 82 const PrefService::Preference* metrics_reporting_pref =
84 g_browser_process->local_state()->FindPreference( 83 g_browser_process->local_state()->FindPreference(
85 prefs::kMetricsReportingEnabled); 84 prefs::kMetricsReportingEnabled);
86 bool show_reporting_dialog = !metrics_reporting_pref || 85 bool show_reporting_dialog = !metrics_reporting_pref ||
87 !metrics_reporting_pref->IsManaged(); 86 !metrics_reporting_pref->IsManaged();
88 87
89 if (!show_reporting_dialog) 88 if (!show_reporting_dialog)
90 return true; // Nothing to do 89 return; // Nothing to do
jeremy 2013/05/06 17:59:38 Does this compile?
gab 2013/05/06 18:44:51 Whoops, you're right :) -- I'm on Windows! Cleaned
91 90
92 int response = -1; 91 int response = -1;
93 // Object deletes itself. 92 // Object deletes itself.
94 new FirstRunDialog(show_reporting_dialog, &response); 93 new FirstRunDialog(show_reporting_dialog, &response);
94 dialog_shown = true;
95 95
96 // TODO(port): it should be sufficient to just run the dialog: 96 // TODO(port): it should be sufficient to just run the dialog:
97 // int response = gtk_dialog_run(GTK_DIALOG(dialog)); 97 // int response = gtk_dialog_run(GTK_DIALOG(dialog));
98 // but that spins a nested message loop and hoses us. :( 98 // but that spins a nested message loop and hoses us. :(
99 // http://code.google.com/p/chromium/issues/detail?id=12552 99 // http://code.google.com/p/chromium/issues/detail?id=12552
100 // Instead, run a loop and extract the response manually. 100 // Instead, run a loop directly here.
101 MessageLoop::current()->Run(); 101 MessageLoop::current()->Run();
102
103 return (response == GTK_RESPONSE_ACCEPT);
104 #endif // defined(GOOGLE_CHROME_BUILD) 102 #endif // defined(GOOGLE_CHROME_BUILD)
103 return dialog_shown;
105 } 104 }
106 105
107 FirstRunDialog::FirstRunDialog(bool show_reporting_dialog, int* response) 106 FirstRunDialog::FirstRunDialog(bool show_reporting_dialog, int* response)
108 : dialog_(NULL), 107 : dialog_(NULL),
109 report_crashes_(NULL), 108 report_crashes_(NULL),
110 make_default_(NULL), 109 make_default_(NULL),
111 show_reporting_dialog_(show_reporting_dialog), 110 show_reporting_dialog_(show_reporting_dialog),
112 response_(response) { 111 response_(response) {
113 ShowReportingDialog(); 112 ShowReportingDialog();
114 } 113 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 206 }
208 207
209 void FirstRunDialog::FirstRunDone() { 208 void FirstRunDialog::FirstRunDone() {
210 first_run::SetShouldShowWelcomePage(); 209 first_run::SetShouldShowWelcomePage();
211 210
212 if (dialog_) 211 if (dialog_)
213 gtk_widget_destroy(dialog_); 212 gtk_widget_destroy(dialog_);
214 MessageLoop::current()->Quit(); 213 MessageLoop::current()->Quit();
215 delete this; 214 delete this;
216 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698