Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "android_webview/browser/aw_contents_client_bridge_base.h" | 5 #include "android_webview/browser/aw_contents_client_bridge_base.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "content/public/browser/render_frame_host.h" | 8 #include "content/public/browser/render_frame_host.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 void AwContentsClientBridgeBase::Associate( | 43 void AwContentsClientBridgeBase::Associate( |
| 44 WebContents* web_contents, | 44 WebContents* web_contents, |
| 45 AwContentsClientBridgeBase* handler) { | 45 AwContentsClientBridgeBase* handler) { |
| 46 web_contents->SetUserData(kAwContentsClientBridgeBase, | 46 web_contents->SetUserData(kAwContentsClientBridgeBase, |
| 47 new UserData(handler)); | 47 new UserData(handler)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void AwContentsClientBridgeBase::Disassociate( | |
| 51 WebContents* web_contents) { | |
| 52 web_contents->RemoveUserData(kAwContentsClientBridgeBase); | |
| 53 } | |
| 54 | |
| 50 // static | 55 // static |
| 51 AwContentsClientBridgeBase* AwContentsClientBridgeBase::FromWebContents( | 56 AwContentsClientBridgeBase* AwContentsClientBridgeBase::FromWebContents( |
| 52 WebContents* web_contents) { | 57 WebContents* web_contents) { |
| 53 return UserData::GetContents(web_contents); | 58 return UserData::GetContents(web_contents); |
| 54 } | 59 } |
| 55 | 60 |
| 56 // static | 61 // static |
| 57 AwContentsClientBridgeBase* AwContentsClientBridgeBase::FromID( | 62 AwContentsClientBridgeBase* AwContentsClientBridgeBase::FromID( |
| 58 int render_process_id, | 63 int render_process_id, |
| 59 int render_frame_id) { | 64 int render_frame_id) { |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 61 content::RenderFrameHost* rfh = | 66 content::RenderFrameHost* rfh = |
| 62 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | 67 content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 63 content::WebContents* web_contents = | 68 content::WebContents* web_contents = |
| 64 content::WebContents::FromRenderFrameHost(rfh); | 69 content::WebContents::FromRenderFrameHost(rfh); |
| 65 return UserData::GetContents(web_contents); | 70 return UserData::GetContents(web_contents); |
| 66 } | 71 } |
| 67 | 72 |
| 68 AwContentsClientBridgeBase::~AwContentsClientBridgeBase() { | 73 AwContentsClientBridgeBase::~AwContentsClientBridgeBase() { |
|
boliu
2014/09/05 17:40:52
Does it make sense to call RemoveUerData here rath
| |
| 69 } | 74 } |
| 70 | 75 |
| 71 } // namespace android_webview | 76 } // namespace android_webview |
| OLD | NEW |