OLD | NEW |
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 "android_webview/native/aw_contents_io_thread_client_impl.h" | 5 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "android_webview/common/devtools_instrumentation.h" | 10 #include "android_webview/common/devtools_instrumentation.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // ClientMapEntryUpdater ------------------------------------------------------ | 106 // ClientMapEntryUpdater ------------------------------------------------------ |
107 | 107 |
108 class ClientMapEntryUpdater : public content::WebContentsObserver { | 108 class ClientMapEntryUpdater : public content::WebContentsObserver { |
109 public: | 109 public: |
110 ClientMapEntryUpdater(JNIEnv* env, WebContents* web_contents, | 110 ClientMapEntryUpdater(JNIEnv* env, WebContents* web_contents, |
111 jobject jdelegate); | 111 jobject jdelegate); |
112 | 112 |
113 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE; | 113 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE; |
114 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE; | 114 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE; |
115 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | 115 virtual void WebContentsDestroyed() OVERRIDE; |
116 | 116 |
117 private: | 117 private: |
118 JavaObjectWeakGlobalRef jdelegate_; | 118 JavaObjectWeakGlobalRef jdelegate_; |
119 }; | 119 }; |
120 | 120 |
121 ClientMapEntryUpdater::ClientMapEntryUpdater(JNIEnv* env, | 121 ClientMapEntryUpdater::ClientMapEntryUpdater(JNIEnv* env, |
122 WebContents* web_contents, | 122 WebContents* web_contents, |
123 jobject jdelegate) | 123 jobject jdelegate) |
124 : content::WebContentsObserver(web_contents), | 124 : content::WebContentsObserver(web_contents), |
125 jdelegate_(env, jdelegate) { | 125 jdelegate_(env, jdelegate) { |
126 DCHECK(web_contents); | 126 DCHECK(web_contents); |
127 DCHECK(jdelegate); | 127 DCHECK(jdelegate); |
128 | 128 |
129 if (web_contents->GetMainFrame()) | 129 if (web_contents->GetMainFrame()) |
130 RenderFrameCreated(web_contents->GetMainFrame()); | 130 RenderFrameCreated(web_contents->GetMainFrame()); |
131 } | 131 } |
132 | 132 |
133 void ClientMapEntryUpdater::RenderFrameCreated(RenderFrameHost* rfh) { | 133 void ClientMapEntryUpdater::RenderFrameCreated(RenderFrameHost* rfh) { |
134 IoThreadClientData client_data; | 134 IoThreadClientData client_data; |
135 client_data.io_thread_client = jdelegate_; | 135 client_data.io_thread_client = jdelegate_; |
136 client_data.pending_association = false; | 136 client_data.pending_association = false; |
137 RfhToIoThreadClientMap::GetInstance()->Set( | 137 RfhToIoThreadClientMap::GetInstance()->Set( |
138 GetRenderFrameHostIdPair(rfh), client_data); | 138 GetRenderFrameHostIdPair(rfh), client_data); |
139 } | 139 } |
140 | 140 |
141 void ClientMapEntryUpdater::RenderFrameDeleted(RenderFrameHost* rfh) { | 141 void ClientMapEntryUpdater::RenderFrameDeleted(RenderFrameHost* rfh) { |
142 RfhToIoThreadClientMap::GetInstance()->Erase(GetRenderFrameHostIdPair(rfh)); | 142 RfhToIoThreadClientMap::GetInstance()->Erase(GetRenderFrameHostIdPair(rfh)); |
143 } | 143 } |
144 | 144 |
145 void ClientMapEntryUpdater::WebContentsDestroyed(WebContents* web_contents) { | 145 void ClientMapEntryUpdater::WebContentsDestroyed() { |
146 delete this; | 146 delete this; |
147 } | 147 } |
148 | 148 |
149 } // namespace | 149 } // namespace |
150 | 150 |
151 // AwContentsIoThreadClientImpl ----------------------------------------------- | 151 // AwContentsIoThreadClientImpl ----------------------------------------------- |
152 | 152 |
153 // static | 153 // static |
154 scoped_ptr<AwContentsIoThreadClient> | 154 scoped_ptr<AwContentsIoThreadClient> |
155 AwContentsIoThreadClient::FromID(int render_process_id, int render_frame_id) { | 155 AwContentsIoThreadClient::FromID(int render_process_id, int render_frame_id) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 Java_AwContentsIoThreadClient_newLoginRequest( | 331 Java_AwContentsIoThreadClient_newLoginRequest( |
332 env, java_object_.obj(), jrealm.obj(), jaccount.obj(), jargs.obj()); | 332 env, java_object_.obj(), jrealm.obj(), jaccount.obj(), jargs.obj()); |
333 } | 333 } |
334 | 334 |
335 bool RegisterAwContentsIoThreadClientImpl(JNIEnv* env) { | 335 bool RegisterAwContentsIoThreadClientImpl(JNIEnv* env) { |
336 return RegisterNativesImpl(env); | 336 return RegisterNativesImpl(env); |
337 } | 337 } |
338 | 338 |
339 } // namespace android_webview | 339 } // namespace android_webview |
OLD | NEW |