Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ |
| 6 #define CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ | 6 #define CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/win/scoped_comptr.h" | 18 #include "base/win/scoped_comptr.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 20 | 20 |
| 21 // Represents a class used for creating an IShellLink object. | 21 // Represents a class used for creating an IShellLink object. |
| 22 // Even though an IShellLink also needs the absolute path to an application to | 22 // Even though an IShellLink also needs the absolute path to an application to |
| 23 // be executed, this class does not have any variables for it because current | 23 // be executed, this class does not have any variables for it because current |
| 24 // users always use "chrome.exe" as the application. | 24 // users always use "chrome.exe" as the application. |
| 25 class ShellLinkItem : public base::RefCountedThreadSafe<ShellLinkItem> { | 25 class ShellLinkItem : public base::RefCountedThreadSafe<ShellLinkItem> { |
| 26 public: | 26 public: |
| 27 ShellLinkItem(); | 27 ShellLinkItem(); |
| 28 | 28 |
| 29 const std::wstring& title() const { return title_; } | 29 const std::wstring& title() const { return title_; } |
| 30 const std::wstring& icon_path() const { return icon_path_; } | 30 const std::wstring& icon_path() const { return icon_path_; } |
| 31 int icon_index() const { return icon_index_; } | 31 int icon_index() const { return icon_index_; } |
| 32 const SkBitmap& icon_data() const { return icon_data_; } | 32 const gfx::ImageSkia& icon_image() const { return icon_image_; } |
| 33 | 33 |
| 34 std::wstring GetArguments() const; | 34 std::wstring GetArguments() const; |
| 35 base::CommandLine* GetCommandLine(); | 35 base::CommandLine* GetCommandLine(); |
| 36 | 36 |
| 37 void set_title(const std::wstring& title) { | 37 void set_title(const std::wstring& title) { |
| 38 title_ = title; | 38 title_ = title; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void set_icon(const std::wstring& path, int index) { | 41 void set_icon(const std::wstring& path, int index) { |
| 42 icon_path_ = path; | 42 icon_path_ = path; |
| 43 icon_index_ = index; | 43 icon_index_ = index; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void set_icon_data(const SkBitmap& data) { | 46 void set_image(std::unique_ptr<gfx::ImageSkia> image) { |
|
sky
2017/02/08 16:56:09
Can you make the getter/getter and member consiste
chengx
2017/02/08 19:24:17
Function name updated. Yea, unique_ptr is not need
| |
| 47 icon_data_ = data; | 47 icon_image_ = *image; |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 friend class base::RefCountedThreadSafe<ShellLinkItem>; | 51 friend class base::RefCountedThreadSafe<ShellLinkItem>; |
| 52 ~ShellLinkItem(); | 52 ~ShellLinkItem(); |
| 53 | 53 |
| 54 // Used for storing and appending command-line arguments. | 54 // Used for storing and appending command-line arguments. |
| 55 base::CommandLine command_line_; | 55 base::CommandLine command_line_; |
| 56 | 56 |
| 57 // The string to be displayed in a JumpList. | 57 // The string to be displayed in a JumpList. |
| 58 std::wstring title_; | 58 std::wstring title_; |
| 59 | 59 |
| 60 // The absolute path to an icon to be displayed in a JumpList. | 60 // The absolute path to an icon to be displayed in a JumpList. |
| 61 std::wstring icon_path_; | 61 std::wstring icon_path_; |
| 62 | 62 |
| 63 // The icon index in the icon file. If an icon file consists of two or more | 63 // The icon index in the icon file. If an icon file consists of two or more |
| 64 // icons, set this value to identify the icon. If an icon file consists of | 64 // icons, set this value to identify the icon. If an icon file consists of |
| 65 // one icon, this value is 0. | 65 // one icon, this value is 0. |
| 66 int icon_index_; | 66 int icon_index_; |
| 67 | 67 |
| 68 // Icon bitmap. Used by the browser JumpList. | 68 // Icon image. Used by the browser JumpList. |
| 69 // Note that an icon path must be supplied to IShellLink, so users of this | 69 // Note that an icon path must be supplied to IShellLink, so users of this |
| 70 // class must save icon data to disk. | 70 // class must save icon data to disk. |
| 71 SkBitmap icon_data_; | 71 gfx::ImageSkia icon_image_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); | 73 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; | 76 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; |
| 77 | 77 |
| 78 | 78 |
| 79 // A utility class that hides the boilerplate for updating Windows JumpLists. | 79 // A utility class that hides the boilerplate for updating Windows JumpLists. |
| 80 // Note that JumpLists are available in Windows 7 and later only. | 80 // Note that JumpLists are available in Windows 7 and later only. |
| 81 // | 81 // |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 base::win::ScopedComPtr<ICustomDestinationList> destination_list_; | 132 base::win::ScopedComPtr<ICustomDestinationList> destination_list_; |
| 133 | 133 |
| 134 // The current user setting for "Number of recent items to display in Jump | 134 // The current user setting for "Number of recent items to display in Jump |
| 135 // Lists" option in the "Taskbar and Start Menu Properties". | 135 // Lists" option in the "Taskbar and Start Menu Properties". |
| 136 size_t user_max_items_; | 136 size_t user_max_items_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(JumpListUpdater); | 138 DISALLOW_COPY_AND_ASSIGN(JumpListUpdater); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 #endif // CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ | 141 #endif // CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ |
| OLD | NEW |