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/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
11 #include "chrome/browser/infobars/infobar.h" | |
12 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "components/infobars/core/infobar.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 enum DevicePermissionActions { | 22 enum DevicePermissionActions { |
23 kAllowHttps = 0, | 23 kAllowHttps = 0, |
(...skipping 20 matching lines...) Expand all Loading... |
44 | 44 |
45 InfoBarService* infobar_service = | 45 InfoBarService* infobar_service = |
46 InfoBarService::FromWebContents(web_contents); | 46 InfoBarService::FromWebContents(web_contents); |
47 if (!infobar_service) { | 47 if (!infobar_service) { |
48 // Deny the request if there is no place to show the infobar, e.g. when | 48 // Deny the request if there is no place to show the infobar, e.g. when |
49 // the request comes from a background extension page. | 49 // the request comes from a background extension page. |
50 controller->Deny(false, content::MEDIA_DEVICE_INVALID_STATE); | 50 controller->Deny(false, content::MEDIA_DEVICE_INVALID_STATE); |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( | 54 scoped_ptr<infobars::InfoBar> infobar( |
55 scoped_ptr<ConfirmInfoBarDelegate>( | 55 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
56 new MediaStreamInfoBarDelegate(controller.Pass())))); | 56 new MediaStreamInfoBarDelegate(controller.Pass())))); |
57 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 57 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
58 InfoBar* old_infobar = infobar_service->infobar_at(i); | 58 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i); |
59 if (old_infobar->delegate()->AsMediaStreamInfoBarDelegate()) { | 59 if (old_infobar->delegate()->AsMediaStreamInfoBarDelegate()) { |
60 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); | 60 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); |
61 return true; | 61 return true; |
62 } | 62 } |
63 } | 63 } |
64 infobar_service->AddInfoBar(infobar.Pass()); | 64 infobar_service->AddInfoBar(infobar.Pass()); |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( | 68 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( |
(...skipping 10 matching lines...) Expand all Loading... |
79 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 79 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
80 kCancel, kPermissionActionsMax); | 80 kCancel, kPermissionActionsMax); |
81 controller_->Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); | 81 controller_->Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); |
82 } | 82 } |
83 | 83 |
84 int MediaStreamInfoBarDelegate::GetIconID() const { | 84 int MediaStreamInfoBarDelegate::GetIconID() const { |
85 return controller_->HasVideo() ? | 85 return controller_->HasVideo() ? |
86 IDR_INFOBAR_MEDIA_STREAM_CAMERA : IDR_INFOBAR_MEDIA_STREAM_MIC; | 86 IDR_INFOBAR_MEDIA_STREAM_CAMERA : IDR_INFOBAR_MEDIA_STREAM_MIC; |
87 } | 87 } |
88 | 88 |
89 InfoBarDelegate::Type MediaStreamInfoBarDelegate::GetInfoBarType() const { | 89 infobars::InfoBarDelegate::Type MediaStreamInfoBarDelegate::GetInfoBarType() |
| 90 const { |
90 return PAGE_ACTION_TYPE; | 91 return PAGE_ACTION_TYPE; |
91 } | 92 } |
92 | 93 |
93 MediaStreamInfoBarDelegate* | 94 MediaStreamInfoBarDelegate* |
94 MediaStreamInfoBarDelegate::AsMediaStreamInfoBarDelegate() { | 95 MediaStreamInfoBarDelegate::AsMediaStreamInfoBarDelegate() { |
95 return this; | 96 return this; |
96 } | 97 } |
97 | 98 |
98 base::string16 MediaStreamInfoBarDelegate::GetMessageText() const { | 99 base::string16 MediaStreamInfoBarDelegate::GetMessageText() const { |
99 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 100 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 141 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
141 content::OpenURLParams( | 142 content::OpenURLParams( |
142 google_util::AppendGoogleLocaleParam( | 143 google_util::AppendGoogleLocaleParam( |
143 GURL(chrome::kMediaAccessLearnMoreUrl)), | 144 GURL(chrome::kMediaAccessLearnMoreUrl)), |
144 content::Referrer(), | 145 content::Referrer(), |
145 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 146 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
146 content::PAGE_TRANSITION_LINK, false)); | 147 content::PAGE_TRANSITION_LINK, false)); |
147 | 148 |
148 return false; // Do not dismiss the info bar. | 149 return false; // Do not dismiss the info bar. |
149 } | 150 } |
OLD | NEW |