summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:19:29 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:19:29 +0000
commitcd1c78349190f4084424fe9790f2548b0d52167a (patch)
treed2786ce9f424ddf04ebca6be6d3183bb3463c875 /chrome/installer/util
parent0ef42ff9d9de850a881cfa66f96d4217695a2186 (diff)
downloadchromium_src-cd1c78349190f4084424fe9790f2548b0d52167a.zip
chromium_src-cd1c78349190f4084424fe9790f2548b0d52167a.tar.gz
chromium_src-cd1c78349190f4084424fe9790f2548b0d52167a.tar.bz2
Add a ping delay time master preference.
BUG=1953127 Review URL: http://codereview.chromium.org/149135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19978 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/master_preferences.cc32
-rw-r--r--chrome/installer/util/master_preferences.h19
2 files changed, 43 insertions, 8 deletions
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index c59bc1d..4ff8b2f 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -1,12 +1,13 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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/installer/util/master_preferences.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/path_service.h"
#include "chrome/common/json_value_serializer.h"
-#include "chrome/installer/util/master_preferences.h"
namespace {
@@ -50,6 +51,8 @@ const wchar_t kDistroImportSearchPref[] = L"import_search_engine";
const wchar_t kDistroImportHistoryPref[] = L"import_history";
// Boolean pref that triggers silent import of the default browser bookmarks.
const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks";
+// RLZ ping delay in seconds
+const wchar_t kDistroPingDelay[] = L"ping_delay";
// Register Chrome as default browser for the current user.
const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user";
// The following boolean prefs have the same semantics as the corresponding
@@ -74,6 +77,31 @@ const wchar_t kAltFirstRunBubble[] = L"oem_bubble";
// Boolean pref that triggers silent import of the default browser homepage.
const wchar_t kDistroImportHomePagePref[] = L"import_home_page";
+bool GetDistributionPingDelay(const FilePath& master_prefs_path,
+ int& delay) {
+ FilePath master_prefs = master_prefs_path;
+ if (master_prefs.empty()) {
+ if (!PathService::Get(base::DIR_EXE, &master_prefs))
+ return false;
+ master_prefs = master_prefs.Append(installer_util::kDefaultMasterPrefs);
+ }
+
+ if (!file_util::PathExists(master_prefs))
+ return false;
+
+ scoped_ptr<DictionaryValue> json_root(
+ GetPrefsFromFile(master_prefs.ToWStringHack()));
+ if (!json_root.get())
+ return false;
+
+ DictionaryValue* distro = NULL;
+ if (!json_root->GetDictionary(L"distribution", &distro) ||
+ !distro->GetInteger(kDistroPingDelay, &delay))
+ return false;
+
+ return true;
+}
+
int ParseDistributionPreferences(const std::wstring& master_prefs_path) {
if (!file_util::PathExists(master_prefs_path))
return MASTER_PROFILE_NOT_FOUND;
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index c83464e..856d53e 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -1,16 +1,18 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
//
// This file contains functions processing master preference file used by
// setup and first run.
-#ifndef CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H__
-#define CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H__
+#ifndef CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
+#define CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
#include <string>
#include <vector>
+#include "base/file_util.h"
+
namespace installer_util {
// This is the default name for the master preferences file used to pre-set
@@ -60,6 +62,11 @@ enum MasterPrefResult {
MASTER_PROFILE_IMPORT_HOME_PAGE = 0x1 << 16
};
+// This function gets ping delay (ping_delay in the sample above) from master
+// preferences.
+bool GetDistributionPingDelay(const FilePath& master_prefs_path,
+ int& delay);
+
// The master preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function parses the distribution
// section of the preferences file.
@@ -81,7 +88,8 @@ enum MasterPrefResult {
// "system_level": false,
// "verbose_logging": true,
// "require_eula": true,
-// "alternate_shortcut_text": false
+// "alternate_shortcut_text": false,
+// "ping_delay": 40
// },
// "browser": {
// "show_home_button": true
@@ -119,7 +127,6 @@ int ParseDistributionPreferences(const std::wstring& master_prefs_path);
// preferences file does not contain such list the vector is empty.
std::vector<std::wstring> ParseFirstRunTabs(
const std::wstring& master_prefs_path);
-
}
-#endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H__
+#endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_