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/new_tab_ui.h" | 5 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "apps/app_launcher.h" | 9 #include "apps/app_launcher.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) | 308 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) |
309 : profile_(profile) { | 309 : profile_(profile) { |
310 } | 310 } |
311 | 311 |
312 std::string NewTabUI::NewTabHTMLSource::GetSource() { | 312 std::string NewTabUI::NewTabHTMLSource::GetSource() { |
313 return chrome::kChromeUINewTabHost; | 313 return chrome::kChromeUINewTabHost; |
314 } | 314 } |
315 | 315 |
316 void NewTabUI::NewTabHTMLSource::StartDataRequest( | 316 void NewTabUI::NewTabHTMLSource::StartDataRequest( |
317 const std::string& path, | 317 const std::string& path, |
318 bool is_incognito, | 318 const content::URLDataSource::ExtraRequestInfo& info, |
319 const content::URLDataSource::GotDataCallback& callback) { | 319 const content::URLDataSource::GotDataCallback& callback) { |
320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
321 | 321 |
322 std::map<std::string, std::pair<std::string, int> >::iterator it = | 322 std::map<std::string, std::pair<std::string, int> >::iterator it = |
323 resource_map_.find(path); | 323 resource_map_.find(path); |
324 if (it != resource_map_.end()) { | 324 if (it != resource_map_.end()) { |
325 scoped_refptr<base::RefCountedStaticMemory> resource_bytes( | 325 scoped_refptr<base::RefCountedStaticMemory> resource_bytes( |
326 it->second.second ? | 326 it->second.second ? |
327 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 327 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
328 it->second.second) : | 328 it->second.second) : |
(...skipping 11 matching lines...) Expand all Loading... |
340 // '?2314124523523'. | 340 // '?2314124523523'. |
341 // See http://crbug.com/150252. | 341 // See http://crbug.com/150252. |
342 #if !defined(OS_ANDROID) | 342 #if !defined(OS_ANDROID) |
343 NOTREACHED() << path << " should not have been requested on the NTP"; | 343 NOTREACHED() << path << " should not have been requested on the NTP"; |
344 #endif | 344 #endif |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 scoped_refptr<base::RefCountedMemory> html_bytes( | 348 scoped_refptr<base::RefCountedMemory> html_bytes( |
349 NTPResourceCacheFactory::GetForProfile(profile_)-> | 349 NTPResourceCacheFactory::GetForProfile(profile_)-> |
350 GetNewTabHTML(is_incognito)); | 350 GetNewTabHTML(info.is_incognito)); |
351 | 351 |
352 callback.Run(html_bytes); | 352 callback.Run(html_bytes); |
353 } | 353 } |
354 | 354 |
355 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string& resource) | 355 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string& resource) |
356 const { | 356 const { |
357 std::map<std::string, std::pair<std::string, int> >::const_iterator it = | 357 std::map<std::string, std::pair<std::string, int> >::const_iterator it = |
358 resource_map_.find(resource); | 358 resource_map_.find(resource); |
359 if (it != resource_map_.end()) | 359 if (it != resource_map_.end()) |
360 return it->second.first; | 360 return it->second.first; |
(...skipping 11 matching lines...) Expand all Loading... |
372 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 372 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
373 const char* mime_type, | 373 const char* mime_type, |
374 int resource_id) { | 374 int resource_id) { |
375 DCHECK(resource); | 375 DCHECK(resource); |
376 DCHECK(mime_type); | 376 DCHECK(mime_type); |
377 resource_map_[std::string(resource)] = | 377 resource_map_[std::string(resource)] = |
378 std::make_pair(std::string(mime_type), resource_id); | 378 std::make_pair(std::string(mime_type), resource_id); |
379 } | 379 } |
380 | 380 |
381 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 381 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
OLD | NEW |