| 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/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/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 SharedResourcesDataSource::~SharedResourcesDataSource() { | 69 SharedResourcesDataSource::~SharedResourcesDataSource() { |
| 70 } | 70 } |
| 71 | 71 |
| 72 void SharedResourcesDataSource::StartDataRequest(const std::string& path, | 72 void SharedResourcesDataSource::StartDataRequest(const std::string& path, |
| 73 bool is_incognito, | 73 bool is_incognito, |
| 74 int request_id) { | 74 int request_id) { |
| 75 int idr = PathToIDR(path); | 75 int idr = PathToIDR(path); |
| 76 DCHECK_NE(-1, idr) << " path: " << path; | 76 DCHECK_NE(-1, idr) << " path: " << path; |
| 77 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 77 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 78 scoped_refptr<base::RefCountedStaticMemory> bytes( | 78 scoped_refptr<base::RefCountedStaticMemory> bytes( |
| 79 rb.LoadDataResourceBytes(idr)); | 79 rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_NONE)); |
| 80 | 80 |
| 81 SendResponse(request_id, bytes); | 81 SendResponse(request_id, bytes); |
| 82 } | 82 } |
| 83 | 83 |
| 84 std::string SharedResourcesDataSource::GetMimeType( | 84 std::string SharedResourcesDataSource::GetMimeType( |
| 85 const std::string& path) const { | 85 const std::string& path) const { |
| 86 // 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 |
| 87 // registry. | 87 // registry. |
| 88 // http://code.google.com/p/chromium/issues/detail?id=59849 | 88 // http://code.google.com/p/chromium/issues/detail?id=59849 |
| 89 base::ThreadRestrictions::ScopedAllowIO allow_io; | 89 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 90 | 90 |
| 91 std::string mime_type; | 91 std::string mime_type; |
| 92 net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type); | 92 net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type); |
| 93 return mime_type; | 93 return mime_type; |
| 94 } | 94 } |
| OLD | NEW |