OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_JUMPLIST_WIN_H_ | 5 #ifndef CHROME_BROWSER_JUMPLIST_WIN_H_ |
6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ | 6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
15 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
16 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
17 #include "chrome/browser/history/history_service.h" | 16 #include "chrome/browser/history/history_service.h" |
18 #include "chrome/browser/history/history_types.h" | 17 #include "chrome/browser/history/history_types.h" |
| 18 #include "chrome/browser/jumplist_updater_win.h" |
19 #include "chrome/browser/sessions/tab_restore_service.h" | 19 #include "chrome/browser/sessions/tab_restore_service.h" |
20 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 20 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "third_party/skia/include/core/SkBitmap.h" | |
23 | 22 |
24 namespace base { | 23 namespace base { |
25 class FilePath; | 24 class FilePath; |
26 } | 25 } |
27 | 26 |
28 namespace chrome { | 27 namespace chrome { |
29 struct FaviconImageResult; | 28 struct FaviconImageResult; |
30 } | 29 } |
31 | 30 |
32 namespace content { | 31 namespace content { |
33 class NotificationRegistrar; | 32 class NotificationRegistrar; |
34 } | 33 } |
35 | 34 |
36 class Profile; | 35 class Profile; |
37 class PageUsageData; | 36 class PageUsageData; |
38 | 37 |
39 // Represents a class used for creating an IShellLink object by the utility | |
40 // functions in this file. | |
41 // This class consists of three strings and a integer. | |
42 // * arguments (std::wstring) | |
43 // The arguments for the application. | |
44 // * title (std::wstring) | |
45 // The string to be displayed in a JumpList. | |
46 // * icon (std::wstring) | |
47 // The absolute path to an icon to be displayed in a JumpList. | |
48 // * index (int) | |
49 // The icon index in the icon file. If an icon file consists of two or more | |
50 // icons, set this value to identify the icon. If an icon file consists of | |
51 // one icon, this value is 0. | |
52 // Even though an IShellLink also needs the absolute path to an application to | |
53 // be executed, this class does not have any variables for it because our | |
54 // utility functions always use "chrome.exe" as the application and we don't | |
55 // need it. | |
56 class ShellLinkItem : public base::RefCountedThreadSafe<ShellLinkItem> { | |
57 public: | |
58 ShellLinkItem() : index_(0), favicon_(false) { | |
59 } | |
60 | |
61 const std::wstring& arguments() const { return arguments_; } | |
62 const std::wstring& title() const { return title_; } | |
63 const std::wstring& icon() const { return icon_; } | |
64 int index() const { return index_; } | |
65 const SkBitmap& data() const { return data_; } | |
66 | |
67 void SetArguments(const std::wstring& arguments) { | |
68 arguments_ = arguments; | |
69 } | |
70 | |
71 void SetTitle(const std::wstring& title) { | |
72 title_ = title; | |
73 } | |
74 | |
75 void SetIcon(const std::wstring& icon, int index, bool favicon) { | |
76 icon_ = icon; | |
77 index_ = index; | |
78 favicon_ = favicon; | |
79 } | |
80 | |
81 void SetIconData(const SkBitmap& data) { | |
82 data_ = data; | |
83 } | |
84 | |
85 private: | |
86 friend class base::RefCountedThreadSafe<ShellLinkItem>; | |
87 | |
88 ~ShellLinkItem() {} | |
89 | |
90 std::wstring arguments_; | |
91 std::wstring title_; | |
92 std::wstring icon_; | |
93 SkBitmap data_; | |
94 int index_; | |
95 bool favicon_; | |
96 | |
97 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); | |
98 }; | |
99 | |
100 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; | |
101 | |
102 // A class which implements an application JumpList. | 38 // A class which implements an application JumpList. |
103 // This class encapsulates operations required for updating an application | 39 // This class encapsulates operations required for updating an application |
104 // JumpList: | 40 // JumpList: |
105 // * Retrieving "Most Visited" pages from HistoryService; | 41 // * Retrieving "Most Visited" pages from HistoryService; |
106 // * Retrieving strings from the application resource; | 42 // * Retrieving strings from the application resource; |
107 // * Creatng COM objects used by JumpList from PageUsageData objects; | 43 // * Creatng COM objects used by JumpList from PageUsageData objects; |
108 // * Adding COM objects to JumpList, etc. | 44 // * Adding COM objects to JumpList, etc. |
109 // | 45 // |
110 // This class also implements TabRestoreServiceObserver. So, once we call | 46 // This class also implements TabRestoreServiceObserver. So, once we call |
111 // AddObserver() and register this class as an observer, it automatically | 47 // AddObserver() and register this class as an observer, it automatically |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 base::CancelableTaskTracker::TaskId task_id_; | 186 base::CancelableTaskTracker::TaskId task_id_; |
251 | 187 |
252 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ | 188 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ |
253 // as they may be used by up to 3 threads. | 189 // as they may be used by up to 3 threads. |
254 base::Lock list_lock_; | 190 base::Lock list_lock_; |
255 | 191 |
256 DISALLOW_COPY_AND_ASSIGN(JumpList); | 192 DISALLOW_COPY_AND_ASSIGN(JumpList); |
257 }; | 193 }; |
258 | 194 |
259 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ | 195 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ |
OLD | NEW |