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 const int kGroupedInfobarAudioPosition = 0; |
| 29 const int kGroupedInfobarVideoPosition = 1; |
| 30 |
| 31 // Get a list of content types being requested. Note that the order of the |
| 32 // resulting array corresponds to the kGroupedInfobarAudio/VideoPermission |
| 33 // constants. |
28 std::vector<ContentSettingsType> GetContentSettingsTypes( | 34 std::vector<ContentSettingsType> GetContentSettingsTypes( |
29 MediaStreamDevicesController* controller) { | 35 MediaStreamDevicesController* controller) { |
30 std::vector<ContentSettingsType> types; | 36 std::vector<ContentSettingsType> types; |
31 if (controller->IsAskingForAudio()) | 37 if (controller->IsAskingForAudio()) |
32 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 38 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
33 if (controller->IsAskingForVideo()) | 39 if (controller->IsAskingForVideo()) |
34 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 40 types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
35 return types; | 41 return types; |
36 } | 42 } |
37 | 43 |
(...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. | 93 // we don't want WebRTC to be waiting for an answer that will never come. |
88 controller_->Cancelled(); | 94 controller_->Cancelled(); |
89 } | 95 } |
90 | 96 |
91 MediaStreamInfoBarDelegateAndroid* | 97 MediaStreamInfoBarDelegateAndroid* |
92 MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() { | 98 MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() { |
93 return this; | 99 return this; |
94 } | 100 } |
95 | 101 |
96 bool MediaStreamInfoBarDelegateAndroid::Accept() { | 102 bool MediaStreamInfoBarDelegateAndroid::Accept() { |
97 controller_->PermissionGranted(); | 103 if (GetPermissionCount() == 2) { |
| 104 controller_->GroupedRequestFinished( |
| 105 GetAcceptState(kGroupedInfobarAudioPosition), |
| 106 GetAcceptState(kGroupedInfobarVideoPosition)); |
| 107 } else { |
| 108 DCHECK_EQ(1, GetPermissionCount()); |
| 109 controller_->PermissionGranted(); |
| 110 } |
98 return true; | 111 return true; |
99 } | 112 } |
100 | 113 |
101 bool MediaStreamInfoBarDelegateAndroid::Cancel() { | 114 bool MediaStreamInfoBarDelegateAndroid::Cancel() { |
102 controller_->PermissionDenied(); | 115 controller_->PermissionDenied(); |
103 return true; | 116 return true; |
104 } | 117 } |
OLD | NEW |