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.h" | 5 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
13 #include "components/google/core/browser/google_util.h" | 13 #include "components/google/core/browser/google_util.h" |
14 #include "components/infobars/core/infobar.h" | 14 #include "components/infobars/core/infobar.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "content/public/common/origin_util.h" | |
17 #include "grit/components_strings.h" | 16 #include "grit/components_strings.h" |
18 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 enum DevicePermissionActions { | 23 enum DevicePermissionActions { |
25 kAllowHttps = 0, | 24 kAllowHttps = 0, |
26 kAllowHttp, | 25 kAllowHttp, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 116 } |
118 | 117 |
119 base::string16 MediaStreamInfoBarDelegate::GetButtonLabel( | 118 base::string16 MediaStreamInfoBarDelegate::GetButtonLabel( |
120 InfoBarButton button) const { | 119 InfoBarButton button) const { |
121 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 120 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
122 IDS_MEDIA_CAPTURE_ALLOW : IDS_MEDIA_CAPTURE_BLOCK); | 121 IDS_MEDIA_CAPTURE_ALLOW : IDS_MEDIA_CAPTURE_BLOCK); |
123 } | 122 } |
124 | 123 |
125 bool MediaStreamInfoBarDelegate::Accept() { | 124 bool MediaStreamInfoBarDelegate::Accept() { |
126 GURL origin(controller_->GetSecurityOriginSpec()); | 125 GURL origin(controller_->GetSecurityOriginSpec()); |
127 if (content::IsOriginSecure(origin)) { | 126 if (origin.SchemeIsSecure()) { |
128 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 127 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
129 kAllowHttps, kPermissionActionsMax); | 128 kAllowHttps, kPermissionActionsMax); |
130 } else { | 129 } else { |
131 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 130 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
132 kAllowHttp, kPermissionActionsMax); | 131 kAllowHttp, kPermissionActionsMax); |
133 } | 132 } |
134 controller_->PermissionGranted(); | 133 controller_->PermissionGranted(); |
135 return true; | 134 return true; |
136 } | 135 } |
137 | 136 |
(...skipping 12 matching lines...) Expand all Loading... |
150 WindowOpenDisposition disposition) { | 149 WindowOpenDisposition disposition) { |
151 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 150 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
152 content::OpenURLParams( | 151 content::OpenURLParams( |
153 GURL(chrome::kMediaAccessLearnMoreUrl), | 152 GURL(chrome::kMediaAccessLearnMoreUrl), |
154 content::Referrer(), | 153 content::Referrer(), |
155 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 154 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
156 ui::PAGE_TRANSITION_LINK, false)); | 155 ui::PAGE_TRANSITION_LINK, false)); |
157 | 156 |
158 return false; // Do not dismiss the info bar. | 157 return false; // Do not dismiss the info bar. |
159 } | 158 } |
OLD | NEW |