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

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: 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..d1b7e757234b7593cb7c4cd71a6dd7dde06885a1
--- /dev/null
+++ b/chrome/browser/ui/web_applications/hosted_app_tab_helper.h
@@ -0,0 +1,101 @@
+// 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.
+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);
+
+ const gfx::ImageFamily& icon_family() {
+ return icon_family_;
+ }
+
+ void set_fetch_icons_immediately(bool fetch_icons_immediately) {
+ fetch_icons_immediately_ = fetch_icons_immediately;
tapted 2013/11/11 08:52:57 nit: remove extra space after `=`
calamity 2013/11/13 06:37:14 Done.
+ }
+
+ void set_delegate(HostedAppTabHelperDelegate* delegate) {
+ delegate_ = delegate;
+ }
+
+ private:
+ explicit HostedAppTabHelper(content::WebContents* web_contents);
+ 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 completion.
+ void FetchIconsIfNecessaryForCreateHostedApp();
+
+ // Creates and installs the hosted app for |web_app_info_|.
+ void FinishCreateHostedApp();
+
+ // 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;
+
+ // Candidate favicon URLs for the current page. Repopulated each page load.
+ scoped_ptr<std::set<GURL> > favicon_url_candidates_;
+
+ // The current page's icons. This stores . Populated by FetchIcons().
tapted 2013/11/11 08:52:57 there's a sentence fragment in the comment here
calamity 2013/11/13 06:37:14 Done.
+ gfx::ImageFamily icon_family_;
tapted 2013/11/11 08:52:57 nit: perhaps call this image_family_? (icon_family
calamity 2013/11/13 06:37:14 Done.
+
+ // Request ids of in-progress requests.
+ std::set<int> in_progress_requests_;
+
+ // Info of a web app to create a hosted app for.
+ scoped_ptr<WebApplicationInfo> web_app_info_;
+
+ // 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