| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) | 288 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) |
| 289 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()), | 289 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()), |
| 290 profile_(profile) { | 290 profile_(profile) { |
| 291 } | 291 } |
| 292 | 292 |
| 293 void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, | 293 void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, |
| 294 bool is_incognito, | 294 bool is_incognito, |
| 295 int request_id) { | 295 int request_id) { |
| 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 297 | 297 |
| 298 if (AppLauncherHandler::HandlePing(profile_, path)) { | 298 if (!path.empty() && path[0] != '#') { |
| 299 return; | |
| 300 } else if (!path.empty() && path[0] != '#') { | |
| 301 // A path under new-tab was requested; it's likely a bad relative | 299 // A path under new-tab was requested; it's likely a bad relative |
| 302 // URL from the new tab page, but in any case it's an error. | 300 // URL from the new tab page, but in any case it's an error. |
| 303 NOTREACHED() << path << " should not have been requested on the NTP"; | 301 NOTREACHED() << path << " should not have been requested on the NTP"; |
| 304 return; | 302 return; |
| 305 } | 303 } |
| 306 | 304 |
| 307 scoped_refptr<RefCountedMemory> html_bytes( | 305 scoped_refptr<RefCountedMemory> html_bytes( |
| 308 NTPResourceCacheFactory::GetForProfile(profile_)-> | 306 NTPResourceCacheFactory::GetForProfile(profile_)-> |
| 309 GetNewTabHTML(is_incognito)); | 307 GetNewTabHTML(is_incognito)); |
| 310 | 308 |
| 311 SendResponse(request_id, html_bytes); | 309 SendResponse(request_id, html_bytes); |
| 312 } | 310 } |
| 313 | 311 |
| 314 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { | 312 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { |
| 315 return "text/html"; | 313 return "text/html"; |
| 316 } | 314 } |
| 317 | 315 |
| 318 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { | 316 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { |
| 319 return false; | 317 return false; |
| 320 } | 318 } |
| OLD | NEW |