| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_COCOA_LOCATION_BAR_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ |
| 6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 virtual LocationBarTesting* GetLocationBarForTesting() { return this; } | 67 virtual LocationBarTesting* GetLocationBarForTesting() { return this; } |
| 68 | 68 |
| 69 // Overridden from LocationBarTesting: | 69 // Overridden from LocationBarTesting: |
| 70 virtual int PageActionCount(); | 70 virtual int PageActionCount(); |
| 71 virtual int PageActionVisibleCount(); | 71 virtual int PageActionVisibleCount(); |
| 72 virtual ExtensionAction* GetPageAction(size_t index); | 72 virtual ExtensionAction* GetPageAction(size_t index); |
| 73 virtual ExtensionAction* GetVisiblePageAction(size_t index); | 73 virtual ExtensionAction* GetVisiblePageAction(size_t index); |
| 74 virtual void TestPageActionPressed(size_t index); | 74 virtual void TestPageActionPressed(size_t index); |
| 75 | 75 |
| 76 // Set the starred state of the bookmark star. |
| 77 void SetStarred(bool starred); |
| 78 |
| 76 // Updates the location bar. Resets the bar's permanent text and | 79 // Updates the location bar. Resets the bar's permanent text and |
| 77 // security style, and if |should_restore_state| is true, restores | 80 // security style, and if |should_restore_state| is true, restores |
| 78 // saved state from the tab (for tab switching). | 81 // saved state from the tab (for tab switching). |
| 79 void Update(const TabContents* tab, bool should_restore_state); | 82 void Update(const TabContents* tab, bool should_restore_state); |
| 80 | 83 |
| 81 // Returns the current TabContents. | 84 // Returns the current TabContents. |
| 82 TabContents* GetTabContents() const; | 85 TabContents* GetTabContents() const; |
| 83 | 86 |
| 84 // Sets preview_enabled_ for the PageActionImageView associated with this | 87 // Sets preview_enabled_ for the PageActionImageView associated with this |
| 85 // |page_action|. If |preview_enabled|, the location bar will display the | 88 // |page_action|. If |preview_enabled|, the location bar will display the |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Used to display a clickable icon in the location bar. | 135 // Used to display a clickable icon in the location bar. |
| 133 class LocationBarImageView { | 136 class LocationBarImageView { |
| 134 public: | 137 public: |
| 135 explicit LocationBarImageView() : image_(nil), | 138 explicit LocationBarImageView() : image_(nil), |
| 136 label_(nil), | 139 label_(nil), |
| 137 visible_(false) {} | 140 visible_(false) {} |
| 138 virtual ~LocationBarImageView() {} | 141 virtual ~LocationBarImageView() {} |
| 139 | 142 |
| 140 // Sets the image. | 143 // Sets the image. |
| 141 void SetImage(NSImage* image); | 144 void SetImage(NSImage* image); |
| 142 void SetImage(SkBitmap* image); | 145 |
| 146 // Get the |resource_id| image resource and set the image. |
| 147 void SetIcon(int resource_id); |
| 143 | 148 |
| 144 // Sets the label text, font, and color. |text| may be nil; |color| and | 149 // Sets the label text, font, and color. |text| may be nil; |color| and |
| 145 // |font| are ignored if |text| is nil. | 150 // |font| are ignored if |text| is nil. |
| 146 void SetLabel(NSString* text, NSFont* baseFont, NSColor* color); | 151 void SetLabel(NSString* text, NSFont* baseFont, NSColor* color); |
| 147 | 152 |
| 148 // Sets the visibility. SetImage() should be called with a valid image | 153 // Sets the visibility. SetImage() should be called with a valid image |
| 149 // before the visibility is set to |true|. | 154 // before the visibility is set to |true|. |
| 150 void SetVisible(bool visible); | 155 void SetVisible(bool visible); |
| 151 | 156 |
| 152 const NSImage* GetImage() const { return image_; } | 157 const NSImage* GetImage() const { return image_; } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // Shows the page info dialog. | 193 // Shows the page info dialog. |
| 189 virtual void OnMousePressed(NSRect bounds); | 194 virtual void OnMousePressed(NSRect bounds); |
| 190 | 195 |
| 191 private: | 196 private: |
| 192 // The location bar view that owns us. | 197 // The location bar view that owns us. |
| 193 LocationBarViewMac* owner_; | 198 LocationBarViewMac* owner_; |
| 194 | 199 |
| 195 DISALLOW_COPY_AND_ASSIGN(LocationIconView); | 200 DISALLOW_COPY_AND_ASSIGN(LocationIconView); |
| 196 }; | 201 }; |
| 197 | 202 |
| 203 // Used to display the bookmark star in the RHS. |
| 204 class StarIconView : public LocationBarImageView { |
| 205 public: |
| 206 explicit StarIconView(CommandUpdater* command_updater); |
| 207 virtual ~StarIconView() {} |
| 208 |
| 209 // Shows the bookmark bubble. |
| 210 virtual void OnMousePressed(NSRect bounds); |
| 211 |
| 212 // Set the image and tooltip based on |starred|. |
| 213 void SetStarred(bool starred); |
| 214 |
| 215 virtual const NSString* GetToolTip(); |
| 216 |
| 217 private: |
| 218 // For bringing up bookmark bar. |
| 219 CommandUpdater* command_updater_; // Weak, owned by Browser. |
| 220 |
| 221 // The string to show for a tooltip. |
| 222 scoped_nsobject<NSString> tooltip_; |
| 223 |
| 224 DISALLOW_COPY_AND_ASSIGN(StarIconView); |
| 225 }; |
| 226 |
| 198 // PageActionImageView is used to display the icon for a given Page Action | 227 // PageActionImageView is used to display the icon for a given Page Action |
| 199 // and notify the extension when the icon is clicked. | 228 // and notify the extension when the icon is clicked. |
| 200 class PageActionImageView : public LocationBarImageView, | 229 class PageActionImageView : public LocationBarImageView, |
| 201 public ImageLoadingTracker::Observer, | 230 public ImageLoadingTracker::Observer, |
| 202 public NotificationObserver { | 231 public NotificationObserver { |
| 203 public: | 232 public: |
| 204 PageActionImageView(LocationBarViewMac* owner, | 233 PageActionImageView(LocationBarViewMac* owner, |
| 205 Profile* profile, | 234 Profile* profile, |
| 206 ExtensionAction* page_action); | 235 ExtensionAction* page_action); |
| 207 virtual ~PageActionImageView(); | 236 virtual ~PageActionImageView(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 419 |
| 391 // The user's desired disposition for how their input should be opened. | 420 // The user's desired disposition for how their input should be opened. |
| 392 WindowOpenDisposition disposition_; | 421 WindowOpenDisposition disposition_; |
| 393 | 422 |
| 394 // A view that shows an icon to the left of the address. | 423 // A view that shows an icon to the left of the address. |
| 395 LocationIconView location_icon_view_; | 424 LocationIconView location_icon_view_; |
| 396 | 425 |
| 397 // Security info as text which floats left of the page actions. | 426 // Security info as text which floats left of the page actions. |
| 398 LocationBarImageView security_label_view_; | 427 LocationBarImageView security_label_view_; |
| 399 | 428 |
| 429 // Bookmark star right of page actions. |
| 430 StarIconView star_icon_view_; |
| 431 |
| 400 // Any installed Page Actions. | 432 // Any installed Page Actions. |
| 401 PageActionViewList page_action_views_; | 433 PageActionViewList page_action_views_; |
| 402 | 434 |
| 403 // The content blocked views. | 435 // The content blocked views. |
| 404 ContentSettingViews content_setting_views_; | 436 ContentSettingViews content_setting_views_; |
| 405 | 437 |
| 406 Profile* profile_; | 438 Profile* profile_; |
| 407 | 439 |
| 408 Browser* browser_; | 440 Browser* browser_; |
| 409 | 441 |
| 410 ToolbarModel* toolbar_model_; // Weak, owned by Browser. | 442 ToolbarModel* toolbar_model_; // Weak, owned by Browser. |
| 411 | 443 |
| 412 // Image used in drawing keyword hint. | 444 // Image used in drawing keyword hint. |
| 413 scoped_nsobject<NSImage> tab_button_image_; | 445 scoped_nsobject<NSImage> tab_button_image_; |
| 414 | 446 |
| 415 // The transition type to use for the navigation. | 447 // The transition type to use for the navigation. |
| 416 PageTransition::Type transition_; | 448 PageTransition::Type transition_; |
| 417 | 449 |
| 418 // Used to register for notifications received by NotificationObserver. | 450 // Used to register for notifications received by NotificationObserver. |
| 419 NotificationRegistrar registrar_; | 451 NotificationRegistrar registrar_; |
| 420 | 452 |
| 421 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); | 453 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); |
| 422 }; | 454 }; |
| 423 | 455 |
| 424 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ | 456 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ |
| OLD | NEW |