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((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(new base::FundamentalValue((int)(*it)->GetId())); |
1191 (*it)->Remove(); | 1191 (*it)->Remove(); |
1192 } | 1192 } |
1193 SetResult(json_results); | 1193 SetResult(json_results); |
1194 RecordApiFunctions(DOWNLOADS_FUNCTION_ERASE); | 1194 RecordApiFunctions(DOWNLOADS_FUNCTION_ERASE); |
1195 return true; | 1195 return true; |
1196 } | 1196 } |
1197 | 1197 |
1198 DownloadsRemoveFileFunction::DownloadsRemoveFileFunction() {} | 1198 DownloadsRemoveFileFunction::DownloadsRemoveFileFunction() {} |
1199 | 1199 |
1200 DownloadsRemoveFileFunction::~DownloadsRemoveFileFunction() { | 1200 DownloadsRemoveFileFunction::~DownloadsRemoveFileFunction() { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 return true; | 1472 return true; |
1473 } | 1473 } |
1474 | 1474 |
1475 void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { | 1475 void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { |
1476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1477 if (Fault(url.empty(), errors::kIconNotFound, &error_)) { | 1477 if (Fault(url.empty(), errors::kIconNotFound, &error_)) { |
1478 SendResponse(false); | 1478 SendResponse(false); |
1479 return; | 1479 return; |
1480 } | 1480 } |
1481 RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); | 1481 RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); |
1482 SetResult(base::Value::CreateStringValue(url)); | 1482 SetResult(new base::StringValue(url)); |
1483 SendResponse(true); | 1483 SendResponse(true); |
1484 } | 1484 } |
1485 | 1485 |
1486 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( | 1486 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( |
1487 Profile* profile, | 1487 Profile* profile, |
1488 DownloadManager* manager) | 1488 DownloadManager* manager) |
1489 : profile_(profile), | 1489 : profile_(profile), |
1490 notifier_(manager, this) { | 1490 notifier_(manager, this) { |
1491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1492 DCHECK(profile_); | 1492 DCHECK(profile_); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 } | 1812 } |
1813 | 1813 |
1814 void ExtensionDownloadsEventRouter::OnDownloadRemoved( | 1814 void ExtensionDownloadsEventRouter::OnDownloadRemoved( |
1815 DownloadManager* manager, DownloadItem* download_item) { | 1815 DownloadManager* manager, DownloadItem* download_item) { |
1816 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1816 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1817 if (download_item->IsTemporary()) | 1817 if (download_item->IsTemporary()) |
1818 return; | 1818 return; |
1819 DispatchEvent(events::kOnDownloadErased, | 1819 DispatchEvent(events::kOnDownloadErased, |
1820 true, | 1820 true, |
1821 extensions::Event::WillDispatchCallback(), | 1821 extensions::Event::WillDispatchCallback(), |
1822 base::Value::CreateIntegerValue(download_item->GetId())); | 1822 new base::FundamentalValue((int)download_item->GetId())); |
1823 } | 1823 } |
1824 | 1824 |
1825 void ExtensionDownloadsEventRouter::DispatchEvent( | 1825 void ExtensionDownloadsEventRouter::DispatchEvent( |
1826 const char* event_name, | 1826 const char* event_name, |
1827 bool include_incognito, | 1827 bool include_incognito, |
1828 const extensions::Event::WillDispatchCallback& will_dispatch_callback, | 1828 const extensions::Event::WillDispatchCallback& will_dispatch_callback, |
1829 base::Value* arg) { | 1829 base::Value* arg) { |
1830 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1830 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1831 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) | 1831 if (!extensions::ExtensionSystem::Get(profile_)->event_router()) |
1832 return; | 1832 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 extensions::UnloadedExtensionInfo* unloaded = | 1867 extensions::UnloadedExtensionInfo* unloaded = |
1868 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 1868 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
1869 std::set<const extensions::Extension*>::iterator iter = | 1869 std::set<const extensions::Extension*>::iterator iter = |
1870 shelf_disabling_extensions_.find(unloaded->extension); | 1870 shelf_disabling_extensions_.find(unloaded->extension); |
1871 if (iter != shelf_disabling_extensions_.end()) | 1871 if (iter != shelf_disabling_extensions_.end()) |
1872 shelf_disabling_extensions_.erase(iter); | 1872 shelf_disabling_extensions_.erase(iter); |
1873 break; | 1873 break; |
1874 } | 1874 } |
1875 } | 1875 } |
1876 } | 1876 } |
OLD | NEW |