Home | History | Annotate | Download | only in ui
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_
      6 #define CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_
      7 
      8 #include <vector>
      9 
     10 #include "content/public/browser/web_contents_observer.h"
     11 #include "content/public/browser/web_contents_user_data.h"
     12 #include "content/public/common/favicon_url.h"
     13 #include "third_party/skia/include/core/SkBitmap.h"
     14 #include "ui/gfx/image/image_skia.h"
     15 
     16 namespace gfx {
     17 class Size;
     18 }
     19 
     20 // Per-tab class to help manage metro pinning.
     21 class MetroPinTabHelper
     22     : public content::WebContentsObserver,
     23       public content::WebContentsUserData<MetroPinTabHelper> {
     24  public:
     25   virtual ~MetroPinTabHelper();
     26 
     27   bool IsPinned() const;
     28 
     29   void TogglePinnedToStartScreen();
     30 
     31   // content::WebContentsObserver overrides:
     32   virtual void DidNavigateMainFrame(
     33       const content::LoadCommittedDetails& details,
     34       const content::FrameNavigateParams& params) OVERRIDE;
     35   virtual void DidUpdateFaviconURL(
     36       const std::vector<content::FaviconURL>& candidates) OVERRIDE;
     37 
     38  private:
     39   // The FaviconDownloader class handles downloading the favicons when a page
     40   // is being pinned. After it has downloaded any available favicons it will
     41   // continue on with the page pinning action.
     42   class FaviconChooser;
     43 
     44   explicit MetroPinTabHelper(content::WebContents* web_contents);
     45   friend class content::WebContentsUserData<MetroPinTabHelper>;
     46 
     47   // Favicon download callback.
     48   void DidDownloadFavicon(int id,
     49                           int http_status_code,
     50                           const GURL& image_url,
     51                           const std::vector<SkBitmap>& bitmaps,
     52                           const std::vector<gfx::Size>& original_bitmap_sizes);
     53 
     54   void UnPinPageFromStartScreen();
     55 
     56   // Called by the |favicon_chooser_| when it has finished.
     57   void FaviconDownloaderFinished();
     58 
     59   // Candidate Favicon URLs for the current page.
     60   std::vector<content::FaviconURL> favicon_url_candidates_;
     61 
     62   // The currently active FaviconChooser, if there is one.
     63   scoped_ptr<FaviconChooser> favicon_chooser_;
     64 
     65 
     66   DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper);
     67 };
     68 
     69 #endif  // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_
     70