| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/favicon/favicon_service_factory.h" | 20 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 21 #include "chrome/browser/history/top_sites_factory.h" | 21 #include "chrome/browser/history/top_sites_factory.h" |
| 22 #include "chrome/browser/metrics/jumplist_metrics_win.h" | 22 #include "chrome/browser/metrics/jumplist_metrics_win.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 24 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 25 #include "chrome/browser/shell_integration_win.h" | 25 #include "chrome/browser/shell_integration_win.h" |
| 26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_icon_resources_win.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 31 #include "chrome/installer/util/browser_distribution.h" | 32 #include "chrome/installer/util/browser_distribution.h" |
| 32 #include "components/favicon/core/favicon_service.h" | 33 #include "components/favicon/core/favicon_service.h" |
| 33 #include "components/favicon_base/favicon_types.h" | 34 #include "components/favicon_base/favicon_types.h" |
| 34 #include "components/history/core/browser/history_service.h" | 35 #include "components/history/core/browser/history_service.h" |
| 35 #include "components/history/core/browser/page_usage_data.h" | 36 #include "components/history/core/browser/page_usage_data.h" |
| 36 #include "components/history/core/browser/top_sites.h" | 37 #include "components/history/core/browser/top_sites.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 scoped_refptr<ShellLinkItem> chrome = CreateShellLink(); | 144 scoped_refptr<ShellLinkItem> chrome = CreateShellLink(); |
| 144 base::string16 chrome_title = l10n_util::GetStringUTF16(IDS_NEW_WINDOW); | 145 base::string16 chrome_title = l10n_util::GetStringUTF16(IDS_NEW_WINDOW); |
| 145 base::ReplaceSubstringsAfterOffset( | 146 base::ReplaceSubstringsAfterOffset( |
| 146 &chrome_title, 0, L"&", base::StringPiece16()); | 147 &chrome_title, 0, L"&", base::StringPiece16()); |
| 147 chrome->set_title(chrome_title); | 148 chrome->set_title(chrome_title); |
| 148 chrome->set_icon(chrome_path.value(), icon_index); | 149 chrome->set_icon(chrome_path.value(), icon_index); |
| 149 items.push_back(chrome); | 150 items.push_back(chrome); |
| 150 } | 151 } |
| 151 | 152 |
| 152 // Create an IShellLink object which launches Chrome in incognito mode, and | 153 // Create an IShellLink object which launches Chrome in incognito mode, and |
| 153 // add it to the collection. We use our application icon as the icon for | 154 // add it to the collection. |
| 154 // this item. | |
| 155 if (incognito_availability != IncognitoModePrefs::DISABLED) { | 155 if (incognito_availability != IncognitoModePrefs::DISABLED) { |
| 156 scoped_refptr<ShellLinkItem> incognito = CreateShellLink(); | 156 scoped_refptr<ShellLinkItem> incognito = CreateShellLink(); |
| 157 incognito->GetCommandLine()->AppendSwitch(switches::kIncognito); | 157 incognito->GetCommandLine()->AppendSwitch(switches::kIncognito); |
| 158 base::string16 incognito_title = | 158 base::string16 incognito_title = |
| 159 l10n_util::GetStringUTF16(IDS_NEW_INCOGNITO_WINDOW); | 159 l10n_util::GetStringUTF16(IDS_NEW_INCOGNITO_WINDOW); |
| 160 base::ReplaceSubstringsAfterOffset( | 160 base::ReplaceSubstringsAfterOffset( |
| 161 &incognito_title, 0, L"&", base::StringPiece16()); | 161 &incognito_title, 0, L"&", base::StringPiece16()); |
| 162 incognito->set_title(incognito_title); | 162 incognito->set_title(incognito_title); |
| 163 incognito->set_icon(chrome_path.value(), icon_index); | 163 incognito->set_icon(chrome_path.value(), icon_resources::kIncognitoIndex); |
| 164 items.push_back(incognito); | 164 items.push_back(incognito); |
| 165 } | 165 } |
| 166 | 166 |
| 167 return jumplist_updater->AddTasks(items); | 167 return jumplist_updater->AddTasks(items); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Updates the application JumpList. | 170 // Updates the application JumpList. |
| 171 bool UpdateJumpList(const wchar_t* app_id, | 171 bool UpdateJumpList(const wchar_t* app_id, |
| 172 const ShellLinkItemList& most_visited_pages, | 172 const ShellLinkItemList& most_visited_pages, |
| 173 const ShellLinkItemList& recently_closed_pages, | 173 const ShellLinkItemList& recently_closed_pages, |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { | 636 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { |
| 637 } | 637 } |
| 638 | 638 |
| 639 void JumpList::TopSitesChanged(history::TopSites* top_sites, | 639 void JumpList::TopSitesChanged(history::TopSites* top_sites, |
| 640 ChangeReason change_reason) { | 640 ChangeReason change_reason) { |
| 641 top_sites->GetMostVisitedURLs( | 641 top_sites->GetMostVisitedURLs( |
| 642 base::Bind(&JumpList::OnMostVisitedURLsAvailable, | 642 base::Bind(&JumpList::OnMostVisitedURLsAvailable, |
| 643 weak_ptr_factory_.GetWeakPtr()), | 643 weak_ptr_factory_.GetWeakPtr()), |
| 644 false); | 644 false); |
| 645 } | 645 } |
| OLD | NEW |