Upstream version 10.38.217.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / android / xwalk_icon_helper.h
1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef XWALK_RUNTIME_BROWSER_ANDROID_XWALK_ICON_HELPER_H_
6 #define XWALK_RUNTIME_BROWSER_ANDROID_XWALK_ICON_HELPER_H_
7
8 #include <string>
9 #include <vector>
10 #include "content/public/browser/web_contents_observer.h"
11 #include "url/gurl.h"
12
13 class SkBitmap;
14
15 namespace content {
16 struct FaviconURL;
17 class WebContents;
18 }
19
20 namespace gfx {
21 class Size;
22 }
23
24 namespace xwalk {
25
26 class XWalkIconHelper : public content::WebContentsObserver {
27  public:
28   class Listener {
29    public:
30     virtual void OnIconAvailable(const GURL& icon_url) = 0;
31     virtual void OnReceivedIcon(const GURL& icon_url,
32                                 const SkBitmap& bitmap) = 0;
33    protected:
34     virtual ~Listener() {}
35   };
36
37   explicit XWalkIconHelper(content::WebContents* web_contents);
38   virtual ~XWalkIconHelper();
39
40   void SetListener(Listener* listener);
41
42   void DownloadIcon(const GURL& icon_url);
43
44   // From WebContentsObserver
45   virtual void DidUpdateFaviconURL(
46       const std::vector<content::FaviconURL>& candidates) OVERRIDE;
47
48   void DownloadFaviconCallback(
49       int id,
50       int http_status_code,
51       const GURL& image_url,
52       const std::vector<SkBitmap>& bitmaps,
53       const std::vector<gfx::Size>& original_bitmap_sizes);
54
55  private:
56   Listener* listener_;
57
58   DISALLOW_COPY_AND_ASSIGN(XWalkIconHelper);
59 };
60
61 }  // namespace xwalk
62
63 #endif  // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_ICON_HELPER_H_