diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 20:14:00 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 20:14:00 +0000 |
commit | 2c47bc10fd06fc047dda9526e81a125f6bf0db39 (patch) | |
tree | 5df370a0aa9dadbb99a7f7dfcd533f4eb3bf1dde /chrome/browser/autocomplete/autocomplete_edit_view_mac.h | |
parent | 4c619ad0d418331d0f61b245149d056144b39739 (diff) | |
download | chromium_src-2c47bc10fd06fc047dda9526e81a125f6bf0db39.zip chromium_src-2c47bc10fd06fc047dda9526e81a125f6bf0db39.tar.gz chromium_src-2c47bc10fd06fc047dda9526e81a125f6bf0db39.tar.bz2 |
Initial implemention of Mac Omnibox.
AutocompletePopupViewMac implements AutocompletePopupView in terms of a bare NSWindow containing an NSTableView. AutocompleteTableTarget implements an Obj-C class to bridge from appkit callbacks back to the popup view (and from there to the model which contains the data it needs).
AutocompleteEditViewMac implements AutocompleteEditView in terms of an NSTextField, which is passed down from a nib owner. It works with the popup view to make sure the popup is positioned correctly. AutocompleteFieldDelegate is an internal Obj-C class to bridge from appkit callbacks back to the edit view (and then the edit model).
LocationBarViewMac implements LocationBar for interacting with the rest of the browser, and AutocompleteEditController for managing the edit and popup views. It is mostly placeholder code stolen from the gtk implementation.
---
I've tried to implement an amount of code which worked and was useful, but which didn't drag on and on into the future. So no tab to search or hints or anything, sometimes ugly, selection may be funky, etc.
Review URL: http://codereview.chromium.org/50074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13534 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_mac.h')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h new file mode 100644 index 0000000..8a6147e --- /dev/null +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h @@ -0,0 +1,124 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ +#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ + +#import <Cocoa/Cocoa.h> + +#include "base/basictypes.h" +#include "base/scoped_nsobject.h" +#include "base/scoped_ptr.h" +#include "chrome/browser/autocomplete/autocomplete.h" +#include "chrome/browser/autocomplete/autocomplete_edit_view.h" +#include "chrome/browser/toolbar_model.h" +#include "chrome/common/page_transition_types.h" +#include "webkit/glue/window_open_disposition.h" + +class AutocompleteEditController; +@class AutocompleteEditHelper; +class AutocompleteEditModel; +class AutocompletePopupViewMac; +class CommandUpdater; +class Profile; +class TabContents; +class ToolbarModel; + +// Implements AutocompleteEditView on an NSTextField. + +class AutocompleteEditViewMac : public AutocompleteEditView { + public: + AutocompleteEditViewMac(AutocompleteEditController* controller, + ToolbarModel* toolbar_model, + Profile* profile, + CommandUpdater* command_updater); + virtual ~AutocompleteEditViewMac(); + + // Implement the AutocompleteEditView interface. + // TODO(shess): See if this couldn't be simplified to: + // virtual AEM* model() const { ... } + virtual AutocompleteEditModel* model() { return model_.get(); } + virtual const AutocompleteEditModel* model() const { return model_.get(); } + + virtual void SaveStateToTab(TabContents* tab); + virtual void Update(const TabContents* tab_for_state_restoring) { + NOTIMPLEMENTED(); + } + + virtual void OpenURL(const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition, + const GURL& alternate_nav_url, + size_t selected_line, + const std::wstring& keyword); + + virtual std::wstring GetText() const; + virtual void SetUserText(const std::wstring& text) { NOTIMPLEMENTED(); } + virtual void SetUserText(const std::wstring& text, + const std::wstring& display_text, + bool update_popup) { NOTIMPLEMENTED(); } + + virtual void SetWindowTextAndCaretPos(const std::wstring& text, + size_t caret_pos); + + virtual bool IsSelectAll() { + NOTIMPLEMENTED(); + return false; + } + + virtual void SelectAll(bool reversed); + virtual void RevertAll(); + virtual void UpdatePopup(); + virtual void ClosePopup(); + void UpdateAndStyleText(const std::wstring& display_text, + size_t user_text_length); + virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, + bool save_original_selection); + virtual bool OnInlineAutocompleteTextMaybeChanged( + const std::wstring& display_text, size_t user_text_length); + virtual void OnRevertTemporaryText(); + virtual void OnBeforePossibleChange() { NOTIMPLEMENTED(); } + virtual bool OnAfterPossibleChange() { NOTIMPLEMENTED(); return false; } + + // Helper functions which forward to our private: model_. + void OnUpOrDownKeyPressed(int dir); + void OnEscapeKeyPressed(); + void OnSetFocus(bool f); + void OnKillFocus(); + void AcceptInput(WindowOpenDisposition disposition, bool for_drop); + void OnAfterPossibleChange(const std::wstring& new_text, + bool selection_differs, + bool text_differs, + bool just_deleted_text, + bool at_end_of_edit); + + // TODO(shess): Get rid of this. Right now it's needed because of + // the ordering of initialization in tab_contents_controller.mm. + void SetField(NSTextField* field); + + // Helper for LocationBarBridge. + void FocusLocation(); + + private: + scoped_ptr<AutocompleteEditModel> model_; + scoped_ptr<AutocompletePopupViewMac> popup_view_; + + AutocompleteEditController* controller_; + ToolbarModel* toolbar_model_; + + // The object that handles additional command functionality exposed on the + // edit, such as invoking the keyword editor. + CommandUpdater* command_updater_; + + NSTextField* field_; // owned by tab controller + + // Objective-C object to bridge field_ delegate calls to C++. + scoped_nsobject<AutocompleteEditHelper> edit_helper_; + + std::wstring saved_temporary_text_; + + DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); +}; + +#endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |