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 #ifndef CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDROID _H_ | 5 #ifndef CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDROID _H_ |
6 #define CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDROID _H_ | 6 #define CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDROID _H_ |
7 | 7 |
8 #include "components/enhanced_bookmarks/bookmark_image_service.h" | 8 #include "components/enhanced_bookmarks/bookmark_image_service.h" |
9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
10 | 10 |
11 namespace chrome { | 11 namespace chrome { |
12 class BitmapFetcher; | 12 class BitmapFetcher; |
13 } | 13 } |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class BrowserContext; | 16 class BrowserContext; |
17 class RenderFrameHost; | 17 class RenderFrameHost; |
18 class WebContents; | 18 class WebContents; |
19 } | 19 } |
20 | 20 |
21 namespace enhanced_bookmarks { | 21 namespace enhanced_bookmarks { |
22 | 22 |
23 class BookmarkImageServiceAndroid : public BookmarkImageService { | 23 class BookmarkImageServiceAndroid : public BookmarkImageService { |
24 public: | 24 public: |
25 explicit BookmarkImageServiceAndroid(content::BrowserContext* browserContext); | 25 explicit BookmarkImageServiceAndroid(content::BrowserContext* browserContext); |
26 | 26 |
27 ~BookmarkImageServiceAndroid() override; | |
28 | |
27 void RetrieveSalientImage(const GURL& page_url, | 29 void RetrieveSalientImage(const GURL& page_url, |
28 const GURL& image_url, | 30 const GURL& image_url, |
29 const std::string& referrer, | 31 const std::string& referrer, |
30 net::URLRequest::ReferrerPolicy referrer_policy, | 32 net::URLRequest::ReferrerPolicy referrer_policy, |
31 bool update_bookmark) override; | 33 bool update_bookmark) override; |
32 | 34 |
33 // Searches the current page for a salient image, if a url is found the image | 35 // Searches the current page for a salient image, if a url is found the image |
34 // is fetched and stored. | 36 // is fetched and stored. |
35 void RetrieveSalientImageFromContext( | 37 void RetrieveSalientImageFromContext( |
36 content::RenderFrameHost* render_frame_host, | 38 content::RenderFrameHost* render_frame_host, |
37 const GURL& page_url, | 39 const GURL& page_url, |
38 bool update_bookmark); | 40 bool update_bookmark); |
39 | 41 |
40 // Investigates if the tab points to a bookmarked url in needs of an updated | 42 // Investigates if the tab points to a bookmarked url in needs of an updated |
41 // image. If it is, invokes RetrieveSalientImageFromContext() for the relevant | 43 // image. If it is, invokes RetrieveSalientImageFromContext() for the relevant |
42 // urls. | 44 // urls. |
43 void FinishSuccessfulPageLoadForTab(content::WebContents* web_contents, | 45 void FinishSuccessfulPageLoadForTab(content::WebContents* web_contents, |
44 bool update_bookmark); | 46 bool update_bookmark); |
45 | 47 |
46 private: | 48 private: |
47 void RetrieveSalientImageFromContextCallback(const GURL& page_url, | 49 void RetrieveSalientImageFromContextCallback(const GURL& page_url, |
48 bool update_bookmark, | 50 bool update_bookmark, |
49 const base::Value* result); | 51 const base::Value* result); |
50 | 52 |
53 gfx::Image ResizeImage(gfx::Image image) override; | |
54 | |
51 content::BrowserContext* browser_context_; | 55 content::BrowserContext* browser_context_; |
52 // The script injected in a page to extract image urls. | 56 // The script injected in a page to extract image urls. |
53 base::string16 script_; | 57 base::string16 script_; |
58 scoped_ptr<gfx::Size> max_size_; | |
noyau (Ping after 24h)
2015/02/13 09:57:42
Need comment. And why is this a scoped ptr and not
Ian Wen
2015/02/13 22:51:24
Changed to gfx::Size.
| |
54 | 59 |
55 class BitmapFetcherHandler : private chrome::BitmapFetcherDelegate { | 60 class BitmapFetcherHandler : private chrome::BitmapFetcherDelegate { |
56 public: | 61 public: |
57 explicit BitmapFetcherHandler(BookmarkImageServiceAndroid* service, | 62 explicit BitmapFetcherHandler(BookmarkImageServiceAndroid* service, |
58 const GURL& image_url) | 63 const GURL& image_url) |
59 : service_(service), bitmap_fetcher_(image_url, this) {} | 64 : service_(service), bitmap_fetcher_(image_url, this) {} |
60 void Start(content::BrowserContext* browser_context, | 65 void Start(content::BrowserContext* browser_context, |
61 const std::string& referrer, | 66 const std::string& referrer, |
62 net::URLRequest::ReferrerPolicy referrer_policy, | 67 net::URLRequest::ReferrerPolicy referrer_policy, |
63 int load_flags, | 68 int load_flags, |
(...skipping 12 matching lines...) Expand all Loading... | |
76 | 81 |
77 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherHandler); | 82 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherHandler); |
78 }; | 83 }; |
79 | 84 |
80 DISALLOW_COPY_AND_ASSIGN(BookmarkImageServiceAndroid); | 85 DISALLOW_COPY_AND_ASSIGN(BookmarkImageServiceAndroid); |
81 }; | 86 }; |
82 | 87 |
83 } // namespace enhanced_bookmarks | 88 } // namespace enhanced_bookmarks |
84 | 89 |
85 #endif // CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDR OID_H_ | 90 #endif // CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDR OID_H_ |
OLD | NEW |