blob: a1a2f4e844337740619a56ee54ddc2d71c1af579 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit09911bf2008-07-26 23:55:294
[email protected]f3ec7742009-01-15 00:59:165#include "chrome/browser/tab_contents/tab_util.h"
initial.commit09911bf2008-07-26 23:55:296
7#include "chrome/browser/render_view_host.h"
8#include "chrome/browser/render_process_host.h"
[email protected]e3c404b2008-12-23 01:07:329#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
[email protected]f3ec7742009-01-15 00:59:1610#include "chrome/browser/tab_contents/web_contents.h"
initial.commit09911bf2008-07-26 23:55:2911#include "net/url_request/url_request.h"
12
13bool 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]a3a1d142008-12-19 00:42:3030WebContents* tab_util::GetWebContentsByID(int render_process_id,
initial.commit09911bf2008-07-26 23:55:2931 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.botbf09a502008-08-24 00:55:5539