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

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

Issue 9515010: Chrome on Android : Begin removing references to themes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolving the comment that I missed. Created 8 years, 9 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
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 html_source->AddResource("suggestions_page.js", "application/javascript", 152 html_source->AddResource("suggestions_page.js", "application/javascript",
153 IDR_SUGGESTIONS_PAGE_JS); 153 IDR_SUGGESTIONS_PAGE_JS);
154 } 154 }
155 // ChromeURLDataManager assumes the ownership of the html_source and in some 155 // ChromeURLDataManager assumes the ownership of the html_source and in some
156 // tests immediately deletes it, so html_source should not be accessed after 156 // tests immediately deletes it, so html_source should not be accessed after
157 // this call. 157 // this call.
158 GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source); 158 GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source);
159 159
160 pref_change_registrar_.Init(GetProfile()->GetPrefs()); 160 pref_change_registrar_.Init(GetProfile()->GetPrefs());
161 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); 161 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this);
162
163 #if !defined(OS_ANDROID)
164 // TODO(tedchoc): Remove when Android uses a natively rendered Android UI
165 // for the NTP.
162 // Listen for theme installation. 166 // Listen for theme installation.
163 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 167 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
164 content::Source<ThemeService>( 168 content::Source<ThemeService>(
165 ThemeServiceFactory::GetForProfile(GetProfile()))); 169 ThemeServiceFactory::GetForProfile(GetProfile())));
170 #endif
166 } 171 }
167 172
168 NewTabUI::~NewTabUI() { 173 NewTabUI::~NewTabUI() {
169 g_live_new_tabs.Pointer()->erase(this); 174 g_live_new_tabs.Pointer()->erase(this);
170 } 175 }
171 176
172 // The timer callback. If enough time has elapsed since the last paint 177 // The timer callback. If enough time has elapsed since the last paint
173 // message, we say we're done painting; otherwise, we keep waiting. 178 // message, we say we're done painting; otherwise, we keep waiting.
174 void NewTabUI::PaintTimeout() { 179 void NewTabUI::PaintTimeout() {
175 // The amount of time there must be no painting for us to consider painting 180 // The amount of time there must be no painting for us to consider painting
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const content::NotificationSource& source, 228 const content::NotificationSource& source,
224 const content::NotificationDetails& details) { 229 const content::NotificationDetails& details) {
225 switch (type) { 230 switch (type) {
226 case chrome::NOTIFICATION_PREF_CHANGED: { // kShowBookmarkBar 231 case chrome::NOTIFICATION_PREF_CHANGED: { // kShowBookmarkBar
227 StringValue attached( 232 StringValue attached(
228 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? 233 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ?
229 "true" : "false"); 234 "true" : "false");
230 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached); 235 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached);
231 break; 236 break;
232 } 237 }
238 #if !defined(OS_ANDROID)
239 // TODO(tedchoc): Remove when Android uses a natively rendered Android UI
240 // for the NTP.
233 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 241 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
234 InitializeCSSCaches(); 242 InitializeCSSCaches();
235 StringValue attribution( 243 StringValue attribution(
236 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage( 244 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage(
237 IDR_THEME_NTP_ATTRIBUTION) ? "true" : "false"); 245 IDR_THEME_NTP_ATTRIBUTION) ? "true" : "false");
238 web_ui()->CallJavascriptFunction("ntp.themeChanged", attribution); 246 web_ui()->CallJavascriptFunction("ntp.themeChanged", attribution);
239 break; 247 break;
240 } 248 }
249 #endif
241 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: { 250 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: {
242 last_paint_ = base::TimeTicks::Now(); 251 last_paint_ = base::TimeTicks::Now();
243 break; 252 break;
244 } 253 }
245 default: 254 default:
246 CHECK(false) << "Unexpected notification: " << type; 255 CHECK(false) << "Unexpected notification: " << type;
247 } 256 }
248 } 257 }
249 258
250 void NewTabUI::InitializeCSSCaches() { 259 void NewTabUI::InitializeCSSCaches() {
260 #if !defined(OS_ANDROID)
261 // TODO(tedchoc): Remove when Android uses a natively rendered Android UI
262 // for the NTP.
251 Profile* profile = GetProfile(); 263 Profile* profile = GetProfile();
252 ThemeSource* theme = new ThemeSource(profile); 264 ThemeSource* theme = new ThemeSource(profile);
253 profile->GetChromeURLDataManager()->AddDataSource(theme); 265 profile->GetChromeURLDataManager()->AddDataSource(theme);
266 #endif
254 } 267 }
255 268
256 // static 269 // static
257 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { 270 void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
258 NewTabPageHandler::RegisterUserPrefs(prefs); 271 NewTabPageHandler::RegisterUserPrefs(prefs);
259 AppLauncherHandler::RegisterUserPrefs(prefs); 272 AppLauncherHandler::RegisterUserPrefs(prefs);
260 MostVisitedHandler::RegisterUserPrefs(prefs); 273 MostVisitedHandler::RegisterUserPrefs(prefs);
261 if (NewTabUI::IsSuggestionsPageEnabled()) 274 if (NewTabUI::IsSuggestionsPageEnabled())
262 SuggestionsHandler::RegisterUserPrefs(prefs); 275 SuggestionsHandler::RegisterUserPrefs(prefs);
263 } 276 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 420 }
408 421
409 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 422 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
410 const char* mime_type, 423 const char* mime_type,
411 int resource_id) { 424 int resource_id) {
412 DCHECK(resource); 425 DCHECK(resource);
413 DCHECK(mime_type); 426 DCHECK(mime_type);
414 resource_map_[std::string(resource)] = 427 resource_map_[std::string(resource)] =
415 std::make_pair(std::string(mime_type), resource_id); 428 std::make_pair(std::string(mime_type), resource_id);
416 } 429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698