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

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

Issue 50603005: Add cross-platform API to get the form factor of the device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small formatting changes Created 7 years, 1 month 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
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/command_line.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/google/google_util.h" 13 #include "chrome/browser/google/google_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/chrome_version_info.h" 16 #include "chrome/common/chrome_version_info.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
20 #include "grit/browser_resources.h" 20 #include "grit/browser_resources.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "ui/base/device_form_factor.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/base/webui/jstemplate_builder.h" 25 #include "ui/base/webui/jstemplate_builder.h"
25 #include "ui/base/webui/web_ui_util.h" 26 #include "ui/base/webui/web_ui_util.h"
26 27
27 using chrome::VersionInfo; 28 using chrome::VersionInfo;
28 using content::BrowserThread; 29 using content::BrowserThread;
29 30
30 namespace { 31 namespace {
31 32
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 l10n_util::GetStringUTF16(IDS_NEW_TAB_BOOKMARKS_TITLE)); 126 l10n_util::GetStringUTF16(IDS_NEW_TAB_BOOKMARKS_TITLE));
126 localized_strings.SetString("open_tabs_document_title", 127 localized_strings.SetString("open_tabs_document_title",
127 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_TITLE)); 128 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_TITLE));
128 129
129 webui::SetFontAndTextDirection(&localized_strings); 130 webui::SetFontAndTextDirection(&localized_strings);
130 131
131 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). 132 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
132 GetRawDataResource(IDR_NEW_TAB_ANDROID_HTML)); 133 GetRawDataResource(IDR_NEW_TAB_ANDROID_HTML));
133 localized_strings.SetString( 134 localized_strings.SetString(
134 "device", 135 "device",
135 CommandLine::ForCurrentProcess()->HasSwitch(switches::kTabletUI) ? 136 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET ?
136 "tablet" : "phone"); 137 "tablet" : "phone");
137 138
138 bool bookmark_shortcuts_allowed = false; 139 bool bookmark_shortcuts_allowed = false;
139 if (CommandLine::ForCurrentProcess()->HasSwitch( 140 if (CommandLine::ForCurrentProcess()->HasSwitch(
140 switches::kDisableAddToHomescreen)) { 141 switches::kDisableAddToHomescreen)) {
141 bookmark_shortcuts_allowed = true; 142 bookmark_shortcuts_allowed = true;
142 } else if (CommandLine::ForCurrentProcess()->HasSwitch( 143 } else if (CommandLine::ForCurrentProcess()->HasSwitch(
143 switches::kEnableAddToHomescreen)) { 144 switches::kEnableAddToHomescreen)) {
144 bookmark_shortcuts_allowed = false; 145 bookmark_shortcuts_allowed = false;
145 } else if (VersionInfo::GetChannel() == VersionInfo::CHANNEL_STABLE) { 146 } else if (VersionInfo::GetChannel() == VersionInfo::CHANNEL_STABLE) {
(...skipping 28 matching lines...) Expand all
174 size_t after_offset = pos + template_data_placeholder.size(); 175 size_t after_offset = pos + template_data_placeholder.size();
175 full_html.append(new_tab_html.data() + after_offset, 176 full_html.append(new_tab_html.data() + after_offset,
176 new_tab_html.size() - after_offset); 177 new_tab_html.size() - after_offset);
177 } else { 178 } else {
178 NOTREACHED(); 179 NOTREACHED();
179 full_html.assign(new_tab_html.data(), new_tab_html.size()); 180 full_html.assign(new_tab_html.data(), new_tab_html.size());
180 } 181 }
181 182
182 new_tab_html_ = base::RefCountedString::TakeString(&full_html); 183 new_tab_html_ = base::RefCountedString::TakeString(&full_html);
183 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698