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 // Per-tab class to help manage metro pinning.
     17 class MetroPinTabHelper
     18     : public content::WebContentsObserver,
     19       public content::WebContentsUserData<MetroPinTabHelper> {
     20  public:
     21   virtual ~MetroPinTabHelper();
     22 
     23   bool IsPinned() const;
     24 
     25   void TogglePinnedToStartScreen();
     26 
     27   // content::WebContentsObserver overrides:
     28   virtual void DidNavigateMainFrame(
     29       const content::LoadCommittedDetails& details,
     30       const content::FrameNavigateParams& params) OVERRIDE;
     31   virtual void DidUpdateFaviconURL(
     32       int32 page_id,
     33       const std::vector<content::FaviconURL>& candidates) OVERRIDE;
     34 
     35  private:
     36   // The FaviconDownloader class handles downloading the favicons when a page
     37   // is being pinned. After it has downloaded any available favicons it will
     38   // continue on with the page pinning action.
     39   class FaviconChooser;
     40 
     41   explicit MetroPinTabHelper(content::WebContents* web_contents);
     42   friend class content::WebContentsUserData<MetroPinTabHelper>;
     43 
     44   // Favicon download callback.
     45   void DidDownloadFavicon(int id,
     46                           int http_status_code,
     47                           const GURL& image_url,
     48                           int requested_size,
     49                           const std::vector<SkBitmap>& bitmaps);
     50 
     51   void UnPinPageFromStartScreen();
     52 
     53   // Called by the |favicon_chooser_| when it has finished.
     54   void FaviconDownloaderFinished();
     55 
     56   // Candidate Favicon URLs for the current page.
     57   std::vector<content::FaviconURL> favicon_url_candidates_;
     58 
     59   // The currently active FaviconChooser, if there is one.
     60   scoped_ptr<FaviconChooser> favicon_chooser_;
     61 
     62 
     63   DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper);
     64 };
     65 
     66 #endif  // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_
     67