| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | |
| 7 | |
| 8 #import <Cocoa/Cocoa.h> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/scoped_nsobject.h" | |
| 12 #include "base/scoped_ptr.h" | |
| 13 #include "chrome/browser/autocomplete/autocomplete.h" | |
| 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | |
| 15 #include "chrome/browser/toolbar_model.h" | |
| 16 #include "chrome/common/page_transition_types.h" | |
| 17 #include "webkit/glue/window_open_disposition.h" | |
| 18 | |
| 19 class AutocompleteEditController; | |
| 20 @class AutocompleteEditHelper; | |
| 21 class AutocompleteEditModel; | |
| 22 class AutocompletePopupViewMac; | |
| 23 class CommandUpdater; | |
| 24 class Profile; | |
| 25 class TabContents; | |
| 26 class ToolbarModel; | |
| 27 | |
| 28 // Implements AutocompleteEditView on an NSTextField. | |
| 29 | |
| 30 class AutocompleteEditViewMac : public AutocompleteEditView { | |
| 31 public: | |
| 32 AutocompleteEditViewMac(AutocompleteEditController* controller, | |
| 33 ToolbarModel* toolbar_model, | |
| 34 Profile* profile, | |
| 35 CommandUpdater* command_updater); | |
| 36 virtual ~AutocompleteEditViewMac(); | |
| 37 | |
| 38 // Implement the AutocompleteEditView interface. | |
| 39 // TODO(shess): See if this couldn't be simplified to: | |
| 40 // virtual AEM* model() const { ... } | |
| 41 virtual AutocompleteEditModel* model() { return model_.get(); } | |
| 42 virtual const AutocompleteEditModel* model() const { return model_.get(); } | |
| 43 | |
| 44 virtual void SaveStateToTab(TabContents* tab); | |
| 45 virtual void Update(const TabContents* tab_for_state_restoring) { | |
| 46 NOTIMPLEMENTED(); | |
| 47 } | |
| 48 | |
| 49 virtual void OpenURL(const GURL& url, | |
| 50 WindowOpenDisposition disposition, | |
| 51 PageTransition::Type transition, | |
| 52 const GURL& alternate_nav_url, | |
| 53 size_t selected_line, | |
| 54 const std::wstring& keyword); | |
| 55 | |
| 56 virtual std::wstring GetText() const; | |
| 57 virtual void SetUserText(const std::wstring& text) { NOTIMPLEMENTED(); } | |
| 58 virtual void SetUserText(const std::wstring& text, | |
| 59 const std::wstring& display_text, | |
| 60 bool update_popup) { NOTIMPLEMENTED(); } | |
| 61 | |
| 62 virtual void SetWindowTextAndCaretPos(const std::wstring& text, | |
| 63 size_t caret_pos); | |
| 64 | |
| 65 virtual bool IsSelectAll() { | |
| 66 NOTIMPLEMENTED(); | |
| 67 return false; | |
| 68 } | |
| 69 | |
| 70 virtual void SelectAll(bool reversed); | |
| 71 virtual void RevertAll(); | |
| 72 virtual void UpdatePopup(); | |
| 73 virtual void ClosePopup(); | |
| 74 void UpdateAndStyleText(const std::wstring& display_text, | |
| 75 size_t user_text_length); | |
| 76 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, | |
| 77 bool save_original_selection); | |
| 78 virtual bool OnInlineAutocompleteTextMaybeChanged( | |
| 79 const std::wstring& display_text, size_t user_text_length); | |
| 80 virtual void OnRevertTemporaryText(); | |
| 81 virtual void OnBeforePossibleChange() { NOTIMPLEMENTED(); } | |
| 82 virtual bool OnAfterPossibleChange() { NOTIMPLEMENTED(); return false; } | |
| 83 | |
| 84 // Helper functions which forward to our private: model_. | |
| 85 void OnUpOrDownKeyPressed(int dir); | |
| 86 void OnEscapeKeyPressed(); | |
| 87 void OnSetFocus(bool f); | |
| 88 void OnKillFocus(); | |
| 89 void AcceptInput(WindowOpenDisposition disposition, bool for_drop); | |
| 90 void OnAfterPossibleChange(const std::wstring& new_text, | |
| 91 bool selection_differs, | |
| 92 bool text_differs, | |
| 93 bool just_deleted_text, | |
| 94 bool at_end_of_edit); | |
| 95 | |
| 96 // TODO(shess): Get rid of this. Right now it's needed because of | |
| 97 // the ordering of initialization in tab_contents_controller.mm. | |
| 98 void SetField(NSTextField* field); | |
| 99 | |
| 100 // Helper for LocationBarBridge. | |
| 101 void FocusLocation(); | |
| 102 | |
| 103 private: | |
| 104 scoped_ptr<AutocompleteEditModel> model_; | |
| 105 scoped_ptr<AutocompletePopupViewMac> popup_view_; | |
| 106 | |
| 107 AutocompleteEditController* controller_; | |
| 108 ToolbarModel* toolbar_model_; | |
| 109 | |
| 110 // The object that handles additional command functionality exposed on the | |
| 111 // edit, such as invoking the keyword editor. | |
| 112 CommandUpdater* command_updater_; | |
| 113 | |
| 114 NSTextField* field_; // owned by tab controller | |
| 115 | |
| 116 // Objective-C object to bridge field_ delegate calls to C++. | |
| 117 scoped_nsobject<AutocompleteEditHelper> edit_helper_; | |
| 118 | |
| 119 std::wstring saved_temporary_text_; | |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); | |
| 122 }; | |
| 123 | |
| 124 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | |
| OLD | NEW |