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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 #include "content/public/browser/render_process_host.h" | 62 #include "content/public/browser/render_process_host.h" |
63 #include "content/public/browser/render_view_host.h" | 63 #include "content/public/browser/render_view_host.h" |
64 #include "content/public/browser/render_widget_host_view.h" | 64 #include "content/public/browser/render_widget_host_view.h" |
65 #include "content/public/browser/resource_context.h" | 65 #include "content/public/browser/resource_context.h" |
66 #include "content/public/browser/resource_dispatcher_host.h" | 66 #include "content/public/browser/resource_dispatcher_host.h" |
67 #include "content/public/browser/web_contents.h" | 67 #include "content/public/browser/web_contents.h" |
68 #include "content/public/browser/web_contents_view.h" | 68 #include "content/public/browser/web_contents_view.h" |
69 #include "extensions/browser/event_router.h" | 69 #include "extensions/browser/event_router.h" |
70 #include "extensions/browser/extension_function_dispatcher.h" | 70 #include "extensions/browser/extension_function_dispatcher.h" |
71 #include "extensions/browser/extension_prefs.h" | 71 #include "extensions/browser/extension_prefs.h" |
72 #include "extensions/browser/extension_registry.h" | |
72 #include "extensions/browser/extension_system.h" | 73 #include "extensions/browser/extension_system.h" |
73 #include "extensions/common/extension.h" | 74 #include "extensions/common/extension.h" |
74 #include "extensions/common/permissions/permissions_data.h" | 75 #include "extensions/common/permissions/permissions_data.h" |
75 #include "net/base/filename_util.h" | 76 #include "net/base/filename_util.h" |
76 #include "net/base/load_flags.h" | 77 #include "net/base/load_flags.h" |
77 #include "net/http/http_util.h" | 78 #include "net/http/http_util.h" |
78 #include "net/url_request/url_request.h" | 79 #include "net/url_request/url_request.h" |
79 #include "third_party/skia/include/core/SkBitmap.h" | 80 #include "third_party/skia/include/core/SkBitmap.h" |
80 #include "ui/base/webui/web_ui_util.h" | 81 #include "ui/base/webui/web_ui_util.h" |
81 #include "ui/gfx/image/image_skia.h" | 82 #include "ui/gfx/image/image_skia.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 if (*query_in.limit.get() < 0) { | 502 if (*query_in.limit.get() < 0) { |
502 *error = errors::kInvalidQueryLimit; | 503 *error = errors::kInvalidQueryLimit; |
503 return; | 504 return; |
504 } | 505 } |
505 limit = *query_in.limit.get(); | 506 limit = *query_in.limit.get(); |
506 } | 507 } |
507 if (limit > 0) { | 508 if (limit > 0) { |
508 query_out.Limit(limit); | 509 query_out.Limit(limit); |
509 } | 510 } |
510 | 511 |
511 std::string state_string = | 512 std::string state_string = downloads::ToString(query_in.state); |
512 downloads::ToString(query_in.state); | |
513 if (!state_string.empty()) { | 513 if (!state_string.empty()) { |
514 DownloadItem::DownloadState state = StateEnumFromString(state_string); | 514 DownloadItem::DownloadState state = StateEnumFromString(state_string); |
515 if (state == DownloadItem::MAX_DOWNLOAD_STATE) { | 515 if (state == DownloadItem::MAX_DOWNLOAD_STATE) { |
516 *error = errors::kInvalidState; | 516 *error = errors::kInvalidState; |
517 return; | 517 return; |
518 } | 518 } |
519 query_out.AddFilter(state); | 519 query_out.AddFilter(state); |
520 } | 520 } |
521 std::string danger_string = | 521 std::string danger_string = |
522 downloads::ToString(query_in.danger); | 522 downloads::ToString(query_in.danger); |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1515 } | 1515 } |
1516 RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); | 1516 RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); |
1517 SetResult(new base::StringValue(url)); | 1517 SetResult(new base::StringValue(url)); |
1518 SendResponse(true); | 1518 SendResponse(true); |
1519 } | 1519 } |
1520 | 1520 |
1521 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( | 1521 ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( |
1522 Profile* profile, | 1522 Profile* profile, |
1523 DownloadManager* manager) | 1523 DownloadManager* manager) |
1524 : profile_(profile), | 1524 : profile_(profile), |
1525 notifier_(manager, this) { | 1525 notifier_(manager, this), |
1526 scoped_extension_registry_observer_(this) { | |
1526 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1527 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1527 DCHECK(profile_); | 1528 DCHECK(profile_); |
1528 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 1529 scoped_extension_registry_observer_.Add( |
1529 content::Source<Profile>(profile_)); | 1530 extensions::ExtensionRegistry::Get(profile_)); |
1530 extensions::EventRouter* router = extensions::EventRouter::Get(profile_); | 1531 extensions::EventRouter* router = extensions::EventRouter::Get(profile_); |
1531 if (router) | 1532 if (router) |
1532 router->RegisterObserver(this, | 1533 router->RegisterObserver(this, |
1533 downloads::OnDeterminingFilename::kEventName); | 1534 downloads::OnDeterminingFilename::kEventName); |
1534 } | 1535 } |
1535 | 1536 |
1536 ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() { | 1537 ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() { |
1537 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1538 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1538 extensions::EventRouter* router = extensions::EventRouter::Get(profile_); | 1539 extensions::EventRouter* router = extensions::EventRouter::Get(profile_); |
1539 if (router) | 1540 if (router) |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1890 notification_source.event_name = event_name; | 1891 notification_source.event_name = event_name; |
1891 notification_source.profile = profile_; | 1892 notification_source.profile = profile_; |
1892 content::Source<DownloadsNotificationSource> content_source( | 1893 content::Source<DownloadsNotificationSource> content_source( |
1893 ¬ification_source); | 1894 ¬ification_source); |
1894 content::NotificationService::current()->Notify( | 1895 content::NotificationService::current()->Notify( |
1895 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 1896 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
1896 content_source, | 1897 content_source, |
1897 content::Details<std::string>(&json_args)); | 1898 content::Details<std::string>(&json_args)); |
1898 } | 1899 } |
1899 | 1900 |
1900 void ExtensionDownloadsEventRouter::Observe( | 1901 void ExtensionDownloadsEventRouter::OnExtensionUnloaded( |
1901 int type, | 1902 content::BrowserContext* browser_context, |
1902 const content::NotificationSource& source, | 1903 const extensions::Extension* extension, |
1903 const content::NotificationDetails& details) { | 1904 extensions::UnloadedExtensionInfo::Reason reason) { |
1904 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1905 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1905 switch (type) { | 1906 std::set<const extensions::Extension*>::iterator iter = |
1906 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 1907 shelf_disabling_extensions_.find(extension); |
1907 extensions::UnloadedExtensionInfo* unloaded = | |
1908 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | |
1909 std::set<const extensions::Extension*>::iterator iter = | |
1910 shelf_disabling_extensions_.find(unloaded->extension); | |
1911 if (iter != shelf_disabling_extensions_.end()) | 1908 if (iter != shelf_disabling_extensions_.end()) |
benjhayden
2014/04/24 17:38:48
Is the indentation correct here? I can't tell.
limasdf
2014/04/24 18:27:47
My bad. Done.
| |
1912 shelf_disabling_extensions_.erase(iter); | 1909 shelf_disabling_extensions_.erase(iter); |
1913 break; | |
1914 } | |
1915 } | |
1916 } | 1910 } |
OLD | NEW |