| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/image_source.h" | 5 #include "chrome/browser/ui/webui/chromeos/image_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char* kWhitelistedFiles[] = { | 23 const char* kWhitelistedFiles[] = { |
| 24 "fcc/label.png" | 24 "fcc/label.png" |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 // Callback for user_manager::UserImageLoader. | 27 // Callback for user_manager::UserImageLoader. |
| 28 void ImageLoaded( | 28 void ImageLoaded( |
| 29 const content::URLDataSource::GotDataCallback& got_data_callback, | 29 const content::URLDataSource::GotDataCallback& got_data_callback, |
| 30 const user_manager::UserImage& user_image) { | 30 const user_manager::UserImage& user_image) { |
| 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 31 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 32 | 32 |
| 33 if (user_image.has_raw_image()) | 33 if (user_image.has_raw_image()) |
| 34 got_data_callback.Run(new base::RefCountedBytes(user_image.raw_image())); | 34 got_data_callback.Run(new base::RefCountedBytes(user_image.raw_image())); |
| 35 else | 35 else |
| 36 got_data_callback.Run(NULL); | 36 got_data_callback.Run(NULL); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Looks for the image at |path| under the shared assets directory. | 39 // Looks for the image at |path| under the shared assets directory. |
| 40 void StartOnBlockingPool( | 40 void StartOnBlockingPool( |
| 41 const std::string& path, | 41 const std::string& path, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 net::GetWellKnownMimeTypeFromExtension(ext.substr(1), &mime_type); | 103 net::GetWellKnownMimeTypeFromExtension(ext.substr(1), &mime_type); |
| 104 return mime_type; | 104 return mime_type; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool ImageSource::IsWhitelisted(const std::string& path) const { | 107 bool ImageSource::IsWhitelisted(const std::string& path) const { |
| 108 const char** end = kWhitelistedFiles + arraysize(kWhitelistedFiles); | 108 const char** end = kWhitelistedFiles + arraysize(kWhitelistedFiles); |
| 109 return std::find(kWhitelistedFiles, end, path) != end; | 109 return std::find(kWhitelistedFiles, end, path) != end; |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace chromeos | 112 } // namespace chromeos |
| OLD | NEW |