1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_CONTENT_SETTING_DECORATION_H_
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_CONTENT_SETTING_DECORATION_H_
8 #include "base/memory/scoped_ptr.h"
9 #import "chrome/browser/ui/cocoa/location_bar/image_decoration.h"
10 #include "components/content_settings/core/common/content_settings_types.h"
12 // ContentSettingDecoration is used to display the content settings
13 // images on the current page.
15 @class ContentSettingAnimationState;
16 class ContentSettingImageModel;
17 class LocationBarViewMac;
24 class ContentSettingDecoration : public ImageDecoration {
26 ContentSettingDecoration(ContentSettingsType settings_type,
27 LocationBarViewMac* owner,
29 virtual ~ContentSettingDecoration();
31 // Updates the image and visibility state based on the supplied WebContents.
32 // Returns true if the decoration's visible state changed.
33 bool UpdateFromWebContents(content::WebContents* web_contents);
35 // Overridden from |LocationBarDecoration|
36 virtual bool AcceptsMousePress() OVERRIDE;
37 virtual bool OnMousePressed(NSRect frame, NSPoint location) OVERRIDE;
38 virtual NSString* GetToolTip() OVERRIDE;
39 virtual CGFloat GetWidthForSpace(CGFloat width) OVERRIDE;
40 virtual void DrawInFrame(NSRect frame, NSView* control_view) OVERRIDE;
41 virtual NSPoint GetBubblePointInFrame(NSRect frame) OVERRIDE;
43 // Called from internal animator. Only public because ObjC objects can't
45 virtual void AnimationTimerFired();
49 void SetToolTip(NSString* tooltip);
51 // Returns an attributed string with the animated text.
52 base::scoped_nsobject<NSAttributedString> CreateAnimatedText();
54 // Measure the width of the animated text.
55 CGFloat MeasureTextWidth();
57 scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
59 LocationBarViewMac* owner_; // weak
60 Profile* profile_; // weak
62 base::scoped_nsobject<NSString> tooltip_;
64 // Used when the decoration has animated text.
65 base::scoped_nsobject<ContentSettingAnimationState> animation_;
67 base::scoped_nsobject<NSAttributedString> animated_text_;
69 DISALLOW_COPY_AND_ASSIGN(ContentSettingDecoration);
72 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_CONTENT_SETTING_DECORATION_H_