Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui.cc

Issue 14039004: Add int params to URLDataSource::StartDataRequest(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changing struct -> ints. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/webui/metrics_handler.h" 17 #include "chrome/browser/ui/webui/metrics_handler.h"
18 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" 18 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h"
19 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" 19 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h"
20 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" 20 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
21 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 21 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
22 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 22 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
23 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" 23 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h"
24 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "components/user_prefs/pref_registry_syncable.h" 27 #include "components/user_prefs/pref_registry_syncable.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/render_view_host.h" 31 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/url_data_source.h" 32 #include "content/public/browser/url_data_source.h"
32 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_ui.h" 34 #include "content/public/browser/web_ui.h"
34 #include "grit/browser_resources.h" 35 #include "grit/browser_resources.h"
35 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
36 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
37 38
38 #if !defined(OS_ANDROID) 39 #if !defined(OS_ANDROID)
39 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 40 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) 309 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile)
309 : profile_(profile) { 310 : profile_(profile) {
310 } 311 }
311 312
312 std::string NewTabUI::NewTabHTMLSource::GetSource() { 313 std::string NewTabUI::NewTabHTMLSource::GetSource() {
313 return chrome::kChromeUINewTabHost; 314 return chrome::kChromeUINewTabHost;
314 } 315 }
315 316
316 void NewTabUI::NewTabHTMLSource::StartDataRequest( 317 void NewTabUI::NewTabHTMLSource::StartDataRequest(
317 const std::string& path, 318 const std::string& path,
318 bool is_incognito, 319 int render_process_id,
320 int render_view_id,
319 const content::URLDataSource::GotDataCallback& callback) { 321 const content::URLDataSource::GotDataCallback& callback) {
320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 322 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
321 323
322 std::map<std::string, std::pair<std::string, int> >::iterator it = 324 std::map<std::string, std::pair<std::string, int> >::iterator it =
323 resource_map_.find(path); 325 resource_map_.find(path);
324 if (it != resource_map_.end()) { 326 if (it != resource_map_.end()) {
325 scoped_refptr<base::RefCountedStaticMemory> resource_bytes( 327 scoped_refptr<base::RefCountedStaticMemory> resource_bytes(
326 it->second.second ? 328 it->second.second ?
327 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 329 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
328 it->second.second) : 330 it->second.second) :
329 new base::RefCountedStaticMemory); 331 new base::RefCountedStaticMemory);
330 callback.Run(resource_bytes); 332 callback.Run(resource_bytes);
331 return; 333 return;
332 } 334 }
333 335
334 if (!path.empty() && path[0] != '#') { 336 if (!path.empty() && path[0] != '#') {
335 // A path under new-tab was requested; it's likely a bad relative 337 // A path under new-tab was requested; it's likely a bad relative
336 // URL from the new tab page, but in any case it's an error. 338 // URL from the new tab page, but in any case it's an error.
337 339
338 // TODO(dtrainor): Can remove this #if check once we update the 340 // TODO(dtrainor): Can remove this #if check once we update the
339 // accessibility script to no longer try to access urls like 341 // accessibility script to no longer try to access urls like
340 // '?2314124523523'. 342 // '?2314124523523'.
341 // See http://crbug.com/150252. 343 // See http://crbug.com/150252.
342 #if !defined(OS_ANDROID) 344 #if !defined(OS_ANDROID)
343 NOTREACHED() << path << " should not have been requested on the NTP"; 345 NOTREACHED() << path << " should not have been requested on the NTP";
344 #endif 346 #endif
345 return; 347 return;
346 } 348 }
347 349
350 content::RenderProcessHost* render_host =
351 content::RenderProcessHost::FromID(render_process_id);
352 DCHECK(render_host != NULL);
jam 2013/04/17 00:45:09 ditto
Jered 2013/04/17 01:03:08 Done.
353 const bool is_incognito = render_host->GetBrowserContext()->IsOffTheRecord();
348 scoped_refptr<base::RefCountedMemory> html_bytes( 354 scoped_refptr<base::RefCountedMemory> html_bytes(
349 NTPResourceCacheFactory::GetForProfile(profile_)-> 355 NTPResourceCacheFactory::GetForProfile(profile_)->
350 GetNewTabHTML(is_incognito)); 356 GetNewTabHTML(is_incognito));
351 357
352 callback.Run(html_bytes); 358 callback.Run(html_bytes);
353 } 359 }
354 360
355 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string& resource) 361 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string& resource)
356 const { 362 const {
357 std::map<std::string, std::pair<std::string, int> >::const_iterator it = 363 std::map<std::string, std::pair<std::string, int> >::const_iterator it =
(...skipping 14 matching lines...) Expand all
372 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 378 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
373 const char* mime_type, 379 const char* mime_type,
374 int resource_id) { 380 int resource_id) {
375 DCHECK(resource); 381 DCHECK(resource);
376 DCHECK(mime_type); 382 DCHECK(mime_type);
377 resource_map_[std::string(resource)] = 383 resource_map_[std::string(resource)] =
378 std::make_pair(std::string(mime_type), resource_id); 384 std::make_pair(std::string(mime_type), resource_id);
379 } 385 }
380 386
381 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} 387 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698