On Sun, Dec 20, 2009 at 03:03:23AM -0800, Evan Martin wrote:
> On Sat, Dec 19, 2009 at 9:32 PM, cpu <c...@chromium.org> wrote:
> > Yes, the MasterPreferences is what we use so far. It is just a json
> > file in a particular path. I am not sure if we have enabled this for
> > the linux build.
>
> It hasn't.
>
> See browser_main.cc around line 540, the part that mentions
> ProcessMasterPreferences:
> http://src.chromium.org/cgi-bin/gitweb.cgi?p=chromium.git;a=blob;f=chrome/browser/browser_main.cc;h=ff1d17d7277b5df9a9e1d901adaf326ee6c2c6ff;hb=HEAD#l539
>
> You could probably follow the Windows implementation of
> ProcessMasterPreferences (see first_run_win) to make a Linux one, but
> it will of course be rather different.
Okay, I started looking into this. After a bit of work, I'm to the
point where I need to process the master_preferences json file.
That is, I am currently writing a ProcessMasterPreferences function
in first_run_gtk.cc. It looks like for Windows much of the work for
processing the file is done using install_util, which doesn't appear
to even be included in the build for Linux. So, I have a couple of
questions...
What would be the preferred approach to processing the
master_preferences file in Linux? At a glance, it looks like
chrome/installer/util/master_preferences.cc might have everything
needed if it was built it for Linux, but should the parsing be done
somewhere more general and/or more portable? Documentation says
that chrome/installer has "source files and projects for making the
installer (MSI package)."
My other question is about the location of the master_preferences
file. In Windows, the file is required to be located in the same
directory as the chrome EXE (DIR_EXE). For Linux, I'm not sure that
this would fit. Any thoughts?
I will attach what I've come up with so far, in case someone is
interested. There are probably things I've done already that are
completely wrong :)
Thanks much,
Brian
--
Chromium Developers mailing list: chromium-dev@googlegroups.com
View archives, change email options, or unsubscribe:
http://groups.google.com/group/chromium-dev
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 521513f..884968b 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -59,6 +59,7 @@
#include "chrome/common/result_codes.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/master_preferences.h"
+#include "googleurl/src/gurl.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "net/base/cookie_monster.h"
@@ -258,7 +259,14 @@ void AddFirstRunNewTabs(BrowserInit* browser_init,
#else
// TODO(cpu): implement first run experience for other platforms.
void AddFirstRunNewTabs(BrowserInit* browser_init,
- const std::vector<std::wstring>& new_tabs) {
+ const std::vector<GURL>& new_tabs) {
+ std::vector<GURL>::const_iterator it = new_tabs.begin();
+ while (it != new_tabs.end()) {
+ std::cout << *it << std::endl;
+ if (it->is_valid())
+ browser_init->AddFirstRunTab(*it);
+ ++it;
+ }
}
#endif
@@ -550,6 +558,26 @@ int BrowserMain(const MainFunctionParams& parameters) {
AddFirstRunNewTabs(&browser_init, first_run_tabs);
#endif // OS_WIN
+#if defined(OS_LINUX)
+ // Process master preferences differently for Linux
+ std::vector<GURL> first_run_tabs;
+
+ /*
+ // specify some first_run_tabs urls manually just to test that this works
+ // in Linux
+ GURL a("http://www.landrover.com");
+ GURL b("http://www.pizzahut.com");
+ first_run_tabs.push_back(a);
+ first_run_tabs.push_back(b);
+ */
+ first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir,
+ FilePath(), &first_run_tabs, &homepage_defined, &import_items,
+ &dont_import_items);
+
+ if (first_run_tabs.size())
+ AddFirstRunNewTabs(&browser_init, first_run_tabs);
+#endif
+
// If we are running in App mode, we do not want to show the importer
// (first run) UI.
if (!first_run_ui_bypass &&
diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h
index 3b2d996..3667ae3 100644
--- a/chrome/browser/first_run.h
+++ b/chrome/browser/first_run.h
@@ -11,6 +11,7 @@
#include "app/gfx/native_widget_types.h"
#include "base/basictypes.h"
#include "chrome/browser/browser_process_impl.h"
+#include "googleurl/src/gurl.h"
class CommandLine;
class FilePath;
@@ -63,6 +64,14 @@ class FirstRun {
int* do_import_items,
int* dont_import_items);
#endif // OS_WIN
+#if defined(OS_LINUX)
+ static bool ProcessMasterPreferences(const FilePath& user_data_dir,
+ const FilePath& master_prefs_path,
+ std::vector<GURL>* new_tabs,
+ bool* homepage_defined,
+ int* do_import_items,
+ int* dont_import_items);
+#endif
// Returns true if this is the first time chrome is run for this user.
static bool IsChromeFirstRun();
diff --git a/chrome/browser/first_run_gtk.cc b/chrome/browser/first_run_gtk.cc
index 3d4a091..1676223 100644
--- a/chrome/browser/first_run_gtk.cc
+++ b/chrome/browser/first_run_gtk.cc
@@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/file_path.h"
+#include "base/path_service.h"
#include "chrome/browser/first_run.h"
+#include "chrome/common/result_codes.h"
+#include "chrome/installer/util/master_preferences.h"
+
+#include "googleurl/src/gurl.h"
#include "chrome/browser/gtk/first_run_dialog.h"
@@ -12,3 +18,37 @@ bool OpenFirstRunDialog(Profile* profile, bool homepage_defined,
ProcessSingleton* process_singleton) {
return FirstRunDialog::Show(profile, process_singleton);
}
+
+bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
+ const FilePath& master_prefs_path,
+ std::vector<GURL>* new_tabs,
+ bool* homepage_defined,
+ int* do_import_items,
+ int* dont_import_items) {
+ std::cout << "Processing master preferences file for Linux..." << std::endl;
+ DCHECK(!user_data_dir.empty());
+ FilePath master_prefs = master_prefs_path;
+ if (master_prefs.empty()) {
+ // The default location of the master prefs is next to the chrome binary.
+ if (!PathService::Get(base::DIR_EXE, &master_prefs))
+ return true;
+ // TODO: is there a better way to append here (without using the
+ // FromWStringHack?
+ FilePath default_master_pref =
+ FilePath::FromWStringHack(installer_util::kDefaultMasterPrefs);
+ master_prefs = master_prefs.Append(default_master_pref);
+ }
+
+ // Trouble!
+ /*
+ scoped_ptr<DictionaryValue> prefs(
+ installer_util::ParseDistributionPreferences(master_prefs));
+ if (!prefs.get())
+ return true;
+
+ if (new_tabs)
+ *new_tabs = installer_util::GetFirstRunTabs(prefs.get());
+
+ */
+ return true;
+}