OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/win/jumplist.h" | 5 #include "chrome/browser/win/jumplist.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/timer/elapsed_timer.h" | 23 #include "base/timer/elapsed_timer.h" |
24 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/favicon/favicon_service_factory.h" | 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
27 #include "chrome/browser/history/top_sites_factory.h" | 27 #include "chrome/browser/history/top_sites_factory.h" |
28 #include "chrome/browser/metrics/jumplist_metrics_win.h" | 28 #include "chrome/browser/metrics/jumplist_metrics_win.h" |
29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 30 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
31 #include "chrome/browser/shell_integration_win.h" | 31 #include "chrome/browser/shell_integration_win.h" |
32 #include "chrome/browser/win/jumplist_file_util.h" | 32 #include "chrome/browser/win/jumplist_file_util.h" |
| 33 #include "chrome/browser/win/jumplist_update_util.h" |
33 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
34 #include "chrome/common/chrome_icon_resources_win.h" | 35 #include "chrome/common/chrome_icon_resources_win.h" |
35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
37 #include "chrome/grit/generated_resources.h" | 38 #include "chrome/grit/generated_resources.h" |
38 #include "chrome/install_static/install_util.h" | 39 #include "chrome/install_static/install_util.h" |
39 #include "components/favicon/core/favicon_service.h" | 40 #include "components/favicon/core/favicon_service.h" |
40 #include "components/history/core/browser/top_sites.h" | 41 #include "components/history/core/browser/top_sites.h" |
41 #include "components/prefs/pref_change_registrar.h" | 42 #include "components/prefs/pref_change_registrar.h" |
42 #include "components/sessions/core/session_types.h" | 43 #include "components/sessions/core/session_types.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const char* kSwitchNames[] = { switches::kUserDataDir }; | 92 const char* kSwitchNames[] = { switches::kUserDataDir }; |
92 const base::CommandLine& command_line = | 93 const base::CommandLine& command_line = |
93 *base::CommandLine::ForCurrentProcess(); | 94 *base::CommandLine::ForCurrentProcess(); |
94 shell_link->GetCommandLine()->CopySwitchesFrom(command_line, | 95 shell_link->GetCommandLine()->CopySwitchesFrom(command_line, |
95 kSwitchNames, | 96 kSwitchNames, |
96 arraysize(kSwitchNames)); | 97 arraysize(kSwitchNames)); |
97 } | 98 } |
98 | 99 |
99 // Creates a ShellLinkItem preloaded with common switches. | 100 // Creates a ShellLinkItem preloaded with common switches. |
100 scoped_refptr<ShellLinkItem> CreateShellLink() { | 101 scoped_refptr<ShellLinkItem> CreateShellLink() { |
101 scoped_refptr<ShellLinkItem> link(new ShellLinkItem); | 102 auto link = base::MakeRefCounted<ShellLinkItem>(); |
102 AppendCommonSwitches(link.get()); | 103 AppendCommonSwitches(link.get()); |
103 return link; | 104 return link; |
104 } | 105 } |
105 | 106 |
106 // Creates a temporary icon file to be shown in JumpList. | 107 // Creates a temporary icon file to be shown in JumpList. |
107 bool CreateIconFile(const gfx::ImageSkia& image_skia, | 108 bool CreateIconFile(const gfx::ImageSkia& image_skia, |
108 const base::FilePath& icon_dir, | 109 const base::FilePath& icon_dir, |
109 base::FilePath* icon_path) { | 110 base::FilePath* icon_path) { |
110 // Retrieve the path to a temporary file. | 111 // Retrieve the path to a temporary file. |
111 // We don't have to care about the extension of this temporary file because | 112 // We don't have to care about the extension of this temporary file because |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 Terminate(); | 286 Terminate(); |
286 } | 287 } |
287 | 288 |
288 void JumpList::OnMostVisitedURLsAvailable( | 289 void JumpList::OnMostVisitedURLsAvailable( |
289 const history::MostVisitedURLList& urls) { | 290 const history::MostVisitedURLList& urls) { |
290 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 291 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
291 | 292 |
292 { | 293 { |
293 JumpListData* data = &jumplist_data_->data; | 294 JumpListData* data = &jumplist_data_->data; |
294 base::AutoLock auto_lock(data->list_lock_); | 295 base::AutoLock auto_lock(data->list_lock_); |
| 296 |
| 297 // There is no need to update the JumpList if the top most visited sites in |
| 298 // display have not changed. |
| 299 if (MostVisitedItemsUnchanged(data->most_visited_pages_, urls, |
| 300 kMostVisitedItems)) { |
| 301 return; |
| 302 } |
| 303 |
295 data->most_visited_pages_.clear(); | 304 data->most_visited_pages_.clear(); |
296 | 305 |
297 for (size_t i = 0; i < urls.size() && i < kMostVisitedItems; i++) { | 306 for (size_t i = 0; i < urls.size() && i < kMostVisitedItems; i++) { |
298 const history::MostVisitedURL& url = urls[i]; | 307 const history::MostVisitedURL& url = urls[i]; |
299 scoped_refptr<ShellLinkItem> link = CreateShellLink(); | 308 scoped_refptr<ShellLinkItem> link = CreateShellLink(); |
300 std::string url_string = url.url.spec(); | 309 std::string url_string = url.url.spec(); |
301 base::string16 url_string_wide = base::UTF8ToUTF16(url_string); | 310 base::string16 url_string_wide = base::UTF8ToUTF16(url_string); |
302 link->GetCommandLine()->AppendArgNative(url_string_wide); | 311 link->GetCommandLine()->AppendArgNative(url_string_wide); |
303 link->GetCommandLine()->AppendSwitchASCII( | 312 link->GetCommandLine()->AppendSwitchASCII( |
304 switches::kWinJumplistAction, jumplist::kMostVisitedCategory); | 313 switches::kWinJumplistAction, jumplist::kMostVisitedCategory); |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 app_id, profile_dir, local_most_visited_pages, | 868 app_id, profile_dir, local_most_visited_pages, |
860 local_recently_closed_pages, most_visited_pages_have_updates, | 869 local_recently_closed_pages, most_visited_pages_have_updates, |
861 recently_closed_pages_have_updates, incognito_availability)) { | 870 recently_closed_pages_have_updates, incognito_availability)) { |
862 base::AutoLock auto_lock(data->list_lock_); | 871 base::AutoLock auto_lock(data->list_lock_); |
863 if (most_visited_pages_have_updates) | 872 if (most_visited_pages_have_updates) |
864 data->most_visited_pages_have_updates_ = true; | 873 data->most_visited_pages_have_updates_ = true; |
865 if (recently_closed_pages_have_updates) | 874 if (recently_closed_pages_have_updates) |
866 data->recently_closed_pages_have_updates_ = true; | 875 data->recently_closed_pages_have_updates_ = true; |
867 } | 876 } |
868 } | 877 } |
OLD | NEW |