summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/nibs/en.lproj/Toolbar.xib30
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h7
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm13
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field.h19
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field.mm20
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.h (renamed from chrome/browser/cocoa/location_bar_cell.h)5
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm (renamed from chrome/browser/cocoa/location_bar_cell.mm)6
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm (renamed from chrome/browser/cocoa/location_bar_cell_unittest.mm)20
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_editor.h17
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_editor.mm33
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm (renamed from chrome/browser/cocoa/location_bar_fieldeditor_unittest.mm)10
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_unittest.mm46
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h3
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm2
-rw-r--r--chrome/browser/cocoa/toolbar_controller.h15
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm37
-rw-r--r--chrome/chrome.gyp13
17 files changed, 215 insertions, 81 deletions
diff --git a/chrome/app/nibs/en.lproj/Toolbar.xib b/chrome/app/nibs/en.lproj/Toolbar.xib
index 0eeeffd..49d293d 100644
--- a/chrome/app/nibs/en.lproj/Toolbar.xib
+++ b/chrome/app/nibs/en.lproj/Toolbar.xib
@@ -9,7 +9,7 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="48"/>
- <integer value="1"/>
+ <integer value="4"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1545,6 +1545,7 @@
<string>38.IBPluginDependency</string>
<string>39.CustomClassName</string>
<string>39.IBPluginDependency</string>
+ <string>4.CustomClassName</string>
<string>4.IBPluginDependency</string>
<string>42.IBEditorWindowLastContentRect</string>
<string>42.IBPluginDependency</string>
@@ -1612,7 +1613,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ToolbarButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>LocationBarCell</string>
+ <string>AutocompleteTextFieldCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ToolbarButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1629,6 +1630,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ToolbarButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>AutocompleteTextField</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{361, 757}, {274, 273}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1739,6 +1741,22 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">AutocompleteTextField</string>
+ <string key="superclassName">NSTextField</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/autocomplete_text_field.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">AutocompleteTextFieldCell</string>
+ <string key="superclassName">NSTextFieldCell</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/autocomplete_text_field_cell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">BackgroundGradientView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -1767,14 +1785,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">LocationBarCell</string>
- <string key="superclassName">NSTextFieldCell</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/cocoa/location_bar_cell.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
index 9b22412..7c70b4c 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
@@ -20,12 +20,13 @@ class AutocompleteEditController;
@class AutocompleteEditHelper;
class AutocompleteEditModel;
class AutocompletePopupViewMac;
+@class AutocompleteTextField;
class CommandUpdater;
class Profile;
class TabContents;
class ToolbarModel;
-// Implements AutocompleteEditView on an NSTextField.
+// Implements AutocompleteEditView on an AutocompleteTextField.
class AutocompleteEditViewMac : public AutocompleteEditView {
public:
@@ -33,7 +34,7 @@ class AutocompleteEditViewMac : public AutocompleteEditView {
ToolbarModel* toolbar_model,
Profile* profile,
CommandUpdater* command_updater,
- NSTextField* field);
+ AutocompleteTextField* field);
virtual ~AutocompleteEditViewMac();
// Implement the AutocompleteEditView interface.
@@ -140,7 +141,7 @@ class AutocompleteEditViewMac : public AutocompleteEditView {
// edit, such as invoking the keyword editor.
CommandUpdater* command_updater_;
- NSTextField* field_; // owned by tab controller
+ AutocompleteTextField* field_; // owned by tab controller
// Objective-C object to bridge field_ delegate calls to C++.
scoped_nsobject<AutocompleteEditHelper> edit_helper_;
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index 2c541c8..98271c1 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -8,6 +8,7 @@
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
+#include "chrome/browser/cocoa/autocomplete_text_field.h"
#include "chrome/browser/tab_contents/tab_contents.h"
// Focus-handling between |field_| and |model_| is a bit subtle.
@@ -125,12 +126,16 @@ NSRange ComponentToNSRange(const url_parse::Component& component) {
- (void)windowDidResignKey:(NSNotification*)notification;
@end
+// TODO(shess): AutocompletePopupViewMac doesn't really need an
+// NSTextField. It wants to know where the position the popup, what
+// font to use, and it also needs to be able to attach the popup to
+// the window |field_| is in.
AutocompleteEditViewMac::AutocompleteEditViewMac(
AutocompleteEditController* controller,
ToolbarModel* toolbar_model,
Profile* profile,
CommandUpdater* command_updater,
- NSTextField* field)
+ AutocompleteTextField* field)
: model_(new AutocompleteEditModel(this, controller, profile)),
popup_view_(new AutocompletePopupViewMac(this, model_.get(), profile,
field)),
@@ -522,9 +527,9 @@ void AutocompleteEditViewMac::OnWillBeginEditing() {
// We should only arrive here when the field is focussed.
DCHECK([field_ currentEditor]);
- // TODO(shess): Having the control key depressed changes the desired
- // TLD for autocomplete, which changes the results. Not sure if we
- // can detect that without subclassing NSTextField.
+ // TODO(shess): Detect control-key situation. Since this code is
+ // called on first edit, not on receipt of focus, it may be that we
+ // cannot correctly handle this without refactoring.
const bool controlDown = false;
model_->OnSetFocus(controlDown);
diff --git a/chrome/browser/cocoa/autocomplete_text_field.h b/chrome/browser/cocoa/autocomplete_text_field.h
new file mode 100644
index 0000000..709bd17
--- /dev/null
+++ b/chrome/browser/cocoa/autocomplete_text_field.h
@@ -0,0 +1,19 @@
+// 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_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
+#define CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
+
+#import <Cocoa/Cocoa.h>
+
+// TODO(shess): This class will add decorations to support keyword
+// search and hints. Adding as a stub so that I can clean up naming
+// around this code all at once before layering other changes over in
+// parallel.
+
+@interface AutocompleteTextField : NSTextField {
+}
+@end
+
+#endif // CHROME_BROWSER_COCOA_AUTOCOMPLETE_TEXT_FIELD_H_
diff --git a/chrome/browser/cocoa/autocomplete_text_field.mm b/chrome/browser/cocoa/autocomplete_text_field.mm
new file mode 100644
index 0000000..0efb310a
--- /dev/null
+++ b/chrome/browser/cocoa/autocomplete_text_field.mm
@@ -0,0 +1,20 @@
+// 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/cocoa/autocomplete_text_field.h"
+
+#include "base/logging.h"
+#include "chrome/browser/cocoa/autocomplete_text_field_cell.h"
+
+@implementation AutocompleteTextField
+
++ (Class)cellClass {
+ return [AutocompleteTextFieldCell class];
+}
+
+- (void)awakeFromNib {
+ DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]);
+}
+
+@end
diff --git a/chrome/browser/cocoa/location_bar_cell.h b/chrome/browser/cocoa/autocomplete_text_field_cell.h
index 0bfb1dd..983e370 100644
--- a/chrome/browser/cocoa/location_bar_cell.h
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.h
@@ -4,9 +4,8 @@
#import <Cocoa/Cocoa.h>
-// A cell that draws the location bar, for now all it does is shift
-// the text down so it is vertically centered.
+// A cell that draws the autocomplete field.
-@interface LocationBarCell : NSTextFieldCell {
+@interface AutocompleteTextFieldCell : NSTextFieldCell {
}
@end
diff --git a/chrome/browser/cocoa/location_bar_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index e033d61..23396af 100644
--- a/chrome/browser/cocoa/location_bar_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "chrome/browser/cocoa/location_bar_cell.h"
+#import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
#import "third_party/GTM/AppKit/GTMTheme.h"
const NSInteger kBaselineOffset = 2;
-@implementation LocationBarCell
+@implementation AutocompleteTextFieldCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.25] set];
@@ -28,7 +28,7 @@ const NSInteger kBaselineOffset = 2;
[stroke set];
NSFrameRectWithWidthUsingOperation(frame, 1.0, NSCompositeSourceOver);
- // Draw the location bar shadow.
+ // Draw the shadow.
[[NSColor colorWithCalibratedWhite:0.0 alpha:0.05] setFill];
NSRectFillUsingOperation(shadowFrame, NSCompositeSourceOver);
diff --git a/chrome/browser/cocoa/location_bar_cell_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
index 1dd8e47..173f1ab 100644
--- a/chrome/browser/cocoa/location_bar_cell_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
@@ -5,19 +5,25 @@
#import <Cocoa/Cocoa.h>
#include "base/scoped_nsobject.h"
-#import "chrome/browser/cocoa/location_bar_cell.h"
+#import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-class LocationBarCellTest : public testing::Test {
+// TODO(shess): Make a sensible distinction between
+// AutocompleteTextField unittesting and AutocompleteTextFieldCell
+// unittesting - or, since AutocompleteTextFieldCell doesn't really
+// have independent existence, just put tests for both in
+// autocomplete_text_field_unittest.mm.
+
+class AutocompleteTextFieldCellTest : public testing::Test {
public:
- LocationBarCellTest() {
+ AutocompleteTextFieldCellTest() {
NSRect frame = NSMakeRect(0, 0, 50, 30);
view_.reset([[NSTextField alloc] initWithFrame:frame]);
- scoped_nsobject<LocationBarCell> cell(
- [[LocationBarCell alloc] initTextCell:@"Testing"]);
+ scoped_nsobject<AutocompleteTextFieldCell> cell(
+ [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]);
[view_ setCell:cell.get()];
[cocoa_helper_.contentView() addSubview:view_.get()];
}
@@ -28,14 +34,14 @@ class LocationBarCellTest : public testing::Test {
// Test adding/removing from the view hierarchy, mostly to ensure nothing
// leaks or crashes.
-TEST_F(LocationBarCellTest, AddRemove) {
+TEST_F(AutocompleteTextFieldCellTest, AddRemove) {
EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]);
[view_.get() removeFromSuperview];
EXPECT_FALSE([view_ superview]);
}
// Test drawing, mostly to ensure nothing leaks or crashes.
-TEST_F(LocationBarCellTest, Display) {
+TEST_F(AutocompleteTextFieldCellTest, Display) {
[view_ display];
}
diff --git a/chrome/browser/cocoa/autocomplete_text_field_editor.h b/chrome/browser/cocoa/autocomplete_text_field_editor.h
new file mode 100644
index 0000000..1d4d073
--- /dev/null
+++ b/chrome/browser/cocoa/autocomplete_text_field_editor.h
@@ -0,0 +1,17 @@
+// 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.
+
+#import <Cocoa/Cocoa.h>
+
+// Field editor used for the autocomplete field.
+@interface AutocompleteTextFieldEditor : NSTextView {
+}
+
+// Copy contents of the TextView to the designated clipboard as plain
+// text.
+- (void)performCopy:(NSPasteboard*)pb;
+
+// Same as above, note that this calls through to performCopy.
+- (void)performCut:(NSPasteboard*)pb;
+@end
diff --git a/chrome/browser/cocoa/autocomplete_text_field_editor.mm b/chrome/browser/cocoa/autocomplete_text_field_editor.mm
new file mode 100644
index 0000000..4c29bb3
--- /dev/null
+++ b/chrome/browser/cocoa/autocomplete_text_field_editor.mm
@@ -0,0 +1,33 @@
+// 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.
+
+#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
+
+#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
+
+@implementation AutocompleteTextFieldEditor
+
+- (void)copy:(id)sender {
+ NSPasteboard* pb = [NSPasteboard generalPasteboard];
+ [self performCopy:pb];
+}
+
+- (void)cut:(id)sender {
+ NSPasteboard* pb = [NSPasteboard generalPasteboard];
+ [self performCut:pb];
+}
+
+- (void)performCopy:(NSPasteboard*)pb {
+ [pb declareTypes:[NSArray array] owner:nil];
+ [self writeSelectionToPasteboard:pb types:
+ [NSArray arrayWithObject:NSStringPboardType]];
+}
+
+- (void)performCut:(NSPasteboard*)pb {
+ [self performCopy:pb];
+ [self delete:nil];
+}
+
+@end
diff --git a/chrome/browser/cocoa/location_bar_fieldeditor_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm
index fca4411..71314cf 100644
--- a/chrome/browser/cocoa/location_bar_fieldeditor_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "chrome/browser/cocoa/toolbar_controller.h"
+#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
#include "base/scoped_nsobject.h"
#include "base/scoped_ptr.h"
@@ -32,7 +32,7 @@ bool ClipboardContainsText(NSPasteboard* pb, NSString* cmp) {
} // namespace
-class LocationBarFieldEditorTest : public PlatformTest {
+class AutocompleteTextFieldEditorTest : public PlatformTest {
public:
virtual void SetUp() {
PlatformTest::SetUp();
@@ -54,15 +54,15 @@ class LocationBarFieldEditorTest : public PlatformTest {
NSPasteboard *pb_;
};
-TEST_F(LocationBarFieldEditorTest, CutCopyTest) {
+TEST_F(AutocompleteTextFieldEditorTest, CutCopyTest) {
// Make sure pasteboard is empty before we start.
ASSERT_EQ(NumTypesOnPasteboard(clipboard()), 0);
NSString* test_string_1 = @"astring";
NSString* test_string_2 = @"another string";
- scoped_nsobject<LocationBarFieldEditor> field_editor(
- [[LocationBarFieldEditor alloc] init]);
+ scoped_nsobject<AutocompleteTextFieldEditor> field_editor(
+ [[AutocompleteTextFieldEditor alloc] init]);
[field_editor.get() setRichText:YES];
// Put some text on the clipboard.
diff --git a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
new file mode 100644
index 0000000..9e861a8
--- /dev/null
+++ b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
@@ -0,0 +1,46 @@
+// 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.
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/scoped_nsobject.h"
+#import "chrome/browser/cocoa/autocomplete_text_field.h"
+#import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
+#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class AutocompleteTextFieldTest : public testing::Test {
+ public:
+ AutocompleteTextFieldTest() {
+ NSRect frame = NSMakeRect(0, 0, 50, 30);
+ field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]);
+ [field_ setStringValue:@"Testing"];
+ [cocoa_helper_.contentView() addSubview:field_.get()];
+ }
+
+ CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
+ scoped_nsobject<AutocompleteTextField> field_;
+};
+
+// Test that we have the right cell class.
+TEST_F(AutocompleteTextFieldTest, CellClass) {
+ EXPECT_TRUE([[field_ cell] isKindOfClass:[AutocompleteTextFieldCell class]]);
+}
+
+// Test adding/removing from the view hierarchy, mostly to ensure nothing
+// leaks or crashes.
+TEST_F(AutocompleteTextFieldTest, AddRemove) {
+ EXPECT_EQ(cocoa_helper_.contentView(), [field_ superview]);
+ [field_.get() removeFromSuperview];
+ EXPECT_FALSE([field_ superview]);
+}
+
+// Test drawing, mostly to ensure nothing leaks or crashes.
+TEST_F(AutocompleteTextFieldTest, Display) {
+ [field_ display];
+}
+
+} // namespace
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index 26cd8fb..0bb630e 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -12,6 +12,7 @@
#include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
#include "chrome/browser/location_bar.h"
+@class AutocompleteTextField;
class CommandUpdater;
class ToolbarModel;
@@ -23,7 +24,7 @@ class LocationBarViewMac : public AutocompleteEditController,
public LocationBar,
public LocationBarTesting {
public:
- LocationBarViewMac(NSTextField* field,
+ LocationBarViewMac(AutocompleteTextField* field,
CommandUpdater* command_updater,
ToolbarModel* toolbar_model,
Profile* profile);
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index 4409ba6..edbd4a5 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -15,7 +15,7 @@
// 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,
+LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field,
CommandUpdater* command_updater,
ToolbarModel* toolbar_model,
Profile* profile)
diff --git a/chrome/browser/cocoa/toolbar_controller.h b/chrome/browser/cocoa/toolbar_controller.h
index 4f9f3d1..fc93070 100644
--- a/chrome/browser/cocoa/toolbar_controller.h
+++ b/chrome/browser/cocoa/toolbar_controller.h
@@ -13,6 +13,8 @@
#import "chrome/browser/cocoa/bookmark_bar_controller.h"
#include "chrome/common/pref_member.h"
+@class AutocompleteTextField;
+@class AutocompleteTextFieldEditor;
class CommandUpdater;
class LocationBar;
class LocationBarViewMac;
@@ -24,15 +26,6 @@ class TabContents;
class ToolbarModel;
class ToolbarView;
-// Field editor used for the location bar.
-@interface LocationBarFieldEditor : NSTextView
-// Copy contents of the TextView to the designated clipboard as plain text.
-- (void)performCopy:(NSPasteboard*)pb;
-
-// Same as above, note that this calls through to performCopy.
-- (void)performCut:(NSPasteboard*)pb;
-@end
-
// A controller for the toolbar in the browser window. Manages
// updating the state for location bar and back/fwd/reload/go buttons.
// Manages the bookmark bar and it's position in the window relative to
@@ -45,7 +38,7 @@ class ToolbarView;
Profile* profile_; // weak, one per window
scoped_ptr<CommandObserverBridge> commandObserver_;
scoped_ptr<LocationBarViewMac> locationBarView_;
- scoped_nsobject<LocationBarFieldEditor> locationBarFieldEditor_; // strong
+ scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_;
scoped_nsobject<BookmarkBarController> bookmarkBarController_;
id<BookmarkURLOpener> bookmarkBarDelegate_; // weak
NSView* webContentView_; // weak; where the web goes
@@ -70,7 +63,7 @@ class ToolbarView;
IBOutlet NSButton* goButton_;
IBOutlet NSButton* pageButton_;
IBOutlet NSButton* wrenchButton_;
- IBOutlet NSTextField* locationBar_;
+ IBOutlet AutocompleteTextField* locationBar_;
}
// Initialize the toolbar and register for command updates. The profile is
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index c16ab73..bb28cfa 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -7,6 +7,8 @@
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
+#import "chrome/browser/cocoa/autocomplete_text_field.h"
+#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
#import "chrome/browser/cocoa/location_bar_view_mac.h"
#include "chrome/browser/cocoa/nsimage_cache.h"
#include "chrome/browser/profile.h"
@@ -21,30 +23,6 @@
static NSString* const kStarImageName = @"star_Template.pdf";
static NSString* const kStarredImageName = @"starred.pdf";
-@implementation LocationBarFieldEditor
-- (void)copy:(id)sender {
- NSPasteboard* pb = [NSPasteboard generalPasteboard];
- [self performCopy:pb];
-}
-
-- (void)cut:(id)sender {
- NSPasteboard* pb = [NSPasteboard generalPasteboard];
- [self performCut:pb];
-}
-
-- (void)performCopy:(NSPasteboard*)pb {
- [pb declareTypes:[NSArray array] owner:nil];
- [self writeSelectionToPasteboard:pb types:
- [NSArray arrayWithObject:NSStringPboardType]];
-}
-
-- (void)performCut:(NSPasteboard*)pb {
- [self performCopy:pb];
- [self delete:nil];
-}
-
-@end
-
@interface ToolbarController(Private)
- (void)initCommandStatus:(CommandUpdater*)commands;
- (void)prefChanged:(std::wstring*)prefName;
@@ -245,15 +223,16 @@ class PrefObserverBridge : public NotificationObserver {
if (obj == locationBar_) {
// Lazilly construct Field editor, Cocoa UI code always runs on the
// same thread, so there shoudn't be a race condition here.
- if (locationBarFieldEditor_.get() == nil) {
- locationBarFieldEditor_.reset([[LocationBarFieldEditor alloc] init]);
+ if (autocompleteTextFieldEditor_.get() == nil) {
+ autocompleteTextFieldEditor_.reset(
+ [[AutocompleteTextFieldEditor alloc] init]);
}
// This needs to be called every time, otherwise notifications
// aren't sent correctly.
- DCHECK(locationBarFieldEditor_.get());
- [locationBarFieldEditor_.get() setFieldEditor:YES];
- return locationBarFieldEditor_.get();
+ DCHECK(autocompleteTextFieldEditor_.get());
+ [autocompleteTextFieldEditor_.get() setFieldEditor:YES];
+ return autocompleteTextFieldEditor_.get();
}
return nil;
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 7068f73..e78c383 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -738,6 +738,12 @@
'browser/chrome_thread.h',
'browser/cocoa/about_window_controller.h',
'browser/cocoa/about_window_controller.mm',
+ 'browser/cocoa/autocomplete_text_field.h',
+ 'browser/cocoa/autocomplete_text_field.mm',
+ 'browser/cocoa/autocomplete_text_field_cell.h',
+ 'browser/cocoa/autocomplete_text_field_cell.mm',
+ 'browser/cocoa/autocomplete_text_field_editor.h',
+ 'browser/cocoa/autocomplete_text_field_editor.mm',
'browser/cocoa/background_gradient_view.h',
'browser/cocoa/background_gradient_view.mm',
'browser/cocoa/base_view.h',
@@ -796,8 +802,6 @@
'browser/cocoa/gradient_button_cell.mm',
'browser/cocoa/hung_renderer_controller.h',
'browser/cocoa/hung_renderer_controller.mm',
- 'browser/cocoa/location_bar_cell.h',
- 'browser/cocoa/location_bar_cell.mm',
'browser/cocoa/location_bar_view_mac.h',
'browser/cocoa/location_bar_view_mac.mm',
'browser/cocoa/menu_localizer.h',
@@ -3583,6 +3587,9 @@
# without an explicit exclusion since gyp is smart enough to
# exclude them from non-Mac builds.
'browser/cocoa/about_window_controller_unittest.mm',
+ 'browser/cocoa/autocomplete_text_field_cell_unittest.mm',
+ 'browser/cocoa/autocomplete_text_field_editor_unittest.mm',
+ 'browser/cocoa/autocomplete_text_field_unittest.mm',
'browser/cocoa/base_view_unittest.mm',
'browser/cocoa/background_gradient_view_unittest.mm',
'browser/cocoa/blocked_popup_container_controller_unittest.mm',
@@ -3603,9 +3610,7 @@
'browser/cocoa/find_bar_view_unittest.mm',
'browser/cocoa/fullscreen_window_unittest.mm',
'browser/cocoa/hung_renderer_controller_unittest.mm',
- 'browser/cocoa/location_bar_cell_unittest.mm',
'browser/cocoa/location_bar_view_mac_unittest.mm',
- 'browser/cocoa/location_bar_fieldeditor_unittest.mm',
'browser/cocoa/gradient_button_cell_unittest.mm',
'browser/cocoa/nsimage_cache_unittest.mm',
'browser/cocoa/preferences_window_controller_unittest.mm',