Index: chrome/browser/ui/app_list/search/launcher_search/extension_badged_icon_image.h |
diff --git a/chrome/browser/ui/app_list/search/launcher_search/extension_badged_icon_image.h b/chrome/browser/ui/app_list/search/launcher_search/extension_badged_icon_image.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..55a5e187aca5fe806d9e1976703dcee692ad7afb |
--- /dev/null |
+++ b/chrome/browser/ui/app_list/search/launcher_search/extension_badged_icon_image.h |
@@ -0,0 +1,73 @@ |
+// Copyright 2015 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_APP_LIST_SEARCH_LAUNCHER_SEARCH_EXTENSION_BADGED_ICON_IMAGE_H_ |
+#define CHROME_BROWSER_UI_APP_LIST_SEARCH_LAUNCHER_SEARCH_EXTENSION_BADGED_ICON_IMAGE_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "extensions/browser/extension_icon_image.h" |
+#include "extensions/common/extension.h" |
+#include "ui/gfx/image/image_skia.h" |
+#include "url/gurl.h" |
+ |
+namespace app_list { |
+ |
+// Provides an icon image which is badged with extension icon. If custom icon |
+// image is not specified, extension icon will be used. |
+class ExtensionBadgedIconImage : extensions::IconImage::Observer { |
+ public: |
+ class Observer { |
+ public: |
+ // Called when icon image is changed. To obtain the new image, call |
+ // GetIconImage method. |
+ virtual void OnIconImageChanged(ExtensionBadgedIconImage* image) = 0; |
+ }; |
+ |
+ ExtensionBadgedIconImage(const GURL& icon_url, |
Matt Giuca
2015/04/22 03:31:37
custom_icon_url
Also add comment:
// If |icon_url
yawano
2015/04/22 12:23:47
Done.
|
+ Profile* profile, |
+ const extensions::Extension* extension, |
+ const int icon_dimension); |
+ ~ExtensionBadgedIconImage() override; |
+ |
+ // Adds |observer| to listen icon image changed event. To get fresh icon |
+ // image, you need to add observer before you call GetIconImage. |
+ void AddObserver(Observer* observer); |
+ |
+ // Removes |observer|. |
+ void RemoveObserver(Observer* observer); |
+ |
+ // Called by |extension_icon_image_| when extension icon image is changed. |
Matt Giuca
2015/04/22 03:31:37
Convention is not to document overrides. Just repl
yawano
2015/04/22 12:23:47
Done.
|
+ void OnExtensionIconImageChanged(extensions::IconImage* image) override; |
+ |
+ // Returns badged icon image |
+ gfx::ImageSkia GetIconImage() const; |
Matt Giuca
2015/04/22 03:31:37
const gfx::ImageSkia&
yawano
2015/04/22 12:23:47
Done.
|
+ |
+ private: |
+ // Called when custom icon image is loaded. |
+ void OnCustomIconLoaded(const gfx::Image& image); |
+ |
+ // Updates icon image. |
+ void Update(); |
+ |
+ // Sets new icon image, and notify to observers. |
+ void SetIconImage(const gfx::ImageSkia& image); |
+ |
+ const extensions::IconImage extension_icon_image_; |
+ gfx::ImageSkia custom_icon_image_; |
+ |
+ // Badged icon image. |
Matt Giuca
2015/04/22 03:31:37
Remove this comment.
yawano
2015/04/22 12:23:47
Done.
|
+ gfx::ImageSkia badged_icon_image_; |
+ |
+ std::set<Observer*> observers_; |
Matt Giuca
2015/04/22 03:31:37
nit: Blank line after.
Also, maybe swap this with
yawano
2015/04/22 12:23:47
Done.
|
+ const gfx::Size icon_size_; |
+ |
+ base::WeakPtrFactory<ExtensionBadgedIconImage> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionBadgedIconImage); |
+}; |
+ |
+} // namespace app_list |
+ |
+#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_LAUNCHER_SEARCH_EXTENSION_BADGED_ICON_IMAGE_H_ |