| Index: views/controls/textfield/native_textfield_views.h
|
| diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
|
| index b8b4e6e2a16745e98bf8a3d4d5c18771cd7de618..983e63b085e9c07dfc9609d26084a3a7e9b1d54e 100644
|
| --- a/views/controls/textfield/native_textfield_views.h
|
| +++ b/views/controls/textfield/native_textfield_views.h
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2011 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.
|
|
|
| @@ -6,6 +6,7 @@
|
| #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_
|
| #pragma once
|
|
|
| +#include "app/menus/simple_menu_model.h"
|
| #include "base/string16.h"
|
| #include "base/task.h"
|
| #include "gfx/font.h"
|
| @@ -20,13 +21,13 @@ class Canvas;
|
| namespace views {
|
|
|
| class KeyEvent;
|
| +class Menu2;
|
| class TextfieldViewsModel;
|
|
|
| // A views/skia only implementation of NativeTextfieldWrapper.
|
| // No platform specific code is used.
|
| // Following features are not yet supported.
|
| // * BIDI
|
| -// * Context Menu.
|
| // * IME/i18n support.
|
| // * X selection (only if we want to support).
|
| // * STYLE_MULTILINE, STYLE_LOWERCASE text. (These are not used in
|
| @@ -34,7 +35,9 @@ class TextfieldViewsModel;
|
| // * Double click to select word, and triple click to select all.
|
| // * Undo/Redo
|
| class NativeTextfieldViews : public views::View,
|
| - public NativeTextfieldWrapper {
|
| + public views::ContextMenuController,
|
| + public NativeTextfieldWrapper,
|
| + public menus::SimpleMenuModel::Delegate {
|
| public:
|
| explicit NativeTextfieldViews(Textfield* parent);
|
| ~NativeTextfieldViews();
|
| @@ -52,6 +55,11 @@ class NativeTextfieldViews : public views::View,
|
| virtual void DidGainFocus();
|
| virtual void WillLoseFocus();
|
|
|
| + // views::ContextMenuController overrides:
|
| + virtual void ShowContextMenu(View* source,
|
| + const gfx::Point& p,
|
| + bool is_mouse_gesture);
|
| +
|
| // NativeTextfieldWrapper overrides:
|
| virtual string16 GetText() const;
|
| virtual void UpdateText();
|
| @@ -79,6 +87,13 @@ class NativeTextfieldViews : public views::View,
|
| virtual void HandleDidGainFocus();
|
| virtual void HandleWillLoseFocus();
|
|
|
| + // menus::SimpleMenuModel::Delegate overrides
|
| + virtual bool IsCommandIdChecked(int command_id) const;
|
| + virtual bool IsCommandIdEnabled(int command_id) const;
|
| + virtual bool GetAcceleratorForCommandId(int command_id,
|
| + menus::Accelerator* accelerator);
|
| + virtual void ExecuteCommand(int command_id);
|
| +
|
| // class name of internal
|
| static const char kViewClassName[];
|
|
|
| @@ -144,6 +159,13 @@ class NativeTextfieldViews : public views::View,
|
| // Find a cusor position for given |point| in this views coordinates.
|
| size_t FindCursorPosition(const gfx::Point& point) const;
|
|
|
| + // Utility function to inform the parent textfield (and its controller if any)
|
| + // that the text in the textfield has changed.
|
| + void PropagateTextChange();
|
| +
|
| + // Utility function to create the context menu if one does not already exist.
|
| + void InitContextMenuIfRequired();
|
| +
|
| // The parent textfield, the owner of this object.
|
| Textfield* textfield_;
|
|
|
| @@ -168,6 +190,10 @@ class NativeTextfieldViews : public views::View,
|
| // A runnable method factory for callback to update the cursor.
|
| ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_;
|
|
|
| + // Context menu and its content list for the textfield.
|
| + scoped_ptr<menus::SimpleMenuModel> context_menu_contents_;
|
| + scoped_ptr<Menu2> context_menu_menu_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews);
|
| };
|
|
|
|
|