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 14 matching lines...) Expand all Loading... |
25 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
26 #include "base/values.h" | 26 #include "base/values.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/download/download_file_icon_extractor.h" | 28 #include "chrome/browser/download/download_file_icon_extractor.h" |
29 #include "chrome/browser/download/download_query.h" | 29 #include "chrome/browser/download/download_query.h" |
30 #include "chrome/browser/download/download_service.h" | 30 #include "chrome/browser/download/download_service.h" |
31 #include "chrome/browser/download/download_service_factory.h" | 31 #include "chrome/browser/download/download_service_factory.h" |
32 #include "chrome/browser/download/download_util.h" | 32 #include "chrome/browser/download/download_util.h" |
33 #include "chrome/browser/extensions/event_names.h" | 33 #include "chrome/browser/extensions/event_names.h" |
34 #include "chrome/browser/extensions/event_router.h" | 34 #include "chrome/browser/extensions/event_router.h" |
| 35 #include "chrome/browser/extensions/extension_system.h" |
35 #include "chrome/browser/icon_loader.h" | 36 #include "chrome/browser/icon_loader.h" |
36 #include "chrome/browser/icon_manager.h" | 37 #include "chrome/browser/icon_manager.h" |
37 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 38 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
38 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
39 #include "chrome/browser/ui/webui/web_ui_util.h" | 40 #include "chrome/browser/ui/webui/web_ui_util.h" |
40 #include "chrome/common/chrome_notification_types.h" | 41 #include "chrome/common/chrome_notification_types.h" |
41 #include "chrome/common/extensions/api/downloads.h" | 42 #include "chrome/common/extensions/api/downloads.h" |
42 #include "content/public/browser/download_interrupt_reasons.h" | 43 #include "content/public/browser/download_interrupt_reasons.h" |
43 #include "content/public/browser/download_item.h" | 44 #include "content/public/browser/download_item.h" |
44 #include "content/public/browser/download_save_info.h" | 45 #include "content/public/browser/download_save_info.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } | 487 } |
487 query_out.AddFilter(base::Bind(&IsNotTemporaryDownloadFilter)); | 488 query_out.AddFilter(base::Bind(&IsNotTemporaryDownloadFilter)); |
488 query_out.Search(all_items.begin(), all_items.end(), results); | 489 query_out.Search(all_items.begin(), all_items.end(), results); |
489 } | 490 } |
490 | 491 |
491 void DispatchEventInternal( | 492 void DispatchEventInternal( |
492 Profile* target_profile, | 493 Profile* target_profile, |
493 const char* event_name, | 494 const char* event_name, |
494 const std::string& json_args, | 495 const std::string& json_args, |
495 scoped_ptr<base::ListValue> event_args) { | 496 scoped_ptr<base::ListValue> event_args) { |
496 if (!target_profile->GetExtensionEventRouter()) | 497 if (!extensions::ExtensionSystem::Get(target_profile)->event_router()) |
497 return; | 498 return; |
498 target_profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 499 extensions::ExtensionSystem::Get(target_profile)->event_router()-> |
499 event_name, | 500 DispatchEventToRenderers(event_name, event_args.Pass(), target_profile, |
500 event_args.Pass(), | 501 GURL(), extensions::EventFilteringInfo()); |
501 target_profile, | |
502 GURL(), | |
503 extensions::EventFilteringInfo()); | |
504 | |
505 ExtensionDownloadsEventRouter::DownloadsNotificationSource | 502 ExtensionDownloadsEventRouter::DownloadsNotificationSource |
506 notification_source; | 503 notification_source; |
507 notification_source.event_name = event_name; | 504 notification_source.event_name = event_name; |
508 notification_source.profile = target_profile; | 505 notification_source.profile = target_profile; |
509 content::Source<ExtensionDownloadsEventRouter::DownloadsNotificationSource> | 506 content::Source<ExtensionDownloadsEventRouter::DownloadsNotificationSource> |
510 content_source(¬ification_source); | 507 content_source(¬ification_source); |
511 std::string args_copy(json_args); | 508 std::string args_copy(json_args); |
512 content::NotificationService::current()->Notify( | 509 content::NotificationService::current()->Notify( |
513 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 510 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
514 content_source, | 511 content_source, |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 if (profile_->HasOffTheRecordProfile() && | 1008 if (profile_->HasOffTheRecordProfile() && |
1012 !profile_->IsOffTheRecord()) { | 1009 !profile_->IsOffTheRecord()) { |
1013 DispatchEventInternal( | 1010 DispatchEventInternal( |
1014 profile_->GetOffTheRecordProfile(), | 1011 profile_->GetOffTheRecordProfile(), |
1015 event_name, | 1012 event_name, |
1016 json_args, | 1013 json_args, |
1017 scoped_ptr<base::ListValue>(args->DeepCopy())); | 1014 scoped_ptr<base::ListValue>(args->DeepCopy())); |
1018 } | 1015 } |
1019 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); | 1016 DispatchEventInternal(profile_, event_name, json_args, args.Pass()); |
1020 } | 1017 } |
OLD | NEW |