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

Side by Side Diff: chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm

Issue 207027: [Mac] Polish the search engine manager (Closed)
Patch Set: '' Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/edit_search_engine_cocoa_controller.h" 5 #import "chrome/browser/cocoa/edit_search_engine_cocoa_controller.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #import "base/mac_util.h" 9 #import "base/mac_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // will not let the user save. If this is an edit, then this will set all 95 // will not let the user save. If this is an edit, then this will set all
96 // the images to the "valid" state. 96 // the images to the "valid" state.
97 [self validateFields]; 97 [self validateFields];
98 } 98 }
99 99
100 // When the window closes, clean ourselves up. 100 // When the window closes, clean ourselves up.
101 - (void)windowWillClose:(NSNotification*)notif { 101 - (void)windowWillClose:(NSNotification*)notif {
102 [self autorelease]; 102 [self autorelease];
103 } 103 }
104 104
105 // Performs the logic of closing the window. If we are a sheet, then it ends the
106 // modal session; otherwise, it closes the window.
107 - (void)doClose {
108 if ([[self window] isSheet]) {
109 [NSApp endSheet:[self window]];
110 } else {
111 [[self window] close];
112 }
113 }
114
105 - (IBAction)cancel:(id)sender { 115 - (IBAction)cancel:(id)sender {
106 [[self window] close]; 116 [self doClose];
107 } 117 }
108 118
109 - (IBAction)save:(id)sender { 119 - (IBAction)save:(id)sender {
110 DCHECK([self validateFields]); 120 DCHECK([self validateFields]);
111 std::wstring title = base::SysNSStringToWide([nameField_ stringValue]); 121 std::wstring title = base::SysNSStringToWide([nameField_ stringValue]);
112 std::wstring keyword = base::SysNSStringToWide([keywordField_ stringValue]); 122 std::wstring keyword = base::SysNSStringToWide([keywordField_ stringValue]);
113 std::wstring url = base::SysNSStringToWide([urlField_ stringValue]); 123 std::wstring url = base::SysNSStringToWide([urlField_ stringValue]);
114 controller_->AcceptAddOrEdit(title, keyword, url); 124 controller_->AcceptAddOrEdit(title, keyword, url);
115 [[self window] close]; 125 [self doClose];
116 } 126 }
117 127
118 // Delegate method for the text fields. 128 // Delegate method for the text fields.
119 129
120 - (void)controlTextDidChange:(NSNotification*)notif { 130 - (void)controlTextDidChange:(NSNotification*)notif {
121 [self validateFields]; 131 [self validateFields];
122 } 132 }
123 133
124 - (void)controlTextDidEndEditing:(NSNotification*)notif { 134 - (void)controlTextDidEndEditing:(NSNotification*)notif {
125 [self validateFields]; 135 [self validateFields];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 toolTip:IDS_SEARCH_ENGINES_INVALID_URL_TT 175 toolTip:IDS_SEARCH_ENGINES_INVALID_URL_TT
166 forImageView:urlImage_ 176 forImageView:urlImage_
167 textField:urlField_]; 177 textField:urlField_];
168 178
169 BOOL isValid = (titleValid && keywordValid && urlValid); 179 BOOL isValid = (titleValid && keywordValid && urlValid);
170 [doneButton_ setEnabled:isValid]; 180 [doneButton_ setEnabled:isValid];
171 return isValid; 181 return isValid;
172 } 182 }
173 183
174 @end 184 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698