OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/ntp_resource_cache.h" | 5 #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/animation.h" | 10 #include "app/animation.h" |
11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
13 #include "app/theme_provider.h" | 13 #include "app/theme_provider.h" |
14 #include "base/command_line.h" | |
15 #include "base/file_util.h" | 14 #include "base/file_util.h" |
16 #include "base/ref_counted_memory.h" | 15 #include "base/ref_counted_memory.h" |
17 #include "base/string16.h" | 16 #include "base/string16.h" |
18 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
19 #include "base/time.h" | 18 #include "base/time.h" |
20 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
21 #include "base/values.h" | 20 #include "base/values.h" |
22 #include "chrome/browser/browser_thread.h" | 21 #include "chrome/browser/browser_thread.h" |
23 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 22 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
24 #include "chrome/browser/dom_ui/shown_sections_handler.h" | 23 #include "chrome/browser/dom_ui/shown_sections_handler.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 189 } |
191 } else { | 190 } else { |
192 NOTREACHED(); | 191 NOTREACHED(); |
193 } | 192 } |
194 } | 193 } |
195 | 194 |
196 void NTPResourceCache::CreateNewTabIncognitoHTML() { | 195 void NTPResourceCache::CreateNewTabIncognitoHTML() { |
197 DictionaryValue localized_strings; | 196 DictionaryValue localized_strings; |
198 localized_strings.SetString("title", | 197 localized_strings.SetString("title", |
199 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 198 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
200 int new_tab_message_ids = IDS_NEW_TAB_OTR_MESSAGE; | |
201 int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; | |
202 #if defined(OS_CHROMEOS) | |
203 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | |
204 new_tab_message_ids = IDS_NEW_TAB_GUEST_SESSION_MESSAGE; | |
205 new_tab_html_idr = IDR_GUEST_SESSION_TAB_HTML; | |
206 } | |
207 #endif | |
208 localized_strings.SetString("content", | 199 localized_strings.SetString("content", |
209 l10n_util::GetStringFUTF16(new_tab_message_ids, | 200 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, |
210 GetUrlWithLang(GURL(kLearnMoreIncognitoUrl)))); | 201 GetUrlWithLang(GURL(kLearnMoreIncognitoUrl)))); |
211 localized_strings.SetString("extensionsmessage", | 202 localized_strings.SetString("extensionsmessage", |
212 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, | 203 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, |
213 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 204 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
214 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); | 205 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); |
215 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 206 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( |
216 prefs::kShowBookmarkBar); | 207 prefs::kShowBookmarkBar); |
217 localized_strings.SetString("bookmarkbarattached", | 208 localized_strings.SetString("bookmarkbarattached", |
218 bookmark_bar_attached ? "true" : "false"); | 209 bookmark_bar_attached ? "true" : "false"); |
219 | 210 |
220 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); | 211 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); |
221 | 212 |
222 static const base::StringPiece incognito_tab_html( | 213 static const base::StringPiece incognito_tab_html( |
223 ResourceBundle::GetSharedInstance().GetRawDataResource( | 214 ResourceBundle::GetSharedInstance().GetRawDataResource( |
224 new_tab_html_idr)); | 215 IDR_INCOGNITO_TAB_HTML)); |
225 | 216 |
226 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 217 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
227 incognito_tab_html, &localized_strings); | 218 incognito_tab_html, &localized_strings); |
228 | 219 |
229 new_tab_incognito_html_ = new RefCountedBytes; | 220 new_tab_incognito_html_ = new RefCountedBytes; |
230 new_tab_incognito_html_->data.resize(full_html.size()); | 221 new_tab_incognito_html_->data.resize(full_html.size()); |
231 std::copy(full_html.begin(), full_html.end(), | 222 std::copy(full_html.begin(), full_html.end(), |
232 new_tab_incognito_html_->data.begin()); | 223 new_tab_incognito_html_->data.begin()); |
233 } | 224 } |
234 | 225 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 std::string css_string; | 503 std::string css_string; |
513 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 504 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
514 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); | 505 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); |
515 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); | 506 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); |
516 | 507 |
517 new_tab_css_ = new RefCountedBytes; | 508 new_tab_css_ = new RefCountedBytes; |
518 new_tab_css_->data.resize(css_string.size()); | 509 new_tab_css_->data.resize(css_string.size()); |
519 std::copy(css_string.begin(), css_string.end(), | 510 std::copy(css_string.begin(), css_string.end(), |
520 new_tab_css_->data.begin()); | 511 new_tab_css_->data.begin()); |
521 } | 512 } |
OLD | NEW |