Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/media/media_stream_infobar_delegate.cc

Issue 180633008: Add different error codes for getUserMedia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 29 matching lines...) Expand all
40 scoped_ptr<MediaStreamDevicesController> controller( 40 scoped_ptr<MediaStreamDevicesController> controller(
41 new MediaStreamDevicesController(web_contents, request, callback)); 41 new MediaStreamDevicesController(web_contents, request, callback));
42 if (controller->DismissInfoBarAndTakeActionOnSettings()) 42 if (controller->DismissInfoBarAndTakeActionOnSettings())
43 return false; 43 return false;
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); 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<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar(
55 scoped_ptr<ConfirmInfoBarDelegate>( 55 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 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());
(...skipping 10 matching lines...) Expand all
71 controller_(controller.Pass()) { 71 controller_(controller.Pass()) {
72 DCHECK(controller_.get()); 72 DCHECK(controller_.get());
73 DCHECK(controller_->HasAudio() || controller_->HasVideo()); 73 DCHECK(controller_->HasAudio() || controller_->HasVideo());
74 } 74 }
75 75
76 void MediaStreamInfoBarDelegate::InfoBarDismissed() { 76 void MediaStreamInfoBarDelegate::InfoBarDismissed() {
77 // Deny the request if the infobar was closed with the 'x' button, since 77 // Deny the request if the infobar was closed with the 'x' button, since
78 // we don't want WebRTC to be waiting for an answer that will never come. 78 // we don't want WebRTC to be waiting for an answer that will never come.
79 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", 79 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
80 kCancel, kPermissionActionsMax); 80 kCancel, kPermissionActionsMax);
81 controller_->Deny(false); 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 InfoBarDelegate::Type MediaStreamInfoBarDelegate::GetInfoBarType() const {
90 return PAGE_ACTION_TYPE; 90 return PAGE_ACTION_TYPE;
91 } 91 }
(...skipping 28 matching lines...) Expand all
120 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", 120 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
121 kAllowHttp, kPermissionActionsMax); 121 kAllowHttp, kPermissionActionsMax);
122 } 122 }
123 controller_->Accept(true); 123 controller_->Accept(true);
124 return true; 124 return true;
125 } 125 }
126 126
127 bool MediaStreamInfoBarDelegate::Cancel() { 127 bool MediaStreamInfoBarDelegate::Cancel() {
128 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", 128 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
129 kDeny, kPermissionActionsMax); 129 kDeny, kPermissionActionsMax);
130 controller_->Deny(true); 130 controller_->Deny(true, content::MEDIA_DEVICE_PERMISSION_DENIED);
131 return true; 131 return true;
132 } 132 }
133 133
134 base::string16 MediaStreamInfoBarDelegate::GetLinkText() const { 134 base::string16 MediaStreamInfoBarDelegate::GetLinkText() const {
135 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 135 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
136 } 136 }
137 137
138 bool MediaStreamInfoBarDelegate::LinkClicked( 138 bool MediaStreamInfoBarDelegate::LinkClicked(
139 WindowOpenDisposition disposition) { 139 WindowOpenDisposition disposition) {
140 web_contents()->OpenURL(content::OpenURLParams( 140 web_contents()->OpenURL(content::OpenURLParams(
141 google_util::AppendGoogleLocaleParam( 141 google_util::AppendGoogleLocaleParam(
142 GURL(chrome::kMediaAccessLearnMoreUrl)), 142 GURL(chrome::kMediaAccessLearnMoreUrl)),
143 content::Referrer(), 143 content::Referrer(),
144 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 144 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
145 content::PAGE_TRANSITION_LINK, 145 content::PAGE_TRANSITION_LINK,
146 false)); 146 false));
147 147
148 return false; // Do not dismiss the info bar. 148 return false; // Do not dismiss the info bar.
149 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_stream_devices_controller.cc ('k') | chrome/browser/media/webrtc_browsertest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698