| 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 29 matching lines...) Expand all Loading... |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 // The URL for the the Learn More page shown on incognito new tab. | 56 // The URL for the the Learn More page shown on incognito new tab. |
| 56 const char kLearnMoreIncognitoUrl[] = | 57 const char kLearnMoreIncognitoUrl[] = |
| 57 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
| 58 "http://www.google.com/support/chromeos/bin/answer.py?answer=95464"; | 59 "http://www.google.com/support/chromeos/bin/answer.py?answer=95464"; |
| 59 #else | 60 #else |
| 60 "http://www.google.com/support/chrome/bin/answer.py?answer=95464"; | 61 "http://www.google.com/support/chrome/bin/answer.py?answer=95464"; |
| 61 #endif | 62 #endif |
| 62 | 63 |
| 64 // The URL for the Learn More page shown on guest session new tab. |
| 65 const char kLearnMoreGuestSessionUrl[] = |
| 66 "http://www.google.com/support/chromeos/bin/answer.py?answer=1057090"; |
| 67 |
| 63 // The URL for bookmark sync service help. | 68 // The URL for bookmark sync service help. |
| 64 const char kSyncServiceHelpUrl[] = | 69 const char kSyncServiceHelpUrl[] = |
| 65 "http://www.google.com/support/chrome/bin/answer.py?answer=165139"; | 70 "http://www.google.com/support/chrome/bin/answer.py?answer=165139"; |
| 66 | 71 |
| 67 // The URL to be loaded to display Help. | 72 // The URL to be loaded to display Help. |
| 68 const char kHelpContentUrl[] = | 73 const char kHelpContentUrl[] = |
| 69 "http://www.google.com/support/chrome/"; | 74 "http://www.google.com/support/chrome/"; |
| 70 | 75 |
| 71 string16 GetUrlWithLang(const GURL& url) { | 76 string16 GetUrlWithLang(const GURL& url) { |
| 72 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); | 77 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 198 } |
| 194 } else { | 199 } else { |
| 195 NOTREACHED(); | 200 NOTREACHED(); |
| 196 } | 201 } |
| 197 } | 202 } |
| 198 | 203 |
| 199 void NTPResourceCache::CreateNewTabIncognitoHTML() { | 204 void NTPResourceCache::CreateNewTabIncognitoHTML() { |
| 200 DictionaryValue localized_strings; | 205 DictionaryValue localized_strings; |
| 201 localized_strings.SetString("title", | 206 localized_strings.SetString("title", |
| 202 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 207 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 208 int new_tab_message_ids = IDS_NEW_TAB_OTR_MESSAGE; |
| 209 int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; |
| 210 const char* new_tab_link = kLearnMoreIncognitoUrl; |
| 211 // TODO(altimofeev): consider implementation without 'if def' usage. |
| 212 #if defined(OS_CHROMEOS) |
| 213 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 214 new_tab_message_ids = IDS_NEW_TAB_GUEST_SESSION_MESSAGE; |
| 215 new_tab_html_idr = IDR_GUEST_SESSION_TAB_HTML; |
| 216 new_tab_link = kLearnMoreGuestSessionUrl; |
| 217 } |
| 218 #endif |
| 203 localized_strings.SetString("content", | 219 localized_strings.SetString("content", |
| 204 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, | 220 l10n_util::GetStringFUTF16(new_tab_message_ids, |
| 205 GetUrlWithLang(GURL(kLearnMoreIncognitoUrl)))); | 221 GetUrlWithLang(GURL(new_tab_link)))); |
| 206 localized_strings.SetString("extensionsmessage", | 222 localized_strings.SetString("extensionsmessage", |
| 207 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, | 223 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, |
| 208 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 224 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| 209 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); | 225 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); |
| 210 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 226 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( |
| 211 prefs::kShowBookmarkBar); | 227 prefs::kShowBookmarkBar); |
| 212 localized_strings.SetString("bookmarkbarattached", | 228 localized_strings.SetString("bookmarkbarattached", |
| 213 bookmark_bar_attached ? "true" : "false"); | 229 bookmark_bar_attached ? "true" : "false"); |
| 214 | 230 |
| 215 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); | 231 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); |
| 216 | 232 |
| 217 static const base::StringPiece incognito_tab_html( | 233 static const base::StringPiece incognito_tab_html( |
| 218 ResourceBundle::GetSharedInstance().GetRawDataResource( | 234 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 219 IDR_INCOGNITO_TAB_HTML)); | 235 new_tab_html_idr)); |
| 220 | 236 |
| 221 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 237 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
| 222 incognito_tab_html, &localized_strings); | 238 incognito_tab_html, &localized_strings); |
| 223 | 239 |
| 224 new_tab_incognito_html_ = new RefCountedBytes; | 240 new_tab_incognito_html_ = new RefCountedBytes; |
| 225 new_tab_incognito_html_->data.resize(full_html.size()); | 241 new_tab_incognito_html_->data.resize(full_html.size()); |
| 226 std::copy(full_html.begin(), full_html.end(), | 242 std::copy(full_html.begin(), full_html.end(), |
| 227 new_tab_incognito_html_->data.begin()); | 243 new_tab_incognito_html_->data.begin()); |
| 228 } | 244 } |
| 229 | 245 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 std::string css_string; | 521 std::string css_string; |
| 506 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 522 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
| 507 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); | 523 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); |
| 508 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); | 524 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); |
| 509 | 525 |
| 510 new_tab_css_ = new RefCountedBytes; | 526 new_tab_css_ = new RefCountedBytes; |
| 511 new_tab_css_->data.resize(css_string.size()); | 527 new_tab_css_->data.resize(css_string.size()); |
| 512 std::copy(css_string.begin(), css_string.end(), | 528 std::copy(css_string.begin(), css_string.end(), |
| 513 new_tab_css_->data.begin()); | 529 new_tab_css_->data.begin()); |
| 514 } | 530 } |
| OLD | NEW |