Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / components / favicon / core / favicon_driver.h
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
7
8 class GURL;
9
10 namespace gfx {
11 class Image;
12 }
13
14 // Interface that allows Favicon core code to interact with its driver (i.e.,
15 // obtain information from it and give information to it). A concrete
16 // implementation must be provided by the driver.
17 class FaviconDriver {
18  public:
19
20   // Starts the download for the given favicon. When finished, the driver
21   // will call OnDidDownloadFavicon() with the results.
22   // Returns the unique id of the download request. The id will be passed
23   // in OnDidDownloadFavicon().
24   // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
25   // from the bitmap results. If there are no bitmap results <=
26   // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and
27   // is the only result. A |max_bitmap_size| of 0 means unlimited.
28   virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0;
29
30   // Returns whether the user is operating in an off-the-record context.
31   virtual bool IsOffTheRecord() = 0;
32
33   // Returns the bitmap of the current page's favicon. Requires GetActiveURL()
34   // to be valid.
35   virtual const gfx::Image GetActiveFaviconImage() = 0;
36
37   // Returns the URL of the current page's favicon. Requires GetActiveURL() to
38   // be valid.
39   virtual const GURL GetActiveFaviconURL() = 0;
40
41   // Returns whether the page's favicon is valid (returns false if the default
42   // favicon is being used). Requires GetActiveURL() to be valid.
43   virtual bool GetActiveFaviconValidity() = 0;
44
45   // Returns the URL of the current page, if any. Returns an invalid
46   // URL otherwise.
47   virtual const GURL GetActiveURL() = 0;
48
49   // Notifies the driver a favicon image is available. |image| is not
50   // necessarily 16x16. |icon_url| is the url the image is from. If
51   // |is_active_favicon| is true the image corresponds to the favicon
52   // (possibly empty) of the page.
53   virtual void OnFaviconAvailable(const gfx::Image& image,
54                                   const GURL& icon_url,
55                                   bool is_active_favicon) = 0;
56 };
57
58 #endif  // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_