license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | f3ec774 | 2009-01-15 00:59:16 | [diff] [blame^] | 5 | #include "chrome/browser/tab_contents/tab_util.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
| 7 | #include "chrome/browser/render_view_host.h" |
| 8 | #include "chrome/browser/render_process_host.h" |
[email protected] | e3c404b | 2008-12-23 01:07:32 | [diff] [blame] | 9 | #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
[email protected] | f3ec774 | 2009-01-15 00:59:16 | [diff] [blame^] | 10 | #include "chrome/browser/tab_contents/web_contents.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | #include "net/url_request/url_request.h" |
| 12 | |
| 13 | bool tab_util::GetTabContentsID(URLRequest* request, |
| 14 | int* render_process_id, |
| 15 | int* render_view_id) { |
| 16 | |
| 17 | if (!request || !render_process_id || !render_view_id) |
| 18 | return false; |
| 19 | |
| 20 | ResourceDispatcherHost::ExtraRequestInfo* info = |
| 21 | ResourceDispatcherHost::ExtraInfoForRequest(request); |
| 22 | if (!info) |
| 23 | return false; |
| 24 | |
| 25 | *render_process_id = info->render_process_host_id; |
| 26 | *render_view_id = info->render_view_id; |
| 27 | return true; |
| 28 | } |
| 29 | |
[email protected] | a3a1d14 | 2008-12-19 00:42:30 | [diff] [blame] | 30 | WebContents* tab_util::GetWebContentsByID(int render_process_id, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | int render_view_id) { |
| 32 | RenderViewHost* render_view_host = |
| 33 | RenderViewHost::FromID(render_process_id, render_view_id); |
| 34 | if (!render_view_host) |
| 35 | return NULL; |
| 36 | |
| 37 | return static_cast<WebContents*>(render_view_host->delegate()); |
| 38 | } |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 39 | |