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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 | 1036 |
1037 void DownloadsDownloadFunction::OnStarted( | 1037 void DownloadsDownloadFunction::OnStarted( |
1038 const base::FilePath& creator_suggested_filename, | 1038 const base::FilePath& creator_suggested_filename, |
1039 extensions::api::downloads::FilenameConflictAction creator_conflict_action, | 1039 extensions::api::downloads::FilenameConflictAction creator_conflict_action, |
1040 DownloadItem* item, | 1040 DownloadItem* item, |
1041 net::Error error) { | 1041 net::Error error) { |
1042 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1042 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1043 VLOG(1) << __FUNCTION__ << " " << item << " " << error; | 1043 VLOG(1) << __FUNCTION__ << " " << item << " " << error; |
1044 if (item) { | 1044 if (item) { |
1045 DCHECK_EQ(net::OK, error); | 1045 DCHECK_EQ(net::OK, error); |
1046 SetResult(base::Value::CreateIntegerValue(item->GetId())); | 1046 SetResult(new base::FundamentalValue(static_cast<int>(item->GetId()))); |
1047 if (!creator_suggested_filename.empty()) { | 1047 if (!creator_suggested_filename.empty()) { |
1048 ExtensionDownloadsEventRouterData* data = | 1048 ExtensionDownloadsEventRouterData* data = |
1049 ExtensionDownloadsEventRouterData::Get(item); | 1049 ExtensionDownloadsEventRouterData::Get(item); |
1050 if (!data) { | 1050 if (!data) { |
1051 data = new ExtensionDownloadsEventRouterData( | 1051 data = new ExtensionDownloadsEventRouterData( |
1052 item, | 1052 item, |
1053 scoped_ptr<base::DictionaryValue>(new base::DictionaryValue())); | 1053 scoped_ptr<base::DictionaryValue>(new base::DictionaryValue())); |
1054 } | 1054 } |
1055 data->CreatorSuggestedFilename( | 1055 data->CreatorSuggestedFilename( |
1056 creator_suggested_filename, creator_conflict_action); | 1056 creator_suggested_filename, creator_conflict_action); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 RunDownloadQuery(params->query, | 1180 RunDownloadQuery(params->query, |
1181 manager, | 1181 manager, |
1182 incognito_manager, | 1182 incognito_manager, |
1183 &error_, | 1183 &error_, |
1184 &results); | 1184 &results); |
1185 if (!error_.empty()) | 1185 if (!error_.empty()) |
1186 return false; | 1186 return false; |
1187 base::ListValue* json_results = new base::ListValue(); | 1187 base::ListValue* json_results = new base::ListValue(); |
1188 for (DownloadManager::DownloadVector::const_iterator it = results.begin(); | 1188 for (DownloadManager::DownloadVector::const_iterator it = results.begin(); |
1189 it != results.end(); ++it) { | 1189 it != results.end(); ++it) { |
1190 json_results->Append(base::Value::CreateIntegerValue((*it)->GetId())); | 1190 json_results->Append( |
| 1191 new base::FundamentalValue(static_cast<int>((*it)->GetId()))); |
1191 (*it)->Remove(); | 1192 (*it)->Remove(); |
1192 } | 1193 } |
1193 SetResult(json_results); | 1194 SetResult(json_results); |
1194 RecordApiFunctions(DOWNLOADS_FUNCTION_ERASE); | 1195 RecordApiFunctions(DOWNLOADS_FUNCTION_ERASE); |
1195 return true; | 1196 return true; |
1196 } | 1197 } |
1197 | 1198 |
1198 DownloadsRemoveFileFunction::DownloadsRemoveFileFunction() {} | 1199 DownloadsRemoveFileFunction::DownloadsRemoveFileFunction() {} |
1199 | 1200 |
1200 DownloadsRemoveFileFunction::~DownloadsRemoveFileFunction() { | 1201 DownloadsRemoveFileFunction::~DownloadsRemoveFileFunction() { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 return true; | 1473 return true; |
1473 } | 1474 } |
1474 | 1475 |
1475 void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { | 1476 void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { |
1476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1477 if (Fault(url.empty(), errors::kIconNotFound, &error_)) { | 1478 if (Fault(url.empty(), errors::kIconNotFound, &error_)) { |
1478 SendResponse(false); | 1479 SendResponse(false); |
1479 return; | 1480 return; |
1480 } | 1481 } |
1481 RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); | 1482 RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); |
1482 SetResult(base::Value::CreateStringValue(url)); | 1483 SetResult(new base::StringValue(url)); |
1483 SendResponse(true); | 1484 SendResponse(true); |
1484 } | 1485 } |
1485 | 1486 |
1486 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( | 1487 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( |
1487 Profile* profile, | 1488 Profile* profile, |
1488 DownloadManager* manager) | 1489 DownloadManager* manager) |
1489 : profile_(profile), | 1490 : profile_(profile), |
1490 notifier_(manager, this) { | 1491 notifier_(manager, this) { |
1491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1492 DCHECK(profile_); | 1493 DCHECK(profile_); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 } | 1813 } |
1813 | 1814 |
1814 void ExtensionDownloadsEventRouter::OnDownloadRemoved( | 1815 void ExtensionDownloadsEventRouter::OnDownloadRemoved( |
1815 DownloadManager* manager, DownloadItem* download_item) { | 1816 DownloadManager* manager, DownloadItem* download_item) { |
1816 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1817 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1817 if (download_item->IsTemporary()) | 1818 if (download_item->IsTemporary()) |
1818 return; | 1819 return; |
1819 DispatchEvent(events::kOnDownloadErased, | 1820 DispatchEvent(events::kOnDownloadErased, |
1820 true, | 1821 true, |
1821 extensions::Event::WillDispatchCallback(), | 1822 extensions::Event::WillDispatchCallback(), |
1822 base::Value::CreateIntegerValue(download_item->GetId())); | 1823 new base::FundamentalValue( |
| 1824 static_cast<int>(download_item->GetId()))); |
1823 } | 1825 } |
1824 | 1826 |
1825 void ExtensionDownloadsEventRouter::DispatchEvent( | 1827 void ExtensionDownloadsEventRouter::DispatchEvent( |
1826 const char* event_name, | 1828 const char* event_name, |
1827 bool include_incognito, | 1829 bool include_incognito, |
1828 const extensions::Event::WillDispatchCallback& will_dispatch_callback, | 1830 const extensions::Event::WillDispatchCallback& will_dispatch_callback, |
1829 base::Value* arg) { | 1831 base::Value* arg) { |
1830 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1832 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1831 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) | 1833 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) |
1832 return; | 1834 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 extensions::UnloadedExtensionInfo* unloaded = | 1869 extensions::UnloadedExtensionInfo* unloaded = |
1868 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 1870 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
1869 std::set<const extensions::Extension*>::iterator iter = | 1871 std::set<const extensions::Extension*>::iterator iter = |
1870 shelf_disabling_extensions_.find(unloaded->extension); | 1872 shelf_disabling_extensions_.find(unloaded->extension); |
1871 if (iter != shelf_disabling_extensions_.end()) | 1873 if (iter != shelf_disabling_extensions_.end()) |
1872 shelf_disabling_extensions_.erase(iter); | 1874 shelf_disabling_extensions_.erase(iter); |
1873 break; | 1875 break; |
1874 } | 1876 } |
1875 } | 1877 } |
1876 } | 1878 } |
OLD | NEW |