| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/task.h" | 11 #include "base/task.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/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
| 16 #include "chrome/browser/extensions/extension_processes_api_constants.h" | 16 #include "chrome/browser/extensions/extension_processes_api_constants.h" |
| 17 #include "chrome/browser/extensions/extension_tabs_module.h" | 17 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 18 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 18 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| 19 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/renderer_host/render_process_host.h" | 20 #include "chrome/browser/renderer_host/render_process_host.h" |
| 21 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
| 22 #include "chrome/browser/tab_contents_wrapper.h" |
| 22 #include "chrome/browser/task_manager/task_manager.h" | 23 #include "chrome/browser/task_manager/task_manager.h" |
| 23 #include "chrome/common/extensions/extension_error_utils.h" | 24 #include "chrome/common/extensions/extension_error_utils.h" |
| 24 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
| 25 #include "chrome/common/notification_type.h" | 26 #include "chrome/common/notification_type.h" |
| 26 | 27 |
| 27 namespace keys = extension_processes_api_constants; | 28 namespace keys = extension_processes_api_constants; |
| 28 | 29 |
| 29 DictionaryValue* CreateProcessValue(int process_id, | 30 DictionaryValue* CreateProcessValue(int process_id, |
| 30 std::string type, | 31 std::string type, |
| 31 double cpu, | 32 double cpu, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (profile && profile->GetExtensionEventRouter()) { | 154 if (profile && profile->GetExtensionEventRouter()) { |
| 154 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 155 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 155 event_name, json_args, NULL, GURL()); | 156 event_name, json_args, NULL, GURL()); |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 | 159 |
| 159 bool GetProcessIdForTabFunction::RunImpl() { | 160 bool GetProcessIdForTabFunction::RunImpl() { |
| 160 int tab_id; | 161 int tab_id; |
| 161 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); | 162 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| 162 | 163 |
| 163 TabContents* contents = NULL; | 164 TabContentsWrapper* contents = NULL; |
| 164 int tab_index = -1; | 165 int tab_index = -1; |
| 165 if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(), | 166 if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(), |
| 166 NULL, NULL, &contents, &tab_index)) { | 167 NULL, NULL, &contents, &tab_index)) { |
| 167 error_ = ExtensionErrorUtils::FormatErrorMessage( | 168 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 168 extension_tabs_module_constants::kTabNotFoundError, | 169 extension_tabs_module_constants::kTabNotFoundError, |
| 169 base::IntToString(tab_id)); | 170 base::IntToString(tab_id)); |
| 170 return false; | 171 return false; |
| 171 } | 172 } |
| 172 | 173 |
| 173 // Return the process ID of the tab as an integer. | 174 // Return the process ID of the tab as an integer. |
| 174 int id = base::GetProcId(contents->GetRenderProcessHost()->GetHandle()); | 175 int id = base::GetProcId(contents->tab_contents()-> |
| 176 GetRenderProcessHost()->GetHandle()); |
| 175 result_.reset(Value::CreateIntegerValue(id)); | 177 result_.reset(Value::CreateIntegerValue(id)); |
| 176 return true; | 178 return true; |
| 177 } | 179 } |
| OLD | NEW |