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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <set> | 10 #include <set> |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 int icon_size = kDefaultIconSize; | 853 int icon_size = kDefaultIconSize; |
854 if (options && options->size.get()) | 854 if (options && options->size.get()) |
855 icon_size = *options->size.get(); | 855 icon_size = *options->size.get(); |
856 DownloadManager* manager = NULL; | 856 DownloadManager* manager = NULL; |
857 DownloadManager* incognito_manager = NULL; | 857 DownloadManager* incognito_manager = NULL; |
858 GetManagers(profile(), include_incognito(), &manager, &incognito_manager); | 858 GetManagers(profile(), include_incognito(), &manager, &incognito_manager); |
859 DownloadItem* download_item = manager->GetDownload(params->download_id); | 859 DownloadItem* download_item = manager->GetDownload(params->download_id); |
860 if (!download_item && incognito_manager) | 860 if (!download_item && incognito_manager) |
861 download_item = incognito_manager->GetDownload(params->download_id); | 861 download_item = incognito_manager->GetDownload(params->download_id); |
862 if (!download_item || download_item->GetTargetFilePath().empty()) { | 862 if (!download_item || download_item->GetTargetFilePath().empty()) { |
863 // The DownloadItem is is added to history when the path is determined. If | |
864 // the download is not in history, then we don't have a path / final | |
865 // filename and no icon. | |
866 error_ = download_extension_errors::kInvalidOperationError; | 863 error_ = download_extension_errors::kInvalidOperationError; |
867 return false; | 864 return false; |
868 } | 865 } |
869 // In-progress downloads return the intermediate filename for GetFullPath() | 866 // In-progress downloads return the intermediate filename for GetFullPath() |
870 // which doesn't have the final extension. Therefore we won't be able to | 867 // which doesn't have the final extension. Therefore we won't be able to |
871 // derive a good file icon for it. So we use GetTargetFilePath() instead. | 868 // derive a good file icon for it. So we use GetTargetFilePath() instead. |
872 DCHECK(icon_extractor_.get()); | 869 DCHECK(icon_extractor_.get()); |
873 DCHECK(icon_size == 16 || icon_size == 32); | 870 DCHECK(icon_size == 16 || icon_size == 32); |
874 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath( | 871 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath( |
875 download_item->GetTargetFilePath(), | 872 download_item->GetTargetFilePath(), |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 if (profile_->HasOffTheRecordProfile() && | 1002 if (profile_->HasOffTheRecordProfile() && |
1006 !profile_->IsOffTheRecord()) { | 1003 !profile_->IsOffTheRecord()) { |
1007 DispatchEventInternal( | 1004 DispatchEventInternal( |
1008 profile_->GetOffTheRecordProfile(), | 1005 profile_->GetOffTheRecordProfile(), |
1009 event_name, | 1006 event_name, |
1010 json_args, | 1007 json_args, |
1011 scoped_ptr<base::ListValue>(args->DeepCopy())); | 1008 scoped_ptr<base::ListValue>(args->DeepCopy())); |
1012 } | 1009 } |
1013 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); | 1010 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); |
1014 } | 1011 } |
OLD | NEW |