| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 109 } |
| 109 | 110 |
| 110 base::string16 MediaStreamInfoBarDelegate::GetButtonLabel( | 111 base::string16 MediaStreamInfoBarDelegate::GetButtonLabel( |
| 111 InfoBarButton button) const { | 112 InfoBarButton button) const { |
| 112 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 113 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 113 IDS_MEDIA_CAPTURE_ALLOW : IDS_MEDIA_CAPTURE_DENY); | 114 IDS_MEDIA_CAPTURE_ALLOW : IDS_MEDIA_CAPTURE_DENY); |
| 114 } | 115 } |
| 115 | 116 |
| 116 bool MediaStreamInfoBarDelegate::Accept() { | 117 bool MediaStreamInfoBarDelegate::Accept() { |
| 117 GURL origin(controller_->GetSecurityOriginSpec()); | 118 GURL origin(controller_->GetSecurityOriginSpec()); |
| 118 if (origin.SchemeIsSecure()) { | 119 if (IsOriginSecure(origin)) { |
| 119 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 120 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
| 120 kAllowHttps, kPermissionActionsMax); | 121 kAllowHttps, kPermissionActionsMax); |
| 121 } else { | 122 } else { |
| 122 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 123 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
| 123 kAllowHttp, kPermissionActionsMax); | 124 kAllowHttp, kPermissionActionsMax); |
| 124 } | 125 } |
| 125 controller_->Accept(true); | 126 controller_->Accept(true); |
| 126 return true; | 127 return true; |
| 127 } | 128 } |
| 128 | 129 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 141 WindowOpenDisposition disposition) { | 142 WindowOpenDisposition disposition) { |
| 142 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 143 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
| 143 content::OpenURLParams( | 144 content::OpenURLParams( |
| 144 GURL(chrome::kMediaAccessLearnMoreUrl), | 145 GURL(chrome::kMediaAccessLearnMoreUrl), |
| 145 content::Referrer(), | 146 content::Referrer(), |
| 146 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 147 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 147 ui::PAGE_TRANSITION_LINK, false)); | 148 ui::PAGE_TRANSITION_LINK, false)); |
| 148 | 149 |
| 149 return false; // Do not dismiss the info bar. | 150 return false; // Do not dismiss the info bar. |
| 150 } | 151 } |
| OLD | NEW |