OLD | NEW |
| 1 |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 4 // found in the LICENSE file. |
4 | 5 |
5 #include "chrome/browser/first_run.h" | 6 #include "chrome/browser/first_run.h" |
6 | 7 |
7 #include "chrome/app/breakpad_linux.h" | 8 #include "chrome/browser/gtk/first_run_dialog.h" |
8 // We need to reach through the browser process to tweak the metrics flag. | |
9 #include "chrome/browser/browser_process.h" | |
10 #include "chrome/common/pref_names.h" | |
11 #include "chrome/common/pref_service.h" | |
12 #include "chrome/installer/util/google_update_settings.h" | |
13 | |
14 #include "base/message_loop.h" | |
15 | |
16 namespace { | |
17 | |
18 // Callback for the "response" signal of the first run dialog. | |
19 // Fills in the int* |data| with the dialog response and quits the message loop. | |
20 // See the TODO below for why this is necessary (it's a bug). | |
21 void DialogResponseCallback(GtkDialog* dialog, gint response, | |
22 gpointer data) { | |
23 int* response_out = static_cast<int*>(data); | |
24 *response_out = response; | |
25 MessageLoop::current()->Quit(); | |
26 } | |
27 | |
28 } // namespace | |
29 | 9 |
30 bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { | 10 bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { |
31 #if defined(GOOGLE_CHROME_BUILD) | 11 // TODO(port): Use process_singleton to make sure Chrome can not be started |
32 GtkWidget* dialog = gtk_dialog_new_with_buttons( | 12 // while this process is active. |
33 "Google Chrome Dev Build", | 13 return FirstRunDialog::Show(profile); |
34 NULL, // No parent | |
35 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | |
36 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, | |
37 NULL); | |
38 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
39 g_signal_connect(G_OBJECT(dialog), "delete-event", | |
40 G_CALLBACK(gtk_widget_hide_on_delete), NULL); | |
41 | |
42 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; | |
43 gtk_box_set_spacing(GTK_BOX(content_area), 18); | |
44 | |
45 GtkWidget* vbox = gtk_vbox_new(FALSE, 12); | |
46 // Force a size on the vbox so the labels wrap. | |
47 gtk_widget_set_size_request(vbox, 400, -1); | |
48 | |
49 GtkWidget* privacy_label = gtk_label_new( | |
50 "This version of Google Chrome for Linux is not appropriate for " | |
51 "general consumer use. Certain privacy features are unavailable " | |
52 "at this time as described in our privacy policy at"); | |
53 gtk_misc_set_alignment(GTK_MISC(privacy_label), 0, 0); | |
54 gtk_label_set_line_wrap(GTK_LABEL(privacy_label), TRUE); | |
55 gtk_box_pack_start(GTK_BOX(vbox), privacy_label, FALSE, FALSE, 0); | |
56 | |
57 GtkWidget* url_label = gtk_label_new(NULL); | |
58 gtk_label_set_markup(GTK_LABEL(url_label), | |
59 "<tt>http://www.google.com/chrome/intl/en/privacy_linux.html</tt>"); | |
60 // Set selectable to allow copy and paste. | |
61 gtk_label_set_selectable(GTK_LABEL(url_label), TRUE); | |
62 gtk_box_pack_start(GTK_BOX(vbox), url_label, FALSE, FALSE, 0); | |
63 | |
64 GtkWidget* intro_label = gtk_label_new( | |
65 "This dialog would normally prompt you to import information from other " | |
66 "browsers, but that is not yet fully implemented.\n" | |
67 "Instead, we have only one important setting available: Crash dumps. " | |
68 "We cannot fix your crashes without your crash reports, so there's " | |
69 "little reason to run a dev channel build without turning them on."); | |
70 gtk_misc_set_alignment(GTK_MISC(intro_label), 0, 0); | |
71 gtk_label_set_line_wrap(GTK_LABEL(intro_label), TRUE); | |
72 gtk_box_pack_start(GTK_BOX(vbox), intro_label, FALSE, FALSE, 0); | |
73 | |
74 GtkWidget* check = gtk_check_button_new(); | |
75 GtkWidget* check_label = gtk_label_new(NULL); | |
76 gtk_label_set_markup(GTK_LABEL(check_label), | |
77 "<b>Optional:</b> Help make Google Chrome better by " | |
78 "automatically sending crash reports (and eventually " | |
79 "usage statistics, but that is also unimplemented) " | |
80 "to Google."); | |
81 gtk_label_set_line_wrap(GTK_LABEL(check_label), TRUE); | |
82 gtk_container_add(GTK_CONTAINER(check), check_label); | |
83 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); | |
84 | |
85 #define UTF8_BULLET " \xE2\x80\xA2 " | |
86 GtkWidget* crashinfo_label = gtk_label_new(NULL); | |
87 gtk_label_set_markup(GTK_LABEL(crashinfo_label), | |
88 "A crash dump contains:\n" | |
89 UTF8_BULLET "Stacks and registers of all the threads in the crashing " | |
90 "process\n" | |
91 UTF8_BULLET "The current URL if a render process crashes\n" | |
92 UTF8_BULLET "<tt>/proc/cpuinfo</tt>, <tt>/etc/lsb-release</tt>\n" | |
93 UTF8_BULLET "Other misc information about the process (its " | |
94 "<tt>/proc/pid/maps</tt>, <tt>/proc/pid/status</tt>, etc.)"); | |
95 gtk_misc_set_alignment(GTK_MISC(crashinfo_label), 0, 0); | |
96 gtk_label_set_line_wrap(GTK_LABEL(crashinfo_label), TRUE); | |
97 gtk_box_pack_start(GTK_BOX(vbox), crashinfo_label, FALSE, FALSE, 0); | |
98 | |
99 gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0); | |
100 gtk_widget_show_all(vbox); | |
101 | |
102 // TODO(port): it should be sufficient to just run the dialog: | |
103 // int response = gtk_dialog_run(GTK_DIALOG(dialog)); | |
104 // but that spins a nested message loop and hoses us. :( | |
105 // http://code.google.com/p/chromium/issues/detail?id=12552 | |
106 // Instead, run a loop and extract the response manually. | |
107 int response = 0; | |
108 g_signal_connect(G_OBJECT(dialog), "response", | |
109 G_CALLBACK(DialogResponseCallback), &response); | |
110 gtk_widget_show(dialog); | |
111 MessageLoop::current()->Run(); | |
112 // End of above TODO. | |
113 | |
114 bool accepted = (response == GTK_RESPONSE_ACCEPT); | |
115 if (accepted) { | |
116 // Mark that first run has ran. | |
117 FirstRun::CreateSentinel(); | |
118 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) { | |
119 // They opted in. | |
120 if (GoogleUpdateSettings::SetCollectStatsConsent(true)) { | |
121 InitCrashReporter(); | |
122 } | |
123 } else { | |
124 GoogleUpdateSettings::SetCollectStatsConsent(false); | |
125 } | |
126 } | |
127 | |
128 gtk_widget_destroy(dialog); | |
129 return accepted; | |
130 #else // defined(GOOGLE_CHROME_BUILD) | |
131 FirstRun::CreateSentinel(); | |
132 return true; | |
133 #endif | |
134 } | 14 } |
OLD | NEW |