diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 22:57:43 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 22:57:43 +0000 |
commit | 65f77adcaf52868c720a73ba3ca08dee7899d707 (patch) | |
tree | b52ca0501b37438dd211388b58c066b73f4a2fda /chrome | |
parent | c284946e12e85a287e5095bde26efa72e84bb56b (diff) | |
download | chromium_src-65f77adcaf52868c720a73ba3ca08dee7899d707.zip chromium_src-65f77adcaf52868c720a73ba3ca08dee7899d707.tar.gz chromium_src-65f77adcaf52868c720a73ba3ca08dee7899d707.tar.bz2 |
linux: Implement a first run dialog.
BUG=11971
Review URL: http://codereview.chromium.org/115722
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_main.cc | 9 | ||||
-rw-r--r-- | chrome/browser/first_run.cc | 9 | ||||
-rw-r--r-- | chrome/browser/first_run_gtk.cc | 109 | ||||
-rw-r--r-- | chrome/chrome.gyp | 1 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cc | 12 |
5 files changed, 120 insertions, 20 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index cec8e46..d2bc9de 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -536,6 +536,12 @@ int BrowserMain(const MainFunctionParams& parameters) { process_singleton.Create(); +#if defined(TOOLKIT_GTK) + // It is important for this to happen before the first run dialog, as it + // styles the dialog as well. + gtk_util::InitRCStyles(); +#endif + // TODO: This block of code should probably be used on all platforms! // On Mac OS X we display this dialog before setting the value of // kMetricsReportingEnabled, so we display this dialog much earlier. @@ -613,9 +619,6 @@ int BrowserMain(const MainFunctionParams& parameters) { // the installation event. RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run); #endif -#if defined(TOOLKIT_GTK) - gtk_util::InitRCStyles(); -#endif // Config the network module so it has access to resources. net::NetModule::SetResourceProvider(NetResourceProvider); diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc index 15cc575..540aa61 100644 --- a/chrome/browser/first_run.cc +++ b/chrome/browser/first_run.cc @@ -30,13 +30,12 @@ const char kSentinelFile[] = "First Run Alpha"; // Gives the full path to the sentinel file. The file might not exist. bool GetFirstRunSentinelFilePath(FilePath* path) { - FilePath exe_path; - if (!PathService::Get(base::DIR_EXE, &exe_path)) - return false; - FilePath first_run_sentinel; #if defined(OS_WIN) + FilePath exe_path; + if (!PathService::Get(base::DIR_EXE, &exe_path)) + return false; if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) { first_run_sentinel = exe_path; } else { @@ -44,7 +43,7 @@ bool GetFirstRunSentinelFilePath(FilePath* path) { return false; } #else - // TODO(port): logic as above. Not important for our "First Run Dev" file. + // TODO(port): logic as above. Not important for our "First Run Alpha" file. if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) return false; #endif diff --git a/chrome/browser/first_run_gtk.cc b/chrome/browser/first_run_gtk.cc new file mode 100644 index 0000000..8543780 --- /dev/null +++ b/chrome/browser/first_run_gtk.cc @@ -0,0 +1,109 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/first_run.h" + +// We need to reach through the browser process to tweak the metrics flag. +#include "chrome/browser/browser_process.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" + +#include "base/message_loop.h" + +namespace { + +// Callback for the "response" signal of the first run dialog. +// Fills in the int* |data| with the dialog response and quits the message loop. +// See the TODO below for why this is necessary (it's a bug). +void DialogResponseCallback(GtkDialog* dialog, gint response, + gpointer data) { + int* response_out = static_cast<int*>(data); + *response_out = response; + MessageLoop::current()->Quit(); +} + +} // namespace + +void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { +#if defined(GOOGLE_CHROME_BUILD) + GtkWidget* dialog = gtk_dialog_new_with_buttons( + "Google Chrome Alpha", + NULL, // No parent + (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); + g_signal_connect(G_OBJECT(dialog), "delete-event", + G_CALLBACK(gtk_widget_hide_on_delete), NULL); + + GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; + gtk_box_set_spacing(GTK_BOX(content_area), 18); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 12); + // Force a size on the vbox so the labels wrap. + gtk_widget_set_size_request(vbox, 400, -1); + + GtkWidget* intro_label = gtk_label_new( + "This dialog would normally prompt you to import information from other " + "browsers, but that is not yet fully implemented.\n\n" + "Instead, we have only one important setting available: Crash dumps. " + "We cannot fix your crashes without your crash reports, so there's " + "little reason to run a dev channel build without turning them on."); + gtk_misc_set_alignment(GTK_MISC(intro_label), 0, 0); + gtk_label_set_line_wrap(GTK_LABEL(intro_label), TRUE); + gtk_box_pack_start(GTK_BOX(vbox), intro_label, FALSE, FALSE, 0); + + GtkWidget* check = gtk_check_button_new(); + GtkWidget* check_label = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(check_label), + "<b>Optional:</b> Help make Google Chrome better by " + "automatically sending crash reports (and eventually " + "usage statistics, but that is also unimplemented) " + "to Google."); + gtk_label_set_line_wrap(GTK_LABEL(check_label), TRUE); + gtk_container_add(GTK_CONTAINER(check), check_label); + gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); + + #define UTF8_BULLET " \xE2\x80\xA2 " + GtkWidget* crashinfo_label = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(crashinfo_label), + "A crash dump contains:\n" + UTF8_BULLET "Stacks and registers of all the threads in the crashing " + "process\n" + UTF8_BULLET "The current URL if a render process crashes\n" + UTF8_BULLET "<tt>/proc/cpuinfo</tt>, <tt>/etc/lsb-release</tt>\n" + UTF8_BULLET "Other misc information about the process (its " + "<tt>/proc/pid/maps</tt>, <tt>/proc/pid/status</tt>, etc.)"); + gtk_misc_set_alignment(GTK_MISC(crashinfo_label), 0, 0); + gtk_label_set_line_wrap(GTK_LABEL(crashinfo_label), TRUE); + gtk_box_pack_start(GTK_BOX(vbox), crashinfo_label, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0); + gtk_widget_show_all(vbox); + + // TODO(port): it should be sufficient to just run the dialog: + // int response = gtk_dialog_run(GTK_DIALOG(dialog)); + // but that spins a nested message loop and hoses us. :( + // http://code.google.com/p/chromium/issues/detail?id=12552 + // Instead, run a loop and extract the response manually. + int response = 0; + g_signal_connect(G_OBJECT(dialog), "response", + G_CALLBACK(DialogResponseCallback), &response); + gtk_widget_show(dialog); + MessageLoop::current()->Run(); + // End of above TODO. + + if (response == GTK_RESPONSE_ACCEPT && + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) { + // They opted in. + g_browser_process->local_state()->SetBoolean( + prefs::kMetricsReportingEnabled, true); + } + + gtk_widget_destroy(dialog); +#endif // defined(GOOGLE_CHROME_BUILD) + + // Mark that first run has ran. + FirstRun::CreateSentinel(); +} diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 8e852f3..6cecfdd 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -853,6 +853,7 @@ 'browser/first_run.h', 'browser/first_run_mac.mm', 'browser/first_run_win.cc', + 'browser/first_run_gtk.cc', 'browser/gears_integration.cc', 'browser/gears_integration.h', 'browser/google_update.cc', diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc index de4babc..50aa826 100644 --- a/chrome/common/temp_scaffolding_stubs.cc +++ b/chrome/common/temp_scaffolding_stubs.cc @@ -136,18 +136,6 @@ bool ShellIntegration::IsDefaultBrowser() { //-------------------------------------------------------------------------- -#if defined(OS_LINUX) -void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { - // http://code.google.com/p/chromium/issues/detail?id=11971 - // - // Note that on Windows, this eventually calls into - // FirstRunViewBase::FirstRunComplete, which then creates the First - // Run sentinel. We should refactor that out into the caller of - // this function. - NOTIMPLEMENTED(); -} -#endif - // static bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, const FilePath& master_prefs_path, |