summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_main.cc7
-rw-r--r--chrome/browser/first_run.cc14
-rw-r--r--chrome/browser/first_run.h4
-rw-r--r--chrome/browser/first_run_gtk.cc7
-rw-r--r--chrome/browser/first_run_mac.mm3
-rw-r--r--chrome/browser/first_run_win.cc10
-rw-r--r--chrome/browser/views/first_run_view.cc8
-rw-r--r--chrome/browser/views/first_run_view.h6
-rw-r--r--chrome/common/temp_scaffolding_stubs.h2
9 files changed, 45 insertions, 16 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 2044261..a6df834 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -624,11 +624,10 @@ int BrowserMain(const MainFunctionParams& parameters) {
// preferences are registered, since some of the code that the importer
// touches reads preferences.
if (is_first_run && !first_run_ui_bypass) {
- OpenFirstRunDialog(profile, &process_singleton);
- // If user cancelled the first run dialog box, the first run sentinel file
- // didn't get created and we should exit Chrome.
- if (FirstRun::IsChromeFirstRun())
+ if (!OpenFirstRunDialog(profile, &process_singleton)) {
+ // The user cancelled the first run dialog box, we should exit Chrome.
return ResultCodes::NORMAL_EXIT;
+ }
}
#endif // OS_POSIX
diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc
index 10281c0..f0b0f74 100644
--- a/chrome/browser/first_run.cc
+++ b/chrome/browser/first_run.cc
@@ -58,9 +58,19 @@ bool GetFirstRunSentinelFilePath(FilePath* path) {
// TODO(port): Mac should share this code.
#if !defined(OS_MACOSX)
bool FirstRun::IsChromeFirstRun() {
+ // A troolean, 0 means not yet set, 1 means set to true, 2 set to false.
+ static int first_run = 0;
+ if (first_run != 0)
+ return first_run == 1;
+
FilePath first_run_sentinel;
- return (GetFirstRunSentinelFilePath(&first_run_sentinel) &&
- !file_util::PathExists(first_run_sentinel));
+ if (!GetFirstRunSentinelFilePath(&first_run_sentinel) ||
+ file_util::PathExists(first_run_sentinel)) {
+ first_run = 2;
+ return false;
+ }
+ first_run = 1;
+ return true;
}
#endif
diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h
index cc8b4db..030c535 100644
--- a/chrome/browser/first_run.h
+++ b/chrome/browser/first_run.h
@@ -148,6 +148,8 @@ class FirstRunBrowserProcess : public BrowserProcessImpl {
// |profile| and perhaps some other tasks.
// |process_singleton| is used to lock the handling of CopyData messages
// while the First Run UI is visible.
-void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton);
+// Returns true if the user clicked "Start", false if the user pressed "Cancel"
+// or closed the dialog.
+bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton);
#endif // CHROME_BROWSER_FIRST_RUN_H_
diff --git a/chrome/browser/first_run_gtk.cc b/chrome/browser/first_run_gtk.cc
index b324fec..277dbeb 100644
--- a/chrome/browser/first_run_gtk.cc
+++ b/chrome/browser/first_run_gtk.cc
@@ -27,7 +27,7 @@ void DialogResponseCallback(GtkDialog* dialog, gint response,
} // namespace
-void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
+bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
#if defined(GOOGLE_CHROME_BUILD)
GtkWidget* dialog = gtk_dialog_new_with_buttons(
"Google Chrome Dev Build",
@@ -111,7 +111,8 @@ void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
MessageLoop::current()->Run();
// End of above TODO.
- if (response == GTK_RESPONSE_ACCEPT) {
+ bool accepted = (response == GTK_RESPONSE_ACCEPT);
+ if (accepted) {
// Mark that first run has ran.
FirstRun::CreateSentinel();
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
@@ -125,7 +126,9 @@ void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
}
gtk_widget_destroy(dialog);
+ return accepted;
#else // defined(GOOGLE_CHROME_BUILD)
FirstRun::CreateSentinel();
+ return true;
#endif
}
diff --git a/chrome/browser/first_run_mac.mm b/chrome/browser/first_run_mac.mm
index 933729ff5..7292e9d 100644
--- a/chrome/browser/first_run_mac.mm
+++ b/chrome/browser/first_run_mac.mm
@@ -30,7 +30,7 @@ bool FirstRun::IsChromeFirstRun() {
#endif // defined(GOOGLE_CHROME_BUILD)
}
-void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
+bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
// OpenFirstRunDialog is a no-op on non-branded builds.
#if defined(GOOGLE_CHROME_BUILD)
// Breakpad should not be enabled on first run until the user has explicitly
@@ -56,4 +56,5 @@ void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) {
InitCrashProcessInfo();
}
#endif // defined(GOOGLE_CHROME_BUILD)
+ return true;
}
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc
index 1d4d7bb4..4e58792 100644
--- a/chrome/browser/first_run_win.cc
+++ b/chrome/browser/first_run_win.cc
@@ -340,13 +340,17 @@ bool Upgrade::SwapNewChromeExeIfPresent() {
return false;
}
-void OpenFirstRunDialog(Profile* profile,
+bool OpenFirstRunDialog(Profile* profile,
ProcessSingleton* process_singleton) {
DCHECK(profile);
DCHECK(process_singleton);
+ // We need the FirstRunView to outlive its parent, as we retrieve the accept
+ // state from it after the dialog has been closed.
+ scoped_ptr<FirstRunView> first_run_view(new FirstRunView(profile));
+ first_run_view->SetParentOwned(false);
views::Window* first_run_ui = views::Window::CreateChromeWindow(
- NULL, gfx::Rect(), new FirstRunView(profile));
+ NULL, gfx::Rect(), first_run_view.get());
DCHECK(first_run_ui);
// We need to avoid dispatching new tabs when we are doing the import
@@ -363,6 +367,8 @@ void OpenFirstRunDialog(Profile* profile,
// that keyboard accelerators (Enter, Esc, etc) work in the dialog box.
MessageLoopForUI::current()->Run(g_browser_process->accelerator_handler());
process_singleton->Unlock();
+
+ return first_run_view->accepted();
}
namespace {
diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc
index 23e2b59..00904e9 100644
--- a/chrome/browser/views/first_run_view.cc
+++ b/chrome/browser/views/first_run_view.cc
@@ -39,14 +39,13 @@ FirstRunView::FirstRunView(Profile* profile)
actions_import_(NULL),
actions_shorcuts_(NULL),
customize_link_(NULL),
- customize_selected_(false) {
+ customize_selected_(false),
+ accepted_(false) {
importer_host_ = new ImporterHost();
SetupControls();
}
FirstRunView::~FirstRunView() {
- // Exit the message loop we were started with so that startup can continue.
- MessageLoop::current()->Quit();
}
void FirstRunView::SetupControls() {
@@ -184,12 +183,15 @@ bool FirstRunView::Accept() {
if (default_browser_->checked())
SetDefaultBrowser();
+ accepted_ = true;
FirstRunComplete();
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
return true;
}
bool FirstRunView::Cancel() {
UserMetrics::RecordAction(L"FirstRunDef_Cancel", profile_);
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
return true;
}
diff --git a/chrome/browser/views/first_run_view.h b/chrome/browser/views/first_run_view.h
index 54f8515..abc2d48 100644
--- a/chrome/browser/views/first_run_view.h
+++ b/chrome/browser/views/first_run_view.h
@@ -28,6 +28,8 @@ class FirstRunView : public FirstRunViewBase,
explicit FirstRunView(Profile* profile);
virtual ~FirstRunView();
+ bool accepted() const { return accepted_;}
+
// Overridden from views::View:
virtual gfx::Size GetPreferredSize();
virtual void Layout();
@@ -61,6 +63,10 @@ class FirstRunView : public FirstRunViewBase,
views::Link* customize_link_;
bool customize_selected_;
+ // Whether the user accepted (pressed the "Start" button as opposed to
+ // "Cancel").
+ bool accepted_;
+
DISALLOW_COPY_AND_ASSIGN(FirstRunView);
};
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 6d67947..dd17bb7 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -51,7 +51,7 @@ class Message;
//---------------------------------------------------------------------------
// These stubs are for Browser_main()
-void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton);
+bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton);
void InstallJankometer(const CommandLine&);