Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.cc

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/media/media_stream_devices_controller.h" 5 #include "chrome/browser/media/media_stream_devices_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/containers/scoped_ptr_map.h" 9 #include "base/containers/scoped_ptr_map.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/render_frame_host.h" 30 #include "content/public/browser/render_frame_host.h"
31 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_widget_host_view.h" 32 #include "content/public/browser/render_widget_host_view.h"
33 #include "content/public/common/media_stream_request.h" 33 #include "content/public/common/media_stream_request.h"
34 #include "content/public/common/origin_util.h" 34 #include "content/public/common/origin_util.h"
35 #include "extensions/common/constants.h" 35 #include "extensions/common/constants.h"
36 #include "grit/theme_resources.h" 36 #include "grit/theme_resources.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 38
39 #if defined(OS_ANDROID) 39 #if defined(ANDROID_JAVA_UI)
40 #include <vector> 40 #include <vector>
41 41
42 #include "chrome/browser/android/preferences/pref_service_bridge.h" 42 #include "chrome/browser/android/preferences/pref_service_bridge.h"
43 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 43 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
44 #include "content/public/browser/android/content_view_core.h" 44 #include "content/public/browser/android/content_view_core.h"
45 #include "ui/android/window_android.h" 45 #include "ui/android/window_android.h"
46 #endif // OS_ANDROID 46 #endif // ANDROID_JAVA_UI
47 47
48 using content::BrowserThread; 48 using content::BrowserThread;
49 49
50 namespace { 50 namespace {
51 51
52 // Returns true if the given ContentSettingsType is being requested in 52 // Returns true if the given ContentSettingsType is being requested in
53 // |request|. 53 // |request|.
54 bool ContentTypeIsRequested(ContentSettingsType type, 54 bool ContentTypeIsRequested(ContentSettingsType type,
55 const content::MediaStreamRequest& request) { 55 const content::MediaStreamRequest& request) {
56 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) 56 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 request_, &denial_reason); 163 request_, &denial_reason);
164 old_video_setting_ = GetContentSetting( 164 old_video_setting_ = GetContentSetting(
165 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, request_, &denial_reason); 165 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, request_, &denial_reason);
166 166
167 // If either setting is ask, we show the infobar. 167 // If either setting is ask, we show the infobar.
168 if (old_audio_setting_ == CONTENT_SETTING_ASK || 168 if (old_audio_setting_ == CONTENT_SETTING_ASK ||
169 old_video_setting_ == CONTENT_SETTING_ASK) { 169 old_video_setting_ == CONTENT_SETTING_ASK) {
170 return; 170 return;
171 } 171 }
172 172
173 #if defined(OS_ANDROID) 173 #if defined(ANDROID_JAVA_UI)
174 std::vector<ContentSettingsType> content_settings_types; 174 std::vector<ContentSettingsType> content_settings_types;
175 if (IsAllowedForAudio()) 175 if (IsAllowedForAudio())
176 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 176 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
177 177
178 if (IsAllowedForVideo()) { 178 if (IsAllowedForVideo()) {
179 content_settings_types.push_back( 179 content_settings_types.push_back(
180 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 180 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
181 } 181 }
182 182
183 // If the site had been previously granted the access to audio or video but 183 // If the site had been previously granted the access to audio or video but
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 result = CONTENT_SETTING_ALLOW; 574 result = CONTENT_SETTING_ALLOW;
575 } else if (user_decision == CONTENT_SETTING_BLOCK) { 575 } else if (user_decision == CONTENT_SETTING_BLOCK) {
576 result = CONTENT_SETTING_BLOCK; 576 result = CONTENT_SETTING_BLOCK;
577 } 577 }
578 } 578 }
579 return result; 579 return result;
580 } 580 }
581 581
582 bool MediaStreamDevicesController::IsUserAcceptAllowed( 582 bool MediaStreamDevicesController::IsUserAcceptAllowed(
583 ContentSettingsType content_type) const { 583 ContentSettingsType content_type) const {
584 #if defined(OS_ANDROID) 584 #if defined(ANDROID_JAVA_UI)
585 content::ContentViewCore* cvc = 585 content::ContentViewCore* cvc =
586 content::ContentViewCore::FromWebContents(web_contents_); 586 content::ContentViewCore::FromWebContents(web_contents_);
587 if (!cvc) 587 if (!cvc)
588 return false; 588 return false;
589 589
590 ui::WindowAndroid* window_android = cvc->GetWindowAndroid(); 590 ui::WindowAndroid* window_android = cvc->GetWindowAndroid();
591 if (!window_android) 591 if (!window_android)
592 return false; 592 return false;
593 593
594 std::string android_permission = 594 std::string android_permission =
595 PrefServiceBridge::GetAndroidPermissionForContentSetting(content_type); 595 PrefServiceBridge::GetAndroidPermissionForContentSetting(content_type);
596 bool android_permission_blocked = false; 596 bool android_permission_blocked = false;
597 if (!android_permission.empty()) { 597 if (!android_permission.empty()) {
598 android_permission_blocked = 598 android_permission_blocked =
599 !window_android->HasPermission(android_permission) && 599 !window_android->HasPermission(android_permission) &&
600 !window_android->CanRequestPermission(android_permission); 600 !window_android->CanRequestPermission(android_permission);
601 } 601 }
602 if (android_permission_blocked) 602 if (android_permission_blocked)
603 return false; 603 return false;
604 604
605 // Don't approve device requests if the tab was hidden. 605 // Don't approve device requests if the tab was hidden.
606 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 606 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
607 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? 607 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video?
608 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 608 return web_contents_->GetRenderWidgetHostView()->IsShowing();
609 #endif 609 #endif
610 return true; 610 return true;
611 } 611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698