Chromium Code Reviews| 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 "chrome/browser/media/media_stream_infobar_delegate_android.h" | 5 #include "chrome/browser/media/media_stream_infobar_delegate_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 16 #include "components/content_settings/core/common/content_settings_types.h" | 16 #include "components/content_settings/core/common/content_settings_types.h" |
| 17 #include "components/google/core/browser/google_util.h" | 17 #include "components/google/core/browser/google_util.h" |
| 18 #include "components/infobars/core/infobar.h" | 18 #include "components/infobars/core/infobar.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/origin_util.h" | 20 #include "content/public/common/origin_util.h" |
| 21 #include "grit/components_strings.h" | 21 #include "grit/components_strings.h" |
| 22 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Get a list of content types being requested. Note that the order of the | |
| 29 // resulting array is important, see |Accept()|. | |
| 28 std::vector<ContentSettingsType> GetContentSettingsTypes( | 30 std::vector<ContentSettingsType> GetContentSettingsTypes( |
| 29 MediaStreamDevicesController* controller) { | 31 MediaStreamDevicesController* controller) { |
| 30 std::vector<ContentSettingsType> types; | 32 std::vector<ContentSettingsType> types; |
| 31 if (controller->IsAskingForAudio()) | 33 if (controller->IsAskingForAudio()) |
| 32 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 34 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 33 if (controller->IsAskingForVideo()) | 35 if (controller->IsAskingForVideo()) |
| 34 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 36 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 35 return types; | 37 return types; |
| 36 } | 38 } |
| 37 | 39 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 // we don't want WebRTC to be waiting for an answer that will never come. | 89 // we don't want WebRTC to be waiting for an answer that will never come. |
| 88 controller_->Cancelled(); | 90 controller_->Cancelled(); |
| 89 } | 91 } |
| 90 | 92 |
| 91 MediaStreamInfoBarDelegateAndroid* | 93 MediaStreamInfoBarDelegateAndroid* |
| 92 MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() { | 94 MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() { |
| 93 return this; | 95 return this; |
| 94 } | 96 } |
| 95 | 97 |
| 96 bool MediaStreamInfoBarDelegateAndroid::Accept() { | 98 bool MediaStreamInfoBarDelegateAndroid::Accept() { |
| 97 controller_->PermissionGranted(); | 99 if (GetPermissionCount() == 2) { |
| 100 // Accept state 0 -> Audio, Accept state 1 -> Video. | |
|
gone
2016/05/31 21:20:42
Define these explicitly as global constants?
tsergeant
2016/06/02 07:04:36
Done.
| |
| 101 controller_->PermissionSplitResult(GetAcceptState(0), GetAcceptState(1)); | |
| 102 } else { | |
| 103 DCHECK_EQ(1, GetPermissionCount()); | |
| 104 controller_->PermissionGranted(); | |
| 105 } | |
| 98 return true; | 106 return true; |
| 99 } | 107 } |
| 100 | 108 |
| 101 bool MediaStreamInfoBarDelegateAndroid::Cancel() { | 109 bool MediaStreamInfoBarDelegateAndroid::Cancel() { |
| 102 controller_->PermissionDenied(); | 110 controller_->PermissionDenied(); |
| 103 return true; | 111 return true; |
| 104 } | 112 } |
| OLD | NEW |