| 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 #include <propvarutil.h> | 10 #include <propvarutil.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 23 #include "base/win/scoped_comptr.h" | 23 #include "base/win/scoped_comptr.h" |
| 24 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
| 25 #include "chrome/browser/favicon/favicon_service.h" | 25 #include "chrome/browser/favicon/favicon_service.h" |
| 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 26 #include "chrome/browser/history/history.h" | 27 #include "chrome/browser/history/history.h" |
| 27 #include "chrome/browser/history/page_usage_data.h" | 28 #include "chrome/browser/history/page_usage_data.h" |
| 28 #include "chrome/browser/history/top_sites.h" | 29 #include "chrome/browser/history/top_sites.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/sessions/session_types.h" | 31 #include "chrome/browser/sessions/session_types.h" |
| 31 #include "chrome/browser/sessions/tab_restore_service.h" | 32 #include "chrome/browser/sessions/tab_restore_service.h" |
| 32 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 33 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 33 #include "chrome/browser/shell_integration.h" | 34 #include "chrome/browser/shell_integration.h" |
| 34 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
| 35 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 TabRestoreServiceFactory::GetForProfile(profile_); | 568 TabRestoreServiceFactory::GetForProfile(profile_); |
| 568 if (tab_restore_service) | 569 if (tab_restore_service) |
| 569 tab_restore_service->RemoveObserver(this); | 570 tab_restore_service->RemoveObserver(this); |
| 570 registrar_.reset(); | 571 registrar_.reset(); |
| 571 } | 572 } |
| 572 profile_ = NULL; | 573 profile_ = NULL; |
| 573 } | 574 } |
| 574 | 575 |
| 575 void JumpList::CancelPendingUpdate() { | 576 void JumpList::CancelPendingUpdate() { |
| 576 if (handle_) { | 577 if (handle_) { |
| 577 FaviconService* favicon_service = | 578 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
| 578 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 579 profile_, Profile::EXPLICIT_ACCESS); |
| 579 favicon_service->CancelRequest(handle_); | 580 favicon_service->CancelRequest(handle_); |
| 580 handle_ = NULL; | 581 handle_ = NULL; |
| 581 } | 582 } |
| 582 } | 583 } |
| 583 | 584 |
| 584 void JumpList::Terminate() { | 585 void JumpList::Terminate() { |
| 585 CancelPendingUpdate(); | 586 CancelPendingUpdate(); |
| 586 RemoveObserver(); | 587 RemoveObserver(); |
| 587 } | 588 } |
| 588 | 589 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 GURL url; | 693 GURL url; |
| 693 { | 694 { |
| 694 base::AutoLock auto_lock(list_lock_); | 695 base::AutoLock auto_lock(list_lock_); |
| 695 if (icon_urls_.empty()) | 696 if (icon_urls_.empty()) |
| 696 return false; | 697 return false; |
| 697 // Ask FaviconService if it has a favicon of a URL. | 698 // Ask FaviconService if it has a favicon of a URL. |
| 698 // When FaviconService has one, it will call OnFaviconDataAvailable(). | 699 // When FaviconService has one, it will call OnFaviconDataAvailable(). |
| 699 url = GURL(icon_urls_.front().first); | 700 url = GURL(icon_urls_.front().first); |
| 700 } | 701 } |
| 701 FaviconService* favicon_service = | 702 FaviconService* favicon_service = |
| 702 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 703 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 703 handle_ = favicon_service->GetFaviconForURL( | 704 handle_ = favicon_service->GetFaviconForURL( |
| 704 url, history::FAVICON, &favicon_consumer_, | 705 profile_, url, history::FAVICON, &favicon_consumer_, |
| 705 base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this))); | 706 base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this))); |
| 706 return true; | 707 return true; |
| 707 } | 708 } |
| 708 | 709 |
| 709 void JumpList::OnFaviconDataAvailable( | 710 void JumpList::OnFaviconDataAvailable( |
| 710 FaviconService::Handle handle, | 711 FaviconService::Handle handle, |
| 711 history::FaviconData favicon) { | 712 history::FaviconData favicon) { |
| 712 // If there is currently a favicon request in progress, it is now outdated, | 713 // If there is currently a favicon request in progress, it is now outdated, |
| 713 // as we have received another, so nullify the handle from the old request. | 714 // as we have received another, so nullify the handle from the old request. |
| 714 handle_ = NULL; | 715 handle_ = NULL; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 if ((*item)->data().get() && | 784 if ((*item)->data().get() && |
| 784 gfx::PNGCodec::Decode((*item)->data()->front(), | 785 gfx::PNGCodec::Decode((*item)->data()->front(), |
| 785 (*item)->data()->size(), | 786 (*item)->data()->size(), |
| 786 &icon_bitmap)) { | 787 &icon_bitmap)) { |
| 787 FilePath icon_path; | 788 FilePath icon_path; |
| 788 if (CreateIconFile(icon_bitmap, icon_dir_, &icon_path)) | 789 if (CreateIconFile(icon_bitmap, icon_dir_, &icon_path)) |
| 789 (*item)->SetIcon(icon_path.value(), 0, true); | 790 (*item)->SetIcon(icon_path.value(), 0, true); |
| 790 } | 791 } |
| 791 } | 792 } |
| 792 } | 793 } |
| OLD | NEW |