OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 133 |
134 // How the background image on the new tab page should be tiled (see tiling | 134 // How the background image on the new tab page should be tiled (see tiling |
135 // masks in theme_service.h). | 135 // masks in theme_service.h). |
136 std::string GetNewTabBackgroundTilingCSS( | 136 std::string GetNewTabBackgroundTilingCSS( |
137 const ui::ThemeProvider& theme_provider) { | 137 const ui::ThemeProvider& theme_provider) { |
138 int repeat_mode = | 138 int repeat_mode = |
139 theme_provider.GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING); | 139 theme_provider.GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING); |
140 return ThemeProperties::TilingToString(repeat_mode); | 140 return ThemeProperties::TilingToString(repeat_mode); |
141 } | 141 } |
142 | 142 |
143 bool IsMDIncognitoTabEnabled() { | |
144 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
145 switches::kEnableMaterialDesignIncognitoNTP); | |
146 } | |
147 | |
143 } // namespace | 148 } // namespace |
144 | 149 |
145 NTPResourceCache::NTPResourceCache(Profile* profile) | 150 NTPResourceCache::NTPResourceCache(Profile* profile) |
146 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false), | 151 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false), |
147 should_show_apps_page_(NewTabUI::ShouldShowApps()), | 152 should_show_apps_page_(NewTabUI::ShouldShowApps()), |
148 should_show_other_devices_menu_(true) { | 153 should_show_other_devices_menu_(true) { |
149 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 154 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
150 content::Source<ThemeService>( | 155 content::Source<ThemeService>( |
151 ThemeServiceFactory::GetForProfile(profile))); | 156 ThemeServiceFactory::GetForProfile(profile))); |
152 | 157 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 new_tab_incognito_html_ = nullptr; | 273 new_tab_incognito_html_ = nullptr; |
269 new_tab_html_ = nullptr; | 274 new_tab_html_ = nullptr; |
270 new_tab_incognito_css_ = nullptr; | 275 new_tab_incognito_css_ = nullptr; |
271 new_tab_css_ = nullptr; | 276 new_tab_css_ = nullptr; |
272 } | 277 } |
273 | 278 |
274 void NTPResourceCache::CreateNewTabIncognitoHTML() { | 279 void NTPResourceCache::CreateNewTabIncognitoHTML() { |
275 base::DictionaryValue localized_strings; | 280 base::DictionaryValue localized_strings; |
276 localized_strings.SetString("title", | 281 localized_strings.SetString("title", |
277 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 282 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
278 int new_tab_description_ids = IDS_NEW_TAB_OTR_DESCRIPTION; | 283 |
279 int new_tab_heading_ids = IDS_NEW_TAB_OTR_HEADING; | 284 int new_tab_heading_ids; |
285 int new_tab_description_ids; | |
286 int new_tab_warning_ids; | |
287 int new_tab_features_ids; | |
288 int new_tab_html_idr; | |
Dan Beam
2017/04/11 00:31:12
all these uninitialized ints make me a little nerv
msramek
2017/04/11 19:04:27
Done.
Me too, actually :) The current approach se
| |
289 | |
290 if (IsMDIncognitoTabEnabled() && !profile_->IsGuestSession()) { | |
291 new_tab_description_ids = IDS_NEW_TAB_OTR_SUBTITLE; | |
292 new_tab_heading_ids = IDS_NEW_TAB_OTR_TITLE; | |
293 new_tab_warning_ids = IDS_NEW_TAB_OTR_VISIBLE; | |
294 new_tab_features_ids = IDS_NEW_TAB_OTR_NOT_SAVED; | |
295 new_tab_html_idr = IDR_MD_INCOGNITO_TAB_HTML; | |
296 } else { | |
297 new_tab_description_ids = IDS_NEW_TAB_OTR_DESCRIPTION; | |
298 new_tab_heading_ids = IDS_NEW_TAB_OTR_HEADING; | |
299 new_tab_warning_ids = IDS_NEW_TAB_OTR_MESSAGE_WARNING; | |
300 // new_tab_features_ids is not used in the old version. | |
Dan Beam
2017/04/11 00:31:12
new_tab_feature_ids is not initialized explicitly,
msramek
2017/04/11 19:04:27
Indeed, but its only usage is guarded by IsMDIncog
| |
301 new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; | |
302 } | |
303 | |
280 int new_tab_link_ids = IDS_NEW_TAB_OTR_LEARN_MORE_LINK; | 304 int new_tab_link_ids = IDS_NEW_TAB_OTR_LEARN_MORE_LINK; |
281 int new_tab_warning_ids = IDS_NEW_TAB_OTR_MESSAGE_WARNING; | |
282 int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; | |
283 const char* new_tab_link = kLearnMoreIncognitoUrl; | 305 const char* new_tab_link = kLearnMoreIncognitoUrl; |
284 | 306 |
285 if (profile_->IsGuestSession()) { | 307 if (profile_->IsGuestSession()) { |
286 localized_strings.SetString("guestTabDescription", | 308 localized_strings.SetString("guestTabDescription", |
287 l10n_util::GetStringUTF16(new_tab_description_ids)); | 309 l10n_util::GetStringUTF16(new_tab_description_ids)); |
288 localized_strings.SetString("guestTabHeading", | 310 localized_strings.SetString("guestTabHeading", |
289 l10n_util::GetStringUTF16(new_tab_heading_ids)); | 311 l10n_util::GetStringUTF16(new_tab_heading_ids)); |
290 } else { | 312 } else { |
291 localized_strings.SetString("incognitoTabDescription", | 313 localized_strings.SetString("incognitoTabDescription", |
292 l10n_util::GetStringUTF16(new_tab_description_ids)); | 314 l10n_util::GetStringUTF16(new_tab_description_ids)); |
293 localized_strings.SetString("incognitoTabHeading", | 315 localized_strings.SetString("incognitoTabHeading", |
294 l10n_util::GetStringUTF16(new_tab_heading_ids)); | 316 l10n_util::GetStringUTF16(new_tab_heading_ids)); |
317 if (IsMDIncognitoTabEnabled()) { | |
318 localized_strings.SetString( | |
319 "incognitoTabFeatures", | |
320 l10n_util::GetStringUTF16(new_tab_features_ids)); | |
321 } | |
295 localized_strings.SetString("incognitoTabWarning", | 322 localized_strings.SetString("incognitoTabWarning", |
296 l10n_util::GetStringUTF16(new_tab_warning_ids)); | 323 l10n_util::GetStringUTF16(new_tab_warning_ids)); |
297 } | 324 } |
298 | 325 |
299 localized_strings.SetString("learnMore", | 326 localized_strings.SetString("learnMore", |
300 l10n_util::GetStringUTF16(new_tab_link_ids)); | 327 l10n_util::GetStringUTF16(new_tab_link_ids)); |
301 localized_strings.SetString("learnMoreLink", new_tab_link); | 328 localized_strings.SetString("learnMoreLink", new_tab_link); |
302 | 329 |
303 bool bookmark_bar_attached = | 330 bool bookmark_bar_attached = |
304 profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); | 331 profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 // Get our template. | 611 // Get our template. |
585 static const base::StringPiece new_tab_theme_css( | 612 static const base::StringPiece new_tab_theme_css( |
586 ResourceBundle::GetSharedInstance().GetRawDataResource( | 613 ResourceBundle::GetSharedInstance().GetRawDataResource( |
587 IDR_NEW_TAB_4_THEME_CSS)); | 614 IDR_NEW_TAB_4_THEME_CSS)); |
588 | 615 |
589 // Create the string from our template and the replacements. | 616 // Create the string from our template and the replacements. |
590 std::string css_string = | 617 std::string css_string = |
591 ui::ReplaceTemplateExpressions(new_tab_theme_css, substitutions); | 618 ui::ReplaceTemplateExpressions(new_tab_theme_css, substitutions); |
592 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 619 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
593 } | 620 } |
OLD | NEW |