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