summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 03:30:55 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 03:30:55 +0000
commitce47a3c7f3296d5fb72b2c980377b613c35d4c33 (patch)
tree19d0495a77672f9f65016d6d4b23286e5b4015ee
parent49bcfd24022de81f8492f261cd6781803f902026 (diff)
downloadchromium_src-ce47a3c7f3296d5fb72b2c980377b613c35d4c33.zip
chromium_src-ce47a3c7f3296d5fb72b2c980377b613c35d4c33.tar.gz
chromium_src-ce47a3c7f3296d5fb72b2c980377b613c35d4c33.tar.bz2
GTK: disable "edit search engines" and "paste and go" in location bar view when appropriate.
BUG=29089 TEST=see bug Review URL: http://codereview.chromium.org/667009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40596 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc5
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view.h4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc10
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h2
8 files changed, 28 insertions, 5 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index f5b6b2b..74fd71f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -8,9 +8,11 @@
#include "base/basictypes.h"
#include "base/string_util.h"
+#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/keyword_provider.h"
+#include "chrome/browser/command_updater.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/net/url_fixer_upper.h"
@@ -186,6 +188,9 @@ void AutocompleteEditModel::StartAutocomplete(
}
bool AutocompleteEditModel::CanPasteAndGo(const std::wstring& text) const {
+ if (!view_->GetCommandUpdater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL))
+ return false;
+
paste_and_go_url_ = GURL();
paste_and_go_transition_ = PageTransition::TYPED;
paste_and_go_alternate_nav_url_ = GURL();
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view.h b/chrome/browser/autocomplete/autocomplete_edit_view.h
index 021b5cd..2b8d78d 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view.h
@@ -18,6 +18,7 @@
#include "webkit/glue/window_open_disposition.h"
class AutocompleteEditModel;
+class CommandUpdater;
class GURL;
class TabContents;
@@ -129,6 +130,9 @@ class AutocompleteEditView {
// Returns the gfx::NativeView of the edit view.
virtual gfx::NativeView GetNativeView() const = 0;
+ // Returns the command updater for this view.
+ virtual CommandUpdater* GetCommandUpdater() = 0;
+
protected:
virtual ~AutocompleteEditView() {}
};
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index ae241e0..083f6a2 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -560,6 +560,10 @@ gfx::NativeView AutocompleteEditViewGtk::GetNativeView() const {
return alignment_.get();
}
+CommandUpdater* AutocompleteEditViewGtk::GetCommandUpdater() {
+ return command_updater_;
+}
+
void AutocompleteEditViewGtk::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -926,6 +930,8 @@ void AutocompleteEditViewGtk::HandlePopulatePopup(GtkMenu* menu) {
gtk_menu_shell_append(GTK_MENU_SHELL(menu), search_engine_menuitem);
g_signal_connect(search_engine_menuitem, "activate",
G_CALLBACK(HandleEditSearchEnginesThunk), this);
+ gtk_widget_set_sensitive(search_engine_menuitem,
+ command_updater_->IsCommandEnabled(IDC_EDIT_SEARCH_ENGINES));
gtk_widget_show(search_engine_menuitem);
// We need to update the paste and go controller before we know what text
@@ -936,7 +942,6 @@ void AutocompleteEditViewGtk::HandlePopulatePopup(GtkMenu* menu) {
gchar* text = gtk_clipboard_wait_for_text(x_clipboard);
std::wstring text_wstr = UTF8ToWide(text);
g_free(text);
- bool can_paste_and_go = model_->CanPasteAndGo(text_wstr);
// Paste and Go menu item.
GtkWidget* paste_go_menuitem = gtk_menu_item_new_with_mnemonic(
@@ -946,7 +951,8 @@ void AutocompleteEditViewGtk::HandlePopulatePopup(GtkMenu* menu) {
gtk_menu_shell_append(GTK_MENU_SHELL(menu), paste_go_menuitem);
g_signal_connect(paste_go_menuitem, "activate",
G_CALLBACK(HandlePasteAndGoThunk), this);
- gtk_widget_set_sensitive(paste_go_menuitem, can_paste_and_go);
+ gtk_widget_set_sensitive(paste_go_menuitem,
+ model_->CanPasteAndGo(text_wstr));
gtk_widget_show(paste_go_menuitem);
}
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index 0affbd8..e90d755 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -25,7 +25,6 @@ class AutocompleteEditController;
class AutocompleteEditModel;
class AutocompletePopupView;
class BubblePositioner;
-class CommandUpdater;
class Profile;
class TabContents;
@@ -111,6 +110,7 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
virtual void OnBeforePossibleChange();
virtual bool OnAfterPossibleChange();
virtual gfx::NativeView GetNativeView() const;
+ virtual CommandUpdater* GetCommandUpdater();
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
index 21d57ad..11bb62f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
@@ -15,7 +15,6 @@ class AutocompleteEditController;
class AutocompletePopupViewMac;
class BubblePositioner;
class Clipboard;
-class CommandUpdater;
class Profile;
class ToolbarModel;
@@ -76,6 +75,7 @@ class AutocompleteEditViewMac : public AutocompleteEditView,
virtual void OnBeforePossibleChange();
virtual bool OnAfterPossibleChange();
virtual gfx::NativeView GetNativeView() const;
+ virtual CommandUpdater* GetCommandUpdater();
// Implement the AutocompleteTextFieldObserver interface.
virtual void OnControlKeyChanged(bool pressed);
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index a78a6b7..1da63ec 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -565,6 +565,10 @@ gfx::NativeView AutocompleteEditViewMac::GetNativeView() const {
return field_;
}
+CommandUpdater* AutocompleteEditViewMac::GetCommandUpdater() {
+ return command_updater_;
+}
+
void AutocompleteEditViewMac::OnDidBeginEditing() {
// We should only arrive here when the field is focussed.
DCHECK([field_ currentEditor]);
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index b39c6f0..fffa276 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -851,6 +851,10 @@ gfx::NativeView AutocompleteEditViewWin::GetNativeView() const {
return m_hWnd;
}
+CommandUpdater* AutocompleteEditViewWin::GetCommandUpdater() {
+ return command_updater_;
+}
+
void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) {
if (CanPasteAndGo(text))
model_->PasteAndGo();
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index 4db0ea6..c24996e 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -25,7 +25,6 @@
#include "views/controls/menu/menu_2.h"
class AutocompletePopupModel;
-class CommandUpdater;
class Profile;
class TabContents;
namespace views {
@@ -121,6 +120,7 @@ class AutocompleteEditViewWin
virtual void OnBeforePossibleChange();
virtual bool OnAfterPossibleChange();
virtual gfx::NativeView GetNativeView() const;
+ virtual CommandUpdater* GetCommandUpdater();
// Exposes custom IAccessible implementation to the overall MSAA hierarchy.
IAccessible* GetIAccessible();