| Index: chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h b/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h
|
| index 754a0808316e99a7b66876a5cc5f24d0128a6dfd..11de3a008fb484d72b9f3dc43ce5b33d1ec73fb7 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h
|
| +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h
|
| @@ -12,6 +12,9 @@
|
| #include "third_party/skia/include/core/SkColor.h"
|
| #include "ui/gfx/vector_icons_public.h"
|
|
|
| +@class DecorationMouseTrackingDelegate;
|
| +@class CrTrackingArea;
|
| +
|
| // Base class for decorations at the left and right of the location
|
| // bar. For instance, the location icon.
|
|
|
| @@ -22,6 +25,8 @@
|
| // Decorations are more like Cocoa cells, except implemented in C++ to
|
| // allow more similarity to the other platform implementations.
|
|
|
| +enum class LocationBarDecorationState { NORMAL, HOVER, PRESSED };
|
| +
|
| class LocationBarDecoration {
|
| public:
|
| LocationBarDecoration();
|
| @@ -36,6 +41,9 @@ class LocationBarDecoration {
|
| // or |kOmittedWidth| if it should be omitted.
|
| virtual CGFloat GetWidthForSpace(CGFloat width);
|
|
|
| + // Returns a NSRect derived from |frame| for the background to fill.
|
| + virtual NSRect GetBackgroundFrame(NSRect frame);
|
| +
|
| // Draw the decoration in the frame provided. The frame will be
|
| // generated from an earlier call to |GetWidthForSpace()|.
|
| virtual void DrawInFrame(NSRect frame, NSView* control_view);
|
| @@ -50,6 +58,10 @@ class LocationBarDecoration {
|
| // Returns the tooltip for this decoration, return |nil| for no tooltip.
|
| virtual NSString* GetToolTip();
|
|
|
| + // Methods to set up and remove the tracking area from the |control_view|.
|
| + CrTrackingArea* SetupTrackingArea(NSRect frame, NSView* control_view);
|
| + void RemoveTrackingArea();
|
| +
|
| // Decorations which do not accept mouse events are treated like the
|
| // field's background for purposes of selecting text. When such
|
| // decorations are adjacent to the text area, they will show the
|
| @@ -57,6 +69,11 @@ class LocationBarDecoration {
|
| // an arrow cursor when the mouse is over them.
|
| virtual bool AcceptsMousePress();
|
|
|
| + // Returns true if the decoration should display a background if it's
|
| + // hovered or pressed. The default value is equivalent to the value returned
|
| + // from AcceptsMousePress().
|
| + virtual bool HasHoverAndPressEffect();
|
| +
|
| // Determine if the item can act as a drag source.
|
| virtual bool IsDraggable();
|
|
|
| @@ -72,10 +89,19 @@ class LocationBarDecoration {
|
| // The pasteboard to drag.
|
| virtual NSPasteboard* GetDragPasteboard();
|
|
|
| - // Called on mouse down. Return |false| to indicate that the press
|
| - // was not processed and should be handled by the cell.
|
| + // Called on mouse down, when the decoration isn't being dragged. Return
|
| + // |false| to indicate that the press was not processed and should be
|
| + // handled by the cell.
|
| virtual bool OnMousePressed(NSRect frame, NSPoint location);
|
|
|
| + // Mouse events called on mouse down/up.
|
| + void OnMouseDown();
|
| + void OnMouseUp();
|
| +
|
| + // Called by |tracking_delegate_| when the mouse enters/exits the decoration.
|
| + void OnMouseEntered();
|
| + void OnMouseExited();
|
| +
|
| // Called to get the right-click menu, return |nil| for no menu.
|
| virtual NSMenu* GetMenu();
|
|
|
| @@ -108,6 +134,8 @@ class LocationBarDecoration {
|
| // to the private DecorationAccessibilityView helper class.
|
| void OnAccessibilityViewAction();
|
|
|
| + LocationBarDecorationState state() { return state_; }
|
| +
|
| // Width returned by |GetWidthForSpace()| when the item should be
|
| // omitted for this width;
|
| static const CGFloat kOmittedWidth;
|
| @@ -130,9 +158,26 @@ class LocationBarDecoration {
|
| NSColor* GetDividerColor(bool location_bar_is_dark) const;
|
|
|
| private:
|
| + // Called when the state of the decoration is updated.
|
| + void UpdateDecorationState();
|
| +
|
| bool visible_ = false;
|
| base::scoped_nsobject<NSView> accessibility_view_;
|
|
|
| + // The decoration's tracking area. Only set if the decoration accepts a mouse
|
| + // press.
|
| + base::scoped_nsobject<CrTrackingArea> tracking_area_;
|
| +
|
| + // The view that |tracking_area_| is added to.
|
| + NSView* tracking_area_owner_;
|
| +
|
| + // Delegate object that handles mouseEntered: and mouseExited: events from
|
| + // the tracking area.
|
| + base::scoped_nsobject<DecorationMouseTrackingDelegate> tracking_delegate_;
|
| +
|
| + // The state of the decoration.
|
| + LocationBarDecorationState state_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(LocationBarDecoration);
|
| };
|
|
|
|
|