summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 08:11:30 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 08:11:30 +0000
commit11a2da1a77c397d687ec142b8fe2103efa45d3f0 (patch)
treed2649fb4d02addb6c6f430fd4c76b955851e5957 /chrome/browser/dom_ui
parent4171f4a814ba9f7f3534f0c8554fe9e2ccaf66ec (diff)
downloadchromium_src-11a2da1a77c397d687ec142b8fe2103efa45d3f0.zip
chromium_src-11a2da1a77c397d687ec142b8fe2103efa45d3f0.tar.gz
chromium_src-11a2da1a77c397d687ec142b8fe2103efa45d3f0.tar.bz2
Reland r57473
TBR=eroman@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.h2
-rw-r--r--chrome/browser/dom_ui/ntp_resource_cache.cc19
-rw-r--r--chrome/browser/dom_ui/shown_sections_handler.cc17
-rw-r--r--chrome/browser/dom_ui/shown_sections_handler.h3
-rw-r--r--chrome/browser/dom_ui/shown_sections_handler_unittest.cc24
5 files changed, 24 insertions, 41 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h
index e091fcf..35e2a87 100644
--- a/chrome/browser/dom_ui/new_tab_ui.h
+++ b/chrome/browser/dom_ui/new_tab_ui.h
@@ -96,7 +96,7 @@ class NewTabUI : public DOMUI,
NotificationRegistrar registrar_;
// The preference version. This used for migrating prefs of the NTP.
- static const int current_pref_version_ = 2;
+ static const int current_pref_version_ = 3;
DISALLOW_COPY_AND_ASSIGN(NewTabUI);
};
diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc
index e92ad6c..05868b7 100644
--- a/chrome/browser/dom_ui/ntp_resource_cache.cc
+++ b/chrome/browser/dom_ui/ntp_resource_cache.cc
@@ -224,6 +224,7 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() {
void NTPResourceCache::CreateNewTabHTML() {
// Show the profile name in the title and most visited labels if the current
// profile is not the default.
+ string16 apps = l10n_util::GetStringUTF16(IDS_NEW_TAB_APPS);
string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
string16 most_visited = l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED);
DictionaryValue localized_strings;
@@ -233,6 +234,7 @@ void NTPResourceCache::CreateNewTabHTML() {
localized_strings.SetString("hasattribution",
profile_->GetThemeProvider()->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ?
"true" : "false");
+ localized_strings.SetString("apps", apps);
localized_strings.SetString("title", title);
localized_strings.SetString("mostvisited", most_visited);
localized_strings.SetString("restorethumbnails",
@@ -396,6 +398,10 @@ void NTPResourceCache::CreateNewTabCSS() {
tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK);
SkColor color_section_link_underline =
tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE);
+ SkColor color_section_header_text =
+ tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT);
+ SkColor color_section_header_text_hover =
+ tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT_HOVER);
SkColor color_header =
tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER);
@@ -443,6 +449,9 @@ void NTPResourceCache::CreateNewTabCSS() {
tp->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "block" : "none"); // $$5
subst2.push_back(SkColorToRGBAString(color_link_underline)); // $$6
subst2.push_back(SkColorToRGBAString(color_section_link_underline)); // $$7
+ subst2.push_back(SkColorToRGBAString(color_section_header_text)); // $$8
+ subst2.push_back(SkColorToRGBAString(
+ color_section_header_text_hover)); // $$9
// Get our template.
static const base::StringPiece new_tab_theme_css(
@@ -450,12 +459,12 @@ void NTPResourceCache::CreateNewTabCSS() {
IDR_NEW_TAB_THEME_CSS));
// Create the string from our template and the replacements.
- const std::string css_string = ReplaceStringPlaceholders(
- new_tab_theme_css, subst, NULL);
- std::string full_css = ReplaceStringPlaceholders(css_string, subst2, NULL);
+ std::string css_string;
+ css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
+ css_string = ReplaceStringPlaceholders(css_string, subst2, NULL);
new_tab_css_ = new RefCountedBytes;
- new_tab_css_->data.resize(full_css.size());
- std::copy(full_css.begin(), full_css.end(),
+ new_tab_css_->data.resize(css_string.size());
+ std::copy(css_string.begin(), css_string.end(),
new_tab_css_->data.begin());
}
diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc
index 2bb3d82..c46724d 100644
--- a/chrome/browser/dom_ui/shown_sections_handler.cc
+++ b/chrome/browser/dom_ui/shown_sections_handler.cc
@@ -89,7 +89,7 @@ void ShownSectionsHandler::HandleSetShownSections(const ListValue* args) {
// static
void ShownSectionsHandler::RegisterUserPrefs(PrefService* pref_service) {
pref_service->RegisterIntegerPref(prefs::kNTPShownSections,
- THUMB | RECENT | TIPS | SYNC);
+ THUMB | RECENT | TIPS | SYNC | APPS);
}
// static
@@ -99,17 +99,10 @@ void ShownSectionsHandler::MigrateUserPrefs(PrefService* pref_service,
bool changed = false;
int shown_sections = pref_service->GetInteger(prefs::kNTPShownSections);
- if (old_pref_version < 1) {
- // TIPS was used in early builds of the NNTP but since it was removed before
- // Chrome 3.0 we want to ensure that it is shown by default.
- shown_sections |= TIPS | SYNC;
- changed = true;
- }
-
- if (old_pref_version < 2) {
- // LIST is no longer used. Change to THUMB.
- shown_sections &= ~LIST;
- shown_sections |= THUMB;
+ if (old_pref_version < 3) {
+ // At version 3, we added apps. To bring attention to the feature, we start
+ // it off as the only expanded section.
+ shown_sections = APPS;
changed = true;
}
diff --git a/chrome/browser/dom_ui/shown_sections_handler.h b/chrome/browser/dom_ui/shown_sections_handler.h
index afe1e26..e097c71 100644
--- a/chrome/browser/dom_ui/shown_sections_handler.h
+++ b/chrome/browser/dom_ui/shown_sections_handler.h
@@ -20,7 +20,8 @@ enum Section {
RECENT = 4,
TIPS = 8,
SYNC = 16,
- DEBUG = 32
+ DEBUG = 32,
+ APPS = 64
};
class ShownSectionsHandler : public DOMMessageHandler,
diff --git a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc
index 48ca9a1..2f9e59b 100644
--- a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc
+++ b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc
@@ -22,28 +22,8 @@ TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) {
pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
pref->SetInteger(prefs::kNTPShownSections, THUMB);
- ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 1);
+ ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 3);
int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
-
- EXPECT_TRUE(shown_sections & THUMB);
- EXPECT_FALSE(shown_sections & LIST);
- EXPECT_FALSE(shown_sections & RECENT);
- EXPECT_TRUE(shown_sections & TIPS);
- EXPECT_TRUE(shown_sections & SYNC);
-}
-
-TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) {
- scoped_ptr<PrefService> pref(new TestingPrefService);
-
- // Set an *old* value
- pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
- pref->SetInteger(prefs::kNTPShownSections, LIST);
-
- ShownSectionsHandler::MigrateUserPrefs(pref.get(), 1, 2);
-
- int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
-
- EXPECT_TRUE(shown_sections & THUMB);
- EXPECT_FALSE(shown_sections & LIST);
+ EXPECT_EQ(APPS, shown_sections);
}