| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void NewTabUI::NewTabHTMLSource::StartDataRequest( | 180 void NewTabUI::NewTabHTMLSource::StartDataRequest( |
| 181 const std::string& path, | 181 const std::string& path, |
| 182 int render_process_id, | 182 int render_process_id, |
| 183 int render_frame_id, | 183 int render_frame_id, |
| 184 const content::URLDataSource::GotDataCallback& callback) { | 184 const content::URLDataSource::GotDataCallback& callback) { |
| 185 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 185 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 186 | 186 |
| 187 std::map<std::string, std::pair<std::string, int> >::iterator it = | 187 std::map<std::string, std::pair<std::string, int> >::iterator it = |
| 188 resource_map_.find(path); | 188 resource_map_.find(path); |
| 189 if (it != resource_map_.end()) { | 189 if (it != resource_map_.end()) { |
| 190 scoped_refptr<base::RefCountedStaticMemory> resource_bytes( | 190 scoped_refptr<base::RefCountedMemory> resource_bytes( |
| 191 it->second.second ? | 191 it->second.second ? |
| 192 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 192 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 193 it->second.second) : | 193 it->second.second) : |
| 194 new base::RefCountedStaticMemory); | 194 new base::RefCountedStaticMemory); |
| 195 callback.Run(resource_bytes.get()); | 195 callback.Run(resource_bytes.get()); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 if (!path.empty() && path[0] != '#') { | 199 if (!path.empty() && path[0] != '#') { |
| 200 // A path under new-tab was requested; it's likely a bad relative | 200 // A path under new-tab was requested; it's likely a bad relative |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 235 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
| 236 const char* mime_type, | 236 const char* mime_type, |
| 237 int resource_id) { | 237 int resource_id) { |
| 238 DCHECK(resource); | 238 DCHECK(resource); |
| 239 DCHECK(mime_type); | 239 DCHECK(mime_type); |
| 240 resource_map_[std::string(resource)] = | 240 resource_map_[std::string(resource)] = |
| 241 std::make_pair(std::string(mime_type), resource_id); | 241 std::make_pair(std::string(mime_type), resource_id); |
| 242 } | 242 } |
| 243 | 243 |
| 244 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 244 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
| OLD | NEW |