| 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/download/download_status_updater.h" | 5 #include "chrome/browser/download/download_status_updater.h" |
| 6 | 6 |
| 7 #include <objbase.h> |
| 7 #include <shobjidl.h> | 8 #include <shobjidl.h> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/win/scoped_comptr.h" | 12 #include "base/win/scoped_comptr.h" |
| 12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "ui/views/win/hwnd_util.h" | 17 #include "ui/views/win/hwnd_util.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 void UpdateTaskbarProgressBar(int download_count, | 21 void UpdateTaskbarProgressBar(int download_count, |
| 21 bool progress_known, | 22 bool progress_known, |
| 22 float progress) { | 23 float progress) { |
| 23 // Taskbar progress bar is only supported on Win7. | 24 // Taskbar progress bar is only supported on Win7. |
| 24 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 25 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 25 return; | 26 return; |
| 26 | 27 |
| 27 base::win::ScopedComPtr<ITaskbarList3> taskbar; | 28 base::win::ScopedComPtr<ITaskbarList3> taskbar; |
| 28 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL, | 29 HRESULT result = ::CoCreateInstance( |
| 29 CLSCTX_INPROC_SERVER); | 30 CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbar)); |
| 30 if (FAILED(result)) { | 31 if (FAILED(result)) { |
| 31 DVLOG(1) << "Failed creating a TaskbarList object: " << result; | 32 DVLOG(1) << "Failed creating a TaskbarList object: " << result; |
| 32 return; | 33 return; |
| 33 } | 34 } |
| 34 | 35 |
| 35 result = taskbar->HrInit(); | 36 result = taskbar->HrInit(); |
| 36 if (FAILED(result)) { | 37 if (FAILED(result)) { |
| 37 LOG(ERROR) << "Failed initializing an ITaskbarList3 interface."; | 38 LOG(ERROR) << "Failed initializing an ITaskbarList3 interface."; |
| 38 return; | 39 return; |
| 39 } | 40 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 | 58 |
| 58 void DownloadStatusUpdater::UpdateAppIconDownloadProgress( | 59 void DownloadStatusUpdater::UpdateAppIconDownloadProgress( |
| 59 content::DownloadItem* download) { | 60 content::DownloadItem* download) { |
| 60 | 61 |
| 61 // Always update overall progress. | 62 // Always update overall progress. |
| 62 float progress = 0; | 63 float progress = 0; |
| 63 int download_count = 0; | 64 int download_count = 0; |
| 64 bool progress_known = GetProgress(&progress, &download_count); | 65 bool progress_known = GetProgress(&progress, &download_count); |
| 65 UpdateTaskbarProgressBar(download_count, progress_known, progress); | 66 UpdateTaskbarProgressBar(download_count, progress_known, progress); |
| 66 } | 67 } |
| OLD | NEW |