OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/command_line.h" |
7 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
8 #include "base/string16.h" | 9 #include "base/string16.h" |
9 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "chrome/browser/google/google_util.h" | 13 #include "chrome/browser/google/google_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
15 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" | 16 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
| 17 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/jstemplate_builder.h" | 18 #include "chrome/common/jstemplate_builder.h" |
17 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
19 #include "grit/browser_resources.h" | 21 #include "grit/browser_resources.h" |
20 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/layout.h" | 24 #include "ui/base/layout.h" |
23 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
24 | 26 |
25 using content::BrowserThread; | 27 using content::BrowserThread; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 localized_strings.SetString("recentlyclosed", | 71 localized_strings.SetString("recentlyclosed", |
70 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED)); | 72 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED)); |
71 | 73 |
72 NewTabPageHandler::GetLocalizedValues(profile_, &localized_strings); | 74 NewTabPageHandler::GetLocalizedValues(profile_, &localized_strings); |
73 | 75 |
74 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); | 76 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); |
75 | 77 |
76 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 78 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
77 GetRawDataResource(IDR_NEW_TAB_4_HTML, | 79 GetRawDataResource(IDR_NEW_TAB_4_HTML, |
78 ui::SCALE_FACTOR_NONE)); | 80 ui::SCALE_FACTOR_NONE)); |
79 | 81 localized_strings.SetString( |
| 82 "device", |
| 83 CommandLine::ForCurrentProcess()->HasSwitch(switches::kTabletUi) ? |
| 84 "tablet" : "phone"); |
80 const char* new_tab_link = kLearnMoreIncognitoUrl; | 85 const char* new_tab_link = kLearnMoreIncognitoUrl; |
81 string16 learnMoreLink = ASCIIToUTF16( | 86 string16 learnMoreLink = ASCIIToUTF16( |
82 google_util::AppendGoogleLocaleParam(GURL(new_tab_link)).spec()); | 87 google_util::AppendGoogleLocaleParam(GURL(new_tab_link)).spec()); |
83 localized_strings.SetString("content", | 88 localized_strings.SetString("content", |
84 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, learnMoreLink)); | 89 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, learnMoreLink)); |
85 | 90 |
86 // Load the new tab page appropriate for this build. | 91 // Load the new tab page appropriate for this build. |
87 std::string full_html; | 92 std::string full_html; |
88 | 93 |
89 // Inject the template data into the HTML so that it is available before any | 94 // Inject the template data into the HTML so that it is available before any |
(...skipping 11 matching lines...) Expand all Loading... |
101 size_t after_offset = pos + template_data_placeholder.size(); | 106 size_t after_offset = pos + template_data_placeholder.size(); |
102 full_html.append(new_tab_html.data() + after_offset, | 107 full_html.append(new_tab_html.data() + after_offset, |
103 new_tab_html.size() - after_offset); | 108 new_tab_html.size() - after_offset); |
104 } else { | 109 } else { |
105 NOTREACHED(); | 110 NOTREACHED(); |
106 full_html.assign(new_tab_html.data(), new_tab_html.size()); | 111 full_html.assign(new_tab_html.data(), new_tab_html.size()); |
107 } | 112 } |
108 | 113 |
109 new_tab_html_ = base::RefCountedString::TakeString(&full_html); | 114 new_tab_html_ = base::RefCountedString::TakeString(&full_html); |
110 } | 115 } |
OLD | NEW |