| 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 #import "chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/media_stream_infobar_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #import "base/sys_string_conversions.h" | 10 #import "base/sys_string_conversions.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 - (void)dealloc { | 62 - (void)dealloc { |
| 63 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 63 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 64 [deviceMenu_ removeAllItems]; | 64 [deviceMenu_ removeAllItems]; |
| 65 [super dealloc]; | 65 [super dealloc]; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Called when "Allow" button is pressed. | 68 // Called when "Allow" button is pressed. |
| 69 - (void)ok:(id)sender { | 69 - (void)ok:(id)sender { |
| 70 std::string audioId, videoId; | 70 std::string audioId, videoId; |
| 71 deviceMenuModel_->GetSelectedDeviceId( | 71 deviceMenuModel_->GetSelectedAudioDeviceId(&audioId); |
| 72 content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, &audioId); | 72 deviceMenuModel_->GetSelectedVideoDeviceId(&videoId); |
| 73 deviceMenuModel_->GetSelectedDeviceId( | |
| 74 content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, &videoId); | |
| 75 bool alwaysAllow = deviceMenuModel_->always_allow(); | 73 bool alwaysAllow = deviceMenuModel_->always_allow(); |
| 76 | 74 |
| 77 static_cast<MediaStreamInfoBarDelegate*>([self delegate])->Accept( | 75 static_cast<MediaStreamInfoBarDelegate*>([self delegate])->Accept( |
| 78 audioId, videoId, alwaysAllow); | 76 audioId, videoId, alwaysAllow); |
| 79 | 77 |
| 80 // Remove the infobar, we're done. | 78 // Remove the infobar, we're done. |
| 81 [super removeSelf]; | 79 [super removeSelf]; |
| 82 } | 80 } |
| 83 | 81 |
| 84 // Called when "Deny" button is pressed. | 82 // Called when "Deny" button is pressed. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 129 |
| 132 // Get the requested media type(s) and add corresponding text to the text | 130 // Get the requested media type(s) and add corresponding text to the text |
| 133 // field. | 131 // field. |
| 134 int messageId = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 132 int messageId = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
| 135 DCHECK(delegate->HasAudio() || delegate->HasVideo()); | 133 DCHECK(delegate->HasAudio() || delegate->HasVideo()); |
| 136 if (!delegate->HasAudio()) | 134 if (!delegate->HasAudio()) |
| 137 messageId = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 135 messageId = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
| 138 else if (!delegate->HasVideo()) | 136 else if (!delegate->HasVideo()) |
| 139 messageId = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 137 messageId = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
| 140 | 138 |
| 141 string16 securityOrigin = UTF8ToUTF16(delegate->GetSecurityOrigin().spec()); | 139 string16 securityOrigin = UTF8ToUTF16(delegate->GetSecurityOriginSpec()); |
| 142 NSString* text = l10n_util::GetNSStringF(messageId, securityOrigin); | 140 NSString* text = l10n_util::GetNSStringF(messageId, securityOrigin); |
| 143 [label1_ setStringValue:text]; | 141 [label1_ setStringValue:text]; |
| 144 | 142 |
| 145 // Add text to the buttons. | 143 // Add text to the buttons. |
| 146 [okButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_ALLOW)]; | 144 [okButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_ALLOW)]; |
| 147 [cancelButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_DENY)]; | 145 [cancelButton_ setTitle:GetNSStringWithFixup(IDS_MEDIA_CAPTURE_DENY)]; |
| 148 | 146 |
| 149 // Populating |deviceMenu_| is handled separately. | 147 // Populating |deviceMenu_| is handled separately. |
| 150 } | 148 } |
| 151 | 149 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 [[[deviceMenu_ menu] itemAtIndex:0] setTitle:@""]; | 257 [[[deviceMenu_ menu] itemAtIndex:0] setTitle:@""]; |
| 260 [[deviceMenu_ cell] setArrowPosition:NSPopUpArrowAtCenter]; | 258 [[deviceMenu_ cell] setArrowPosition:NSPopUpArrowAtCenter]; |
| 261 } | 259 } |
| 262 } | 260 } |
| 263 | 261 |
| 264 - (void)didChangeFrame:(NSNotification*)notification { | 262 - (void)didChangeFrame:(NSNotification*)notification { |
| 265 [self arrangeInfobarLayout]; | 263 [self arrangeInfobarLayout]; |
| 266 } | 264 } |
| 267 | 265 |
| 268 @end // implementation MediaStreamInfoBarController | 266 @end // implementation MediaStreamInfoBarController |
| OLD | NEW |