diff options
23 files changed, 221 insertions, 109 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 059edc4..e94ee26 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -1059,7 +1059,7 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu'; } CommandLine dummy(CommandLine::NO_PROGRAM); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); launch.OpenURLsInBrowser(browser, false, urls); diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index c6a96bd..9547b16 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -1134,7 +1134,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { process_singleton_.reset(new ProcessSingleton(user_data_dir_)); - is_first_run_ = FirstRun::IsChromeFirstRun() || + is_first_run_ = first_run::IsChromeFirstRun() || parsed_command_line().HasSwitch(switches::kFirstRun); if (parsed_command_line().HasSwitch(switches::kImport) || @@ -1249,6 +1249,10 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { parsed_command_line().HasSwitch(switches::kAppId) || parsed_command_line().HasSwitch(switches::kNoFirstRun))) first_run_ui_bypass_ = true; + + // Create Sentinel if no-first-run argument is passed in. + if (parsed_command_line().HasSwitch(switches::kNoFirstRun)) + first_run::CreateSentinel(); } // TODO(viettrungluu): why don't we run this earlier? diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 3965c1d..246ff34 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -137,7 +137,7 @@ int DoUninstallTasks(bool chrome_still_running) { if (ret != chrome::RESULT_CODE_UNINSTALL_USER_CANCEL) { // The following actions are just best effort. VLOG(1) << "Executing uninstall actions"; - if (!FirstRun::RemoveSentinel()) + if (!first_run::RemoveSentinel()) VLOG(1) << "Failed to delete sentinel file."; // We want to remove user level shortcuts and we only care about the ones // created by us and not by the installer so |alternate| is false. diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 73735e8..8714ac7 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -1332,7 +1332,7 @@ void LoginUtils::DoBrowserLaunch(Profile* profile, VLOG(1) << "Launching browser..."; BrowserInit browser_init; int return_code; - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN: BrowserInit::IS_NOT_FIRST_RUN; browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), profile, diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc index 7701184..71d0c2d 100644 --- a/chrome/browser/extensions/default_apps.cc +++ b/chrome/browser/extensions/default_apps.cc @@ -43,7 +43,7 @@ static bool ShouldInstallInProfile(Profile* profile) { // However, this means that multi-profile support is broken: secondary // profiles will not get default apps. // TODO(rogerta): add support for multiple profiles. - if (!FirstRun::IsChromeFirstRun()) + if (!first_run::IsChromeFirstRun()) install_apps = false; break; } diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 92b1787..0211efc 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -13,6 +13,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/first_run/first_run_dialog.h" #include "chrome/browser/first_run/first_run_import_observer.h" +#include "chrome/browser/first_run/first_run_internal.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/importer/external_process_importer_host.h" #include "chrome/browser/importer/importer_host.h" @@ -44,9 +45,6 @@ using content::UserMetricsAction; namespace { -// The kSentinelFile file absence will tell us it is a first run. -const char kSentinelFile[] = "First Run"; - FilePath GetDefaultPrefFilePath(bool create_profile_dir, const FilePath& user_data_dir) { FilePath default_pref_dir = @@ -112,9 +110,48 @@ void SetImportItem(PrefService* user_prefs, } // namespace -// FirstRun ------------------------------------------------------------------- +namespace first_run { +namespace internal { + +const char* const kSentinelFile = "First Run"; +FirstRunState first_run_ = FIRST_RUN_UNKNOWN; + +} // namespace internal +} // namespace first_run + +namespace first_run { + +bool IsChromeFirstRun() { + if (internal::first_run_ != internal::FIRST_RUN_UNKNOWN) + return internal::first_run_ == internal::FIRST_RUN_TRUE; + + FilePath first_run_sentinel; + if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel) || + file_util::PathExists(first_run_sentinel)) { + internal::first_run_ = internal::FIRST_RUN_FALSE; + return false; + } + internal::first_run_ = internal::FIRST_RUN_TRUE; + return true; +} + +bool CreateSentinel() { + FilePath first_run_sentinel; + if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) + return false; + return file_util::WriteFile(first_run_sentinel, "", 0) != -1; +} + +bool RemoveSentinel() { + FilePath first_run_sentinel; + if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) + return false; + return file_util::Delete(first_run_sentinel, false); +} -FirstRun::FirstRunState FirstRun::first_run_ = FIRST_RUN_UNKNOWN; +} // namespace first_run + +// FirstRun ------------------------------------------------------------------- FirstRun::MasterPrefs::MasterPrefs() : ping_delay(0), @@ -307,7 +344,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, // We need to be able to create the first run sentinel or else we cannot // proceed because ImportSettings will launch the importer process which // would end up here if the sentinel is not present. - if (!FirstRun::CreateSentinel()) + if (!first_run::CreateSentinel()) return false; if (prefs.GetBool(installer::master_preferences::kDistroShowWelcomePage, @@ -382,37 +419,6 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, } // static -bool FirstRun::IsChromeFirstRun() { - if (first_run_ != FIRST_RUN_UNKNOWN) - return first_run_ == FIRST_RUN_TRUE; - - FilePath first_run_sentinel; - if (!GetFirstRunSentinelFilePath(&first_run_sentinel) || - file_util::PathExists(first_run_sentinel)) { - first_run_ = FIRST_RUN_FALSE; - return false; - } - first_run_ = FIRST_RUN_TRUE; - return true; -} - -// static -bool FirstRun::RemoveSentinel() { - FilePath first_run_sentinel; - if (!GetFirstRunSentinelFilePath(&first_run_sentinel)) - return false; - return file_util::Delete(first_run_sentinel, false); -} - -// static -bool FirstRun::CreateSentinel() { - FilePath first_run_sentinel; - if (!GetFirstRunSentinelFilePath(&first_run_sentinel)) - return false; - return file_util::WriteFile(first_run_sentinel, "", 0) != -1; -} - -// static bool FirstRun::SetShowFirstRunBubblePref(bool show_bubble) { PrefService* local_state = g_browser_process->local_state(); if (!local_state) @@ -506,29 +512,6 @@ int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { } // static -bool FirstRun::GetFirstRunSentinelFilePath(FilePath* path) { - 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 { - if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) - return false; - } -#else - if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) - return false; -#endif - - *path = first_run_sentinel.AppendASCII(kSentinelFile); - return true; -} - -// static void FirstRun::AutoImport( Profile* profile, bool homepage_defined, @@ -646,7 +629,7 @@ void FirstRun::AutoImport( FirstRun::SetPersonalDataManagerFirstRunPref(); process_singleton->Unlock(); - FirstRun::CreateSentinel(); + first_run::CreateSentinel(); #endif } diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h index 6685f6b..043dbc4 100644 --- a/chrome/browser/first_run/first_run.h +++ b/chrome/browser/first_run/first_run.h @@ -23,6 +23,33 @@ class Profile; class ProcessSingleton; class TemplateURLService; +// TODO(jennyz): All FirstRun class code will be refactored to first_run +// namespace progressively with several changelists to be landed. Therefore, +// we keep first_run namespace and FirstRun in the same file temporarily. + +// This namespace contains the chrome first-run installation actions needed to +// fully test the custom installer. It also contains the opposite actions to +// execute during uninstall. When the first run UI is ready we won't +// do the actions unconditionally. Currently the only action is to create a +// desktop shortcut. +// +// The way we detect first-run is by looking at a 'sentinel' file. +// If it does not exist we understand that we need to do the first time +// install work for this user. After that the sentinel file is created. +namespace first_run { + +// Returns true if this is the first time chrome is run for this user. +bool IsChromeFirstRun(); + +// Creates the sentinel file that signals that chrome has been configured. +bool CreateSentinel(); + +// Removes the sentinel file created in ConfigDone(). Returns false if the +// sentinel file could not be removed. +bool RemoveSentinel(); + +} // namespace first_run + // This class contains the chrome first-run installation actions needed to // fully test the custom installer. It also contains the opposite actions to // execute during uninstall. When the first run UI is ready we won't @@ -91,16 +118,6 @@ class FirstRun { static bool ProcessMasterPreferences(const FilePath& user_data_dir, MasterPrefs* out_prefs); - // Returns true if this is the first time chrome is run for this user. - static bool IsChromeFirstRun(); - - // Creates the sentinel file that signals that chrome has been configured. - static bool CreateSentinel(); - - // Removes the sentinel file created in ConfigDone(). Returns false if the - // sentinel file could not be removed. - static bool RemoveSentinel(); - // Sets the kShouldShowFirstRunBubble local state pref so that the browser // shows the bubble once the main message loop gets going (or refrains from // showing the bubble, if |show_bubble| is false). Returns false if the pref @@ -198,15 +215,6 @@ class FirstRun { static bool ImportBookmarks(const FilePath& import_bookmarks_path); #endif - enum FirstRunState { - FIRST_RUN_UNKNOWN, // The state is not tested or set yet. - FIRST_RUN_TRUE, - FIRST_RUN_FALSE - }; - - // This variable should only be accessed through IsChromeFirstRun(). - static FirstRunState first_run_; - // This class is for scoping purposes. DISALLOW_IMPLICIT_CONSTRUCTORS(FirstRun); }; diff --git a/chrome/browser/first_run/first_run_internal.h b/chrome/browser/first_run/first_run_internal.h new file mode 100644 index 0000000..7cd9497 --- /dev/null +++ b/chrome/browser/first_run/first_run_internal.h @@ -0,0 +1,51 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ +#define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ +#pragma once + +#include <vector> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/gtest_prod_util.h" +#include "base/memory/ref_counted.h" +#include "ui/gfx/native_widget_types.h" + +class CommandLine; +class FilePath; +class GURL; +class ImporterHost; +class ImporterList; +class Profile; +class ProcessSingleton; +class TemplateURLService; + +namespace first_run { +namespace internal { + +enum FirstRunState { + FIRST_RUN_UNKNOWN, // The state is not tested or set yet. + FIRST_RUN_TRUE, + FIRST_RUN_FALSE +}; + +// This variable should only be accessed through IsChromeFirstRun(). +extern FirstRunState first_run_; + +// The kSentinelFile file absence will tell us it is a first run. +extern const char* const kSentinelFile; + +// -- Platform-specific functions -- + +// Gives the full path to the sentinel file. The file might not exist. +// This function has a common implementation on OS_POSIX and a windows specific +// implementation. +bool GetFirstRunSentinelFilePath(FilePath* path); + +} // namespace internal +} // namespace first_run + +#endif // CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ diff --git a/chrome/browser/first_run/first_run_posix.cc b/chrome/browser/first_run/first_run_posix.cc new file mode 100644 index 0000000..330f3fa --- /dev/null +++ b/chrome/browser/first_run/first_run_posix.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2011 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/first_run.h" + +#include "base/path_service.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/first_run/first_run_internal.h" +#include "chrome/browser/importer/importer_host.h" +#include "chrome/browser/importer/importer_list.h" +#include "chrome/browser/importer/importer_progress_dialog.h" +#include "chrome/browser/importer/importer_progress_observer.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/installer/util/master_preferences.h" +#include "chrome/installer/util/master_preferences_constants.h" + +namespace first_run { + +namespace internal { + +bool GetFirstRunSentinelFilePath(FilePath* path) { + FilePath first_run_sentinel; + + if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) + return false; + + *path = first_run_sentinel.AppendASCII(kSentinelFile); + return true; +} + +} // namespace internal + +} // namespace first_run diff --git a/chrome/browser/first_run/first_run_unittest.cc b/chrome/browser/first_run/first_run_unittest.cc index 6a32fe1..601416c 100644 --- a/chrome/browser/first_run/first_run_unittest.cc +++ b/chrome/browser/first_run/first_run_unittest.cc @@ -1,24 +1,25 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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 "base/file_util.h" #include "chrome/browser/first_run/first_run.h" +#include "chrome/browser/first_run/first_run_internal.h" #include "testing/gtest/include/gtest/gtest.h" class FirstRunTest : public testing::Test { protected: virtual void SetUp() { - FirstRun::GetFirstRunSentinelFilePath(&sentinel_path_); + first_run::internal::GetFirstRunSentinelFilePath(&sentinel_path_); } FilePath sentinel_path_; }; TEST_F(FirstRunTest, RemoveSentinel) { - EXPECT_TRUE(FirstRun::CreateSentinel()); + EXPECT_TRUE(first_run::CreateSentinel()); EXPECT_TRUE(file_util::PathExists(sentinel_path_)); - EXPECT_TRUE(FirstRun::RemoveSentinel()); + EXPECT_TRUE(first_run::RemoveSentinel()); EXPECT_FALSE(file_util::PathExists(sentinel_path_)); } diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index 8de0463..4d10848 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -23,11 +23,13 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_updater.h" #include "chrome/browser/first_run/first_run_import_observer.h" +#include "chrome/browser/first_run/first_run_internal.h" #include "chrome/browser/importer/importer_host.h" #include "chrome/browser/importer/importer_list.h" #include "chrome/browser/importer/importer_progress_dialog.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_result_codes.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/worker_thread_ticker.h" @@ -299,6 +301,31 @@ bool DecodeImportParams(const std::string& encoded, } // namespace +namespace first_run { + +namespace internal{ + +bool GetFirstRunSentinelFilePath(FilePath* path) { + FilePath first_run_sentinel; + + 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 { + if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) + return false; + } + + *path = first_run_sentinel.AppendASCII(kSentinelFile); + return true; +} + +} // namespace internal + +} // namespace first_run + // static void FirstRun::PlatformSetup() { CreateChromeDesktopShortcut(); diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index c5e3a84..a338935 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -96,7 +96,7 @@ void DetectFirefoxProfiles(std::vector<importer::SourceProfile*>* profiles) { void DetectGoogleToolbarProfiles( std::vector<importer::SourceProfile*>* profiles, scoped_refptr<net::URLRequestContextGetter> request_context_getter) { - if (FirstRun::IsChromeFirstRun()) + if (first_run::IsChromeFirstRun()) return; importer::SourceProfile* google_toolbar = new importer::SourceProfile; diff --git a/chrome/browser/importer/toolbar_importer.cc b/chrome/browser/importer/toolbar_importer.cc index 971869c..0c7adba 100644 --- a/chrome/browser/importer/toolbar_importer.cc +++ b/chrome/browser/importer/toolbar_importer.cc @@ -526,7 +526,7 @@ bool Toolbar5Importer::ExtractFoldersFromXmlReader( } if (0 == label_vector.size()) { - if (!FirstRun::IsChromeFirstRun()) { + if (!first_run::IsChromeFirstRun()) { bookmark_folders->resize(1); (*bookmark_folders)[0].push_back(bookmark_group_string); } @@ -539,7 +539,7 @@ bool Toolbar5Importer::ExtractFoldersFromXmlReader( for (size_t index = 0; index < label_vector.size(); ++index) { // If this is the first run then we place favorites with no labels // in the title bar. Else they are placed in the "Google Toolbar" folder. - if (!FirstRun::IsChromeFirstRun() || !label_vector[index].empty()) { + if (!first_run::IsChromeFirstRun() || !label_vector[index].empty()) { (*bookmark_folders)[index].push_back(bookmark_group_string); } diff --git a/chrome/browser/importer/toolbar_importer_unittest.cc b/chrome/browser/importer/toolbar_importer_unittest.cc index cd1f98d..29c0a35 100644 --- a/chrome/browser/importer/toolbar_importer_unittest.cc +++ b/chrome/browser/importer/toolbar_importer_unittest.cc @@ -11,6 +11,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/first_run/first_run.h" +#include "chrome/browser/first_run/first_run_internal.h" #include "chrome/browser/importer/toolbar_importer.h" #include "chrome/common/libxml_utils.h" #include "googleurl/src/gurl.h" @@ -322,7 +323,7 @@ static const char* kBadBookmarkNoLabels = // Test doesn't work if the importer thinks this is the first run of Chromium. // Mark this as a subsequent run of the browser. - FirstRun::first_run_ = FirstRun::FIRST_RUN_FALSE; + first_run::internal::first_run_ = first_run::internal::FIRST_RUN_FALSE; // Test case 1 is parsing a basic bookmark with a single label. bookmark_xml = kGoodBookmark; diff --git a/chrome/browser/prefs/session_startup_pref.cc b/chrome/browser/prefs/session_startup_pref.cc index 48b3ab2..a441a4c 100644 --- a/chrome/browser/prefs/session_startup_pref.cc +++ b/chrome/browser/prefs/session_startup_pref.cc @@ -55,7 +55,7 @@ void SessionStartupPref::RegisterUserPrefs(PrefService* prefs) { #ifdef OS_MACOSX // During first run the calling code relies on |DEFAULT| session preference // value to avoid session restore. That is respected here. - if (!FirstRun::IsChromeFirstRun()) { + if (!first_run::IsChromeFirstRun()) { // |DEFAULT| really means "Don't restore". The actual default value could // change, so explicitly set both. if (restore_utils::IsWindowRestoreEnabled()) diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index a2116b5..eaba8b0 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -572,7 +572,7 @@ void Browser::InitBrowserWindow() { } // Permanently dismiss ntp4 bubble for new users. - if (FirstRun::IsChromeFirstRun()) + if (first_run::IsChromeFirstRun()) NewTabPageHandler::DismissIntroMessage(local_state); } diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 97ece1e..bc3c0a4 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -750,7 +750,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, AppIdSwitch) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), command_line, first_run); ASSERT_TRUE(launch.OpenApplicationWindow(browser()->profile())); @@ -1010,7 +1010,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { // Simulate launching again. CommandLine dummy(CommandLine::NO_PROGRAM); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); launch.profile_ = browser()->profile(); diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 12fca50..d88a63a 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -1472,7 +1472,7 @@ bool BrowserInit::LaunchWithProfile::CheckIfAutoLaunched(Profile* profile) { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) || - FirstRun::IsChromeFirstRun()) { + first_run::IsChromeFirstRun()) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&CheckAutoLaunchCallback)); return true; @@ -1668,7 +1668,7 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line, if (!silent_launch) { IsProcessStartup is_process_startup = process_startup ? IS_PROCESS_STARTUP : IS_NOT_PROCESS_STARTUP; - IsFirstRun is_first_run = FirstRun::IsChromeFirstRun() ? + IsFirstRun is_first_run = first_run::IsChromeFirstRun() ? IS_FIRST_RUN : IS_NOT_FIRST_RUN; return browser_init->LaunchBrowser(command_line, profile, cur_dir, is_process_startup, is_first_run, return_code); diff --git a/chrome/browser/ui/browser_init_browsertest.cc b/chrome/browser/ui/browser_init_browsertest.cc index f800915..05c938b 100644 --- a/chrome/browser/ui/browser_init_browsertest.cc +++ b/chrome/browser/ui/browser_init_browsertest.cc @@ -104,7 +104,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) { ASSERT_EQ(popup, observer.added_browser_); CommandLine dummy(CommandLine::NO_PROGRAM); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); // This should create a new window, but re-use the profile from |popup|. If @@ -138,7 +138,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, // Do a simple non-process-startup browser launch. CommandLine dummy(CommandLine::NO_PROGRAM); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); @@ -176,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, // Do a simple non-process-startup browser launch. CommandLine dummy(CommandLine::NO_PROGRAM); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), dummy, first_run); ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); @@ -200,7 +200,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutNoPref) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), command_line, first_run); ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); @@ -228,7 +228,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutWindowPref) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), command_line, first_run); ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); @@ -258,7 +258,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutTabPref) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), command_line, first_run); ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); @@ -287,7 +287,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutPanel) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); - BrowserInit::IsFirstRun first_run = FirstRun::IsChromeFirstRun() ? + BrowserInit::IsFirstRun first_run = first_run::IsChromeFirstRun() ? BrowserInit::IS_FIRST_RUN : BrowserInit::IS_NOT_FIRST_RUN; BrowserInit::LaunchWithProfile launch(FilePath(), command_line, first_run); ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm index d6cf090..f04c7fa 100644 --- a/chrome/browser/ui/cocoa/first_run_dialog.mm +++ b/chrome/browser/ui/cocoa/first_run_dialog.mm @@ -123,7 +123,7 @@ void ShowFirstRun(Profile* profile) { // We don't show the dialog in Chromium. #endif // GOOGLE_CHROME_BUILD - FirstRun::CreateSentinel(); + first_run::CreateSentinel(); // Set preference to show first run bubble and welcome page. // Don't display the minimal bubble if there is no default search provider. diff --git a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm index 5a337a38..43d2320 100644 --- a/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm +++ b/chrome/browser/ui/cocoa/keystone_infobar_delegate.mm @@ -144,7 +144,7 @@ bool KeystonePromotionInfoBarDelegate::Cancel() { // nagged about the update check. (Automated testers, I'm thinking of // you...) CommandLine* commandLine = CommandLine::ForCurrentProcess(); - if (FirstRun::IsChromeFirstRun() || + if (first_run::IsChromeFirstRun() || !profile->GetPrefs()->GetBoolean(prefs::kShowUpdatePromotionInfoBar) || commandLine->HasSwitch(switches::kNoDefaultBrowserCheck)) { return; diff --git a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc index 5ed2e1e..2f1a56b 100644 --- a/chrome/browser/ui/gtk/first_run_dialog.cc +++ b/chrome/browser/ui/gtk/first_run_dialog.cc @@ -404,7 +404,7 @@ void FirstRunDialog::OnResponseDialog(GtkWidget* widget, int response) { *response_ = response; // Mark that first run has ran. - FirstRun::CreateSentinel(); + first_run::CreateSentinel(); // Check if user has opted into reporting. if (report_crashes_ && diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index b84ca34..93daa15 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1317,8 +1317,10 @@ 'browser/first_run/first_run_dialog.h', 'browser/first_run/first_run_import_observer.cc', 'browser/first_run/first_run_import_observer.h', + 'browser/first_run/first_run_internal.h', 'browser/first_run/first_run_linux.cc', 'browser/first_run/first_run_mac.mm', + 'browser/first_run/first_run_posix.cc', 'browser/first_run/first_run_win.cc', 'browser/first_run/try_chrome_dialog_view.cc', 'browser/first_run/try_chrome_dialog_view.h', |