diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 15:41:51 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 15:41:51 +0000 |
commit | 5942dc32a1d9dc32aa208452ec72f8c076153f63 (patch) | |
tree | 511de1b51abf62a8a9f50622db9b2193a2a43e5a /chrome/browser/cocoa | |
parent | 12c3b59ecb82bded702780696dffc15c6955a5f7 (diff) | |
download | chromium_src-5942dc32a1d9dc32aa208452ec72f8c076153f63.zip chromium_src-5942dc32a1d9dc32aa208452ec72f8c076153f63.tar.gz chromium_src-5942dc32a1d9dc32aa208452ec72f8c076153f63.tar.bz2 |
Don't allow drag or click on location icon when editing in omnibox.
After editing the omnibox, clicking the location icon would provide
the page info for the page being shown, though the rest of the omnibox
might be inconsistent with that page. Exposes the logic used by
AutocompleteEditView::GetIcon() to determine when there's a real URL
for page-info (or drag).
BUG=none
TEST=Navigate to a page. Click location icon to see page info. Edit the omnibox, click should not show page info.
Review URL: http://codereview.chromium.org/1594012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/autocomplete_text_field_unittest.mm | 8 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.mm | 14 |
3 files changed, 18 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm index f82fca7..b6f044f 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm @@ -27,9 +27,11 @@ class MockLocationIconView : public LocationBarViewMac::LocationIconView { MockLocationIconView(LocationBarViewMac* owner) : LocationBarViewMac::LocationIconView(owner) {} - // |LocationBarViewMac::LocationIconView::GetDragPasteboard()| - // expects things to be more initialized than they will be, and - // will crash if it is called. + // |LocationBarViewMac::LocationIconView| dragging support needs + // more setup than this test provides. + bool IsDraggable() { + return false; + } virtual NSPasteboard* GetDragPasteboard() { return [NSPasteboard pasteboardWithUniqueName]; } diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h index 7eee821..ebff104 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar_view_mac.h @@ -61,6 +61,9 @@ class LocationBarViewMac : public AutocompleteEditController, virtual void InvalidatePageActions(); virtual void SaveStateToContents(TabContents* contents); virtual void Revert(); + virtual const AutocompleteEditView* location_entry() const { + return edit_view_.get(); + } virtual AutocompleteEditView* location_entry() { return edit_view_.get(); } diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm index c2c10dd..6a7afba 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar_view_mac.mm @@ -601,8 +601,11 @@ LocationBarViewMac::LocationIconView::LocationIconView( LocationBarViewMac::LocationIconView::~LocationIconView() {} void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) { - // TODO(shess): Only allow click if page-info makes sense. - // http://codereview.chromium.org/1594012 + // Do not show page info if the user has been editing the location + // bar, or the location bar is at the NTP. + if (owner_->location_entry()->IsEditingOrEmpty()) + return; + TabContents* tab = owner_->GetTabContents(); NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); if (!nav_entry) { @@ -613,8 +616,11 @@ void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) { } bool LocationBarViewMac::LocationIconView::IsDraggable() { - // TODO(shess): Only allow drag if there's an URL to drag. - // http://codereview.chromium.org/1594012 + // Do not drag if the user has been editing the location bar, or the + // location bar is at the NTP. + if (owner_->location_entry()->IsEditingOrEmpty()) + return false; + return true; } |