Chromium Code Reviews| 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 #include "chrome/browser/jumplist_win.h" | 5 #include "chrome/browser/jumplist_win.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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "chrome/browser/browser_process.h" | |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/favicon/favicon_service.h" | 18 #include "chrome/browser/favicon/favicon_service.h" |
| 18 #include "chrome/browser/favicon/favicon_service_factory.h" | 19 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 19 #include "chrome/browser/history/history_service.h" | 20 #include "chrome/browser/history/history_service.h" |
| 20 #include "chrome/browser/history/top_sites.h" | 21 #include "chrome/browser/history/top_sites.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | |
| 24 #include "chrome/browser/profiles/profile_info_cache.h" | |
| 25 #include "chrome/browser/profiles/profile_manager.h" | |
| 22 #include "chrome/browser/sessions/session_types.h" | 26 #include "chrome/browser/sessions/session_types.h" |
| 23 #include "chrome/browser/sessions/tab_restore_service.h" | 27 #include "chrome/browser/sessions/tab_restore_service.h" |
| 24 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 28 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 25 #include "chrome/browser/shell_integration.h" | 29 #include "chrome/browser/shell_integration.h" |
| 26 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
| 31 #include "components/favicon_base/favicon_types.h" | 35 #include "components/favicon_base/favicon_types.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 items.push_back(incognito); | 124 items.push_back(incognito); |
| 121 } | 125 } |
| 122 | 126 |
| 123 return jumplist_updater->AddTasks(items); | 127 return jumplist_updater->AddTasks(items); |
| 124 } | 128 } |
| 125 | 129 |
| 126 // Updates the application JumpList. | 130 // Updates the application JumpList. |
| 127 bool UpdateJumpList(const wchar_t* app_id, | 131 bool UpdateJumpList(const wchar_t* app_id, |
| 128 const ShellLinkItemList& most_visited_pages, | 132 const ShellLinkItemList& most_visited_pages, |
| 129 const ShellLinkItemList& recently_closed_pages, | 133 const ShellLinkItemList& recently_closed_pages, |
| 134 const ShellLinkItemList& profile_switcher, | |
| 130 IncognitoModePrefs::Availability incognito_availability) { | 135 IncognitoModePrefs::Availability incognito_availability) { |
| 131 // JumpList is implemented only on Windows 7 or later. | 136 // JumpList is implemented only on Windows 7 or later. |
| 132 // So, we should return now when this function is called on earlier versions | 137 // So, we should return now when this function is called on earlier versions |
| 133 // of Windows. | 138 // of Windows. |
| 134 if (!JumpListUpdater::IsEnabled()) | 139 if (!JumpListUpdater::IsEnabled()) |
| 135 return true; | 140 return true; |
| 136 | 141 |
| 137 JumpListUpdater jumplist_updater(app_id); | 142 JumpListUpdater jumplist_updater(app_id); |
| 138 if (!jumplist_updater.BeginUpdate()) | 143 if (!jumplist_updater.BeginUpdate()) |
| 139 return false; | 144 return false; |
| 140 | 145 |
| 141 // We allocate 60% of the given JumpList slots to "most-visited" items | 146 // We allocate 60% of the given JumpList slots to "most-visited" items |
| 142 // and 40% to "recently-closed" items, respectively. | 147 // and 40% to "recently-closed" items, respectively. |
| 143 // Nevertheless, if there are not so many items in |recently_closed_pages|, | 148 // Nevertheless, if there are not so many items in |recently_closed_pages|, |
| 144 // we give the remaining slots to "most-visited" items. | 149 // we give the remaining slots to "most-visited" items. |
| 145 const int kMostVisited = 60; | 150 const int kMostVisited = 60; |
| 146 const int kRecentlyClosed = 40; | 151 const int kRecentlyClosed = 40; |
| 147 const int kTotal = kMostVisited + kRecentlyClosed; | 152 const int kTotal = kMostVisited + kRecentlyClosed; |
| 148 size_t most_visited_items = | 153 size_t most_visited_items = |
| 149 MulDiv(jumplist_updater.user_max_items(), kMostVisited, kTotal); | 154 MulDiv(jumplist_updater.user_max_items(), kMostVisited, kTotal); |
|
tapted
2014/11/04 23:10:48
I think you'll need to update these values - maxin
noms (inactive)
2014/11/10 21:46:08
Annnnnd this went down a crazy alley and now there
| |
| 150 size_t recently_closed_items = | 155 size_t recently_closed_items = |
| 151 jumplist_updater.user_max_items() - most_visited_items; | 156 jumplist_updater.user_max_items() - most_visited_items; |
| 152 if (recently_closed_pages.size() < recently_closed_items) { | 157 if (recently_closed_pages.size() < recently_closed_items) { |
| 153 most_visited_items += recently_closed_items - recently_closed_pages.size(); | 158 most_visited_items += recently_closed_items - recently_closed_pages.size(); |
| 154 recently_closed_items = recently_closed_pages.size(); | 159 recently_closed_items = recently_closed_pages.size(); |
| 155 } | 160 } |
| 156 | 161 |
| 157 // Update the "Most Visited" category of the JumpList. | 162 // Update the "Most Visited" category of the JumpList. |
| 158 // This update request is applied into the JumpList when we commit this | 163 // This update request is applied into the JumpList when we commit this |
| 159 // transaction. | 164 // transaction. |
| 160 if (!jumplist_updater.AddCustomCategory( | 165 if (!jumplist_updater.AddCustomCategory( |
| 161 base::UTF16ToWide( | 166 base::UTF16ToWide( |
| 162 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED)), | 167 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED)), |
| 163 most_visited_pages, most_visited_items)) { | 168 most_visited_pages, most_visited_items)) { |
| 164 return false; | 169 return false; |
| 165 } | 170 } |
| 166 | 171 |
| 167 // Update the "Recently Closed" category of the JumpList. | 172 // Update the "Recently Closed" category of the JumpList. |
| 168 if (!jumplist_updater.AddCustomCategory( | 173 if (!jumplist_updater.AddCustomCategory( |
| 169 base::UTF16ToWide( | 174 base::UTF16ToWide( |
| 170 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED)), | 175 l10n_util::GetStringUTF16(IDS_NEW_TAB_RECENTLY_CLOSED)), |
| 171 recently_closed_pages, recently_closed_items)) { | 176 recently_closed_pages, recently_closed_items)) { |
| 172 return false; | 177 return false; |
| 173 } | 178 } |
| 174 | 179 |
| 180 // Update the "Profiles" category of the JumpList. | |
|
tapted
2014/11/04 23:10:48
nit: Profiles -> People?
(and super-nit: should t
noms (inactive)
2014/11/10 21:46:08
Done re: the comment.
Chrome://settings is still p
| |
| 181 if (!jumplist_updater.AddCustomCategory( | |
| 182 l10n_util::GetStringUTF16(IDS_PROFILES_OPTIONS_GROUP_NAME), | |
| 183 profile_switcher, profile_switcher.size())) { | |
| 184 return false; | |
| 185 } | |
| 186 | |
| 175 // Update the "Tasks" category of the JumpList. | 187 // Update the "Tasks" category of the JumpList. |
| 176 if (!UpdateTaskCategory(&jumplist_updater, incognito_availability)) | 188 if (!UpdateTaskCategory(&jumplist_updater, incognito_availability)) |
| 177 return false; | 189 return false; |
| 178 | 190 |
| 179 // Commit this transaction and send the updated JumpList to Windows. | 191 // Commit this transaction and send the updated JumpList to Windows. |
| 180 if (!jumplist_updater.CommitUpdate()) | 192 if (!jumplist_updater.CommitUpdate()) |
| 181 return false; | 193 return false; |
| 182 | 194 |
| 183 return true; | 195 return true; |
| 184 } | 196 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // observers are detatched at that time. | 229 // observers are detatched at that time. |
| 218 registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 230 registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 219 content::Source<Profile>(profile_)); | 231 content::Source<Profile>(profile_)); |
| 220 } | 232 } |
| 221 tab_restore_service->AddObserver(this); | 233 tab_restore_service->AddObserver(this); |
| 222 pref_change_registrar_.reset(new PrefChangeRegistrar); | 234 pref_change_registrar_.reset(new PrefChangeRegistrar); |
| 223 pref_change_registrar_->Init(profile_->GetPrefs()); | 235 pref_change_registrar_->Init(profile_->GetPrefs()); |
| 224 pref_change_registrar_->Add( | 236 pref_change_registrar_->Add( |
| 225 prefs::kIncognitoModeAvailability, | 237 prefs::kIncognitoModeAvailability, |
| 226 base::Bind(&JumpList::OnIncognitoAvailabilityChanged, this)); | 238 base::Bind(&JumpList::OnIncognitoAvailabilityChanged, this)); |
| 239 | |
| 240 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 241 DCHECK(profile_manager); | |
| 242 avatar_menu_.reset(new AvatarMenu( | |
| 243 &profile_manager->GetProfileInfoCache(), this, NULL)); | |
| 244 avatar_menu_->RebuildMenu(); | |
| 245 UpdateProfileSwitcher(); | |
| 227 } | 246 } |
| 228 | 247 |
| 229 JumpList::~JumpList() { | 248 JumpList::~JumpList() { |
| 230 Terminate(); | 249 Terminate(); |
| 231 } | 250 } |
| 232 | 251 |
| 233 // static | 252 // static |
| 234 bool JumpList::Enabled() { | 253 bool JumpList::Enabled() { |
| 235 return JumpListUpdater::IsEnabled(); | 254 return JumpListUpdater::IsEnabled(); |
| 236 } | 255 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 recently_closed_pages_ = temp_list; | 362 recently_closed_pages_ = temp_list; |
| 344 } | 363 } |
| 345 | 364 |
| 346 // Send a query that retrieves the first favicon. | 365 // Send a query that retrieves the first favicon. |
| 347 StartLoadingFavicon(); | 366 StartLoadingFavicon(); |
| 348 } | 367 } |
| 349 | 368 |
| 350 void JumpList::TabRestoreServiceDestroyed(TabRestoreService* service) { | 369 void JumpList::TabRestoreServiceDestroyed(TabRestoreService* service) { |
| 351 } | 370 } |
| 352 | 371 |
| 372 void JumpList::OnAvatarMenuChanged(AvatarMenu* avatar_menu) { | |
| 373 UpdateProfileSwitcher(); | |
| 374 PostRunUpdate(); | |
| 375 } | |
| 376 | |
| 353 bool JumpList::AddTab(const TabRestoreService::Tab* tab, | 377 bool JumpList::AddTab(const TabRestoreService::Tab* tab, |
| 354 ShellLinkItemList* list, | 378 ShellLinkItemList* list, |
| 355 size_t max_items) { | 379 size_t max_items) { |
| 356 // This code adds the URL and the title strings of the given tab to the | 380 // This code adds the URL and the title strings of the given tab to the |
| 357 // specified list. | 381 // specified list. |
| 358 if (list->size() >= max_items) | 382 if (list->size() >= max_items) |
| 359 return false; | 383 return false; |
| 360 | 384 |
| 361 scoped_refptr<ShellLinkItem> link = CreateShellLink(); | 385 scoped_refptr<ShellLinkItem> link = CreateShellLink(); |
| 362 const sessions::SerializedNavigationEntry& current_navigation = | 386 const sessions::SerializedNavigationEntry& current_navigation = |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 390 waiting_for_icons = !icon_urls_.empty(); | 414 waiting_for_icons = !icon_urls_.empty(); |
| 391 if (waiting_for_icons) { | 415 if (waiting_for_icons) { |
| 392 // Ask FaviconService if it has a favicon of a URL. | 416 // Ask FaviconService if it has a favicon of a URL. |
| 393 // When FaviconService has one, it will call OnFaviconDataAvailable(). | 417 // When FaviconService has one, it will call OnFaviconDataAvailable(). |
| 394 url = GURL(icon_urls_.front().first); | 418 url = GURL(icon_urls_.front().first); |
| 395 } | 419 } |
| 396 } | 420 } |
| 397 | 421 |
| 398 if (!waiting_for_icons) { | 422 if (!waiting_for_icons) { |
| 399 // No more favicons are needed by the application JumpList. Schedule a | 423 // No more favicons are needed by the application JumpList. Schedule a |
| 400 // RunUpdate call. | 424 // RunUpdateOnFileThread call. |
| 401 PostRunUpdate(); | 425 PostRunUpdate(); |
| 402 return; | 426 return; |
| 403 } | 427 } |
| 404 | 428 |
| 405 FaviconService* favicon_service = | 429 FaviconService* favicon_service = |
| 406 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 430 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 407 task_id_ = favicon_service->GetFaviconImageForPageURL( | 431 task_id_ = favicon_service->GetFaviconImageForPageURL( |
| 408 url, | 432 url, |
| 409 base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)), | 433 base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)), |
| 410 &cancelable_task_tracker_); | 434 &cancelable_task_tracker_); |
| 411 } | 435 } |
| 412 | 436 |
| 413 void JumpList::OnFaviconDataAvailable( | 437 void JumpList::OnFaviconDataAvailable( |
| 414 const favicon_base::FaviconImageResult& image_result) { | 438 const favicon_base::FaviconImageResult& image_result) { |
| 415 // If there is currently a favicon request in progress, it is now outdated, | 439 // If there is currently a favicon request in progress, it is now outdated, |
| 416 // as we have received another, so nullify the handle from the old request. | 440 // as we have received another, so nullify the handle from the old request. |
| 417 task_id_ = base::CancelableTaskTracker::kBadTaskId; | 441 task_id_ = base::CancelableTaskTracker::kBadTaskId; |
| 418 // lock the list to set icon data and pop the url | 442 // Lock the list to set icon data and pop the url. |
| 419 { | 443 { |
| 420 base::AutoLock auto_lock(list_lock_); | 444 base::AutoLock auto_lock(list_lock_); |
| 421 // Attach the received data to the ShellLinkItem object. | 445 // Attach the received data to the ShellLinkItem object. |
| 422 // This data will be decoded by the RunUpdate method. | 446 // This data will be decoded by the RunUpdateOnFileThread method. |
| 423 if (!image_result.image.IsEmpty()) { | 447 if (!image_result.image.IsEmpty()) { |
| 424 if (!icon_urls_.empty() && icon_urls_.front().second) | 448 if (!icon_urls_.empty() && icon_urls_.front().second) |
| 425 icon_urls_.front().second->set_icon_data(image_result.image.AsBitmap()); | 449 icon_urls_.front().second->set_icon_data(image_result.image.AsBitmap()); |
| 426 } | 450 } |
| 427 | 451 |
| 428 if (!icon_urls_.empty()) | 452 if (!icon_urls_.empty()) |
| 429 icon_urls_.pop_front(); | 453 icon_urls_.pop_front(); |
| 430 } | 454 } |
| 431 // Check whether we need to load more favicons. | 455 // Check whether we need to load more favicons. |
| 432 StartLoadingFavicon(); | 456 StartLoadingFavicon(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 445 } | 469 } |
| 446 | 470 |
| 447 void JumpList::PostRunUpdate() { | 471 void JumpList::PostRunUpdate() { |
| 448 // Check if incognito windows (or normal windows) are disabled by policy. | 472 // Check if incognito windows (or normal windows) are disabled by policy. |
| 449 IncognitoModePrefs::Availability incognito_availability = | 473 IncognitoModePrefs::Availability incognito_availability = |
| 450 profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) | 474 profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) |
| 451 : IncognitoModePrefs::ENABLED; | 475 : IncognitoModePrefs::ENABLED; |
| 452 | 476 |
| 453 BrowserThread::PostTask( | 477 BrowserThread::PostTask( |
| 454 BrowserThread::FILE, FROM_HERE, | 478 BrowserThread::FILE, FROM_HERE, |
| 455 base::Bind(&JumpList::RunUpdate, this, incognito_availability)); | 479 base::Bind(&JumpList::RunUpdateOnFileThread, |
| 480 this, | |
| 481 incognito_availability)); | |
| 456 } | 482 } |
| 457 | 483 |
| 458 void JumpList::RunUpdate( | 484 void JumpList::RunUpdateOnFileThread( |
| 459 IncognitoModePrefs::Availability incognito_availability) { | 485 IncognitoModePrefs::Availability incognito_availability) { |
| 460 ShellLinkItemList local_most_visited_pages; | 486 ShellLinkItemList local_most_visited_pages; |
| 461 ShellLinkItemList local_recently_closed_pages; | 487 ShellLinkItemList local_recently_closed_pages; |
| 488 ShellLinkItemList local_profile_switcher; | |
| 462 | 489 |
| 463 { | 490 { |
| 464 base::AutoLock auto_lock(list_lock_); | 491 base::AutoLock auto_lock(list_lock_); |
| 465 // Make sure we are not out of date: if icon_urls_ is not empty, then | 492 // Make sure we are not out of date: if icon_urls_ is not empty, then |
| 466 // another notification has been received since we processed this one | 493 // another notification has been received since we processed this one |
| 467 if (!icon_urls_.empty()) | 494 if (!icon_urls_.empty()) |
| 468 return; | 495 return; |
| 469 | 496 |
| 470 // Make local copies of lists so we can release the lock. | 497 // Make local copies of lists so we can release the lock. |
| 471 local_most_visited_pages = most_visited_pages_; | 498 local_most_visited_pages = most_visited_pages_; |
| 472 local_recently_closed_pages = recently_closed_pages_; | 499 local_recently_closed_pages = recently_closed_pages_; |
| 500 local_profile_switcher = profile_switcher_; | |
| 473 } | 501 } |
| 474 | 502 |
| 475 // Delete the directory which contains old icon files, rename the current | 503 // Delete the directory which contains old icon files, rename the current |
| 476 // icon directory, and create a new directory which contains new JumpList | 504 // icon directory, and create a new directory which contains new JumpList |
| 477 // icon files. | 505 // icon files. |
| 478 base::FilePath icon_dir_old(icon_dir_.value() + L"Old"); | 506 base::FilePath icon_dir_old(icon_dir_.value() + L"Old"); |
| 479 if (base::PathExists(icon_dir_old)) | 507 if (base::PathExists(icon_dir_old)) |
| 480 base::DeleteFile(icon_dir_old, true); | 508 base::DeleteFile(icon_dir_old, true); |
| 481 base::Move(icon_dir_, icon_dir_old); | 509 base::Move(icon_dir_, icon_dir_old); |
| 482 base::CreateDirectory(icon_dir_); | 510 base::CreateDirectory(icon_dir_); |
| 483 | 511 |
| 484 // Create temporary icon files for shortcuts in the "Most Visited" category. | 512 // Create temporary icon files for shortcuts in the "Most Visited" category. |
| 485 CreateIconFiles(local_most_visited_pages); | 513 CreateIconFiles(local_most_visited_pages); |
| 486 | 514 |
| 487 // Create temporary icon files for shortcuts in the "Recently Closed" | 515 // Create temporary icon files for shortcuts in the "Recently Closed" |
| 488 // category. | 516 // category. |
| 489 CreateIconFiles(local_recently_closed_pages); | 517 CreateIconFiles(local_recently_closed_pages); |
| 490 | 518 |
| 519 // Create temporary icon files for the profile avatars in the "Profiles" | |
| 520 // category. | |
| 521 CreateIconFiles(local_profile_switcher); | |
| 522 | |
| 491 // We finished collecting all resources needed for updating an application | 523 // We finished collecting all resources needed for updating an application |
| 492 // JumpList. So, create a new JumpList and replace the current JumpList | 524 // JumpList. So, create a new JumpList and replace the current JumpList |
| 493 // with it. | 525 // with it. |
| 494 UpdateJumpList(app_id_.c_str(), local_most_visited_pages, | 526 UpdateJumpList(app_id_.c_str(), |
| 495 local_recently_closed_pages, incognito_availability); | 527 local_most_visited_pages, |
| 528 local_recently_closed_pages, | |
| 529 local_profile_switcher, | |
| 530 incognito_availability); | |
| 496 } | 531 } |
| 497 | 532 |
| 498 void JumpList::CreateIconFiles(const ShellLinkItemList& item_list) { | 533 void JumpList::CreateIconFiles(const ShellLinkItemList& item_list) { |
| 499 for (ShellLinkItemList::const_iterator item = item_list.begin(); | 534 for (ShellLinkItemList::const_iterator item = item_list.begin(); |
| 500 item != item_list.end(); ++item) { | 535 item != item_list.end(); ++item) { |
| 501 base::FilePath icon_path; | 536 base::FilePath icon_path; |
| 502 if (CreateIconFile((*item)->icon_data(), icon_dir_, &icon_path)) | 537 if (CreateIconFile((*item)->icon_data(), icon_dir_, &icon_path)) |
| 503 (*item)->set_icon(icon_path.value(), 0); | 538 (*item)->set_icon(icon_path.value(), 0); |
| 504 } | 539 } |
| 505 } | 540 } |
| 541 | |
| 542 void JumpList::UpdateProfileSwitcher() { | |
| 543 { | |
| 544 base::AutoLock auto_lock(list_lock_); | |
| 545 profile_switcher_.clear(); | |
| 546 for (size_t i = 0; i < avatar_menu_->GetNumberOfItems(); ++i) { | |
| 547 scoped_refptr<ShellLinkItem> link = CreateShellLink(); | |
| 548 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(i); | |
| 549 | |
| 550 link->set_title(item.name); | |
| 551 link->GetCommandLine()->AppendSwitchPath( | |
| 552 switches::kProfileDirectory, item.profile_path.BaseName()); | |
| 553 link->GetCommandLine()->AppendSwitch( | |
| 554 switches::kActivateExistingProfileBrowser); | |
| 555 | |
| 556 gfx::Image avatar; | |
| 557 bool is_rectangle; | |
| 558 profiles::GetTransparentBackgroundProfileAvatar( | |
| 559 item.profile_path, &avatar, &is_rectangle); | |
| 560 link->set_icon_data(avatar.AsBitmap()); | |
| 561 profile_switcher_.push_back(link); | |
| 562 } | |
| 563 } | |
|
tapted
2014/11/04 23:10:48
This is a bit nitty, but it's typically good to av
noms (inactive)
2014/11/10 21:46:08
Done.
| |
| 564 } | |
| OLD | NEW |