Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: chrome/browser/extensions/api/processes/processes_api.cc

Issue 11308012: Remove some TabContentses from extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tabs/tabs_constants.h" 16 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
17 #include "chrome/browser/extensions/event_router.h" 17 #include "chrome/browser/extensions/event_router.h"
18 #include "chrome/browser/extensions/extension_function_util.h" 18 #include "chrome/browser/extensions/extension_function_util.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"
24 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/extensions/extension_error_utils.h" 24 #include "chrome/common/extensions/extension_error_utils.h"
26 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
28 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
30 #include "content/public/browser/notification_types.h" 29 #include "content/public/browser/notification_types.h"
31 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 31 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/render_widget_host.h" 32 #include "content/public/browser/render_widget_host.h"
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 void GetProcessIdForTabFunction::Observe( 544 void GetProcessIdForTabFunction::Observe(
546 int type, 545 int type,
547 const content::NotificationSource& source, 546 const content::NotificationSource& source,
548 const content::NotificationDetails& details) { 547 const content::NotificationDetails& details) {
549 DCHECK_EQ(type, chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY); 548 DCHECK_EQ(type, chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY);
550 registrar_.RemoveAll(); 549 registrar_.RemoveAll();
551 GetProcessIdForTab(); 550 GetProcessIdForTab();
552 } 551 }
553 552
554 void GetProcessIdForTabFunction::GetProcessIdForTab() { 553 void GetProcessIdForTabFunction::GetProcessIdForTab() {
555 TabContents* contents = NULL; 554 content::WebContents* contents = NULL;
556 int tab_index = -1; 555 int tab_index = -1;
557 if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), 556 if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(),
558 NULL, NULL, &contents, &tab_index)) { 557 NULL, NULL, &contents, &tab_index)) {
559 error_ = ExtensionErrorUtils::FormatErrorMessage( 558 error_ = ExtensionErrorUtils::FormatErrorMessage(
560 extensions::tabs_constants::kTabNotFoundError, 559 extensions::tabs_constants::kTabNotFoundError,
561 base::IntToString(tab_id_)); 560 base::IntToString(tab_id_));
562 SetResult(Value::CreateIntegerValue(-1)); 561 SetResult(Value::CreateIntegerValue(-1));
563 SendResponse(false); 562 SendResponse(false);
564 } else { 563 } else {
565 int process_id = contents->web_contents()->GetRenderProcessHost()->GetID(); 564 int process_id = contents->GetRenderProcessHost()->GetID();
566 SetResult(Value::CreateIntegerValue(process_id)); 565 SetResult(Value::CreateIntegerValue(process_id));
567 SendResponse(true); 566 SendResponse(true);
568 } 567 }
569 568
570 // Balance the AddRef in the RunImpl. 569 // Balance the AddRef in the RunImpl.
571 Release(); 570 Release();
572 } 571 }
573 572
574 TerminateFunction::TerminateFunction() : process_id_(-1) { 573 TerminateFunction::TerminateFunction() : process_id_(-1) {
575 } 574 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 739
741 SetResult(processes); 740 SetResult(processes);
742 SendResponse(true); 741 SendResponse(true);
743 742
744 // Balance the AddRef in the RunImpl. 743 // Balance the AddRef in the RunImpl.
745 Release(); 744 Release();
746 #endif // defined(ENABLE_TASK_MANAGER) 745 #endif // defined(ENABLE_TASK_MANAGER)
747 } 746 }
748 747
749 } // namespace extensions 748 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698