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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "content/public/browser/render_process_host.h" | 57 #include "content/public/browser/render_process_host.h" |
58 #include "content/public/browser/render_view_host.h" | 58 #include "content/public/browser/render_view_host.h" |
59 #include "content/public/browser/render_widget_host_view.h" | 59 #include "content/public/browser/render_widget_host_view.h" |
60 #include "content/public/browser/resource_context.h" | 60 #include "content/public/browser/resource_context.h" |
61 #include "content/public/browser/resource_dispatcher_host.h" | 61 #include "content/public/browser/resource_dispatcher_host.h" |
62 #include "content/public/browser/web_contents.h" | 62 #include "content/public/browser/web_contents.h" |
63 #include "extensions/browser/event_router.h" | 63 #include "extensions/browser/event_router.h" |
64 #include "extensions/browser/extension_function_dispatcher.h" | 64 #include "extensions/browser/extension_function_dispatcher.h" |
65 #include "extensions/browser/extension_prefs.h" | 65 #include "extensions/browser/extension_prefs.h" |
66 #include "extensions/browser/extension_registry.h" | 66 #include "extensions/browser/extension_registry.h" |
| 67 #include "extensions/common/permissions/permissions_data.h" |
67 #include "net/base/filename_util.h" | 68 #include "net/base/filename_util.h" |
68 #include "net/base/load_flags.h" | 69 #include "net/base/load_flags.h" |
69 #include "net/http/http_util.h" | 70 #include "net/http/http_util.h" |
70 #include "third_party/skia/include/core/SkBitmap.h" | 71 #include "third_party/skia/include/core/SkBitmap.h" |
71 #include "ui/base/webui/web_ui_util.h" | 72 #include "ui/base/webui/web_ui_util.h" |
72 #include "ui/gfx/image/image_skia.h" | 73 #include "ui/gfx/image/image_skia.h" |
73 | 74 |
74 using content::BrowserContext; | 75 using content::BrowserContext; |
75 using content::BrowserThread; | 76 using content::BrowserThread; |
76 using content::DownloadItem; | 77 using content::DownloadItem; |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 scoped_ptr<downloads::Open::Params> params( | 1380 scoped_ptr<downloads::Open::Params> params( |
1380 downloads::Open::Params::Create(*args_)); | 1381 downloads::Open::Params::Create(*args_)); |
1381 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1382 EXTENSION_FUNCTION_VALIDATE(params.get()); |
1382 DownloadItem* download_item = | 1383 DownloadItem* download_item = |
1383 GetDownload(GetProfile(), include_incognito(), params->download_id); | 1384 GetDownload(GetProfile(), include_incognito(), params->download_id); |
1384 if (InvalidId(download_item, &error_) || | 1385 if (InvalidId(download_item, &error_) || |
1385 Fault(!user_gesture(), errors::kUserGesture, &error_) || | 1386 Fault(!user_gesture(), errors::kUserGesture, &error_) || |
1386 Fault(download_item->GetState() != DownloadItem::COMPLETE, | 1387 Fault(download_item->GetState() != DownloadItem::COMPLETE, |
1387 errors::kNotComplete, | 1388 errors::kNotComplete, |
1388 &error_) || | 1389 &error_) || |
1389 Fault(!GetExtension()->HasAPIPermission(APIPermission::kDownloadsOpen), | 1390 Fault(!GetExtension()->permissions_data()->HasAPIPermission( |
| 1391 APIPermission::kDownloadsOpen), |
1390 errors::kOpenPermission, | 1392 errors::kOpenPermission, |
1391 &error_)) | 1393 &error_)) |
1392 return false; | 1394 return false; |
1393 download_item->OpenDownload(); | 1395 download_item->OpenDownload(); |
1394 RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN); | 1396 RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN); |
1395 return true; | 1397 return true; |
1396 } | 1398 } |
1397 | 1399 |
1398 DownloadsDragFunction::DownloadsDragFunction() {} | 1400 DownloadsDragFunction::DownloadsDragFunction() {} |
1399 | 1401 |
(...skipping 24 matching lines...) Expand all Loading... |
1424 } | 1426 } |
1425 | 1427 |
1426 DownloadsSetShelfEnabledFunction::DownloadsSetShelfEnabledFunction() {} | 1428 DownloadsSetShelfEnabledFunction::DownloadsSetShelfEnabledFunction() {} |
1427 | 1429 |
1428 DownloadsSetShelfEnabledFunction::~DownloadsSetShelfEnabledFunction() {} | 1430 DownloadsSetShelfEnabledFunction::~DownloadsSetShelfEnabledFunction() {} |
1429 | 1431 |
1430 bool DownloadsSetShelfEnabledFunction::RunSync() { | 1432 bool DownloadsSetShelfEnabledFunction::RunSync() { |
1431 scoped_ptr<downloads::SetShelfEnabled::Params> params( | 1433 scoped_ptr<downloads::SetShelfEnabled::Params> params( |
1432 downloads::SetShelfEnabled::Params::Create(*args_)); | 1434 downloads::SetShelfEnabled::Params::Create(*args_)); |
1433 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1435 EXTENSION_FUNCTION_VALIDATE(params.get()); |
1434 if (!GetExtension()->HasAPIPermission(APIPermission::kDownloadsShelf)) { | 1436 if (!GetExtension()->permissions_data()->HasAPIPermission( |
| 1437 APIPermission::kDownloadsShelf)) { |
1435 error_ = download_extension_errors::kShelfPermission; | 1438 error_ = download_extension_errors::kShelfPermission; |
1436 return false; | 1439 return false; |
1437 } | 1440 } |
1438 | 1441 |
1439 RecordApiFunctions(DOWNLOADS_FUNCTION_SET_SHELF_ENABLED); | 1442 RecordApiFunctions(DOWNLOADS_FUNCTION_SET_SHELF_ENABLED); |
1440 DownloadManager* manager = NULL; | 1443 DownloadManager* manager = NULL; |
1441 DownloadManager* incognito_manager = NULL; | 1444 DownloadManager* incognito_manager = NULL; |
1442 GetManagers(GetProfile(), include_incognito(), &manager, &incognito_manager); | 1445 GetManagers(GetProfile(), include_incognito(), &manager, &incognito_manager); |
1443 DownloadService* service = NULL; | 1446 DownloadService* service = NULL; |
1444 DownloadService* incognito_service = NULL; | 1447 DownloadService* incognito_service = NULL; |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 const Extension* extension, | 1922 const Extension* extension, |
1920 UnloadedExtensionInfo::Reason reason) { | 1923 UnloadedExtensionInfo::Reason reason) { |
1921 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1924 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1922 std::set<const Extension*>::iterator iter = | 1925 std::set<const Extension*>::iterator iter = |
1923 shelf_disabling_extensions_.find(extension); | 1926 shelf_disabling_extensions_.find(extension); |
1924 if (iter != shelf_disabling_extensions_.end()) | 1927 if (iter != shelf_disabling_extensions_.end()) |
1925 shelf_disabling_extensions_.erase(iter); | 1928 shelf_disabling_extensions_.erase(iter); |
1926 } | 1929 } |
1927 | 1930 |
1928 } // namespace extensions | 1931 } // namespace extensions |
OLD | NEW |