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