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 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
15 #include "components/google/core/browser/google_util.h" | 16 #include "components/google/core/browser/google_util.h" |
16 #include "components/infobars/core/infobar.h" | 17 #include "components/infobars/core/infobar.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
(...skipping 25 matching lines...) Expand all Loading... |
43 InfoBarService::FromWebContents(web_contents); | 44 InfoBarService::FromWebContents(web_contents); |
44 if (!infobar_service) { | 45 if (!infobar_service) { |
45 // Deny the request if there is no place to show the infobar, e.g. when | 46 // Deny the request if there is no place to show the infobar, e.g. when |
46 // the request comes from a background extension page. | 47 // the request comes from a background extension page. |
47 controller->Cancelled(); | 48 controller->Cancelled(); |
48 return false; | 49 return false; |
49 } | 50 } |
50 | 51 |
51 scoped_ptr<infobars::InfoBar> infobar( | 52 scoped_ptr<infobars::InfoBar> infobar( |
52 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 53 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
53 new MediaStreamInfoBarDelegateAndroid(controller.Pass())))); | 54 new MediaStreamInfoBarDelegateAndroid(std::move(controller))))); |
54 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 55 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
55 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i); | 56 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i); |
56 if (old_infobar->delegate()->AsMediaStreamInfoBarDelegateAndroid()) { | 57 if (old_infobar->delegate()->AsMediaStreamInfoBarDelegateAndroid()) { |
57 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); | 58 infobar_service->ReplaceInfoBar(old_infobar, std::move(infobar)); |
58 return true; | 59 return true; |
59 } | 60 } |
60 } | 61 } |
61 infobar_service->AddInfoBar(infobar.Pass()); | 62 infobar_service->AddInfoBar(std::move(infobar)); |
62 return true; | 63 return true; |
63 } | 64 } |
64 | 65 |
65 bool MediaStreamInfoBarDelegateAndroid::IsRequestingVideoAccess() const { | 66 bool MediaStreamInfoBarDelegateAndroid::IsRequestingVideoAccess() const { |
66 return controller_->IsAskingForVideo(); | 67 return controller_->IsAskingForVideo(); |
67 } | 68 } |
68 | 69 |
69 bool MediaStreamInfoBarDelegateAndroid::IsRequestingMicrophoneAccess() const { | 70 bool MediaStreamInfoBarDelegateAndroid::IsRequestingMicrophoneAccess() const { |
70 return controller_->IsAskingForAudio(); | 71 return controller_->IsAskingForAudio(); |
71 } | 72 } |
72 | 73 |
73 MediaStreamInfoBarDelegateAndroid::MediaStreamInfoBarDelegateAndroid( | 74 MediaStreamInfoBarDelegateAndroid::MediaStreamInfoBarDelegateAndroid( |
74 scoped_ptr<MediaStreamDevicesController> controller) | 75 scoped_ptr<MediaStreamDevicesController> controller) |
75 : ConfirmInfoBarDelegate(), controller_(controller.Pass()) { | 76 : ConfirmInfoBarDelegate(), controller_(std::move(controller)) { |
76 DCHECK(controller_.get()); | 77 DCHECK(controller_.get()); |
77 DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo()); | 78 DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo()); |
78 } | 79 } |
79 | 80 |
80 infobars::InfoBarDelegate::Type | 81 infobars::InfoBarDelegate::Type |
81 MediaStreamInfoBarDelegateAndroid::GetInfoBarType() const { | 82 MediaStreamInfoBarDelegateAndroid::GetInfoBarType() const { |
82 return PAGE_ACTION_TYPE; | 83 return PAGE_ACTION_TYPE; |
83 } | 84 } |
84 | 85 |
85 int MediaStreamInfoBarDelegateAndroid::GetIconId() const { | 86 int MediaStreamInfoBarDelegateAndroid::GetIconId() const { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 return true; | 138 return true; |
138 } | 139 } |
139 | 140 |
140 base::string16 MediaStreamInfoBarDelegateAndroid::GetLinkText() const { | 141 base::string16 MediaStreamInfoBarDelegateAndroid::GetLinkText() const { |
141 return base::string16(); | 142 return base::string16(); |
142 } | 143 } |
143 | 144 |
144 GURL MediaStreamInfoBarDelegateAndroid::GetLinkURL() const { | 145 GURL MediaStreamInfoBarDelegateAndroid::GetLinkURL() const { |
145 return GURL(chrome::kMediaAccessLearnMoreUrl); | 146 return GURL(chrome::kMediaAccessLearnMoreUrl); |
146 } | 147 } |
OLD | NEW |