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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_notification_container.mm

Issue 54303007: [rAc OSX] Add support for tooltips in notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/autofill_notification_container.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_container.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
11 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
12 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" 11 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
13 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h" 12 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h"
14 #include "skia/ext/skia_utils_mac.h"
15 13
16 @implementation AutofillNotificationContainer 14 @implementation AutofillNotificationContainer
17 15
18 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate { 16 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate {
19 if (self = [super init]) { 17 if (self = [super init]) {
20 delegate_ = delegate; 18 delegate_ = delegate;
21 [self setView:[[[NSView alloc] initWithFrame:NSZeroRect] autorelease]]; 19 [self setView:[[[NSView alloc] initWithFrame:NSZeroRect] autorelease]];
22 } 20 }
23 return self; 21 return self;
24 } 22 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 66
69 - (void)setNotifications:(const autofill::DialogNotifications&)notifications { 67 - (void)setNotifications:(const autofill::DialogNotifications&)notifications {
70 notificationControllers_.reset([[NSMutableArray alloc] init]); 68 notificationControllers_.reset([[NSMutableArray alloc] init]);
71 checkboxNotification_.reset(); 69 checkboxNotification_.reset();
72 [[self view] setSubviews:@[]]; 70 [[self view] setSubviews:@[]];
73 71
74 for (size_t i = 0; i < notifications.size(); ++i) { 72 for (size_t i = 0; i < notifications.size(); ++i) {
75 // Create basic notification view. 73 // Create basic notification view.
76 const autofill::DialogNotification& notification = notifications[i]; 74 const autofill::DialogNotification& notification = notifications[i];
77 base::scoped_nsobject<AutofillNotificationController> 75 base::scoped_nsobject<AutofillNotificationController>
78 notificationController([[AutofillNotificationController alloc] init]); 76 notificationController([[AutofillNotificationController alloc]
79 [notificationController setText: 77 initWithNotification:&notification]);
80 base::SysUTF16ToNSString(notification.display_text())];
81 [notificationController setTextColor:
82 gfx::SkColorToCalibratedNSColor(notification.GetTextColor())];
83 [notificationController setBackgroundColor:
84 gfx::SkColorToCalibratedNSColor(notification.GetBackgroundColor())];
85
86 // Add optional checkbox.
87 if (notification.HasCheckbox()) {
88 // No more than one notification with a checkbox.
89 DCHECK(!checkboxNotification_);
90 checkboxNotification_.reset(
91 new autofill::DialogNotification(notification));
92 [notificationController setHasCheckbox:YES];
93 [[notificationController checkbox] setState:
94 (notification.checked() ? NSOnState : NSOffState)];
95 [[notificationController checkbox] setTarget:self];
96 [[notificationController checkbox] setAction:@selector(checkboxClicked:)];
97 }
98 78
99 if (i == 0) { 79 if (i == 0) {
100 [notificationController setHasArrow:notification.HasArrow() 80 [notificationController setHasArrow:notification.HasArrow()
101 withAnchorView:anchorView_]; 81 withAnchorView:anchorView_];
102 } 82 }
103 83
84 if (notification.HasCheckbox()) {
85 // No more than one notification with a checkbox.
86 DCHECK(!checkboxNotification_);
87 checkboxNotification_.reset(
88 new autofill::DialogNotification(notification));
89 [[notificationController checkbox] setTarget:self];
90 [[notificationController checkbox] setAction:@selector(checkboxClicked:)];
91 }
92
104 [notificationControllers_ addObject:notificationController]; 93 [notificationControllers_ addObject:notificationController];
105 [[self view] addSubview:[notificationController view]]; 94 [[self view] addSubview:[notificationController view]];
106 } 95 }
107 } 96 }
108 97
109 - (void)setAnchorView:(NSView*)anchorView { 98 - (void)setAnchorView:(NSView*)anchorView {
110 anchorView_ = anchorView; 99 anchorView_ = anchorView;
111 } 100 }
112 101
113 - (IBAction)checkboxClicked:(id)sender { 102 - (IBAction)checkboxClicked:(id)sender {
114 DCHECK(checkboxNotification_); 103 DCHECK(checkboxNotification_);
115 BOOL isChecked = ([sender state] == NSOnState); 104 BOOL isChecked = ([sender state] == NSOnState);
116 delegate_->NotificationCheckboxStateChanged(checkboxNotification_->type(), 105 delegate_->NotificationCheckboxStateChanged(checkboxNotification_->type(),
117 isChecked); 106 isChecked);
118 } 107 }
119 108
120 @end 109 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698