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