| 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 "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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 html_source->AddResource("suggestions_page.js", "application/javascript", | 157 html_source->AddResource("suggestions_page.js", "application/javascript", |
| 158 IDR_SUGGESTIONS_PAGE_JS); | 158 IDR_SUGGESTIONS_PAGE_JS); |
| 159 } | 159 } |
| 160 // ChromeURLDataManager assumes the ownership of the html_source and in some | 160 // ChromeURLDataManager assumes the ownership of the html_source and in some |
| 161 // tests immediately deletes it, so html_source should not be accessed after | 161 // tests immediately deletes it, so html_source should not be accessed after |
| 162 // this call. | 162 // this call. |
| 163 Profile* profile = GetProfile(); | 163 Profile* profile = GetProfile(); |
| 164 ChromeURLDataManager::AddDataSource(profile, html_source); | 164 ChromeURLDataManager::AddDataSource(profile, html_source); |
| 165 | 165 |
| 166 pref_change_registrar_.Init(GetProfile()->GetPrefs()); | 166 pref_change_registrar_.Init(GetProfile()->GetPrefs()); |
| 167 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); | 167 pref_change_registrar_.Add(prefs::kShowBookmarkBar, |
| 168 base::Bind(&NewTabUI::OnShowBookmarkBarChanged, |
| 169 base::Unretained(this))); |
| 168 | 170 |
| 169 #if defined(ENABLE_THEMES) | 171 #if defined(ENABLE_THEMES) |
| 170 // Listen for theme installation. | 172 // Listen for theme installation. |
| 171 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 173 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 172 content::Source<ThemeService>( | 174 content::Source<ThemeService>( |
| 173 ThemeServiceFactory::GetForProfile(GetProfile()))); | 175 ThemeServiceFactory::GetForProfile(GetProfile()))); |
| 174 #endif | 176 #endif |
| 175 } | 177 } |
| 176 | 178 |
| 177 NewTabUI::~NewTabUI() { | 179 NewTabUI::~NewTabUI() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 #endif | 255 #endif |
| 254 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE: { | 256 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE: { |
| 255 last_paint_ = base::TimeTicks::Now(); | 257 last_paint_ = base::TimeTicks::Now(); |
| 256 break; | 258 break; |
| 257 } | 259 } |
| 258 default: | 260 default: |
| 259 CHECK(false) << "Unexpected notification: " << type; | 261 CHECK(false) << "Unexpected notification: " << type; |
| 260 } | 262 } |
| 261 } | 263 } |
| 262 | 264 |
| 263 void NewTabUI::OnPreferenceChanged(PrefServiceBase* service, | 265 void NewTabUI::OnShowBookmarkBarChanged() { |
| 264 const std::string& pref_name) { | |
| 265 StringValue attached( | 266 StringValue attached( |
| 266 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? | 267 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? |
| 267 "true" : "false"); | 268 "true" : "false"); |
| 268 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached); | 269 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached); |
| 269 } | 270 } |
| 270 | 271 |
| 271 void NewTabUI::InitializeCSSCaches() { | 272 void NewTabUI::InitializeCSSCaches() { |
| 272 #if defined(ENABLE_THEMES) | 273 #if defined(ENABLE_THEMES) |
| 273 Profile* profile = GetProfile(); | 274 Profile* profile = GetProfile(); |
| 274 ThemeSource* theme = new ThemeSource(profile); | 275 ThemeSource* theme = new ThemeSource(profile); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 416 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
| 416 const char* mime_type, | 417 const char* mime_type, |
| 417 int resource_id) { | 418 int resource_id) { |
| 418 DCHECK(resource); | 419 DCHECK(resource); |
| 419 DCHECK(mime_type); | 420 DCHECK(mime_type); |
| 420 resource_map_[std::string(resource)] = | 421 resource_map_[std::string(resource)] = |
| 421 std::make_pair(std::string(mime_type), resource_id); | 422 std::make_pair(std::string(mime_type), resource_id); |
| 422 } | 423 } |
| 423 | 424 |
| 424 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 425 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
| OLD | NEW |