| 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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "chrome/browser/instant/instant_io_context.h" |
| 10 #include "chrome/browser/thumbnails/thumbnail_service.h" | 11 #include "chrome/browser/thumbnails/thumbnail_service.h" |
| 11 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" | 12 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "net/url_request/url_request.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 17 | 19 |
| 18 // Set ThumbnailService now as Profile isn't thread safe. | 20 // Set ThumbnailService now as Profile isn't thread safe. |
| 19 ThumbnailSource::ThumbnailSource(Profile* profile) | 21 ThumbnailSource::ThumbnailSource(Profile* profile) |
| 20 : thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)) { | 22 : thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)) { |
| 21 } | 23 } |
| 22 | 24 |
| 23 ThumbnailSource::~ThumbnailSource() { | 25 ThumbnailSource::~ThumbnailSource() { |
| 24 } | 26 } |
| 25 | 27 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 // drag the image they get no extension. | 47 // drag the image they get no extension. |
| 46 return "image/png"; | 48 return "image/png"; |
| 47 } | 49 } |
| 48 | 50 |
| 49 MessageLoop* ThumbnailSource::MessageLoopForRequestPath( | 51 MessageLoop* ThumbnailSource::MessageLoopForRequestPath( |
| 50 const std::string& path) const { | 52 const std::string& path) const { |
| 51 // TopSites can be accessed from the IO thread. | 53 // TopSites can be accessed from the IO thread. |
| 52 return thumbnail_service_.get() ? | 54 return thumbnail_service_.get() ? |
| 53 NULL : content::URLDataSource::MessageLoopForRequestPath(path); | 55 NULL : content::URLDataSource::MessageLoopForRequestPath(path); |
| 54 } | 56 } |
| 57 |
| 58 bool ThumbnailSource::ShouldServiceRequest( |
| 59 const net::URLRequest* request) const { |
| 60 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) |
| 61 return InstantIOContext::ShouldServiceRequest(request); |
| 62 return URLDataSource::ShouldServiceRequest(request); |
| 63 } |
| OLD | NEW |