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/ntp/thumbnail_source.h" | 5 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 } else if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 53 } else if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
54 path = InstantService::MaybeTranslateInstantPathOnUI(profile_, raw_path); | 54 path = InstantService::MaybeTranslateInstantPathOnUI(profile_, raw_path); |
55 } | 55 } |
56 | 56 |
57 scoped_refptr<base::RefCountedMemory> data; | 57 scoped_refptr<base::RefCountedMemory> data; |
58 if (thumbnail_service_->GetPageThumbnail(GURL(path), &data)) { | 58 if (thumbnail_service_->GetPageThumbnail(GURL(path), &data)) { |
59 // We have the thumbnail. | 59 // We have the thumbnail. |
60 callback.Run(data.get()); | 60 callback.Run(data.get()); |
61 } else { | 61 } else { |
62 callback.Run(default_thumbnail_); | 62 callback.Run(default_thumbnail_.get()); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 std::string ThumbnailSource::GetMimeType(const std::string&) const { | 66 std::string ThumbnailSource::GetMimeType(const std::string&) const { |
67 // We need to explicitly return a mime type, otherwise if the user tries to | 67 // We need to explicitly return a mime type, otherwise if the user tries to |
68 // drag the image they get no extension. | 68 // drag the image they get no extension. |
69 return "image/png"; | 69 return "image/png"; |
70 } | 70 } |
71 | 71 |
72 base::MessageLoop* ThumbnailSource::MessageLoopForRequestPath( | 72 base::MessageLoop* ThumbnailSource::MessageLoopForRequestPath( |
(...skipping 17 matching lines...) Expand all Loading... |
90 if (!MessageLoopForRequestPath(raw_path)) { | 90 if (!MessageLoopForRequestPath(raw_path)) { |
91 id_to_url_map_[raw_path] = | 91 id_to_url_map_[raw_path] = |
92 InstantService::MaybeTranslateInstantPathOnIO(request, raw_path); | 92 InstantService::MaybeTranslateInstantPathOnIO(request, raw_path); |
93 } | 93 } |
94 return true; | 94 return true; |
95 } | 95 } |
96 return false; | 96 return false; |
97 } | 97 } |
98 return URLDataSource::ShouldServiceRequest(request); | 98 return URLDataSource::ShouldServiceRequest(request); |
99 } | 99 } |
OLD | NEW |