Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r165669 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 int icon_size = kDefaultIconSize; 856 int icon_size = kDefaultIconSize;
857 if (options && options->size.get()) 857 if (options && options->size.get())
858 icon_size = *options->size.get(); 858 icon_size = *options->size.get();
859 DownloadManager* manager = NULL; 859 DownloadManager* manager = NULL;
860 DownloadManager* incognito_manager = NULL; 860 DownloadManager* incognito_manager = NULL;
861 GetManagers(profile(), include_incognito(), &manager, &incognito_manager); 861 GetManagers(profile(), include_incognito(), &manager, &incognito_manager);
862 DownloadItem* download_item = manager->GetDownload(params->download_id); 862 DownloadItem* download_item = manager->GetDownload(params->download_id);
863 if (!download_item && incognito_manager) 863 if (!download_item && incognito_manager)
864 download_item = incognito_manager->GetDownload(params->download_id); 864 download_item = incognito_manager->GetDownload(params->download_id);
865 if (!download_item || download_item->GetTargetFilePath().empty()) { 865 if (!download_item || download_item->GetTargetFilePath().empty()) {
866 // The DownloadItem is is added to history when the path is determined. If
867 // the download is not in history, then we don't have a path / final
868 // filename and no icon.
869 error_ = download_extension_errors::kInvalidOperationError; 866 error_ = download_extension_errors::kInvalidOperationError;
870 return false; 867 return false;
871 } 868 }
872 // In-progress downloads return the intermediate filename for GetFullPath() 869 // In-progress downloads return the intermediate filename for GetFullPath()
873 // which doesn't have the final extension. Therefore we won't be able to 870 // which doesn't have the final extension. Therefore we won't be able to
874 // derive a good file icon for it. So we use GetTargetFilePath() instead. 871 // derive a good file icon for it. So we use GetTargetFilePath() instead.
875 DCHECK(icon_extractor_.get()); 872 DCHECK(icon_extractor_.get());
876 DCHECK(icon_size == 16 || icon_size == 32); 873 DCHECK(icon_size == 16 || icon_size == 32);
877 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath( 874 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath(
878 download_item->GetTargetFilePath(), 875 download_item->GetTargetFilePath(),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 if (profile_->HasOffTheRecordProfile() && 1005 if (profile_->HasOffTheRecordProfile() &&
1009 !profile_->IsOffTheRecord()) { 1006 !profile_->IsOffTheRecord()) {
1010 DispatchEventInternal( 1007 DispatchEventInternal(
1011 profile_->GetOffTheRecordProfile(), 1008 profile_->GetOffTheRecordProfile(),
1012 event_name, 1009 event_name,
1013 json_args, 1010 json_args,
1014 scoped_ptr<base::ListValue>(args->DeepCopy())); 1011 scoped_ptr<base::ListValue>(args->DeepCopy()));
1015 } 1012 }
1016 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); 1013 DispatchEventInternal(profile_, event_name, json_args, args.Pass());
1017 } 1014 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698