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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/media/media_stream_devices_menu_model.h" | 12 #include "chrome/browser/media/media_stream_devices_menu_model.h" |
13 #include "chrome/browser/ui/cocoa/hover_close_button.h" | 13 #include "chrome/browser/ui/cocoa/hover_close_button.h" |
14 #include "chrome/browser/ui/cocoa/infobars/infobar.h" | 14 #include "chrome/browser/ui/cocoa/infobars/infobar.h" |
15 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" | 15 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" |
16 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 16 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 18 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 | 20 |
21 using InfoBarUtilities::CreateLabel; | 21 using InfoBarUtilities::CreateLabel; |
22 using InfoBarUtilities::MoveControl; | 22 using InfoBarUtilities::MoveControl; |
23 using InfoBarUtilities::VerifyControlOrderAndSpacing; | 23 using InfoBarUtilities::VerifyControlOrderAndSpacing; |
24 using l10n_util::GetNSStringWithFixup; | 24 using l10n_util::GetNSStringWithFixup; |
25 | 25 |
26 InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { | 26 InfoBar* MediaStreamInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) { |
27 MediaStreamInfoBarController* infobar_controller = | 27 MediaStreamInfoBarController* infobar_controller = |
28 [[MediaStreamInfoBarController alloc] initWithDelegate:this | 28 [[MediaStreamInfoBarController alloc] initWithDelegate:this |
29 owner:owner]; | 29 owner:owner]; |
30 return new InfoBar(infobar_controller, this); | 30 return new InfoBar(infobar_controller, this); |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 @interface MediaStreamInfoBarController(Private) | 34 @interface MediaStreamInfoBarController(Private) |
35 | 35 |
36 // Adds text for all buttons and text fields. | 36 // Adds text for all buttons and text fields. |
37 - (void)setLabelTexts; | 37 - (void)setLabelTexts; |
38 | 38 |
39 // Populates the device menu with device id:s. | 39 // Populates the device menu with device id:s. |
40 - (void)rebuildDeviceMenu; | 40 - (void)rebuildDeviceMenu; |
41 | 41 |
42 // Arranges all buttons and pup-up menu relative each other. | 42 // Arranges all buttons and pup-up menu relative each other. |
43 - (void)arrangeInfobarLayout; | 43 - (void)arrangeInfobarLayout; |
44 | 44 |
45 // Create all the components for the infobar. | 45 // Create all the components for the infobar. |
46 - (void)constructView; | 46 - (void)constructView; |
47 | 47 |
48 - (void)showDeviceMenuTitle:(BOOL)showTitle; | 48 - (void)showDeviceMenuTitle:(BOOL)showTitle; |
49 @end | 49 @end |
50 | 50 |
51 | 51 |
52 @implementation MediaStreamInfoBarController | 52 @implementation MediaStreamInfoBarController |
53 | 53 |
54 - (id)initWithDelegate:(MediaStreamInfoBarDelegate*)delegate | 54 - (id)initWithDelegate:(MediaStreamInfoBarDelegate*)delegate |
55 owner:(InfoBarTabHelper*)owner { | 55 owner:(InfoBarTabService*)owner { |
56 if (self = [super initWithDelegate:delegate owner:owner]) { | 56 if (self = [super initWithDelegate:delegate owner:owner]) { |
57 deviceMenuModel_.reset(new MediaStreamDevicesMenuModel(delegate)); | 57 deviceMenuModel_.reset(new MediaStreamDevicesMenuModel(delegate)); |
58 } | 58 } |
59 return self; | 59 return self; |
60 } | 60 } |
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]; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 [[[deviceMenu_ menu] itemAtIndex:0] setTitle:@""]; | 259 [[[deviceMenu_ menu] itemAtIndex:0] setTitle:@""]; |
260 [[deviceMenu_ cell] setArrowPosition:NSPopUpArrowAtCenter]; | 260 [[deviceMenu_ cell] setArrowPosition:NSPopUpArrowAtCenter]; |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 - (void)didChangeFrame:(NSNotification*)notification { | 264 - (void)didChangeFrame:(NSNotification*)notification { |
265 [self arrangeInfobarLayout]; | 265 [self arrangeInfobarLayout]; |
266 } | 266 } |
267 | 267 |
268 @end // implementation MediaStreamInfoBarController | 268 @end // implementation MediaStreamInfoBarController |
OLD | NEW |