Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Unified Diff: chrome/browser/ui/web_applications/hosted_app_tab_helper.h

Issue 64853004: Use high resolution icons where possible for streamlined hosted app icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_experiment_create_app_from_page
Patch Set: rework Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c6d57a4788b24074802f6ae55ea8efb81b601aab
--- /dev/null
+++ b/chrome/browser/ui/web_applications/hosted_app_tab_helper.h
@@ -0,0 +1,109 @@
+// 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 HostedAppTabHelperDelegate;
+class SkBitmap;
+struct WebApplicationInfo;
+
+namespace content {
+struct FaviconURL;
+}
+
+namespace gfx {
+class Size;
+}
+
+// Per-tab class to help manage hosted app taskbar icons and 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);
+
+ // Sets a delegate to notify on icon load. On Windows, this will cause icons
+ // to be fetched immediately once favicon URLs are available.
+ void SetDelegate(HostedAppTabHelperDelegate* delegate);
+
+ 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 the icons in |favicon_url_candidates_|. Downloads are handled in
+ // DidDownloadFavicon().
+ void FetchIcons();
+
+ // Fetches icons for creating the hosted app from |favicon_url_candidates| and
+ // |web_app_info_.icons|. FinishCreateHostedApp() is called on download
+ // completion.
+ void FetchIconsIfNecessaryForCreateHostedApp();
+
+ // 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().
+ 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_;
+
+ // Whether we should fetch icons as soon as the |favicon_url_candidates_| are
+ // updated.
+ bool fetch_icons_immediately_;
+
+ HostedAppTabHelperDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostedAppTabHelper);
+};
+
+#endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698