OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 namespace android_webview { | 105 namespace android_webview { |
106 | 106 |
107 namespace { | 107 namespace { |
108 | 108 |
109 bool g_should_download_favicons = false; | 109 bool g_should_download_favicons = false; |
110 | 110 |
111 bool g_force_auxiliary_bitmap_rendering = false; | 111 bool g_force_auxiliary_bitmap_rendering = false; |
112 | 112 |
| 113 std::string g_locale; |
| 114 |
113 const void* kAwContentsUserDataKey = &kAwContentsUserDataKey; | 115 const void* kAwContentsUserDataKey = &kAwContentsUserDataKey; |
114 | 116 |
115 class AwContentsUserData : public base::SupportsUserData::Data { | 117 class AwContentsUserData : public base::SupportsUserData::Data { |
116 public: | 118 public: |
117 AwContentsUserData(AwContents* ptr) : contents_(ptr) {} | 119 AwContentsUserData(AwContents* ptr) : contents_(ptr) {} |
118 | 120 |
119 static AwContents* GetContents(WebContents* web_contents) { | 121 static AwContents* GetContents(WebContents* web_contents) { |
120 if (!web_contents) | 122 if (!web_contents) |
121 return NULL; | 123 return NULL; |
122 AwContentsUserData* data = static_cast<AwContentsUserData*>( | 124 AwContentsUserData* data = static_cast<AwContentsUserData*>( |
(...skipping 27 matching lines...) Expand all Loading... |
150 const content::RenderViewHost* rvh = | 152 const content::RenderViewHost* rvh = |
151 content::RenderViewHost::FromID(render_process_id, render_view_id); | 153 content::RenderViewHost::FromID(render_process_id, render_view_id); |
152 if (!rvh) return NULL; | 154 if (!rvh) return NULL; |
153 content::WebContents* web_contents = | 155 content::WebContents* web_contents = |
154 content::WebContents::FromRenderViewHost(rvh); | 156 content::WebContents::FromRenderViewHost(rvh); |
155 if (!web_contents) return NULL; | 157 if (!web_contents) return NULL; |
156 return FromWebContents(web_contents); | 158 return FromWebContents(web_contents); |
157 } | 159 } |
158 | 160 |
159 // static | 161 // static |
| 162 void SetLocale(JNIEnv* env, jclass, jstring locale) { |
| 163 g_locale = ConvertJavaStringToUTF8(env, locale); |
| 164 } |
| 165 |
| 166 // static |
| 167 std::string AwContents::GetLocale() { |
| 168 return g_locale; |
| 169 } |
| 170 |
| 171 // static |
160 AwBrowserPermissionRequestDelegate* AwBrowserPermissionRequestDelegate::FromID( | 172 AwBrowserPermissionRequestDelegate* AwBrowserPermissionRequestDelegate::FromID( |
161 int render_process_id, int render_frame_id) { | 173 int render_process_id, int render_frame_id) { |
162 AwContents* aw_contents = AwContents::FromWebContents( | 174 AwContents* aw_contents = AwContents::FromWebContents( |
163 content::WebContents::FromRenderFrameHost( | 175 content::WebContents::FromRenderFrameHost( |
164 content::RenderFrameHost::FromID(render_process_id, | 176 content::RenderFrameHost::FromID(render_process_id, |
165 render_frame_id))); | 177 render_frame_id))); |
166 return implicit_cast<AwBrowserPermissionRequestDelegate*>(aw_contents); | 178 return implicit_cast<AwBrowserPermissionRequestDelegate*>(aw_contents); |
167 } | 179 } |
168 | 180 |
169 AwContents::AwContents(scoped_ptr<WebContents> web_contents) | 181 AwContents::AwContents(scoped_ptr<WebContents> web_contents) |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 | 1203 |
1192 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env, ports, | 1204 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env, ports, |
1193 GetMessagePortMessageFilter()); | 1205 GetMessagePortMessageFilter()); |
1194 } | 1206 } |
1195 | 1207 |
1196 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1208 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1197 g_should_download_favicons = true; | 1209 g_should_download_favicons = true; |
1198 } | 1210 } |
1199 | 1211 |
1200 } // namespace android_webview | 1212 } // namespace android_webview |
OLD | NEW |