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/processes/processes_api.h" | 5 #include "chrome/browser/extensions/api/processes/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/processes/processes_api_constants.h" | 15 #include "chrome/browser/extensions/api/processes/processes_api_constants.h" |
16 #include "chrome/browser/extensions/api/processes/processes_api_factory.h" | 16 #include "chrome/browser/extensions/api/processes/processes_api_factory.h" |
17 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 17 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
18 #include "chrome/browser/extensions/event_router.h" | 18 #include "chrome/browser/extensions/event_router.h" |
| 19 #include "chrome/browser/extensions/extension_function_registry.h" |
19 #include "chrome/browser/extensions/extension_function_util.h" | 20 #include "chrome/browser/extensions/extension_function_util.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
22 #include "chrome/browser/extensions/extension_tab_util.h" | 23 #include "chrome/browser/extensions/extension_tab_util.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/task_manager/task_manager.h" | 25 #include "chrome/browser/task_manager/task_manager.h" |
25 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (router && router->HasEventListener(event_name)) | 482 if (router && router->HasEventListener(event_name)) |
482 return true; | 483 return true; |
483 return false; | 484 return false; |
484 } | 485 } |
485 | 486 |
486 ProcessesAPI::ProcessesAPI(Profile* profile) : profile_(profile) { | 487 ProcessesAPI::ProcessesAPI(Profile* profile) : profile_(profile) { |
487 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( | 488 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( |
488 this, processes_api_constants::kOnUpdated); | 489 this, processes_api_constants::kOnUpdated); |
489 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( | 490 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( |
490 this, processes_api_constants::kOnUpdatedWithMemory); | 491 this, processes_api_constants::kOnUpdatedWithMemory); |
| 492 ExtensionFunctionRegistry* registry = |
| 493 ExtensionFunctionRegistry::GetInstance(); |
| 494 registry->RegisterFunction<extensions::GetProcessIdForTabFunction>(); |
| 495 registry->RegisterFunction<extensions::TerminateFunction>(); |
| 496 registry->RegisterFunction<extensions::GetProcessInfoFunction>(); |
491 } | 497 } |
492 | 498 |
493 ProcessesAPI::~ProcessesAPI() { | 499 ProcessesAPI::~ProcessesAPI() { |
494 } | 500 } |
495 | 501 |
496 void ProcessesAPI::Shutdown() { | 502 void ProcessesAPI::Shutdown() { |
497 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 503 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
498 } | 504 } |
499 | 505 |
500 // static | 506 // static |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 | 763 |
758 SetResult(processes); | 764 SetResult(processes); |
759 SendResponse(true); | 765 SendResponse(true); |
760 | 766 |
761 // Balance the AddRef in the RunImpl. | 767 // Balance the AddRef in the RunImpl. |
762 Release(); | 768 Release(); |
763 #endif // defined(ENABLE_TASK_MANAGER) | 769 #endif // defined(ENABLE_TASK_MANAGER) |
764 } | 770 } |
765 | 771 |
766 } // namespace extensions | 772 } // namespace extensions |
OLD | NEW |