diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-21 19:20:35 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-21 19:20:35 +0000 |
commit | ae49b018895081bbef1bd67d80e0cdeffc3b5558 (patch) | |
tree | 2204c81d41fa79e18e41900e4f06fe8a790aea5e /chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | |
parent | d2405cdc8e15532905e7c8f963cc69039be2b636 (diff) | |
download | chromium_src-ae49b018895081bbef1bd67d80e0cdeffc3b5558.zip chromium_src-ae49b018895081bbef1bd67d80e0cdeffc3b5558.tar.gz chromium_src-ae49b018895081bbef1bd67d80e0cdeffc3b5558.tar.bz2 |
[Mac] Expose AutocompleteEditViewMac to Cocoa code.
This reduces the number of forwarding/delegate shenanigans we have to
go through.
Review URL: http://codereview.chromium.org/211030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_mac.mm')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index 94130e4..aa245e6 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -16,7 +16,6 @@ #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/cocoa/autocomplete_text_field.h" #include "chrome/browser/cocoa/event_utils.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" @@ -128,6 +127,9 @@ NSRange ComponentToNSRange(const url_parse::Component& component) { // It intercepts various control delegate methods and vectors them to // the edit view. +// TODO(shess): Consider moving more of this code off to +// AutocompleteTextFieldObserver. + @interface AutocompleteFieldDelegate : NSObject<NSTextFieldDelegate> { @private AutocompleteEditViewMac* edit_view_; // weak, owns us. @@ -161,6 +163,7 @@ AutocompleteEditViewMac::AutocompleteEditViewMac( DCHECK(command_updater); DCHECK(field); [field_ setDelegate:edit_helper_.get()]; + [field_ setObserver:this]; // Needed so that editing doesn't lose the styling. [field_ setAllowsEditingTextAttributes:YES]; @@ -187,6 +190,7 @@ AutocompleteEditViewMac::~AutocompleteEditViewMac() { // Disconnect field_ from edit_helper_ so that we don't get calls // after destruction. [field_ setDelegate:nil]; + [field_ setObserver:NULL]; } void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) { @@ -858,15 +862,6 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { // it's set to the start of the text. } -// AutocompleteTextField/Editor adds a delegate method which allows us -// to intercept and handle -paste: calls. -- (BOOL)control:(NSControl*)control textShouldPaste:(NSText*)fieldEditor { - edit_view_->OnPaste(); - - // Caller shouldn't also paste. - return NO; -} - - (NSString*)control:(NSControl*)control textPasteActionString:(NSText*)fieldEditor { if (!edit_view_->CanPasteAndGo()) @@ -884,17 +879,4 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { edit_view_->OnDidResignKey(); } -// AutocompleteTextField adds a delegate method which allows us to -// track -flagsChanged: calls. -// -// When the user types Control-Enter, the existing content has "www." -// prepended and ".com" appended. This calls down to -// AutocompleteEditModel::OnControlKeyChanged() so that it can change -// the popup to reflect this. See autocomplete_edit.cc -// OnControlKeyChanged() and OnAfterPossibleChange(). -- (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { - bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; - edit_view_->OnControlKeyChanged(controlFlag); -} - @end |