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/browser/aw_content_browser_client.h" | 5 #include "android_webview/browser/aw_content_browser_client.h" |
6 | 6 |
7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_browser_main_parts.h" | 8 #include "android_webview/browser/aw_browser_main_parts.h" |
9 #include "android_webview/browser/aw_browser_permission_request_delegate.h" | 9 #include "android_webview/browser/aw_browser_permission_request_delegate.h" |
10 #include "android_webview/browser/aw_contents_client_bridge_base.h" | 10 #include "android_webview/browser/aw_contents_client_bridge_base.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 void SaveAccessToken(const GURL& server_url, | 133 void SaveAccessToken(const GURL& server_url, |
134 const base::string16& access_token) override {} | 134 const base::string16& access_token) override {} |
135 | 135 |
136 private: | 136 private: |
137 ~AwAccessTokenStore() override {} | 137 ~AwAccessTokenStore() override {} |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); | 139 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
140 }; | 140 }; |
141 | 141 |
142 } // namespace | 142 void CallbackPermisisonStatusWrapper( |
| 143 const base::Callback<void(content::PermissionStatus)>& callback, |
| 144 bool allowed) { |
| 145 callback.Run(allowed ? content::PERMISSION_STATUS_GRANTED |
| 146 : content::PERMISSION_STATUS_DENIED); |
| 147 } |
| 148 |
| 149 } // anonymous namespace |
143 | 150 |
144 std::string AwContentBrowserClient::GetAcceptLangsImpl() { | 151 std::string AwContentBrowserClient::GetAcceptLangsImpl() { |
145 // Start with the currnet locale. | 152 // Start with the currnet locale. |
146 std::string langs = base::android::GetDefaultLocale(); | 153 std::string langs = base::android::GetDefaultLocale(); |
147 | 154 |
148 // If we're not en-US, add in en-US which will be | 155 // If we're not en-US, add in en-US which will be |
149 // used with a lower q-value. | 156 // used with a lower q-value. |
150 if (base::StringToLowerASCII(langs) != "en-us") { | 157 if (base::StringToLowerASCII(langs) != "en-us") { |
151 langs += ",en-US"; | 158 langs += ",en-US"; |
152 } | 159 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 callback.Run(NULL); | 380 callback.Run(NULL); |
374 } | 381 } |
375 } | 382 } |
376 | 383 |
377 void AwContentBrowserClient::RequestPermission( | 384 void AwContentBrowserClient::RequestPermission( |
378 content::PermissionType permission, | 385 content::PermissionType permission, |
379 content::WebContents* web_contents, | 386 content::WebContents* web_contents, |
380 int bridge_id, | 387 int bridge_id, |
381 const GURL& requesting_frame, | 388 const GURL& requesting_frame, |
382 bool user_gesture, | 389 bool user_gesture, |
383 const base::Callback<void(bool)>& result_callback) { | 390 const base::Callback<void(content::PermissionStatus)>& callback) { |
384 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 391 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
385 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 392 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
386 GURL origin = requesting_frame.GetOrigin(); | 393 GURL origin = requesting_frame.GetOrigin(); |
387 AwBrowserPermissionRequestDelegate* delegate = | 394 AwBrowserPermissionRequestDelegate* delegate = |
388 AwBrowserPermissionRequestDelegate::FromID(render_process_id, | 395 AwBrowserPermissionRequestDelegate::FromID(render_process_id, |
389 render_view_id); | 396 render_view_id); |
390 switch (permission) { | 397 switch (permission) { |
391 case content::PERMISSION_GEOLOCATION: | 398 case content::PERMISSION_GEOLOCATION: |
392 if (!delegate) { | 399 if (!delegate) { |
393 DVLOG(0) << "Dropping GeolocationPermission request"; | 400 DVLOG(0) << "Dropping GeolocationPermission request"; |
394 result_callback.Run(false); | 401 callback.Run(content::PERMISSION_STATUS_DENIED); |
395 return; | 402 return; |
396 } | 403 } |
397 delegate->RequestGeolocationPermission(origin, result_callback); | 404 delegate->RequestGeolocationPermission( |
| 405 origin, base::Bind(&CallbackPermisisonStatusWrapper, callback)); |
398 break; | 406 break; |
399 case content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER: | 407 case content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER: |
400 if (!delegate) { | 408 if (!delegate) { |
401 DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request"; | 409 DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request"; |
402 result_callback.Run(false); | 410 callback.Run(content::PERMISSION_STATUS_DENIED); |
403 return; | 411 return; |
404 } | 412 } |
405 delegate->RequestProtectedMediaIdentifierPermission(origin, | 413 delegate->RequestProtectedMediaIdentifierPermission( |
406 result_callback); | 414 origin, base::Bind(&CallbackPermisisonStatusWrapper, callback)); |
407 break; | 415 break; |
408 case content::PERMISSION_MIDI_SYSEX: | 416 case content::PERMISSION_MIDI_SYSEX: |
409 case content::PERMISSION_NOTIFICATIONS: | 417 case content::PERMISSION_NOTIFICATIONS: |
410 case content::PERMISSION_PUSH_MESSAGING: | 418 case content::PERMISSION_PUSH_MESSAGING: |
411 NOTIMPLEMENTED() << "RequestPermission not implemented for " | 419 NOTIMPLEMENTED() << "RequestPermission not implemented for " |
412 << permission; | 420 << permission; |
413 break; | 421 break; |
414 case content::PERMISSION_NUM: | 422 case content::PERMISSION_NUM: |
415 NOTREACHED() << "Invalid RequestPermission for " << permission; | 423 NOTREACHED() << "Invalid RequestPermission for " << permission; |
416 break; | 424 break; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); | 557 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); |
550 } | 558 } |
551 #endif | 559 #endif |
552 | 560 |
553 content::DevToolsManagerDelegate* | 561 content::DevToolsManagerDelegate* |
554 AwContentBrowserClient::GetDevToolsManagerDelegate() { | 562 AwContentBrowserClient::GetDevToolsManagerDelegate() { |
555 return new AwDevToolsManagerDelegate(); | 563 return new AwDevToolsManagerDelegate(); |
556 } | 564 } |
557 | 565 |
558 } // namespace android_webview | 566 } // namespace android_webview |
OLD | NEW |