Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2317)

Unified Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 7481023: Adding notifications for new sync types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now acknowledges sync types when notification is clocked. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 38545c46c802581cb1742f78c9e67f3efe4adef7..6406996c6aeaae42aba247506165cf69f4b0de37 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
@@ -174,8 +175,10 @@ NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) {
// Watch for pref changes that cause us to need to invalidate the HTML cache.
pref_change_registrar_.Init(profile_->GetPrefs());
+ pref_change_registrar_.Add(prefs::kAcknowledgedSyncTypes, this);
pref_change_registrar_.Add(prefs::kShowBookmarkBar, this);
pref_change_registrar_.Add(prefs::kEnableBookmarkBar, this);
+ pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this);
pref_change_registrar_.Add(prefs::kNTPShownSections, this);
pref_change_registrar_.Add(prefs::kNTPShownPage, this);
}
@@ -218,17 +221,10 @@ void NTPResourceCache::Observe(int type,
new_tab_incognito_css_ = NULL;
new_tab_css_ = NULL;
} else if (chrome::NOTIFICATION_PREF_CHANGED == type) {
- std::string* pref_name = Details<std::string>(details).ptr();
- if (*pref_name == prefs::kShowBookmarkBar ||
- *pref_name == prefs::kEnableBookmarkBar ||
- *pref_name == prefs::kHomePageIsNewTabPage ||
- *pref_name == prefs::kNTPShownSections ||
- *pref_name == prefs::kNTPShownPage) {
- new_tab_incognito_html_ = NULL;
- new_tab_html_ = NULL;
- } else {
- NOTREACHED();
- }
+ // A change occurred to one of the preferences we care about, so flush the
+ // cache.
+ new_tab_incognito_html_ = NULL;
+ new_tab_html_ = NULL;
} else {
NOTREACHED();
}
@@ -359,6 +355,8 @@ void NTPResourceCache::CreateNewTabHTML() {
GetUrlWithLang(GURL(Extension::ChromeStoreLaunchURL())));
localized_strings.SetString("syncpromotext",
l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL));
+ localized_strings.SetString("synclinktext",
+ l10n_util::GetStringUTF16(IDS_SYNC_ADVANCED_OPTIONS));
localized_strings.SetString("trashLabel",
l10n_util::GetStringFUTF16(
IDS_NEW_TAB_TRASH_LABEL,
@@ -408,13 +406,22 @@ void NTPResourceCache::CreateNewTabHTML() {
if (profile_->GetPrefs()->FindPreference(prefs::kNTPPromoStart) &&
profile_->GetPrefs()->FindPreference(prefs::kNTPPromoEnd) &&
profile_->GetPrefs()->FindPreference(prefs::kNTPPromoLine) &&
- PromoResourceServiceUtil::CanShowPromo(profile_)) {
+ PromoResourceServiceUtil::CanShowPromo(profile_) &&
+ InDateRange(profile_->GetPrefs()->GetDouble(prefs::kNTPPromoStart),
+ profile_->GetPrefs()->GetDouble(prefs::kNTPPromoEnd))) {
localized_strings.SetString("serverpromo",
- InDateRange(profile_->GetPrefs()->GetDouble(prefs::kNTPPromoStart),
- profile_->GetPrefs()->GetDouble(prefs::kNTPPromoEnd)) ?
- profile_->GetPrefs()->GetString(prefs::kNTPPromoLine) :
- std::string());
+ profile_->GetPrefs()->GetString(
Evan Stade 2011/08/02 00:33:04 the indentation here is inconsistent with the way
Andrew T Wilson (Slow) 2011/08/02 22:07:42 Done.
+ prefs::kNTPPromoLine));
UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown"));
+ } else {
+ // Not showing a server-provided promo, so check if we need to show a
+ // notification from the sync service instead (don't want to show both).
+ // If no notification is desired, the "syncnotification" attribute is set
+ // to the empty string.
+ if (profile_->HasProfileSyncService()) {
+ localized_strings.SetString("syncnotification",
+ profile_->GetProfileSyncService()->GetSyncNotification());
+ }
}
// Load the new tab page appropriate for this build

Powered by Google App Engine
This is Rietveld 408576698