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

Unified Diff: chrome/browser/cocoa/autocomplete_text_field_editor.mm

Issue 211030: [Mac] Expose AutocompleteEditViewMac to Cocoa code. (Closed)
Patch Set: Rohit's comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/autocomplete_text_field_editor.mm
diff --git a/chrome/browser/cocoa/autocomplete_text_field_editor.mm b/chrome/browser/cocoa/autocomplete_text_field_editor.mm
index 5bcacff42e9dc125bf6c9cf6865f2ae39e7cbee2..6516e4bfd320e32a7e81734f1d0eb1cd1cab8b7f 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_editor.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_editor.mm
@@ -7,6 +7,8 @@
#include "app/l10n_util_mac.h"
#include "base/string_util.h"
#include "grit/generated_resources.h"
+#include "base/sys_string_conversions.h"
+#import "chrome/browser/cocoa/autocomplete_text_field.h"
@implementation AutocompleteTextFieldEditor
@@ -31,18 +33,25 @@
[self delete:nil];
}
-- (BOOL)shouldPaste {
- id delegate = [self delegate];
- if (![delegate respondsToSelector:@selector(textShouldPaste:)] ||
- [delegate textShouldPaste:self]) {
- return YES;
- }
- return NO;
+// This class assumes that the delegate is an AutocompleteTextField.
+// Enforce that assumption.
+- (void)setDelegate:(id)anObject {
+ DCHECK(anObject == nil ||
+ [anObject isKindOfClass:[AutocompleteTextField class]]);
+ [super setDelegate:anObject];
+}
+
+// Convenience method for retrieving the observer from the delegate.
+- (AutocompleteTextFieldObserver*)observer {
+ DCHECK([[self delegate] isKindOfClass:[AutocompleteTextField class]]);
+ return [static_cast<AutocompleteTextField*>([self delegate]) observer];
}
- (void)paste:(id)sender {
- if ([self shouldPaste]) {
- [super paste:sender];
+ AutocompleteTextFieldObserver* observer = [self observer];
+ DCHECK(observer);
+ if (observer) {
+ observer->OnPaste();
}
}
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_editor.h ('k') | chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698