OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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. | |
4 | |
5 #include "android_webview/browser/aw_certificate_error_handler_base.h" | |
6 | |
7 #include "content/public/browser/browser_thread.h" | |
8 #include "content/public/browser/render_view_host.h" | |
9 #include "content/public/browser/web_contents.h" | |
10 | |
11 using content::BrowserThread; | |
12 using content::WebContents; | |
13 | |
14 namespace android_webview { | |
15 | |
16 const void* | |
17 AwCertificateErrorHandlerBase::UserData::kAwCertificateErrorHandlerBase = | |
18 &kAwCertificateErrorHandlerBase; | |
19 | |
20 AwCertificateErrorHandlerBase::UserData::UserData( | |
21 AwCertificateErrorHandlerBase* ptr) | |
22 : contents_(ptr) { | |
23 } | |
24 | |
25 // static | |
26 AwCertificateErrorHandlerBase* | |
27 AwCertificateErrorHandlerBase::UserData::GetContents( | |
28 WebContents* web_contents) { | |
29 if (!web_contents) | |
30 return NULL; | |
31 UserData* data = reinterpret_cast<UserData*>( | |
32 web_contents->GetUserData(kAwCertificateErrorHandlerBase)); | |
33 return data ? data->contents_ : NULL; | |
34 } | |
35 | |
36 // static | |
37 AwCertificateErrorHandlerBase* AwCertificateErrorHandlerBase::FromID( | |
38 int render_process_id, | |
39 int render_view_id) { | |
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
41 const content::RenderViewHost* rvh = | |
42 content::RenderViewHost::FromID(render_process_id, render_view_id); | |
43 if (!rvh) return NULL; | |
44 content::WebContents* web_contents = | |
45 content::WebContents::FromRenderViewHost(rvh); | |
46 if (!web_contents) return NULL; | |
joth
2013/02/22 23:12:41
nit: you already have this check into GetContents.
sgurun-gerrit only
2013/02/23 00:16:14
Done.
| |
47 return UserData::GetContents(web_contents); | |
48 } | |
49 | |
50 AwCertificateErrorHandlerBase::~AwCertificateErrorHandlerBase() { | |
51 } | |
52 | |
53 } // namespace android_webview | |
OLD | NEW |