summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 20:14:00 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 20:14:00 +0000
commit2c47bc10fd06fc047dda9526e81a125f6bf0db39 (patch)
tree5df370a0aa9dadbb99a7f7dfcd533f4eb3bf1dde /chrome
parent4c619ad0d418331d0f61b245149d056144b39739 (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/app_controller_mac.mm16
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h124
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm309
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac.h97
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac.mm250
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h56
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm112
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac_unittest.mm19
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm16
-rw-r--r--chrome/chrome.gyp6
12 files changed, 967 insertions, 42 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 98ed64b..c042dd8 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "app_controller_mac.h"
+#import "chrome/browser/app_controller_mac.h"
-#import "base/message_loop.h"
-#import "chrome/app/chrome_dll_resource.h"
-#import "chrome/browser/browser.h"
-#import "chrome/browser/browser_list.h"
+#include "base/message_loop.h"
+#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_shutdown.h"
#import "chrome/browser/cocoa/bookmark_menu_bridge.h"
-#import "chrome/browser/command_updater.h"
-#import "chrome/browser/profile_manager.h"
-#import "chrome/common/temp_scaffolding_stubs.h"
+#include "chrome/browser/command_updater.h"
+#include "chrome/browser/profile_manager.h"
+#include "chrome/common/temp_scaffolding_stubs.h"
@interface AppController(PRIVATE)
- (void)initMenuState;
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view.h b/chrome/browser/autocomplete/autocomplete_edit_view.h
index 93982fe..27c28e7 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view.h
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// This file defines the interface class AutocompleteEditView. Each toolkit
-// will implement the edit view differently, so that code is inheriently
+// will implement the edit view differently, so that code is inherently
// platform specific. However, the AutocompleteEditModel needs to do some
// communication with the view. Since the model is shared between platforms,
// we need to define an interface that all view implementations will share.
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 277a965..69e8a9b 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -177,7 +177,7 @@ void AutocompleteEditViewGtk::OpenURL(const GURL& url,
model_->SendOpenNotification(selected_line, keyword);
if (disposition != NEW_BACKGROUND_TAB)
- RevertAll(); // Revert the box to its unedited state
+ RevertAll(); // Revert the box to its unedited state.
controller_->OnAutocompleteAccept(url, disposition, transition,
alternate_nav_url);
}
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_
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
new file mode 100644
index 0000000..cc79fc0
--- /dev/null
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -0,0 +1,309 @@
+// 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.
+
+#include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
+
+#include "base/sys_string_conversions.h"
+#include "chrome/browser/autocomplete/autocomplete_edit.h"
+#include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
+
+// Thin Obj-C bridge class that is the delegate of the omnibox field.
+// It intercepts various control delegate methods and vectors them to
+// the edit view.
+
+@interface AutocompleteFieldDelegate : NSObject {
+ @private
+ AutocompleteEditViewMac* edit_view_; // weak, owns us.
+}
+- initWithEditView:(AutocompleteEditViewMac*)view;
+@end
+
+AutocompleteEditViewMac::AutocompleteEditViewMac(
+ AutocompleteEditController* controller,
+ ToolbarModel* toolbar_model,
+ Profile* profile,
+ CommandUpdater* command_updater)
+ : model_(new AutocompleteEditModel(this, controller, profile)),
+ popup_view_(new AutocompletePopupViewMac(this, model_.get(), profile)),
+ controller_(controller),
+ toolbar_model_(toolbar_model),
+ command_updater_(command_updater),
+ field_(nil),
+ edit_helper_([[AutocompleteFieldDelegate alloc] initWithEditView:this]) {
+ DCHECK(controller);
+ DCHECK(toolbar_model);
+ DCHECK(profile);
+ DCHECK(command_updater);
+}
+
+AutocompleteEditViewMac::~AutocompleteEditViewMac() {
+ // TODO(shess): Having to be aware of destructor ordering in this
+ // way seems brittle. There must be a better way.
+
+ // Destroy popup view before this object in case it tries to call us
+ // back in the destructor. Likewise for destroying the model before
+ // this object.
+ popup_view_.reset();
+ model_.reset();
+
+ // Disconnect field_ from edit_helper_ so that we don't get calls
+ // after destruction.
+ [field_ setDelegate:nil];
+}
+
+// TODO(shess): This is the minimal change which seems to unblock
+// getting the minimal Omnibox code checked in without making the
+// world worse. Browser::TabSelectedAt() calls this when the tab
+// changes, but that is only wired up for Windows. I do not yet
+// understand that code well enough to go for it. Once wired up, then
+// code can be removed at:
+// [TabContentsController defocusLocationBar]
+// [TabStripController selectTabWithContents:...]
+void AutocompleteEditViewMac::SaveStateToTab(TabContents* tab) {
+ // TODO(shess): Actually save the state to the tab area.
+
+ // Drop the popup before we change to another tab.
+ ClosePopup();
+}
+
+void AutocompleteEditViewMac::OpenURL(const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const GURL& alternate_nav_url,
+ size_t selected_line,
+ const std::wstring& keyword) {
+ // TODO(shess): Why is the caller passing an invalid url in the
+ // first place? Make sure that case isn't being dropped on the
+ // floor.
+ if (!url.is_valid()) {
+ return;
+ }
+
+ model_->SendOpenNotification(selected_line, keyword);
+
+ if (disposition != NEW_BACKGROUND_TAB)
+ RevertAll(); // Revert the box to its unedited state.
+ controller_->OnAutocompleteAccept(url, disposition, transition,
+ alternate_nav_url);
+}
+
+std::wstring AutocompleteEditViewMac::GetText() const {
+ return base::SysNSStringToWide([field_ stringValue]);
+}
+
+void AutocompleteEditViewMac::SetWindowTextAndCaretPos(const std::wstring& text,
+ size_t caret_pos) {
+ UpdateAndStyleText(text, text.size());
+}
+
+void AutocompleteEditViewMac::SelectAll(bool reversed) {
+ // TODO(shess): Figure out what reversed implies. The gtk version
+ // has it imply inverting the selection front to back, but I don't
+ // even know if that makes sense for Mac.
+ UpdateAndStyleText(GetText(), 0);
+}
+
+void AutocompleteEditViewMac::RevertAll() {
+ ClosePopup();
+ model_->Revert();
+
+ std::wstring tt = GetText();
+ UpdateAndStyleText(tt, tt.size());
+ controller_->OnChanged();
+}
+
+void AutocompleteEditViewMac::UpdatePopup() {
+ model_->SetInputInProgress(true);
+ if (!model_->has_focus())
+ return;
+
+ // TODO(shess):
+ // Shouldn't inline autocomplete when the caret/selection isn't at
+ // the end of the text.
+ //
+ // One option would seem to be to check for a non-nil field
+ // editor, and check it's selected range against its length.
+ model_->StartAutocomplete(false);
+}
+
+void AutocompleteEditViewMac::ClosePopup() {
+ popup_view_->StopAutocomplete();
+}
+
+void AutocompleteEditViewMac::UpdateAndStyleText(
+ const std::wstring& display_text, size_t user_text_length) {
+ NSString* ss = base::SysWideToNSString(display_text);
+ NSMutableAttributedString* as =
+ [[[NSMutableAttributedString alloc] initWithString:ss] autorelease];
+
+ url_parse::Parsed parts;
+ AutocompleteInput::Parse(display_text, model_->GetDesiredTLD(),
+ &parts, NULL);
+ bool emphasize = model_->CurrentTextIsURL() && (parts.host.len > 0);
+ if (emphasize) {
+ // TODO(shess): Pull color out as a constant.
+ [as addAttribute:NSForegroundColorAttributeName
+ value:[NSColor greenColor]
+ range:NSMakeRange((NSInteger)parts.host.begin,
+ (NSInteger)parts.host.end())];
+ }
+
+ // TODO(shess): GTK has this as a member var, figure out why.
+ ToolbarModel::SecurityLevel scheme_security_level =
+ toolbar_model_->GetSchemeSecurityLevel();
+
+ // Emphasize the scheme for security UI display purposes (if necessary).
+ if (!model_->user_input_in_progress() && parts.scheme.is_nonempty() &&
+ (scheme_security_level != ToolbarModel::NORMAL)) {
+ // TODO(shess): Pull colors out as constants.
+ NSColor* color;
+ if (scheme_security_level == ToolbarModel::SECURE) {
+ color = [NSColor blueColor];
+ } else {
+ color = [NSColor blackColor];
+ }
+ [as addAttribute:NSForegroundColorAttributeName value:color
+ range:NSMakeRange((NSInteger)parts.scheme.begin,
+ (NSInteger)parts.scheme.end())];
+ }
+
+ // TODO(shess): Check that this updates the model's sense of focus
+ // correctly.
+ [field_ setObjectValue:as];
+ if (![field_ currentEditor]) {
+ [field_ becomeFirstResponder];
+ DCHECK_EQ(field_, [[field_ window] firstResponder]);
+ }
+
+ NSRange selected_range = NSMakeRange(user_text_length, [as length]);
+ // TODO(shess): What if it didn't get first responder, and there is
+ // no field editor? This will do nothing. Well, at least it won't
+ // crash. Think of something more productive to do, or prove that
+ // it cannot occur and DCHECK appropriately.
+ [[field_ currentEditor] setSelectedRange:selected_range];
+}
+
+void AutocompleteEditViewMac::OnTemporaryTextMaybeChanged(
+ const std::wstring& display_text, bool save_original_selection) {
+ // TODO(shess): I believe this is for when the user arrows around
+ // the popup, will be restored if they hit escape. Figure out if
+ // that is for certain it.
+ if (save_original_selection) {
+ saved_temporary_text_ = GetText();
+ }
+
+ UpdateAndStyleText(display_text, display_text.size());
+}
+
+bool AutocompleteEditViewMac::OnInlineAutocompleteTextMaybeChanged(
+ const std::wstring& display_text, size_t user_text_length) {
+ // TODO(shess): Make sure that this actually works. The round trip
+ // to native form and back may mean that it's the same but not the
+ // same.
+ if (display_text == GetText()) {
+ return false;
+ }
+
+ UpdateAndStyleText(display_text, user_text_length);
+ return true;
+}
+
+void AutocompleteEditViewMac::OnRevertTemporaryText() {
+ UpdateAndStyleText(saved_temporary_text_, saved_temporary_text_.size());
+ saved_temporary_text_.clear();
+}
+
+void AutocompleteEditViewMac::OnUpOrDownKeyPressed(int dir) {
+ model_->OnUpOrDownKeyPressed(dir);
+}
+void AutocompleteEditViewMac::OnEscapeKeyPressed() {
+ model_->OnEscapeKeyPressed();
+}
+void AutocompleteEditViewMac::OnSetFocus(bool f) {
+ model_->OnSetFocus(f);
+}
+void AutocompleteEditViewMac::OnKillFocus() {
+ model_->OnKillFocus();
+}
+void AutocompleteEditViewMac::AcceptInput(
+ WindowOpenDisposition disposition, bool for_drop) {
+ model_->AcceptInput(disposition, for_drop);
+}
+void AutocompleteEditViewMac::OnAfterPossibleChange(
+ const std::wstring& new_text,
+ bool selection_differs,
+ bool text_differs,
+ bool just_deleted_text,
+ bool at_end_of_edit) {
+ model_->OnAfterPossibleChange(new_text, selection_differs, text_differs,
+ just_deleted_text, at_end_of_edit);
+}
+void AutocompleteEditViewMac::SetField(NSTextField* field) {
+ field_ = field;
+ [field_ setDelegate:edit_helper_];
+
+ // The popup code needs the field for sizing and placement.
+ popup_view_->SetField(field_);
+}
+
+void AutocompleteEditViewMac::FocusLocation() {
+ [[field_ window] makeFirstResponder:field_];
+}
+
+@implementation AutocompleteFieldDelegate
+
+- initWithEditView:(AutocompleteEditViewMac*)view {
+ self = [super init];
+ if (self) {
+ edit_view_ = view;
+ }
+ return self;
+}
+
+- (BOOL)control:(NSControl*)control
+ textView:(NSTextView*)textView doCommandBySelector:(SEL)cmd {
+ if (cmd == @selector(moveDown:)) {
+ edit_view_->OnUpOrDownKeyPressed(1);
+ return YES;
+ }
+
+ if (cmd == @selector(moveUp:)) {
+ edit_view_->OnUpOrDownKeyPressed(-1);
+ return YES;
+ }
+
+ if (cmd == @selector(cancelOperation:)) {
+ edit_view_->OnEscapeKeyPressed();
+ return YES;
+ }
+
+ if (cmd == @selector(insertNewline:)) {
+ edit_view_->AcceptInput(CURRENT_TAB, false);
+ return YES;
+ }
+
+ return NO;
+}
+
+- (void)controlTextDidBeginEditing:(NSNotification*)aNotification {
+ edit_view_->OnSetFocus(false);
+}
+
+- (void)controlTextDidChange:(NSNotification*)aNotification {
+ // TODO(shess): Make this more efficient? Or not. For now, just
+ // pass in the current text, indicating that the text and
+ // selection differ, ignoring deletions, and assuming that we're
+ // at the end of the text.
+ edit_view_->OnAfterPossibleChange(edit_view_->GetText(),
+ true, true, false, true);
+}
+
+- (void)controlTextDidEndEditing:(NSNotification*)aNotification {
+ edit_view_->OnKillFocus();
+
+ // TODO(shess): Figure out where the selection belongs. On GTK,
+ // it's set to the start of the text.
+}
+
+@end
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.h b/chrome/browser/autocomplete/autocomplete_popup_view_mac.h
new file mode 100644
index 0000000..958350c
--- /dev/null
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.h
@@ -0,0 +1,97 @@
+// 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_POPUP_VIEW_MAC_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_
+
+#import <Cocoa/Cocoa.h>
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
+#include "base/scoped_nsobject.h"
+#include "chrome/browser/autocomplete/autocomplete.h"
+#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
+#include "webkit/glue/window_open_disposition.h"
+
+class AutocompletePopupModel;
+class AutocompleteEditModel;
+class AutocompleteEditViewMac;
+@class AutocompleteTableTarget;
+class Profile;
+
+// Implements AutocompletePopupView using a raw NSWindow containing an
+// NSTableView.
+
+class AutocompletePopupViewMac : public AutocompletePopupView {
+ public:
+ AutocompletePopupViewMac(AutocompleteEditViewMac* edit_view,
+ AutocompleteEditModel* edit_model,
+ Profile* profile);
+ virtual ~AutocompletePopupViewMac();
+
+ // Implement the AutocompletePopupView interface.
+ virtual bool IsOpen() const;
+ virtual void InvalidateLine(size_t line) {
+ // TODO(shess): Verify that there is no need to implement this.
+ // This is currently used in two places in the model:
+ //
+ // When setting the selected line, the selected line is
+ // invalidated, then the selected line is changed, then the new
+ // selected line is invalidated, then PaintUpdatesNow() is called.
+ // For us PaintUpdatesNow() should be sufficient.
+ //
+ // Same thing happens when changing the hovered line, except with
+ // no call to PaintUpdatesNow(). Since this code does not
+ // currently support special display of the hovered line, there's
+ // nothing to do here.
+ //
+ // deanm indicates that this is an anti-flicker optimization,
+ // which we probably cannot utilize (and may not need) so long as
+ // we're using NSTableView to implement the popup contents. We
+ // may need to move away from NSTableView to implement hover,
+ // though.
+ }
+ virtual void UpdatePopupAppearance();
+ virtual void OnHoverEnabledOrDisabled(bool disabled) { NOTIMPLEMENTED(); }
+
+ // This is only called by model in SetSelectedLine() after updating
+ // everything. Popup should already be visible.
+ virtual void PaintUpdatesNow();
+
+ // Helpers which forward to model_, otherwise our Objective-C helper
+ // object would need model_ to be public:.
+ void StopAutocomplete();
+ size_t ResultRowCount();
+ const std::wstring& ResultContentsAt(size_t i);
+ bool ResultStarredAt(size_t i);
+ const std::wstring& ResultDescriptionAt(size_t i);
+ void AcceptInput(WindowOpenDisposition disposition, bool for_drop);
+
+ // 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) {
+ field_ = field;
+ }
+
+ private:
+ // Create the popup_ instance if needed.
+ void CreatePopupIfNeeded();
+
+ scoped_ptr<AutocompletePopupModel> model_;
+ AutocompleteEditViewMac* edit_view_;
+
+ NSTextField* field_; // owned by tab controller
+
+ scoped_nsobject<AutocompleteTableTarget> table_target_;
+ // TODO(shess): Before checkin review implementation to make sure
+ // that popup_'s object hierarchy doesn't keep references to
+ // destructed objects.
+ scoped_nsobject<NSWindow> popup_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutocompletePopupViewMac);
+};
+
+#endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
new file mode 100644
index 0000000..ba4c95e
--- /dev/null
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -0,0 +1,250 @@
+// 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.
+
+#include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
+
+#include "base/sys_string_conversions.h"
+#include "chrome/browser/autocomplete/autocomplete_edit.h"
+#include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
+#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
+
+// Thin Obj-C bridge class between the target and data source of the
+// popup window's NSTableView and the AutocompletePopupView
+// implementation.
+
+@interface AutocompleteTableTarget : NSObject {
+ @private
+ AutocompletePopupViewMac* popup_view_; // weak, owns us.
+}
+- initWithPopupView:(AutocompletePopupViewMac*)view;
+
+// Tell popup model via popup_view_ about the selected row.
+- (void)select:sender;
+
+// NSTableDataSource methods, filled from data returned by
+// the popup model via popup_view_.
+- (NSInteger)numberOfRowsInTableView:(NSTableView*)aTableView;
+- (id)tableView:(NSTableView*)aTableView
+objectValueForTableColumn:(NSTableColumn*)aTableColumn
+ row:(int)ri;
+
+// Placeholder for finding the star image.
+- (NSImage*)starImage;
+@end
+
+AutocompletePopupViewMac::AutocompletePopupViewMac(
+ AutocompleteEditViewMac* edit_view,
+ AutocompleteEditModel* edit_model,
+ Profile* profile)
+ : model_(new AutocompletePopupModel(this, edit_model, profile)),
+ edit_view_(edit_view),
+ field_(nil),
+ table_target_([[AutocompleteTableTarget alloc] initWithPopupView:this]),
+ popup_(nil) {
+ DCHECK(edit_view);
+ DCHECK(edit_model);
+ DCHECK(profile);
+ edit_model->set_popup_model(model_.get());
+}
+
+AutocompletePopupViewMac::~AutocompletePopupViewMac() {
+ // TODO(shess): Having to be aware of destructor ordering in this
+ // way seems brittle. There must be a better way.
+
+ // Destroy the popup model before this object is destroyed, because
+ // it can call back to us in the destructor.
+ model_.reset();
+
+ // Break references to table_target_ before it is released.
+ NSTableView* table = [popup_ contentView];
+ [table setTarget:nil];
+ [table setDataSource:nil];
+}
+
+bool AutocompletePopupViewMac::IsOpen() const {
+ return [popup_ isVisible] ? true : false;
+}
+
+static NSTableColumn* MakeTableColumn(int tag, Class field_class) {
+ NSNumber* id = [NSNumber numberWithInt:tag];
+ NSTableColumn* col =
+ [[[NSTableColumn alloc] initWithIdentifier:id] autorelease];
+
+ [col setEditable:NO];
+ [col setResizingMask:NSTableColumnNoResizing];
+ [col setDataCell:[[[field_class alloc] init] autorelease]];
+
+ return col;
+}
+
+void AutocompletePopupViewMac::CreatePopupIfNeeded() {
+ if (!popup_) {
+ popup_.reset([[NSWindow alloc] initWithContentRect:NSZeroRect
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:YES]);
+ [popup_ setMovableByWindowBackground:NO];
+ [popup_ setOpaque:YES];
+ [popup_ setHasShadow:YES];
+ [popup_ setLevel:NSNormalWindowLevel];
+
+ NSTableView* table =
+ [[[NSTableView alloc] initWithFrame:NSZeroRect] autorelease];
+ [popup_ setContentView:table];
+
+ [table setTarget:table_target_];
+ [table setAction:@selector(select:)];
+ [table setHeaderView:nil];
+ [table setDataSource:table_target_];
+ [table setIntercellSpacing:NSMakeSize(1.0, 0.0)];
+
+ [table addTableColumn:MakeTableColumn(0, [NSTextFieldCell class])];
+ [table addTableColumn:MakeTableColumn(1, [NSImageCell class])];
+ [table addTableColumn:MakeTableColumn(2, [NSTextFieldCell class])];
+ }
+}
+
+void AutocompletePopupViewMac::UpdatePopupAppearance() {
+ const AutocompleteResult& result = model_->result();
+ if (result.empty()) {
+ [[popup_ parentWindow] removeChildWindow:popup_];
+ [popup_ orderOut:nil];
+ return;
+ }
+
+ CreatePopupIfNeeded();
+
+ // Layout the popup and size it to land underneath the field.
+ // TODO(shess) Consider refactoring to remove this depenency,
+ // because the popup doesn't need any of the field-like aspects of
+ // field_. The edit view could expose helper methods for attaching
+ // the window to the field.
+ NSRect r = [field_ bounds];
+ r = [field_ convertRectToBase:r];
+ r.origin = [[field_ window] convertBaseToScreen:r.origin];
+
+ // TODO(shess): Derive this from the actual image size, once the
+ // image is in the project.
+ static const int kStarWidth = 25;
+
+ NSArray* cols = [[popup_ contentView] tableColumns];
+ [[cols objectAtIndex:0] setWidth:floor((r.size.width - kStarWidth) / 2)];
+ [[cols objectAtIndex:1] setWidth:kStarWidth];
+ [[cols objectAtIndex:2] setWidth:ceil((r.size.width - kStarWidth) / 2)];
+
+ [[popup_ contentView] reloadData];
+ [[popup_ contentView] tile];
+ r.size.height = [[popup_ contentView] frame].size.height;
+ r.origin.y -= r.size.height + 2;
+
+ // Update the selection.
+ PaintUpdatesNow();
+
+ [popup_ setFrame:r display:YES];
+
+ if (!IsOpen()) {
+ [[field_ window] addChildWindow:popup_ ordered:NSWindowAbove];
+ }
+}
+
+// This is only called by model in SetSelectedLine() after updating
+// everything. Popup should already be visible.
+void AutocompletePopupViewMac::PaintUpdatesNow() {
+ NSIndexSet* set = [NSIndexSet indexSetWithIndex:model_->selected_line()];
+ NSTableView* table = [popup_ contentView];
+ [table selectRowIndexes:set byExtendingSelection:NO];
+}
+
+void AutocompletePopupViewMac::StopAutocomplete() {
+ model_->StopAutocomplete();
+}
+
+size_t AutocompletePopupViewMac::ResultRowCount() {
+ return model_->result().size();
+}
+
+const std::wstring& AutocompletePopupViewMac::ResultContentsAt(size_t i) {
+ return model_->result().match_at(i).contents;
+}
+
+bool AutocompletePopupViewMac::ResultStarredAt(size_t i) {
+ return model_->result().match_at(i).starred;
+}
+
+const std::wstring& AutocompletePopupViewMac::ResultDescriptionAt(size_t i) {
+ return model_->result().match_at(i).description;
+}
+
+void AutocompletePopupViewMac::AcceptInput(
+ WindowOpenDisposition disposition, bool for_drop) {
+ edit_view_->AcceptInput(disposition, for_drop);
+}
+
+@implementation AutocompleteTableTarget
+
+- initWithPopupView:(AutocompletePopupViewMac*)view {
+ self = [super init];
+ if (self) {
+ popup_view_ = view;
+ }
+ return self;
+}
+
+- (NSImage*)starImage {
+ // TODO(shess): Figure out a way to share this image with the
+ // toolbar controller.
+ return [NSImage imageNamed:@"starred"];
+}
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView*)aTableView {
+ DCHECK(popup_view_);
+ return static_cast<NSInteger>(popup_view_->ResultRowCount());
+}
+
+- (id)tableView:(NSTableView*)aTableView
+objectValueForTableColumn:(NSTableColumn*)aTableColumn
+ row:(int)ri {
+ int columnIndex = [[aTableColumn identifier] integerValue];
+ size_t rowIndex = static_cast<size_t>(ri);
+ DCHECK(popup_view_);
+ DCHECK_LT(rowIndex, popup_view_->ResultRowCount());
+ DCHECK_LT(columnIndex, 3);
+
+ if (columnIndex == 1) {
+ if (popup_view_->ResultStarredAt(rowIndex)) {
+ return [self starImage];
+ }
+ return nil;
+ }
+
+ NSString* s;
+ if (columnIndex == 0) {
+ s = base::SysWideToNSString(popup_view_->ResultContentsAt(rowIndex));
+ } else {
+ s = base::SysWideToNSString(popup_view_->ResultDescriptionAt(rowIndex));
+ }
+
+ NSMutableParagraphStyle* style =
+ [[[NSMutableParagraphStyle alloc] init] autorelease];
+ [style setLineBreakMode:NSLineBreakByTruncatingTail];
+
+ NSMutableAttributedString* as =
+ [[[NSMutableAttributedString alloc] initWithString:s] autorelease];
+ [as addAttribute:NSParagraphStyleAttributeName value:style
+ range:NSMakeRange(0, [s length])];
+
+ // TODO(shess): There is a ton more styling to be done, here, for
+ // instance URLs different from search suggestions different from secure
+ // URLs, etc. [See AutocompletePopupViewMac::UpdateAndStyleText().]
+ // Deferring in the interests of getting a minimal implementation in.
+
+ return as;
+}
+
+- (void)select:sender {
+ DCHECK(popup_view_);
+ popup_view_->AcceptInput(CURRENT_TAB, false);
+}
+
+@end
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index 2e32afc..1a0ef8d 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -7,14 +7,24 @@
#import <Cocoa/Cocoa.h>
+#include "base/scoped_ptr.h"
+#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/location_bar.h"
-// A C++ bridge class that handles responding to requests from the
-// cross-platform code for information about the location bar.
+class AutocompleteEditViewMac;
+class CommandUpdater;
+class ToolbarModel;
-class LocationBarViewMac : public LocationBar {
+// A C++ bridge class that represents the location bar UI element to
+// the portable code. Wires up an AutocompleteEditViewMac instance to
+// the location bar text field, which handles most of the work.
+
+class LocationBarViewMac : public AutocompleteEditController,
+ public LocationBar {
public:
- LocationBarViewMac(NSTextField* field);
+ LocationBarViewMac(NSTextField* field,
+ CommandUpdater* command_updater,
+ ToolbarModel* toolbar_model);
virtual ~LocationBarViewMac();
// TODO(shess): This is a placeholder for the Omnibox code. The
@@ -27,24 +37,44 @@ class LocationBarViewMac : public LocationBar {
// Overridden from LocationBar
virtual void ShowFirstRunBubble() { NOTIMPLEMENTED(); }
virtual std::wstring GetInputString() const;
- virtual WindowOpenDisposition GetWindowOpenDisposition() const
- { NOTIMPLEMENTED(); return CURRENT_TAB; }
- // TODO(rohitrao): Fix this to return different types once autocomplete and
- // the onmibar are implemented. For now, any URL that comes from the
- // LocationBar has to have been entered by the user, and thus is of type
- // PageTransition::TYPED.
- virtual PageTransition::Type GetPageTransition() const
- { NOTIMPLEMENTED(); return PageTransition::TYPED; }
+ virtual WindowOpenDisposition GetWindowOpenDisposition() const;
+ virtual PageTransition::Type GetPageTransition() const;
virtual void AcceptInput() { NOTIMPLEMENTED(); }
virtual void AcceptInputWithDisposition(WindowOpenDisposition disposition)
{ NOTIMPLEMENTED(); }
virtual void FocusLocation();
virtual void FocusSearch() { NOTIMPLEMENTED(); }
virtual void UpdateFeedIcon() { /* http://crbug.com/8832 */ }
- virtual void SaveStateToContents(TabContents* contents) { NOTIMPLEMENTED(); }
+ virtual void SaveStateToContents(TabContents* contents);
+
+ virtual void OnAutocompleteAccept(const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const GURL& alternate_nav_url);
+ virtual void OnChanged();
+ virtual void OnInputInProgress(bool in_progress);
+ virtual SkBitmap GetFavIcon() const;
+ virtual std::wstring GetTitle() const;
private:
+ scoped_ptr<AutocompleteEditViewMac> edit_view_;
+
NSTextField* field_; // weak, owned by TabContentsController
+ // TODO(shess): Determine ownership of these. We definitely
+ // shouldn't.
+ CommandUpdater* command_updater_; // weak
+ ToolbarModel* toolbar_model_; // weak
+
+ // When we get an OnAutocompleteAccept notification from the autocomplete
+ // edit, we save the input string so we can give it back to the browser on
+ // the LocationBar interface via GetInputString().
+ std::wstring location_input_;
+
+ // The user's desired disposition for how their input should be opened
+ WindowOpenDisposition disposition_;
+
+ // The transition type to use for the navigation
+ PageTransition::Type transition_;
DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac);
};
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index ed660b9..3fe1071 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -4,12 +4,25 @@
#import "chrome/browser/cocoa/location_bar_view_mac.h"
-#include "base/sys_string_conversions.h"
-#include "chrome/browser/net/url_fixer_upper.h"
+#include "base/string_util.h"
+#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/alternate_nav_url_fetcher.h"
+#import "chrome/browser/app_controller_mac.h"
+#import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
+#include "chrome/browser/command_updater.h"
+#include "skia/include/SkBitmap.h"
-LocationBarViewMac::LocationBarViewMac(NSTextField* field)
- : field_(field) {
- // TODO(shess): Placeholder for omnibox changes.
+// TODO(shess): This code is mostly copied from the gtk
+// implementation. Make sure it's all appropriate and flesh it out.
+
+LocationBarViewMac::LocationBarViewMac(NSTextField* field,
+ CommandUpdater* command_updater,
+ ToolbarModel* toolbar_model)
+ : field_(field),
+ command_updater_(command_updater),
+ toolbar_model_(toolbar_model),
+ disposition_(CURRENT_TAB),
+ transition_(PageTransition::TYPED) {
}
LocationBarViewMac::~LocationBarViewMac() {
@@ -17,18 +30,93 @@ LocationBarViewMac::~LocationBarViewMac() {
}
void LocationBarViewMac::Init() {
- // TODO(shess): Placeholder for omnibox changes.
+ // TODO(shess): deanm indicates that it's likely we will eventually
+ // get the profile somewhere between point of construction and
+ // Init(), so mirroring how the gtk code sets this up.
+ Profile* profile = [[NSApp delegate] defaultProfile];
+ edit_view_.reset(new AutocompleteEditViewMac(this,
+ toolbar_model_,
+ profile,
+ command_updater_));
+ // TODO(shess): Include in constructor.
+ edit_view_->SetField(field_);
}
std::wstring LocationBarViewMac::GetInputString() const {
- // TODO(shess): This code is temporary until the omnibox code takes
- // over.
- std::wstring url = base::SysNSStringToWide([field_ stringValue]);
+ return location_input_;
+}
+
+WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const {
+ return disposition_;
+}
- // Try to flesh out the input to make a real URL.
- return URLFixerUpper::FixupURL(url, std::wstring());
+// TODO(shess): Verify that this TODO is TODONE.
+// TODO(rohitrao): Fix this to return different types once autocomplete and
+// the onmibar are implemented. For now, any URL that comes from the
+// LocationBar has to have been entered by the user, and thus is of type
+// PageTransition::TYPED.
+PageTransition::Type LocationBarViewMac::GetPageTransition() const {
+ return transition_;
}
void LocationBarViewMac::FocusLocation() {
- [[field_ window] makeFirstResponder:field_];
+ edit_view_->FocusLocation();
+}
+
+void LocationBarViewMac::SaveStateToContents(TabContents* contents) {
+ // TODO(shess): Why SaveStateToContents vs SaveStateToTab?
+ edit_view_->SaveStateToTab(contents);
+}
+
+void LocationBarViewMac::OnAutocompleteAccept(const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const GURL& alternate_nav_url) {
+ if (!url.is_valid())
+ return;
+
+ location_input_ = UTF8ToWide(url.spec());
+ disposition_ = disposition;
+ transition_ = transition;
+
+ if (!command_updater_)
+ return;
+
+ if (!alternate_nav_url.is_valid()) {
+ command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
+ return;
+ }
+
+ scoped_ptr<AlternateNavURLFetcher> fetcher(
+ new AlternateNavURLFetcher(alternate_nav_url));
+ // The AlternateNavURLFetcher will listen for the pending navigation
+ // notification that will be issued as a result of the "open URL." It
+ // will automatically install itself into that navigation controller.
+ command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
+ if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) {
+ // I'm not sure this should be reachable, but I'm not also sure enough
+ // that it shouldn't to stick in a NOTREACHED(). In any case, this is
+ // harmless; we can simply let the fetcher get deleted here and it will
+ // clean itself up properly.
+ } else {
+ fetcher.release(); // The navigation controller will delete the fetcher.
+ }
+}
+
+void LocationBarViewMac::OnChanged() {
+ NOTIMPLEMENTED();
+}
+
+void LocationBarViewMac::OnInputInProgress(bool in_progress) {
+ NOTIMPLEMENTED();
+}
+
+SkBitmap LocationBarViewMac::GetFavIcon() const {
+ NOTIMPLEMENTED();
+ return SkBitmap();
+}
+
+std::wstring LocationBarViewMac::GetTitle() const {
+ NOTIMPLEMENTED();
+ return std::wstring();
}
diff --git a/chrome/browser/cocoa/location_bar_view_mac_unittest.mm b/chrome/browser/cocoa/location_bar_view_mac_unittest.mm
index f84b15b1..2f205f2 100644
--- a/chrome/browser/cocoa/location_bar_view_mac_unittest.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac_unittest.mm
@@ -8,11 +8,18 @@
#include "chrome/browser/cocoa/location_bar_view_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
+// TODO(shess): Figure out how to unittest this. The code below was
+// testing the hacked-up behavior so you didn't have to be pedantic
+// WRT http://. But that approach is completely and utterly wrong in
+// a world where omnibox is running.
+// http://code.google.com/p/chromium/issues/detail?id=9977
+
+#if 0
class LocationBarViewMacTest : public testing::Test {
public:
LocationBarViewMacTest()
: field_([[NSTextField alloc] init]),
- locationBarView_(new LocationBarViewMac(field_)) {
+ locationBarView_(new LocationBarViewMac(field_, NULL, NULL)) {
}
scoped_nsobject<NSTextField> field_;
@@ -32,11 +39,15 @@ TEST_F(LocationBarViewMacTest, GetInputString) {
EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://chost/"));
[field_ setStringValue:@"www.example.com"];
- EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://www.example.com/"));
+ EXPECT_EQ(locationBarView_->GetInputString(),
+ ASCIIToWide("http://www.example.com/"));
[field_ setStringValue:@"http://example.com"];
- EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://example.com/"));
+ EXPECT_EQ(locationBarView_->GetInputString(),
+ ASCIIToWide("http://example.com/"));
[field_ setStringValue:@"https://www.example.com"];
- EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("https://www.example.com/"));
+ EXPECT_EQ(locationBarView_->GetInputString(),
+ ASCIIToWide("https://www.example.com/"));
}
+#endif
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index e77c30c..01a9c21 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -42,7 +42,8 @@ static NSString* const kStarredImageName = @"starred";
// bar and button state.
- (void)awakeFromNib {
[self initCommandStatus:commands_];
- locationBarView_ = new LocationBarViewMac(locationBar_);
+ locationBarView_ = new LocationBarViewMac(locationBar_, commands_,
+ toolbarModel_);
locationBarView_->Init();
[locationBar_ setStringValue:@"http://dev.chromium.org"];
}
@@ -100,8 +101,21 @@ static NSString* const kStarredImageName = @"starred";
// TODO(pinkerton): there's a lot of ui code in autocomplete_edit.cc
// that we'll want to duplicate. For now, just handle setting the text.
+ // TODO(shess): This is the start of what pinkerton refers to.
+ // Unfortunately, I'm going to need to spend some time wiring things
+ // up. This call should suffice to close any open autocomplete
+ // pulldown. It should also be the right thing to do to save and
+ // restore state, but at this time it's not clear that this is the
+ // right place, and tab is not the right parameter.
+ if (locationBarView_) {
+ locationBarView_->SaveStateToContents(NULL);
+ }
+
// TODO(pinkerton): update the security lock icon and background color
+ // TODO(shess): Determine whether this should happen via
+ // locationBarView_, instead, in which case this class can
+ // potentially lose the locationBar_ reference.
NSString* urlString = base::SysWideToNSString(toolbarModel_->GetText());
[locationBar_ setStringValue:urlString];
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index cc402c5..eb5d36a 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -394,6 +394,8 @@
'browser/autocomplete/autocomplete_edit_view.h',
'browser/autocomplete/autocomplete_edit_view_gtk.cc',
'browser/autocomplete/autocomplete_edit_view_gtk.h',
+ 'browser/autocomplete/autocomplete_edit_view_mac.h',
+ 'browser/autocomplete/autocomplete_edit_view_mac.mm',
'browser/autocomplete/autocomplete_edit_view_win.cc',
'browser/autocomplete/autocomplete_edit_view_win.h',
'browser/autocomplete/autocomplete_popup_model.cc',
@@ -401,6 +403,8 @@
'browser/autocomplete/autocomplete_popup_view.h',
'browser/autocomplete/autocomplete_popup_view_gtk.cc',
'browser/autocomplete/autocomplete_popup_view_gtk.h',
+ 'browser/autocomplete/autocomplete_popup_view_mac.h',
+ 'browser/autocomplete/autocomplete_popup_view_mac.mm',
'browser/autocomplete/autocomplete_popup_view_win.cc',
'browser/autocomplete/autocomplete_popup_view_win.h',
'browser/autocomplete/history_contents_provider.cc',
@@ -1307,8 +1311,6 @@
['include', '^browser/download/save_(file(_manager)?|item|package)\\.cc$'],
],
'sources!': [
- 'browser/autocomplete/autocomplete_edit.cc',
- 'browser/autocomplete/autocomplete_popup_model.cc',
'browser/automation/automation_provider_list_generic.cc',
'browser/bookmarks/bookmark_context_menu.cc',
'browser/bookmarks/bookmark_drop_info.cc',