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.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::Image& icon_data() const { return icon_data_; } |
| 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_icon_data(const gfx::Image& data) { icon_data_ = data; } |
|
sky
2017/02/08 03:14:54
Keep the names consistent, so that rather than set
chengx
2017/02/08 07:42:26
Done.
| |
| 47 icon_data_ = data; | |
| 48 } | |
| 49 | 47 |
| 50 private: | 48 private: |
| 51 friend class base::RefCountedThreadSafe<ShellLinkItem>; | 49 friend class base::RefCountedThreadSafe<ShellLinkItem>; |
| 52 ~ShellLinkItem(); | 50 ~ShellLinkItem(); |
| 53 | 51 |
| 54 // Used for storing and appending command-line arguments. | 52 // Used for storing and appending command-line arguments. |
| 55 base::CommandLine command_line_; | 53 base::CommandLine command_line_; |
| 56 | 54 |
| 57 // The string to be displayed in a JumpList. | 55 // The string to be displayed in a JumpList. |
| 58 std::wstring title_; | 56 std::wstring title_; |
| 59 | 57 |
| 60 // The absolute path to an icon to be displayed in a JumpList. | 58 // The absolute path to an icon to be displayed in a JumpList. |
| 61 std::wstring icon_path_; | 59 std::wstring icon_path_; |
| 62 | 60 |
| 63 // The icon index in the icon file. If an icon file consists of two or more | 61 // 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 | 62 // icons, set this value to identify the icon. If an icon file consists of |
| 65 // one icon, this value is 0. | 63 // one icon, this value is 0. |
| 66 int icon_index_; | 64 int icon_index_; |
| 67 | 65 |
| 68 // Icon bitmap. Used by the browser JumpList. | 66 // Icon image. Used by the browser JumpList. |
| 69 // Note that an icon path must be supplied to IShellLink, so users of this | 67 // Note that an icon path must be supplied to IShellLink, so users of this |
| 70 // class must save icon data to disk. | 68 // class must save icon data to disk. |
| 71 SkBitmap icon_data_; | 69 gfx::Image icon_data_; |
| 72 | 70 |
| 73 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); | 71 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; | 74 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; |
| 77 | 75 |
| 78 | 76 |
| 79 // A utility class that hides the boilerplate for updating Windows JumpLists. | 77 // A utility class that hides the boilerplate for updating Windows JumpLists. |
| 80 // Note that JumpLists are available in Windows 7 and later only. | 78 // Note that JumpLists are available in Windows 7 and later only. |
| 81 // | 79 // |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 base::win::ScopedComPtr<ICustomDestinationList> destination_list_; | 130 base::win::ScopedComPtr<ICustomDestinationList> destination_list_; |
| 133 | 131 |
| 134 // The current user setting for "Number of recent items to display in Jump | 132 // The current user setting for "Number of recent items to display in Jump |
| 135 // Lists" option in the "Taskbar and Start Menu Properties". | 133 // Lists" option in the "Taskbar and Start Menu Properties". |
| 136 size_t user_max_items_; | 134 size_t user_max_items_; |
| 137 | 135 |
| 138 DISALLOW_COPY_AND_ASSIGN(JumpListUpdater); | 136 DISALLOW_COPY_AND_ASSIGN(JumpListUpdater); |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 #endif // CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ | 139 #endif // CHROME_BROWSER_WIN_JUMPLIST_UPDATER_H_ |
| OLD | NEW |