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/extension_processes_api.h" | 5 #include "chrome/browser/extensions/extension_processes_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 | 14 |
15 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 15 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
16 #include "chrome/browser/extensions/extension_event_router.h" | 16 #include "chrome/browser/extensions/event_router.h" |
17 #include "chrome/browser/extensions/extension_function_util.h" | 17 #include "chrome/browser/extensions/extension_function_util.h" |
18 #include "chrome/browser/extensions/extension_processes_api_constants.h" | 18 #include "chrome/browser/extensions/extension_processes_api_constants.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_tab_util.h" | 20 #include "chrome/browser/extensions/extension_tab_util.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/task_manager/task_manager.h" | 22 #include "chrome/browser/task_manager/task_manager.h" |
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 23 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/extensions/extension_error_utils.h" | 25 #include "chrome/common/extensions/extension_error_utils.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 NotifyProfiles(keys::kOnExited, json_args); | 482 NotifyProfiles(keys::kOnExited, json_args); |
483 #endif // defined(ENABLE_TASK_MANAGER) | 483 #endif // defined(ENABLE_TASK_MANAGER) |
484 } | 484 } |
485 | 485 |
486 void ExtensionProcessesEventRouter::DispatchEvent( | 486 void ExtensionProcessesEventRouter::DispatchEvent( |
487 Profile* profile, | 487 Profile* profile, |
488 const char* event_name, | 488 const char* event_name, |
489 const std::string& json_args) { | 489 const std::string& json_args) { |
490 if (profile && profile->GetExtensionEventRouter()) { | 490 if (profile && profile->GetExtensionEventRouter()) { |
491 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 491 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
492 event_name, json_args, NULL, GURL(), EventFilteringInfo()); | 492 event_name, json_args, NULL, GURL(), extensions::EventFilteringInfo()); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 void ExtensionProcessesEventRouter::NotifyProfiles(const char* event_name, | 496 void ExtensionProcessesEventRouter::NotifyProfiles(const char* event_name, |
497 std::string json_args) { | 497 std::string json_args) { |
498 for (ProfileSet::iterator it = profiles_.begin(); | 498 for (ProfileSet::iterator it = profiles_.begin(); |
499 it != profiles_.end(); it++) { | 499 it != profiles_.end(); it++) { |
500 Profile* profile = *it; | 500 Profile* profile = *it; |
501 DispatchEvent(profile, event_name, json_args); | 501 DispatchEvent(profile, event_name, json_args); |
502 } | 502 } |
503 } | 503 } |
504 | 504 |
505 // In order to determine whether there are any listeners for the event of | 505 // In order to determine whether there are any listeners for the event of |
506 // interest, we need to ask each profile whether it has one registered. | 506 // interest, we need to ask each profile whether it has one registered. |
507 // We only need to look for the profiles that have registered with the | 507 // We only need to look for the profiles that have registered with the |
508 // this extension API. | 508 // this extension API. |
509 bool ExtensionProcessesEventRouter::HasEventListeners(std::string& event_name) { | 509 bool ExtensionProcessesEventRouter::HasEventListeners(std::string& event_name) { |
510 for (ProfileSet::iterator it = profiles_.begin(); | 510 for (ProfileSet::iterator it = profiles_.begin(); |
511 it != profiles_.end(); it++) { | 511 it != profiles_.end(); it++) { |
512 Profile* profile = *it; | 512 Profile* profile = *it; |
513 ExtensionEventRouter* router = profile->GetExtensionEventRouter(); | 513 extensions::EventRouter* router = profile->GetExtensionEventRouter(); |
514 if (!router) | 514 if (!router) |
515 continue; | 515 continue; |
516 | 516 |
517 if (router->HasEventListener(event_name)) | 517 if (router->HasEventListener(event_name)) |
518 return true; | 518 return true; |
519 } | 519 } |
520 return false; | 520 return false; |
521 } | 521 } |
522 | 522 |
523 bool GetProcessIdForTabFunction::RunImpl() { | 523 bool GetProcessIdForTabFunction::RunImpl() { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 DCHECK(process_ids_.size() == 0); | 744 DCHECK(process_ids_.size() == 0); |
745 } | 745 } |
746 | 746 |
747 SetResult(processes); | 747 SetResult(processes); |
748 SendResponse(true); | 748 SendResponse(true); |
749 | 749 |
750 // Balance the AddRef in the RunImpl. | 750 // Balance the AddRef in the RunImpl. |
751 Release(); | 751 Release(); |
752 #endif // defined(ENABLE_TASK_MANAGER) | 752 #endif // defined(ENABLE_TASK_MANAGER) |
753 } | 753 } |
OLD | NEW |