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 242 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(CalledOnValidThread()); | 291 DCHECK(CalledOnValidThread()); |
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)) | |
grt (UTC plus 2)
2017/05/30 08:51:41
nit: add braces for multi-line conditional
chengx
2017/05/30 19:37:01
Done.
| |
301 return; | |
302 | |
295 data->most_visited_pages_.clear(); | 303 data->most_visited_pages_.clear(); |
296 | 304 |
297 for (size_t i = 0; i < urls.size() && i < kMostVisitedItems; i++) { | 305 for (size_t i = 0; i < urls.size() && i < kMostVisitedItems; i++) { |
298 const history::MostVisitedURL& url = urls[i]; | 306 const history::MostVisitedURL& url = urls[i]; |
299 scoped_refptr<ShellLinkItem> link = CreateShellLink(); | 307 scoped_refptr<ShellLinkItem> link = CreateShellLink(); |
300 std::string url_string = url.url.spec(); | 308 std::string url_string = url.url.spec(); |
301 base::string16 url_string_wide = base::UTF8ToUTF16(url_string); | 309 base::string16 url_string_wide = base::UTF8ToUTF16(url_string); |
302 link->GetCommandLine()->AppendArgNative(url_string_wide); | 310 link->GetCommandLine()->AppendArgNative(url_string_wide); |
303 link->GetCommandLine()->AppendSwitchASCII( | 311 link->GetCommandLine()->AppendSwitchASCII( |
304 switches::kWinJumplistAction, jumplist::kMostVisitedCategory); | 312 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, | 867 app_id, profile_dir, local_most_visited_pages, |
860 local_recently_closed_pages, most_visited_pages_have_updates, | 868 local_recently_closed_pages, most_visited_pages_have_updates, |
861 recently_closed_pages_have_updates, incognito_availability)) { | 869 recently_closed_pages_have_updates, incognito_availability)) { |
862 base::AutoLock auto_lock(data->list_lock_); | 870 base::AutoLock auto_lock(data->list_lock_); |
863 if (most_visited_pages_have_updates) | 871 if (most_visited_pages_have_updates) |
864 data->most_visited_pages_have_updates_ = true; | 872 data->most_visited_pages_have_updates_ = true; |
865 if (recently_closed_pages_have_updates) | 873 if (recently_closed_pages_have_updates) |
866 data->recently_closed_pages_have_updates_ = true; | 874 data->recently_closed_pages_have_updates_ = true; |
867 } | 875 } |
868 } | 876 } |
OLD | NEW |