| 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 "ui/gfx/image/image_skia.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 base::string16& title() const { return title_; } | 
|   30   const std::wstring& icon_path() const { return icon_path_; } |   30   const base::string16& icon_path() const { return icon_path_; } | 
|   31   int icon_index() const { return icon_index_; } |   31   int icon_index() const { return icon_index_; } | 
|   32   const gfx::ImageSkia& icon_image() const { return icon_image_; } |   32   const gfx::ImageSkia& icon_image() const { return icon_image_; } | 
|   33  |   33  | 
|   34   std::wstring GetArguments() const; |   34   base::string16 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 base::string16& title) { title_ = title; } | 
|   38     title_ = title; |  | 
|   39   } |  | 
|   40  |   38  | 
|   41   void set_icon(const std::wstring& path, int index) { |   39   void set_icon(const base::string16& path, int index) { | 
|   42     icon_path_ = path; |   40     icon_path_ = path; | 
|   43     icon_index_ = index; |   41     icon_index_ = index; | 
|   44   } |   42   } | 
|   45  |   43  | 
|   46   void set_icon_image(const gfx::ImageSkia& image) { |   44   void set_icon_image(const gfx::ImageSkia& image) { | 
|   47     icon_image_ = image; |   45     icon_image_ = image; | 
|   48   } |   46   } | 
|   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   base::string16 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   base::string16 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 image. 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   gfx::ImageSkia icon_image_; |   69   gfx::ImageSkia icon_image_; | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|   87 //      updater.AddCustomCategory(...); |   85 //      updater.AddCustomCategory(...); | 
|   88 //      updater.CommitUpdate(); |   86 //      updater.CommitUpdate(); | 
|   89 //    } |   87 //    } | 
|   90 // |   88 // | 
|   91 // Note: |   89 // Note: | 
|   92 // - Each JumpListUpdater instance is expected to be used once only. |   90 // - Each JumpListUpdater instance is expected to be used once only. | 
|   93 // - The JumpList must be updated in its entirety, i.e. even if a category has |   91 // - The JumpList must be updated in its entirety, i.e. even if a category has | 
|   94 //   not changed, all its items must be added in each update. |   92 //   not changed, all its items must be added in each update. | 
|   95 class JumpListUpdater { |   93 class JumpListUpdater { | 
|   96  public: |   94  public: | 
|   97   explicit JumpListUpdater(const std::wstring& app_user_model_id); |   95   explicit JumpListUpdater(const base::string16& app_user_model_id); | 
|   98   ~JumpListUpdater(); |   96   ~JumpListUpdater(); | 
|   99  |   97  | 
|  100   // Returns true if JumpLists are enabled on this OS. |   98   // Returns true if JumpLists are enabled on this OS. | 
|  101   static bool IsEnabled(); |   99   static bool IsEnabled(); | 
|  102  |  100  | 
|  103   // Returns the current user setting for the maximum number of items to display |  101   // Returns the current user setting for the maximum number of items to display | 
|  104   // in JumpLists. The setting is retrieved in BeginUpdate(). |  102   // in JumpLists. The setting is retrieved in BeginUpdate(). | 
|  105   size_t user_max_items() const { return user_max_items_; } |  103   size_t user_max_items() const { return user_max_items_; } | 
|  106  |  104  | 
|  107   // Starts a transaction that updates the JumpList of this application. |  105   // Starts a transaction that updates the JumpList of this application. | 
|  108   // This must be called prior to updating the JumpList. If this function |  106   // This must be called prior to updating the JumpList. If this function | 
|  109   // returns false, this instance should not be used. |  107   // returns false, this instance should not be used. | 
|  110   bool BeginUpdate(); |  108   bool BeginUpdate(); | 
|  111  |  109  | 
|  112   // Commits the update. |  110   // Commits the update. | 
|  113   bool CommitUpdate(); |  111   bool CommitUpdate(); | 
|  114  |  112  | 
|  115   // Updates the predefined "Tasks" category of the JumpList. |  113   // Updates the predefined "Tasks" category of the JumpList. | 
|  116   bool AddTasks(const ShellLinkItemList& link_items); |  114   bool AddTasks(const ShellLinkItemList& link_items); | 
|  117  |  115  | 
|  118   // Updates an unregistered category of the JumpList. |  116   // Updates an unregistered category of the JumpList. | 
|  119   // This function cannot update registered categories (such as "Tasks") |  117   // This function cannot update registered categories (such as "Tasks") | 
|  120   // because special steps are required for updating them. |  118   // because special steps are required for updating them. | 
|  121   // |max_items| specifies the maximum number of items from |link_items| to add |  119   // |max_items| specifies the maximum number of items from |link_items| to add | 
|  122   // to the JumpList. |  120   // to the JumpList. | 
|  123   bool AddCustomCategory(const std::wstring& category_name, |  121   bool AddCustomCategory(const base::string16& category_name, | 
|  124                          const ShellLinkItemList& link_items, |  122                          const ShellLinkItemList& link_items, | 
|  125                          size_t max_items); |  123                          size_t max_items); | 
|  126  |  124  | 
|  127  private: |  125  private: | 
|  128   // The app ID. |  126   // The app ID. | 
|  129   std::wstring app_user_model_id_; |  127   base::string16 app_user_model_id_; | 
|  130  |  128  | 
|  131   // Windows API interface used to modify JumpLists. |  129   // Windows API interface used to modify JumpLists. | 
|  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 |