summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 21:17:25 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 21:17:25 +0000
commit1b3588ddeb836c3f35127988c795cbce1c1d51a3 (patch)
tree11f218703d2463149b6591f873edfd99a1fbf6d3
parentceed2b8251ca42b050cc3ffb558abfe64a985b44 (diff)
downloadchromium_src-1b3588ddeb836c3f35127988c795cbce1c1d51a3.zip
chromium_src-1b3588ddeb836c3f35127988c795cbce1c1d51a3.tar.gz
chromium_src-1b3588ddeb836c3f35127988c795cbce1c1d51a3.tar.bz2
User profile preferences to find ping delay when not first run of chrome.
BUG=154879 TEST=Install chrome with a nagtive ping delay in master prefs (-60). Start chrome and wait for first RLZ ping, don't do an omnibox search. Then stop chrome and restart it. Do an omnibox search right away, and make sure an RLZ ping is sent within seconds. Review URL: https://chromiumcodereview.appspot.com/11098027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161193 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_browser_main.cc9
-rw-r--r--chrome/browser/first_run/first_run.cc13
-rw-r--r--chrome/browser/first_run/first_run.h8
-rw-r--r--chrome/browser/prefs/browser_prefs.cc2
-rw-r--r--chrome/installer/util/master_preferences.cc15
-rw-r--r--chrome/installer/util/master_preferences_constants.cc1
-rw-r--r--chrome/installer/util/master_preferences_constants.h2
7 files changed, 39 insertions, 11 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 0cd9c2e..309041e 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1230,9 +1230,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
}
PrefService* pref_service = profile_->GetPrefs();
- bool is_google_homepage = pref_service &&
- google_util::IsGoogleHomePageUrl(
- pref_service->GetString(prefs::kHomePage));
+ bool is_google_homepage = google_util::IsGoogleHomePageUrl(
+ pref_service->GetString(prefs::kHomePage));
bool is_google_in_startpages = false;
SessionStartupPref session_startup_prefs =
@@ -1244,7 +1243,9 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
IsGoogleUrl) > 0;
}
- RLZTracker::InitRlzDelayed(is_first_run_, master_prefs_->ping_delay,
+ int ping_delay = is_first_run_ ? master_prefs_->ping_delay :
+ pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str());
+ RLZTracker::InitRlzDelayed(is_first_run_, ping_delay,
is_google_default_search, is_google_homepage,
is_google_in_startpages);
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index a1873c4..88a462d 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -9,6 +9,7 @@
#include "base/file_util.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
+#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
@@ -441,6 +442,18 @@ bool CreateSentinel() {
return file_util::WriteFile(first_run_sentinel, "", 0) != -1;
}
+std::string GetPingDelayPrefName() {
+ return base::StringPrintf("%s.%s",
+ installer::master_preferences::kDistroDict,
+ installer::master_preferences::kDistroPingDelay);
+}
+
+void RegisterUserPrefs(PrefService* prefs) {
+ prefs->RegisterIntegerPref(GetPingDelayPrefName().c_str(),
+ 0,
+ PrefService::UNSYNCABLE_PREF);
+}
+
bool RemoveSentinel() {
FilePath first_run_sentinel;
if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel))
diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h
index 1e57550..4121730 100644
--- a/chrome/browser/first_run/first_run.h
+++ b/chrome/browser/first_run/first_run.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_
#define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_
+#include <string>
#include <vector>
#include "base/basictypes.h"
@@ -18,6 +19,7 @@
class CommandLine;
class FilePath;
class GURL;
+class PrefService;
class Profile;
class ProcessSingleton;
@@ -65,6 +67,12 @@ bool IsChromeFirstRun();
// Creates the sentinel file that signals that chrome has been configured.
bool CreateSentinel();
+// Get RLZ ping delay pref name.
+std::string GetPingDelayPrefName();
+
+// Register user preferences used by the MasterPrefs structure.
+void RegisterUserPrefs(PrefService* prefs);
+
// Removes the sentinel file created in ConfigDone(). Returns false if the
// sentinel file could not be removed.
bool RemoveSentinel();
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 47f54a8..06cdbf8 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
+#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/geolocation/geolocation_prefs.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/browser/google/google_url_tracker_factory.h"
@@ -220,6 +221,7 @@ void RegisterUserPrefs(PrefService* user_prefs) {
extensions::ComponentLoader::RegisterUserPrefs(user_prefs);
extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs);
ExtensionWebUI::RegisterUserPrefs(user_prefs);
+ first_run::RegisterUserPrefs(user_prefs);
GAIAInfoUpdateService::RegisterUserPrefs(user_prefs);
HostContentSettingsMap::RegisterUserPrefs(user_prefs);
IncognitoModePrefs::RegisterUserPrefs(user_prefs);
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 21c05b1..d397b8c 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -17,7 +17,6 @@
namespace {
-const char kDistroDict[] = "distribution";
const char kFirstRunTabs[] = "first_run_tabs";
base::LazyInstance<installer::MasterPreferences> g_master_preferences =
@@ -109,7 +108,8 @@ MasterPreferences::MasterPreferences(const FilePath& prefs_path)
} else {
preferences_read_from_file_ = true;
// Cache a pointer to the distribution dictionary.
- master_dictionary_->GetDictionary(kDistroDict, &distribution_);
+ master_dictionary_->GetDictionary(
+ installer::master_preferences::kDistroDict, &distribution_);
}
InitializeProductFlags();
@@ -169,10 +169,10 @@ void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) {
installer::master_preferences::kAltShortcutText },
};
- std::string name(kDistroDict);
+ std::string name(installer::master_preferences::kDistroDict);
for (int i = 0; i < arraysize(translate_switches); ++i) {
if (cmd_line.HasSwitch(translate_switches[i].cmd_line_switch)) {
- name.resize(arraysize(kDistroDict) - 1);
+ name.assign(installer::master_preferences::kDistroDict);
name.append(".").append(translate_switches[i].distribution_switch);
master_dictionary_->SetBoolean(name, true);
}
@@ -182,7 +182,7 @@ void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) {
std::wstring str_value(cmd_line.GetSwitchValueNative(
installer::switches::kLogFile));
if (!str_value.empty()) {
- name.resize(arraysize(kDistroDict) - 1);
+ name.assign(installer::master_preferences::kDistroDict);
name.append(".").append(installer::master_preferences::kLogFile);
master_dictionary_->SetString(name, str_value);
}
@@ -195,14 +195,15 @@ void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) {
env->GetVar(kGoogleUpdateIsMachineEnvVar, &is_machine_var);
if (!is_machine_var.empty() && is_machine_var[0] == '1') {
VLOG(1) << "Taking system-level from environment.";
- name.resize(arraysize(kDistroDict) - 1);
+ name.assign(installer::master_preferences::kDistroDict);
name.append(".").append(installer::master_preferences::kSystemLevel);
master_dictionary_->SetBoolean(name, true);
}
}
// Cache a pointer to the distribution dictionary. Ignore errors if any.
- master_dictionary_->GetDictionary(kDistroDict, &distribution_);
+ master_dictionary_->GetDictionary(installer::master_preferences::kDistroDict,
+ &distribution_);
InitializeProductFlags();
#endif
diff --git a/chrome/installer/util/master_preferences_constants.cc b/chrome/installer/util/master_preferences_constants.cc
index a59c4f2..9ab31a9 100644
--- a/chrome/installer/util/master_preferences_constants.cc
+++ b/chrome/installer/util/master_preferences_constants.cc
@@ -15,6 +15,7 @@ namespace master_preferences {
const char kChromeShortcutIconIndex[] = "chrome_shortcut_icon_index";
const char kCreateAllShortcuts[] = "create_all_shortcuts";
const char kDisableLogging[] = "disable_logging";
+ const char kDistroDict[] = "distribution";
const char kDistroImportBookmarksPref[] = "import_bookmarks";
const char kDistroImportBookmarksFromFilePref[] =
"import_bookmarks_from_file";
diff --git a/chrome/installer/util/master_preferences_constants.h b/chrome/installer/util/master_preferences_constants.h
index 0de206e..c8a16af 100644
--- a/chrome/installer/util/master_preferences_constants.h
+++ b/chrome/installer/util/master_preferences_constants.h
@@ -34,6 +34,8 @@ extern const char kChromeShortcutIconIndex[];
extern const char kCreateAllShortcuts[];
// Boolean pref that disables all logging.
extern const char kDisableLogging[];
+// Name of the dictionary that holds the distribution values.
+extern const char kDistroDict[];
// Boolean pref that triggers silent import of the default browser bookmarks.
extern const char kDistroImportBookmarksPref[];
// String pref that triggers silent import of bookmarks from the html file at