| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 if (!path.empty() && path[0] != '#') { | 200 if (!path.empty() && path[0] != '#') { |
| 201 // A path under new-tab was requested; it's likely a bad relative | 201 // A path under new-tab was requested; it's likely a bad relative |
| 202 // URL from the new tab page, but in any case it's an error. | 202 // URL from the new tab page, but in any case it's an error. |
| 203 NOTREACHED() << path << " should not have been requested on the NTP"; | 203 NOTREACHED() << path << " should not have been requested on the NTP"; |
| 204 callback.Run(NULL); | 204 callback.Run(NULL); |
| 205 return; | 205 return; |
| 206 } | 206 } |
| 207 | 207 |
| 208 content::WebContents* web_contents = wc_getter.Run(); |
| 208 content::RenderProcessHost* render_host = | 209 content::RenderProcessHost* render_host = |
| 209 wc_getter.Run()->GetRenderProcessHost(); | 210 web_contents ? web_contents->GetRenderProcessHost() : nullptr; |
| 210 NTPResourceCache::WindowType win_type = NTPResourceCache::GetWindowType( | 211 NTPResourceCache::WindowType win_type = NTPResourceCache::GetWindowType( |
| 211 profile_, render_host); | 212 profile_, render_host); |
| 212 scoped_refptr<base::RefCountedMemory> html_bytes( | 213 scoped_refptr<base::RefCountedMemory> html_bytes( |
| 213 NTPResourceCacheFactory::GetForProfile(profile_)-> | 214 NTPResourceCacheFactory::GetForProfile(profile_)-> |
| 214 GetNewTabHTML(win_type)); | 215 GetNewTabHTML(win_type)); |
| 215 | 216 |
| 216 callback.Run(html_bytes.get()); | 217 callback.Run(html_bytes.get()); |
| 217 } | 218 } |
| 218 | 219 |
| 219 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string& resource) | 220 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string& resource) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 256 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
| 256 const char* mime_type, | 257 const char* mime_type, |
| 257 int resource_id) { | 258 int resource_id) { |
| 258 DCHECK(resource); | 259 DCHECK(resource); |
| 259 DCHECK(mime_type); | 260 DCHECK(mime_type); |
| 260 resource_map_[std::string(resource)] = | 261 resource_map_[std::string(resource)] = |
| 261 std::make_pair(std::string(mime_type), resource_id); | 262 std::make_pair(std::string(mime_type), resource_id); |
| 262 } | 263 } |
| 263 | 264 |
| 264 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 265 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
| OLD | NEW |