Chromium Code Reviews| Index: chrome/browser/ui/web_applications/hosted_app_tab_helper.h |
| diff --git a/chrome/browser/ui/web_applications/hosted_app_tab_helper.h b/chrome/browser/ui/web_applications/hosted_app_tab_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d2e4fc0a0e220f30e7960b69ec0e482af01292cf |
| --- /dev/null |
| +++ b/chrome/browser/ui/web_applications/hosted_app_tab_helper.h |
| @@ -0,0 +1,94 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_ |
| +#define CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_ |
| + |
| +#include <set> |
| +#include <vector> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| +#include "content/public/browser/web_contents_user_data.h" |
| +#include "ui/gfx/image/image_family.h" |
| + |
| +class Browser; |
| +class SkBitmap; |
| +struct WebApplicationInfo; |
| + |
| +namespace content { |
| +struct FaviconURL; |
| +} |
| + |
| +namespace gfx { |
| +class Size; |
| +} |
| + |
| +// Per-tab class to help create hosted apps from the current web contents. |
| +class HostedAppTabHelper |
| + : public content::WebContentsObserver, |
| + public content::WebContentsUserData<HostedAppTabHelper> { |
| + public: |
| + virtual ~HostedAppTabHelper(); |
| + |
| + // Creates a hosted app for |web_app_info| using the current tab's icons. |
| + void CreateHostedApp(const WebApplicationInfo& web_app_info); |
|
benwells
2013/11/25 00:40:16
I think this is all that needs to be public on thi
calamity
2013/11/29 05:45:36
Done.
|
| + |
| + const gfx::ImageFamily& image_family() const { |
| + return image_family_; |
| + } |
| + |
| + size_t pending_requests() const { |
| + return in_progress_requests_.size(); |
| + } |
| + |
| + // Icon download callback. |
| + void DidDownloadFavicon(int id, |
| + int http_status_code, |
| + const GURL& image_url, |
| + const std::vector<SkBitmap>& bitmaps, |
| + const std::vector<gfx::Size>& original_bitmap_sizes); |
| + |
| + // content::WebContentsObserver overrides: |
| + virtual void DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) OVERRIDE; |
| + virtual void DidUpdateFaviconURL( |
| + int32 page_id, |
| + const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
| + |
| + protected: |
| + // These are protected to be overriden in testing. |
| + explicit HostedAppTabHelper(content::WebContents* web_contents); |
| + |
| + // Initiates a download of the image at |url| and returns the download id. |
| + virtual int DownloadImage(const GURL& url); |
| + |
| + private: |
| + friend class content::WebContentsUserData<HostedAppTabHelper>; |
| + |
| + // Fetches icons for creating the hosted app from |favicon_url_candidates| and |
| + // |web_app_info_.icons|. FinishCreateHostedApp() is called on download |
| + // completion. |
| + void FetchIcons(); |
| + |
| + // Creates and installs the hosted app for |web_app_info_|. |
| + void FinishCreateHostedApp(); |
| + |
| + // Candidate favicon URLs for the current page. Repopulated each page load. |
| + scoped_ptr<std::set<GURL> > favicon_url_candidates_; |
| + |
| + // The current page's icons. Populated by FetchIcons() or CreateHostedApp(). |
|
benwells
2013/11/25 00:40:16
Is this comment out of date? Seems like only Fetch
calamity
2013/11/29 05:45:36
Done.
|
| + gfx::ImageFamily image_family_; |
| + |
| + // Info of a web app to create a hosted app for. |
| + scoped_ptr<WebApplicationInfo> web_app_info_; |
| + |
| + // Request ids of in-progress requests. |
| + std::set<int> in_progress_requests_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HostedAppTabHelper); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_ |