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 23 matching lines...) Expand all Loading... |
34 idr = kSharedResources[i].value; | 34 idr = kSharedResources[i].value; |
35 break; | 35 break; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 return idr; | 39 return idr; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 SharedResourcesDataSource::SharedResourcesDataSource() | 44 SharedResourcesDataSource::SharedResourcesDataSource() { |
45 : DataSource(chrome::kChromeUIResourcesHost, NULL) { | |
46 } | 45 } |
47 | 46 |
48 SharedResourcesDataSource::~SharedResourcesDataSource() { | 47 SharedResourcesDataSource::~SharedResourcesDataSource() { |
49 } | 48 } |
50 | 49 |
| 50 std::string SharedResourcesDataSource::GetSource() { |
| 51 return chrome::kChromeUIResourcesHost; |
| 52 } |
| 53 |
51 void SharedResourcesDataSource::StartDataRequest(const std::string& path, | 54 void SharedResourcesDataSource::StartDataRequest(const std::string& path, |
52 bool is_incognito, | 55 bool is_incognito, |
53 int request_id) { | 56 int request_id) { |
54 int idr = PathToIDR(path); | 57 int idr = PathToIDR(path); |
55 DCHECK_NE(-1, idr) << " path: " << path; | 58 DCHECK_NE(-1, idr) << " path: " << path; |
56 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 59 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
57 scoped_refptr<base::RefCountedStaticMemory> bytes( | 60 scoped_refptr<base::RefCountedStaticMemory> bytes( |
58 rb.LoadDataResourceBytes(idr)); | 61 rb.LoadDataResourceBytes(idr)); |
59 | 62 |
60 SendResponse(request_id, bytes); | 63 url_data_source()->SendResponse(request_id, bytes); |
61 } | 64 } |
62 | 65 |
63 std::string SharedResourcesDataSource::GetMimeType( | 66 std::string SharedResourcesDataSource::GetMimeType( |
64 const std::string& path) const { | 67 const std::string& path) const { |
65 // Requests should not block on the disk! On Windows this goes to the | 68 // Requests should not block on the disk! On Windows this goes to the |
66 // registry. | 69 // registry. |
67 // http://code.google.com/p/chromium/issues/detail?id=59849 | 70 // http://code.google.com/p/chromium/issues/detail?id=59849 |
68 base::ThreadRestrictions::ScopedAllowIO allow_io; | 71 base::ThreadRestrictions::ScopedAllowIO allow_io; |
69 | 72 |
70 std::string mime_type; | 73 std::string mime_type; |
71 net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type); | 74 net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type); |
72 return mime_type; | 75 return mime_type; |
73 } | 76 } |
OLD | NEW |