Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache_android.cc

Issue 10797053: Add support for differentiating the form factor for Android NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTabletUi)) {
Evan Stade 2012/07/20 21:21:36 ternary operator
Ted C 2012/07/20 21:27:25 Done.
82 localized_strings.SetString("device", "tablet");
83 } else {
84 localized_strings.SetString("device", "phone");
85 }
80 const char* new_tab_link = kLearnMoreIncognitoUrl; 86 const char* new_tab_link = kLearnMoreIncognitoUrl;
81 string16 learnMoreLink = ASCIIToUTF16( 87 string16 learnMoreLink = ASCIIToUTF16(
82 google_util::AppendGoogleLocaleParam(GURL(new_tab_link)).spec()); 88 google_util::AppendGoogleLocaleParam(GURL(new_tab_link)).spec());
83 localized_strings.SetString("content", 89 localized_strings.SetString("content",
84 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, learnMoreLink)); 90 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, learnMoreLink));
85 91
86 // Load the new tab page appropriate for this build. 92 // Load the new tab page appropriate for this build.
87 std::string full_html; 93 std::string full_html;
88 94
89 // Inject the template data into the HTML so that it is available before any 95 // Inject the template data into the HTML so that it is available before any
(...skipping 11 matching lines...) Expand all
101 size_t after_offset = pos + template_data_placeholder.size(); 107 size_t after_offset = pos + template_data_placeholder.size();
102 full_html.append(new_tab_html.data() + after_offset, 108 full_html.append(new_tab_html.data() + after_offset,
103 new_tab_html.size() - after_offset); 109 new_tab_html.size() - after_offset);
104 } else { 110 } else {
105 NOTREACHED(); 111 NOTREACHED();
106 full_html.assign(new_tab_html.data(), new_tab_html.size()); 112 full_html.assign(new_tab_html.data(), new_tab_html.size());
107 } 113 }
108 114
109 new_tab_html_ = base::RefCountedString::TakeString(&full_html); 115 new_tab_html_ = base::RefCountedString::TakeString(&full_html);
110 } 116 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698