| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 
| 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" | 
| 10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" | 
| 11 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 11 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 
| 12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 
| 13 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view_model.h" | 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view_model.h" | 
| 14 #include "ui/base/animation/animation_delegate.h" | 14 #include "ui/base/animation/animation_delegate.h" | 
| 15 #include "ui/base/animation/slide_animation.h" | 15 #include "ui/base/animation/slide_animation.h" | 
| 16 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" | 
| 17 #include "ui/views/view.h" | 17 #include "ui/views/view.h" | 
| 18 #include "webkit/glue/window_open_disposition.h" | 18 #include "webkit/glue/window_open_disposition.h" | 
| 19 | 19 | 
| 20 class AutocompleteEditModel; | 20 class AutocompleteEditModel; | 
| 21 struct AutocompleteMatch; | 21 struct AutocompleteMatch; | 
| 22 class AutocompleteResultView; | 22 class OmniboxResultView; | 
| 23 class Profile; | 23 class Profile; | 
| 24 | 24 | 
| 25 namespace views { | 25 namespace views { | 
| 26 class BubbleBorder; | 26 class BubbleBorder; | 
| 27 } | 27 } | 
| 28 | 28 | 
| 29 // A view representing the contents of the autocomplete popup. | 29 // A view representing the contents of the autocomplete popup. | 
| 30 class AutocompletePopupContentsView : public views::View, | 30 class OmniboxPopupContentsView : public views::View, | 
| 31                                       public AutocompleteResultViewModel, | 31                                  public OmniboxResultViewModel, | 
| 32                                       public AutocompletePopupView, | 32                                  public AutocompletePopupView, | 
| 33                                       public ui::AnimationDelegate { | 33                                  public ui::AnimationDelegate { | 
| 34  public: | 34  public: | 
| 35   // Creates the appropriate type of omnibox dropdown for the | 35   // Creates the appropriate type of omnibox dropdown for the | 
| 36   // current environment, e.g. desktop vs. touch optimized layout. | 36   // current environment, e.g. desktop vs. touch optimized layout. | 
| 37   static AutocompletePopupContentsView* CreateForEnvironment( | 37   static OmniboxPopupContentsView* CreateForEnvironment( | 
| 38       const gfx::Font& font, | 38       const gfx::Font& font, | 
| 39       OmniboxView* omnibox_view, | 39       OmniboxView* omnibox_view, | 
| 40       AutocompleteEditModel* edit_model, | 40       AutocompleteEditModel* edit_model, | 
| 41       views::View* location_bar); | 41       views::View* location_bar); | 
| 42 | 42 | 
| 43   // Returns the bounds the popup should be shown at. This is the display bounds | 43   // Returns the bounds the popup should be shown at. This is the display bounds | 
| 44   // and includes offsets for the dropshadow which this view's border renders. | 44   // and includes offsets for the dropshadow which this view's border renders. | 
| 45   gfx::Rect GetPopupBounds() const; | 45   gfx::Rect GetPopupBounds() const; | 
| 46 | 46 | 
| 47   virtual void LayoutChildren(); | 47   virtual void LayoutChildren(); | 
| 48 | 48 | 
| 49   // Overridden from AutocompletePopupView: | 49   // Overridden from AutocompletePopupView: | 
| 50   virtual bool IsOpen() const OVERRIDE; | 50   virtual bool IsOpen() const OVERRIDE; | 
| 51   virtual void InvalidateLine(size_t line) OVERRIDE; | 51   virtual void InvalidateLine(size_t line) OVERRIDE; | 
| 52   virtual void UpdatePopupAppearance() OVERRIDE; | 52   virtual void UpdatePopupAppearance() OVERRIDE; | 
| 53   virtual gfx::Rect GetTargetBounds() OVERRIDE; | 53   virtual gfx::Rect GetTargetBounds() OVERRIDE; | 
| 54   virtual void PaintUpdatesNow() OVERRIDE; | 54   virtual void PaintUpdatesNow() OVERRIDE; | 
| 55   virtual void OnDragCanceled() OVERRIDE; | 55   virtual void OnDragCanceled() OVERRIDE; | 
| 56 | 56 | 
| 57   // Overridden from AutocompleteResultViewModel: | 57   // Overridden from OmniboxResultViewModel: | 
| 58   virtual bool IsSelectedIndex(size_t index) const OVERRIDE; | 58   virtual bool IsSelectedIndex(size_t index) const OVERRIDE; | 
| 59   virtual bool IsHoveredIndex(size_t index) const OVERRIDE; | 59   virtual bool IsHoveredIndex(size_t index) const OVERRIDE; | 
| 60   virtual const SkBitmap* GetIconIfExtensionMatch(size_t index) const OVERRIDE; | 60   virtual const SkBitmap* GetIconIfExtensionMatch(size_t index) const OVERRIDE; | 
| 61 | 61 | 
| 62   // Overridden from ui::AnimationDelegate: | 62   // Overridden from ui::AnimationDelegate: | 
| 63   virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 63   virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 
| 64 | 64 | 
| 65   // Overridden from views::View: | 65   // Overridden from views::View: | 
| 66   virtual void Layout() OVERRIDE; | 66   virtual void Layout() OVERRIDE; | 
| 67   virtual views::View* GetEventHandlerForPoint( | 67   virtual views::View* GetEventHandlerForPoint( | 
| 68       const gfx::Point& point) OVERRIDE; | 68       const gfx::Point& point) OVERRIDE; | 
| 69   virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 69   virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 
| 70   virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; | 70   virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; | 
| 71   virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 71   virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 
| 72   virtual void OnMouseCaptureLost() OVERRIDE; | 72   virtual void OnMouseCaptureLost() OVERRIDE; | 
| 73   virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; | 73   virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; | 
| 74   virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 74   virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 
| 75   virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 75   virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 
| 76   virtual ui::GestureStatus OnGestureEvent( | 76   virtual ui::GestureStatus OnGestureEvent( | 
| 77       const views::GestureEvent& event) OVERRIDE; | 77       const views::GestureEvent& event) OVERRIDE; | 
| 78 | 78 | 
| 79  protected: | 79  protected: | 
| 80   AutocompletePopupContentsView(const gfx::Font& font, | 80   OmniboxPopupContentsView(const gfx::Font& font, | 
| 81                                 OmniboxView* omnibox_view, | 81                            OmniboxView* omnibox_view, | 
| 82                                 AutocompleteEditModel* edit_model, | 82                            AutocompleteEditModel* edit_model, | 
| 83                                 views::View* location_bar); | 83                            views::View* location_bar); | 
| 84   virtual ~AutocompletePopupContentsView(); | 84   virtual ~OmniboxPopupContentsView(); | 
| 85 | 85 | 
| 86   virtual void PaintResultViews(gfx::Canvas* canvas); | 86   virtual void PaintResultViews(gfx::Canvas* canvas); | 
| 87 | 87 | 
| 88   // Calculates the height needed to show all the results in the model. | 88   // Calculates the height needed to show all the results in the model. | 
| 89   virtual int CalculatePopupHeight(); | 89   virtual int CalculatePopupHeight(); | 
| 90   virtual AutocompleteResultView* CreateResultView( | 90   virtual OmniboxResultView* CreateResultView( | 
| 91       AutocompleteResultViewModel* model, | 91       OmniboxResultViewModel* model, | 
| 92       int model_index, | 92       int model_index, | 
| 93       const gfx::Font& font, | 93       const gfx::Font& font, | 
| 94       const gfx::Font& bold_font); | 94       const gfx::Font& bold_font); | 
| 95 | 95 | 
| 96   // Overridden from views::View: | 96   // Overridden from views::View: | 
| 97   virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 97   virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 
| 98   // This method should not be triggered directly as we paint our children | 98   // This method should not be triggered directly as we paint our children | 
| 99   // in an un-conventional way inside OnPaint. We use a separate canvas to | 99   // in an un-conventional way inside OnPaint. We use a separate canvas to | 
| 100   // paint the children. Hence we override this method to a no-op so that | 100   // paint the children. Hence we override this method to a no-op so that | 
| 101   // the view hierarchy does not "accidentally" trigger this. | 101   // the view hierarchy does not "accidentally" trigger this. | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 178   // flag is reset to false on a mouse pressed event, to make sure we don't | 178   // flag is reset to false on a mouse pressed event, to make sure we don't | 
| 179   // erroneously ignore the next drag. | 179   // erroneously ignore the next drag. | 
| 180   bool ignore_mouse_drag_; | 180   bool ignore_mouse_drag_; | 
| 181 | 181 | 
| 182   // The popup sizes vertically using an animation when the popup is getting | 182   // The popup sizes vertically using an animation when the popup is getting | 
| 183   // shorter (not larger, that makes it look "slow"). | 183   // shorter (not larger, that makes it look "slow"). | 
| 184   ui::SlideAnimation size_animation_; | 184   ui::SlideAnimation size_animation_; | 
| 185   gfx::Rect start_bounds_; | 185   gfx::Rect start_bounds_; | 
| 186   gfx::Rect target_bounds_; | 186   gfx::Rect target_bounds_; | 
| 187 | 187 | 
| 188   DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); | 188   DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); | 
| 189 }; | 189 }; | 
| 190 | 190 | 
| 191 #endif  // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW
     _H_ | 191 #endif  // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 
| OLD | NEW | 
|---|