Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/enhanced_bookmarks/android/bookmark_image_service_android.h

Issue 916783003: Restrict salient image size before storing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(
26 content::BrowserContext* browserContext,
27 scoped_refptr<base::SequencedWorkerPool> pool);
28
29 ~BookmarkImageServiceAndroid() override;
26 30
27 void RetrieveSalientImage(const GURL& page_url, 31 void RetrieveSalientImage(const GURL& page_url,
28 const GURL& image_url, 32 const GURL& image_url,
29 const std::string& referrer, 33 const std::string& referrer,
30 net::URLRequest::ReferrerPolicy referrer_policy, 34 net::URLRequest::ReferrerPolicy referrer_policy,
31 bool update_bookmark) override; 35 bool update_bookmark) override;
32 36
33 // Searches the current page for a salient image, if a url is found the image 37 // Searches the current page for a salient image, if a url is found the image
34 // is fetched and stored. 38 // is fetched and stored.
35 void RetrieveSalientImageFromContext( 39 void RetrieveSalientImageFromContext(
36 content::RenderFrameHost* render_frame_host, 40 content::RenderFrameHost* render_frame_host,
37 const GURL& page_url, 41 const GURL& page_url,
38 bool update_bookmark); 42 bool update_bookmark);
39 43
40 // Investigates if the tab points to a bookmarked url in needs of an updated 44 // Investigates if the tab points to a bookmarked url in needs of an updated
41 // image. If it is, invokes RetrieveSalientImageFromContext() for the relevant 45 // image. If it is, invokes RetrieveSalientImageFromContext() for the relevant
42 // urls. 46 // urls.
43 void FinishSuccessfulPageLoadForTab(content::WebContents* web_contents, 47 void FinishSuccessfulPageLoadForTab(content::WebContents* web_contents,
44 bool update_bookmark); 48 bool update_bookmark);
45 49
46 private: 50 private:
47 void RetrieveSalientImageFromContextCallback(const GURL& page_url, 51 void RetrieveSalientImageFromContextCallback(const GURL& page_url,
48 bool update_bookmark, 52 bool update_bookmark,
49 const base::Value* result); 53 const base::Value* result);
50 54
55 // Resizes the image, if it is larger than device display.
56 gfx::Image ResizeImage(gfx::Image image);
57
51 content::BrowserContext* browser_context_; 58 content::BrowserContext* browser_context_;
52 // The script injected in a page to extract image urls. 59 // The script injected in a page to extract image urls.
53 base::string16 script_; 60 base::string16 script_;
61 scoped_refptr<base::SequencedWorkerPool> pool_;
62 scoped_ptr<gfx::Size> max_size_;
Kibeom Kim (inactive) 2015/02/12 23:24:15 looks like this doesn't have to be scoped_ptr? (Al
Kibeom Kim (inactive) 2015/02/13 05:08:53 ping?
54 63
55 class BitmapFetcherHandler : private chrome::BitmapFetcherDelegate { 64 class BitmapFetcherHandler : private chrome::BitmapFetcherDelegate {
56 public: 65 public:
57 explicit BitmapFetcherHandler(BookmarkImageServiceAndroid* service, 66 explicit BitmapFetcherHandler(BookmarkImageServiceAndroid* service,
58 const GURL& image_url) 67 const GURL& image_url)
59 : service_(service), bitmap_fetcher_(image_url, this) {} 68 : service_(service), bitmap_fetcher_(image_url, this) {}
60 void Start(content::BrowserContext* browser_context, 69 void Start(content::BrowserContext* browser_context,
61 const std::string& referrer, 70 const std::string& referrer,
62 net::URLRequest::ReferrerPolicy referrer_policy, 71 net::URLRequest::ReferrerPolicy referrer_policy,
63 int load_flags, 72 int load_flags,
(...skipping 12 matching lines...) Expand all
76 85
77 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherHandler); 86 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherHandler);
78 }; 87 };
79 88
80 DISALLOW_COPY_AND_ASSIGN(BookmarkImageServiceAndroid); 89 DISALLOW_COPY_AND_ASSIGN(BookmarkImageServiceAndroid);
81 }; 90 };
82 91
83 } // namespace enhanced_bookmarks 92 } // namespace enhanced_bookmarks
84 93
85 #endif // CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDR OID_H_ 94 #endif // CHROME_BROWSER_ENHANCED_BOOKMARKS_ANDROID_BOOKMARK_IMAGE_SERVICE_ANDR OID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698