Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / omnibox / omnibox_view_views.h
index d0d2164..d90767b 100644 (file)
@@ -5,14 +5,15 @@
 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
 
+#include <set>
 #include <string>
 
 #include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
 #include "chrome/browser/ui/omnibox/omnibox_view.h"
 #include "chrome/browser/ui/toolbar/toolbar_model.h"
 #include "ui/base/window_open_disposition.h"
-#include "ui/gfx/animation/animation_delegate.h"
 #include "ui/gfx/range/range.h"
 #include "ui/views/controls/textfield/textfield.h"
 #include "ui/views/controls/textfield/textfield_controller.h"
@@ -27,7 +28,6 @@ class Profile;
 
 namespace gfx {
 class RenderText;
-class SlideAnimation;
 }
 
 namespace ui {
@@ -38,7 +38,6 @@ class OSExchangeData;
 class OmniboxViewViews
     : public OmniboxView,
       public views::Textfield,
-      public gfx::AnimationDelegate,
 #if defined(OS_CHROMEOS)
       public
           chromeos::input_method::InputMethodManager::CandidateWindowObserver,
@@ -54,14 +53,11 @@ class OmniboxViewViews
                    bool popup_window_mode,
                    LocationBarView* location_bar,
                    const gfx::FontList& font_list);
-  virtual ~OmniboxViewViews();
+  ~OmniboxViewViews() override;
 
-  // Initialize, create the underlying views, etc;
+  // Initialize, create the underlying views, etc.
   void Init();
 
-  // Starts an animation that fades in the entire OmniboxView.
-  void FadeIn();
-
   // Exposes the RenderText for tests.
 #if defined(UNIT_TEST)
   gfx::RenderText* GetRenderText() {
@@ -69,37 +65,32 @@ class OmniboxViewViews
   }
 #endif
 
-  // View:
-  virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
-
   // OmniboxView:
-  virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE;
-  virtual void OnTabChanged(const content::WebContents* web_contents) OVERRIDE;
-  virtual void Update() OVERRIDE;
-  virtual base::string16 GetText() const OVERRIDE;
-  virtual void SetUserText(const base::string16& text,
-                           const base::string16& display_text,
-                           bool update_popup) OVERRIDE;
-  virtual void SetForcedQuery() OVERRIDE;
-  virtual void GetSelectionBounds(
-      base::string16::size_type* start,
-      base::string16::size_type* end) const OVERRIDE;
-  virtual void SelectAll(bool reversed) OVERRIDE;
-  virtual void RevertAll() OVERRIDE;
-  virtual void SetFocus() OVERRIDE;
-  virtual int GetTextWidth() const OVERRIDE;
-  virtual bool IsImeComposing() const OVERRIDE;
-  virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
+  void SaveStateToTab(content::WebContents* tab) override;
+  void OnTabChanged(const content::WebContents* web_contents) override;
+  void Update() override;
+  void UpdatePlaceholderText() override;
+  base::string16 GetText() const override;
+  void SetUserText(const base::string16& text,
+                   const base::string16& display_text,
+                   bool update_popup) override;
+  void SetForcedQuery() override;
+  void GetSelectionBounds(base::string16::size_type* start,
+                          base::string16::size_type* end) const override;
+  void SelectAll(bool reversed) override;
+  void RevertAll() override;
+  void SetFocus() override;
+  int GetTextWidth() const override;
+  bool IsImeComposing() const override;
+
+  // views::Textfield:
+  gfx::Size GetMinimumSize() const override;
+  void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
+  void ExecuteCommand(int command_id, int event_flags) override;
 
  private:
   FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag);
 
-  // Return the number of characers in the current buffer.
-  virtual int GetOmniboxTextLength() const OVERRIDE;
-
-  // Try to parse the current text as a URL and colorize the components.
-  virtual void EmphasizeURLComponents() OVERRIDE;
-
   // Update the field with |text| and set the selection.
   void SetTextAndSelectedRange(const base::string16& text,
                                const gfx::Range& range);
@@ -118,83 +109,82 @@ class OmniboxViewViews
   // Handle keyword hint tab-to-search and tabbing through dropdown results.
   bool HandleEarlyTabActions(const ui::KeyEvent& event);
 
+  // Handles a request to change the value of this text field from software
+  // using an accessibility API (typically automation software, screen readers
+  // don't normally use this). Sets the value and clears the selection.
+  void AccessibilitySetValue(const base::string16& new_value);
+
   // OmniboxView:
-  virtual void SetWindowTextAndCaretPos(const base::string16& text,
-                                        size_t caret_pos,
-                                        bool update_popup,
-                                        bool notify_text_changed) OVERRIDE;
-  virtual bool IsSelectAll() const OVERRIDE;
-  virtual bool DeleteAtEndPressed() OVERRIDE;
-  virtual void UpdatePopup() OVERRIDE;
-  virtual void ApplyCaretVisibility() OVERRIDE;
-  virtual void OnTemporaryTextMaybeChanged(
-      const base::string16& display_text,
-      bool save_original_selection,
-      bool notify_text_changed) OVERRIDE;
-  virtual bool OnInlineAutocompleteTextMaybeChanged(
-      const base::string16& display_text, size_t user_text_length) OVERRIDE;
-  virtual void OnInlineAutocompleteTextCleared() OVERRIDE;
-  virtual void OnRevertTemporaryText() OVERRIDE;
-  virtual void OnBeforePossibleChange() OVERRIDE;
-  virtual bool OnAfterPossibleChange() OVERRIDE;
-  virtual gfx::NativeView GetNativeView() const OVERRIDE;
-  virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE;
-  virtual void SetGrayTextAutocompletion(const base::string16& input) OVERRIDE;
-  virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE;
-  virtual int GetWidth() const OVERRIDE;
-  virtual bool IsImeShowingPopup() const OVERRIDE;
-  virtual void ShowImeIfNeeded() OVERRIDE;
-  virtual void OnMatchOpened(const AutocompleteMatch& match,
-                             Profile* profile,
-                             content::WebContents* web_contents) const OVERRIDE;
-  virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
-  virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE;
-  virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE;
+  void SetWindowTextAndCaretPos(const base::string16& text,
+                                size_t caret_pos,
+                                bool update_popup,
+                                bool notify_text_changed) override;
+  bool IsSelectAll() const override;
+  bool DeleteAtEndPressed() override;
+  void UpdatePopup() override;
+  void ApplyCaretVisibility() override;
+  void OnTemporaryTextMaybeChanged(const base::string16& display_text,
+                                   bool save_original_selection,
+                                   bool notify_text_changed) override;
+  bool OnInlineAutocompleteTextMaybeChanged(const base::string16& display_text,
+                                            size_t user_text_length) override;
+  void OnInlineAutocompleteTextCleared() override;
+  void OnRevertTemporaryText() override;
+  void OnBeforePossibleChange() override;
+  bool OnAfterPossibleChange() override;
+  gfx::NativeView GetNativeView() const override;
+  gfx::NativeView GetRelativeWindowForPopup() const override;
+  void SetGrayTextAutocompletion(const base::string16& input) override;
+  base::string16 GetGrayTextAutocompletion() const override;
+  int GetWidth() const override;
+  bool IsImeShowingPopup() const override;
+  void ShowImeIfNeeded() override;
+  void OnMatchOpened(const AutocompleteMatch& match,
+                     content::WebContents* web_contents) override;
+  int GetOmniboxTextLength() const override;
+  void EmphasizeURLComponents() override;
 
   // views::Textfield:
-  virtual const char* GetClassName() const OVERRIDE;
-  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
-  virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
-  virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
-  virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
-  virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
-  virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE;
-  virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
-  virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE;
-  virtual bool SkipDefaultKeyEventProcessing(
-      const ui::KeyEvent& event) OVERRIDE;
-  virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
-  virtual void OnFocus() OVERRIDE;
-  virtual void OnBlur() OVERRIDE;
-  virtual base::string16 GetSelectionClipboardText() const OVERRIDE;
-
-  // gfx::AnimationDelegate:
-  virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
-  virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
+  bool OnKeyReleased(const ui::KeyEvent& event) override;
+  bool IsItemForCommandIdDynamic(int command_id) const override;
+  base::string16 GetLabelForCommandId(int command_id) const override;
+  const char* GetClassName() const override;
+  bool OnMousePressed(const ui::MouseEvent& event) override;
+  bool OnMouseDragged(const ui::MouseEvent& event) override;
+  void OnMouseReleased(const ui::MouseEvent& event) override;
+  bool OnKeyPressed(const ui::KeyEvent& event) override;
+  void OnGestureEvent(ui::GestureEvent* event) override;
+  void AboutToRequestFocusFromTabTraversal(bool reverse) override;
+  bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) override;
+  void GetAccessibleState(ui::AXViewState* state) override;
+  void OnFocus() override;
+  void OnBlur() override;
+  bool IsCommandIdEnabled(int command_id) const override;
+  base::string16 GetSelectionClipboardText() const override;
 
   // chromeos::input_method::InputMethodManager::CandidateWindowObserver:
 #if defined(OS_CHROMEOS)
   virtual void CandidateWindowOpened(
-      chromeos::input_method::InputMethodManager* manager) OVERRIDE;
+      chromeos::input_method::InputMethodManager* manager) override;
   virtual void CandidateWindowClosed(
-      chromeos::input_method::InputMethodManager* manager) OVERRIDE;
+      chromeos::input_method::InputMethodManager* manager) override;
 #endif
 
   // views::TextfieldController:
-  virtual void ContentsChanged(views::Textfield* sender,
-                               const base::string16& new_contents) OVERRIDE;
-  virtual bool HandleKeyEvent(views::Textfield* sender,
-                              const ui::KeyEvent& key_event) OVERRIDE;
-  virtual void OnBeforeUserAction(views::Textfield* sender) OVERRIDE;
-  virtual void OnAfterUserAction(views::Textfield* sender) OVERRIDE;
-  virtual void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) OVERRIDE;
-  virtual void OnWriteDragData(ui::OSExchangeData* data) OVERRIDE;
-  virtual void OnGetDragOperationsForTextfield(int* drag_operations) OVERRIDE;
-  virtual void AppendDropFormats(
+  void ContentsChanged(views::Textfield* sender,
+                       const base::string16& new_contents) override;
+  bool HandleKeyEvent(views::Textfield* sender,
+                      const ui::KeyEvent& key_event) override;
+  void OnBeforeUserAction(views::Textfield* sender) override;
+  void OnAfterUserAction(views::Textfield* sender) override;
+  void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) override;
+  void OnWriteDragData(ui::OSExchangeData* data) override;
+  void OnGetDragOperationsForTextfield(int* drag_operations) override;
+  void AppendDropFormats(
       int* formats,
-      std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
-  virtual int OnDrop(const ui::OSExchangeData& data) OVERRIDE;
-  virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) OVERRIDE;
+      std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override;
+  int OnDrop(const ui::OSExchangeData& data) override;
+  void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) override;
 
   // When true, the location bar view is read only and also is has a slightly
   // different presentation (smaller font size). This is used for popups.
@@ -236,7 +226,8 @@ class OmniboxViewViews
   // and gets a tap. So we use this variable to remember focus state before tap.
   bool select_all_on_gesture_tap_;
 
-  scoped_ptr<gfx::SlideAnimation> fade_in_animation_;
+  // Used to bind callback functions to this object.
+  base::WeakPtrFactory<OmniboxViewViews> weak_ptr_factory_;
 
   DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews);
 };