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

Side by Side Diff: chrome/browser/ui/webui/shared_resources_data_source.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Convert ptr to bool for win compile. Created 8 years, 7 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/shared_resources_data_source.h" 5 #include "chrome/browser/ui/webui/shared_resources_data_source.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "chrome/browser/io_thread.h" 13 #include "chrome/browser/io_thread.h"
14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "grit/shared_resources.h" 17 #include "grit/shared_resources.h"
18 #include "grit/shared_resources_map.h" 18 #include "grit/shared_resources_map.h"
19 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
20 #include "grit/ui_resources.h" 20 #include "grit/ui_resources.h"
21 #include "net/base/mime_util.h" 21 #include "net/base/mime_util.h"
22 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/resource/resource_handle.h"
23 #include "ui/base/ui_base_switches.h" 24 #include "ui/base/ui_base_switches.h"
24 25
25 namespace { 26 namespace {
26 27
27 int PathToIDR(const std::string& path) { 28 int PathToIDR(const std::string& path) {
28 int idr = -1; 29 int idr = -1;
29 if (path == "ui/resources/folder_closed.png") { 30 if (path == "ui/resources/folder_closed.png") {
30 idr = IDR_FOLDER_CLOSED; 31 idr = IDR_FOLDER_CLOSED;
31 } else if (path == "ui/resources/folder_closed_rtl.png") { 32 } else if (path == "ui/resources/folder_closed_rtl.png") {
32 idr = IDR_FOLDER_CLOSED_RTL; 33 idr = IDR_FOLDER_CLOSED_RTL;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SharedResourcesDataSource::~SharedResourcesDataSource() { 69 SharedResourcesDataSource::~SharedResourcesDataSource() {
69 } 70 }
70 71
71 void SharedResourcesDataSource::StartDataRequest(const std::string& path, 72 void SharedResourcesDataSource::StartDataRequest(const std::string& path,
72 bool is_incognito, 73 bool is_incognito,
73 int request_id) { 74 int request_id) {
74 int idr = PathToIDR(path); 75 int idr = PathToIDR(path);
75 DCHECK_NE(-1, idr) << " path: " << path; 76 DCHECK_NE(-1, idr) << " path: " << path;
76 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 77 const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
77 scoped_refptr<base::RefCountedStaticMemory> bytes( 78 scoped_refptr<base::RefCountedStaticMemory> bytes(
78 rb.LoadDataResourceBytes(idr)); 79 rb.LoadDataResourceBytes(idr, ui::ResourceHandle::kScaleFactorNone));
79 80
80 SendResponse(request_id, bytes); 81 SendResponse(request_id, bytes);
81 } 82 }
82 83
83 std::string SharedResourcesDataSource::GetMimeType( 84 std::string SharedResourcesDataSource::GetMimeType(
84 const std::string& path) const { 85 const std::string& path) const {
85 // Requests should not block on the disk! On Windows this goes to the 86 // Requests should not block on the disk! On Windows this goes to the
86 // registry. 87 // registry.
87 // http://code.google.com/p/chromium/issues/detail?id=59849 88 // http://code.google.com/p/chromium/issues/detail?id=59849
88 base::ThreadRestrictions::ScopedAllowIO allow_io; 89 base::ThreadRestrictions::ScopedAllowIO allow_io;
89 90
90 std::string mime_type; 91 std::string mime_type;
91 net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type); 92 net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type);
92 return mime_type; 93 return mime_type;
93 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698