summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 20:44:51 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 20:44:51 +0000
commitcd56238a0514a66c4ecdd9ef9c49a49198656914 (patch)
treeed4257477acdac715e26edb5cf21726ae15b8d81 /chrome/browser/autocomplete
parentf9889ed8c9fc841f29a99c813205ce37b1c08ffb (diff)
downloadchromium_src-cd56238a0514a66c4ecdd9ef9c49a49198656914.zip
chromium_src-cd56238a0514a66c4ecdd9ef9c49a49198656914.tar.gz
chromium_src-cd56238a0514a66c4ecdd9ef9c49a49198656914.tar.bz2
Adds the ability for classes other than native control to process
messages bounced to the parent and wires it up for autocompleteedit, which I'm going to need shortly. BUG=none TEST=none Review URL: http://codereview.chromium.org/4470001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc25
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h20
2 files changed, 44 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 328d55b..b35abc1 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -22,6 +22,7 @@
#include "app/win/drag_source.h"
#include "app/win/drop_target.h"
#include "app/win/iat_patch_function.h"
+#include "app/win/scoped_prop.h"
#include "base/auto_reset.h"
#include "base/basictypes.h"
#include "base/i18n/rtl.h"
@@ -438,6 +439,10 @@ AutocompleteEditViewWin::AutocompleteEditViewWin(
SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0,
reinterpret_cast<LPARAM>(&WordBreakProc));
+ // Makes it EN_SELCHANGE is sent to our parent window and back to us by way of
+ // ProcessWindowMessage.
+ SetEventMask(ENM_SELCHANGE);
+
// Get the metrics for the font.
HDC dc = ::GetDC(NULL);
SelectObject(dc, font_.GetNativeFont());
@@ -468,6 +473,9 @@ AutocompleteEditViewWin::AutocompleteEditViewWin(
SetBackgroundColor(background_color_);
+ message_handler_prop_.reset(
+ views::ChildWindowMessageProcessor::Register(m_hWnd, this));
+
// By default RichEdit has a drop target. Revoke it so that we can install our
// own. Revoke takes care of deleting the existing one.
RevokeDragDrop(m_hWnd);
@@ -1056,6 +1064,19 @@ void AutocompleteEditViewWin::ExecuteCommand(int command_id) {
OnAfterPossibleChange();
}
+bool AutocompleteEditViewWin::ProcessMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result) {
+ if (message == WM_NOTIFY) {
+ NMHDR* header = reinterpret_cast<NMHDR*>(l_param);
+ if (header->code == EN_SELCHANGE) {
+ // TODO(sky): wire this up.
+ }
+ }
+ return false;
+}
+
// static
int CALLBACK AutocompleteEditViewWin::WordBreakProc(LPTSTR edit_text,
int current_pos,
@@ -1246,6 +1267,10 @@ void AutocompleteEditViewWin::OnCut() {
ReplaceSel(L"", true);
}
+void AutocompleteEditViewWin::OnDestroy() {
+ message_handler_prop_.reset();
+}
+
LRESULT AutocompleteEditViewWin::OnGetObject(UINT uMsg,
WPARAM wparam,
LPARAM lparam) {
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index c0abab6..fdeaca6 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -22,8 +22,9 @@
#include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
#include "chrome/common/page_transition_types.h"
#include "gfx/font.h"
-#include "webkit/glue/window_open_disposition.h"
#include "views/controls/menu/menu_2.h"
+#include "views/widget/child_window_message_processor.h"
+#include "webkit/glue/window_open_disposition.h"
class Profile;
class TabContents;
@@ -31,6 +32,12 @@ namespace views {
class View;
}
+namespace app {
+namespace win {
+class ScopedProp;
+}
+}
+
class AutocompleteEditController;
class AutocompleteEditModel;
class AutocompleteEditView;
@@ -46,6 +53,7 @@ class AutocompleteEditViewWin
ES_NOHIDESEL> >,
public CRichEditCommands<AutocompleteEditViewWin>,
public menus::SimpleMenuModel::Delegate,
+ public views::ChildWindowMessageProcessor,
public AutocompleteEditView {
public:
struct State {
@@ -174,6 +182,7 @@ class AutocompleteEditViewWin
MSG_WM_CONTEXTMENU(OnContextMenu)
MSG_WM_COPY(OnCopy)
MSG_WM_CUT(OnCut)
+ MSG_WM_DESTROY(OnDestroy)
MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition)
MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeNotify)
@@ -212,6 +221,11 @@ class AutocompleteEditViewWin
virtual std::wstring GetLabelForCommandId(int command_id) const;
virtual void ExecuteCommand(int command_id);
+ // views::ChildWindowMessageProcessor
+ virtual bool ProcessMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result);
private:
enum MouseButton {
kLeft = 0,
@@ -267,6 +281,7 @@ class AutocompleteEditViewWin
void OnContextMenu(HWND window, const CPoint& point);
void OnCopy();
void OnCut();
+ void OnDestroy();
LRESULT OnGetObject(UINT uMsg, WPARAM wparam, LPARAM lparam);
LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam);
LRESULT OnImeNotify(UINT message, WPARAM wparam, LPARAM lparam);
@@ -519,6 +534,9 @@ class AutocompleteEditViewWin
// Instance of accessibility information and handling.
mutable ScopedComPtr<IAccessible> autocomplete_accessibility_;
+ // ScopedProp returned from registering as a ChildWindowMessageProcessor.
+ scoped_ptr<app::win::ScopedProp> message_handler_prop_;
+
DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin);
};