summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_main.cc
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 20:21:40 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 20:21:40 +0000
commita5391559831871c15cb5239c06c39753efed209a (patch)
treeab81f5f083ab73587d3b93430e63529e21c6c21d /chrome/browser/browser_main.cc
parente3be97ce298466ce151ae856b3bf4164ec5a87c5 (diff)
downloadchromium_src-a5391559831871c15cb5239c06c39753efed209a.zip
chromium_src-a5391559831871c15cb5239c06c39753efed209a.tar.gz
chromium_src-a5391559831871c15cb5239c06c39753efed209a.tar.bz2
First part of the pre-set bookmarks feature
- master prefs format (just url) - defer actual bookmark fu, because early on the bookmarkmodel and other services are not yet running. - cleanup master prefs test, too much code duplication - cleanup ProcessMasterPreferences it had too many params BUG=32728 TEST=unit test included Review URL: http://codereview.chromium.org/660116 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40150 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_main.cc')
-rw-r--r--chrome/browser/browser_main.cc46
1 files changed, 31 insertions, 15 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index a74c1d2..5814816 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -310,11 +310,25 @@ void AddFirstRunNewTabs(BrowserInit* browser_init,
browser_init->AddFirstRunTab(url);
}
}
+
+void AddDefaultBookmarks(BrowserInit* browser_init,
+ const std::vector<std::wstring>& bookmarks) {
+ for (std::vector<std::wstring>::const_iterator it = bookmarks.begin();
+ it != bookmarks.end(); ++it) {
+ GURL url(*it);
+ if (url.is_valid())
+ browser_init->AddDefaultBookmark(url);
+ }
+}
#else
// TODO(cpu): implement first run experience for other platforms.
void AddFirstRunNewTabs(BrowserInit* browser_init,
const std::vector<std::wstring>& new_tabs) {
}
+
+void AddDefaultBookmarks(BrowserInit* browser_init,
+ const std::vector<std::wstring>& bookmarks) {
+}
#endif
#if defined(USE_LINUX_BREAKPAD)
@@ -606,25 +620,22 @@ int BrowserMain(const MainFunctionParams& parameters) {
BrowserInit browser_init;
-#if defined(OS_WIN)
- int rlz_ping_delay = 0;
-#endif
- bool homepage_defined = false;
- int import_items = 0;
- int dont_import_items = 0;
+ FirstRun::MasterPrefs master_prefs = {0};
bool first_run_ui_bypass = false;
if (is_first_run) {
#if defined(OS_WIN)
// On first run, we need to process the master preferences before the
// browser's profile_manager object is created, but after ResourceBundle
// is initialized.
- std::vector<std::wstring> first_run_tabs;
- first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir,
- FilePath(), &first_run_tabs, &rlz_ping_delay, &homepage_defined,
- &import_items, &dont_import_items);
+ first_run_ui_bypass =
+ !FirstRun::ProcessMasterPreferences(user_data_dir,
+ FilePath(), &master_prefs);
// The master prefs might specify a set of urls to display.
- if (first_run_tabs.size())
- AddFirstRunNewTabs(&browser_init, first_run_tabs);
+ if (master_prefs.new_tabs.size())
+ AddFirstRunNewTabs(&browser_init, master_prefs.new_tabs);
+ // The master prefs might specify a set of initial bookmarks.
+ if (master_prefs.bookmarks.size())
+ AddDefaultBookmarks(&browser_init, master_prefs.bookmarks);
#endif // OS_WIN
// If we are running in App mode, we do not want to show the importer
@@ -837,8 +848,11 @@ int BrowserMain(const MainFunctionParams& parameters) {
// touches reads preferences.
if (is_first_run) {
if (!first_run_ui_bypass) {
- if (!OpenFirstRunDialog(profile, homepage_defined, import_items,
- dont_import_items, &process_singleton)) {
+ if (!OpenFirstRunDialog(profile,
+ master_prefs.homepage_defined,
+ master_prefs.do_import_items,
+ master_prefs.dont_import_items,
+ &process_singleton)) {
// The user cancelled the first run dialog box, we should exit Chrome.
return ResultCodes::NORMAL_EXIT;
}
@@ -852,6 +866,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
local_state->SetBoolean(prefs::kMetricsReportingEnabled, true);
#endif // OS_POSIX
}
+
Browser::SetNewHomePagePrefs(user_prefs);
}
@@ -876,7 +891,8 @@ int BrowserMain(const MainFunctionParams& parameters) {
// Init the RLZ library. This just binds the dll and schedules a task on the
// file thread to be run sometime later. If this is the first run we record
// the installation event.
- RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run, rlz_ping_delay);
+ RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run,
+ master_prefs.ping_delay);
#endif
// Configure the network module so it has access to resources.