summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 01:01:43 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 01:01:43 +0000
commitaff9daa13968bf581d0f2f0d266ec61cf9879187 (patch)
tree9832d2f6c46766875f23c86d396f48057b697157
parent27f71dc29377290e7eb1f198de86a59d2be575a2 (diff)
downloadchromium_src-aff9daa13968bf581d0f2f0d266ec61cf9879187.zip
chromium_src-aff9daa13968bf581d0f2f0d266ec61cf9879187.tar.gz
chromium_src-aff9daa13968bf581d0f2f0d266ec61cf9879187.tar.bz2
Merge 60884 - Adjust json data and URL to information from server side on custom logo signal delivery.
BUG=56388 TEST=unit test for web_resource_service still works. Review URL: http://codereview.chromium.org/3523002 TBR=mirandac@chromium.org Review URL: http://codereview.chromium.org/3516005 git-svn-id: svn://svn.chromium.org/chrome/branches/517/src@60889 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/tips_handler.cc7
-rw-r--r--chrome/browser/web_resource/web_resource_service.cc60
-rw-r--r--chrome/common/pref_names.cc7
-rw-r--r--chrome/common/pref_names.h3
4 files changed, 40 insertions, 37 deletions
diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc
index 4858b61..9bf5bdf 100644
--- a/chrome/browser/dom_ui/tips_handler.cc
+++ b/chrome/browser/dom_ui/tips_handler.cc
@@ -45,8 +45,9 @@ void TipsHandler::HandleGetTips(const ListValue* args) {
// We need to check here because the new tab page calls for tips before
// the tip service starts up.
PrefService* current_prefs = dom_ui_->GetProfile()->GetPrefs();
- if (current_prefs->HasPrefPath(prefs::kNTPWebResourceServer)) {
- std::string server = current_prefs->GetString(prefs::kNTPWebResourceServer);
+ if (current_prefs->HasPrefPath(prefs::kNTPTipsResourceServer)) {
+ std::string server = current_prefs->GetString(
+ prefs::kNTPTipsResourceServer);
std::string locale = g_browser_process->GetApplicationLocale();
if (!EndsWith(server, locale, false)) {
dom_ui_->CallJavascriptFunction(L"tips", list_value);
@@ -98,7 +99,7 @@ void TipsHandler::SendTip(const std::string& tip, const std::string& tip_type,
// static
void TipsHandler::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterDictionaryPref(prefs::kNTPWebResourceCache);
- prefs->RegisterStringPref(prefs::kNTPWebResourceServer,
+ prefs->RegisterStringPref(prefs::kNTPLogoResourceServer,
WebResourceService::kDefaultResourceServer);
}
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc
index add7345..4bc6bb6 100644
--- a/chrome/browser/web_resource/web_resource_service.cc
+++ b/chrome/browser/web_resource/web_resource_service.cc
@@ -184,14 +184,9 @@ class WebResourceService::UnpackerClient
bool got_response_;
};
+// Server for custom logo signals.
const char* WebResourceService::kDefaultResourceServer =
-#if defined(OS_MACOSX)
- "https://clients2.google.com/tools/service/npredir?r=chrometips_mac&hl=";
-#elif defined(OS_LINUX)
- "https://clients2.google.com/tools/service/npredir?r=chrometips_linux&hl=";
-#else
- "https://clients2.google.com/tools/service/npredir?r=chrometips_win&hl=";
-#endif
+ "https://www.google.com/support/chrome/bin/topic/30248/inproduct";
WebResourceService::WebResourceService(Profile* profile)
: prefs_(profile->GetPrefs()),
@@ -207,19 +202,14 @@ void WebResourceService::Init() {
prefs_->RegisterStringPref(prefs::kNTPWebResourceCacheUpdate, "0");
prefs_->RegisterRealPref(prefs::kNTPCustomLogoStart, 0);
prefs_->RegisterRealPref(prefs::kNTPCustomLogoEnd, 0);
- std::string locale = g_browser_process->GetApplicationLocale();
- if (prefs_->HasPrefPath(prefs::kNTPWebResourceServer)) {
- web_resource_server_ = prefs_->GetString(prefs::kNTPWebResourceServer);
- // If we are in the correct locale, initialization is done.
- if (EndsWith(web_resource_server_, locale, false))
- return;
+ if (prefs_->HasPrefPath(prefs::kNTPLogoResourceServer)) {
+ web_resource_server_ = prefs_->GetString(prefs::kNTPLogoResourceServer);
+ return;
}
- // If we have not yet set a server, or if the web resource server is set to
- // the wrong locale, reset the server and force an immediate update.
+ // If we have not yet set a server, reset and force an immediate update.
web_resource_server_ = kDefaultResourceServer;
- web_resource_server_.append(locale);
prefs_->SetString(prefs::kNTPWebResourceCacheUpdate, "");
}
@@ -264,7 +254,7 @@ void WebResourceService::UpdateResourceCache(const std::string& json_data) {
// Update resource server and cache update time in preferences.
prefs_->SetString(prefs::kNTPWebResourceCacheUpdate,
base::DoubleToString(base::Time::Now().ToDoubleT()));
- prefs_->SetString(prefs::kNTPWebResourceServer, web_resource_server_);
+ prefs_->SetString(prefs::kNTPLogoResourceServer, web_resource_server_);
}
void WebResourceService::UnpackTips(const DictionaryValue& parsed_json) {
@@ -325,29 +315,37 @@ void WebResourceService::UnpackLogoSignal(const DictionaryValue& parsed_json) {
// Check for newly received start and end values.
if (parsed_json.GetDictionary("topic", &topic_dict)) {
if (topic_dict->GetList("answers", &answer_list)) {
+ std::string logo_start_string = "";
+ std::string logo_end_string = "";
for (ListValue::const_iterator tip_iter = answer_list->begin();
tip_iter != answer_list->end(); ++tip_iter) {
if (!(*tip_iter)->IsType(Value::TYPE_DICTIONARY))
continue;
DictionaryValue* a_dic =
static_cast<DictionaryValue*>(*tip_iter);
- std::string logo_start_string;
- std::string logo_end_string;
- if (a_dic->GetString("custom_logo_start", &logo_start_string) &&
- a_dic->GetString("custom_logo_end", &logo_end_string)) {
- // If both times can be correctly parsed, then set new logo
- // start and end times.
- base::Time start_time;
- base::Time end_time;
- if (base::Time::FromString(
- ASCIIToWide(logo_start_string).c_str(), &start_time) &&
- base::Time::FromString(
- ASCIIToWide(logo_end_string).c_str(), &end_time)) {
- logo_start = start_time.ToDoubleT();
- logo_end = end_time.ToDoubleT();
+ std::string logo_signal;
+ if (a_dic->GetString("name", &logo_signal)) {
+ if (logo_signal == "custom_logo_start") {
+ a_dic->GetString("inproduct", &logo_start_string);
+ } else if (logo_signal == "custom_logo_end") {
+ a_dic->GetString("inproduct", &logo_end_string);
}
}
}
+ if (!logo_start_string.empty() &&
+ logo_start_string.length() > 0 &&
+ !logo_end_string.empty() &&
+ logo_end_string.length() > 0) {
+ base::Time start_time;
+ base::Time end_time;
+ if (base::Time::FromString(
+ ASCIIToWide(logo_start_string).c_str(), &start_time) &&
+ base::Time::FromString(
+ ASCIIToWide(logo_end_string).c_str(), &end_time)) {
+ logo_start = start_time.ToDoubleT();
+ logo_end = end_time.ToDoubleT();
+ }
+ }
}
}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index fe59528..83b9b53 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -864,8 +864,11 @@ const char kNTPWebResourceCache[] = "ntp.web_resource_cache";
// Last time of update of web_resource_cache.
const char kNTPWebResourceCacheUpdate[] = "ntp.web_resource_cache_update";
-// Last server used to fill web_resource_cache.
-const char kNTPWebResourceServer[] = "ntp.web_resource_server";
+// Last server used to fill tips.
+const char kNTPTipsResourceServer[] = "ntp.tips_resource_server";
+
+// Last server used to fill logo_resource_cache.
+const char kNTPLogoResourceServer[] = "ntp.logo_resource_server";
// Which sections should be visible on the new tab page
// 1 - Show the most visited sites in a grid
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 289ee20..8d44661 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -319,7 +319,8 @@ extern const char kNTPMostVisitedURLsBlacklist[];
extern const char kNTPMostVisitedPinnedURLs[];
extern const char kNTPWebResourceCache[];
extern const char kNTPWebResourceCacheUpdate[];
-extern const char kNTPWebResourceServer[];
+extern const char kNTPTipsResourceServer[];
+extern const char kNTPLogoResourceServer[];
extern const char kNTPShownSections[];
extern const char kNTPPrefVersion[];
extern const char kNTPCustomLogoStart[];