| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_LOCATION_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <map> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "app/gfx/font.h" | 12 #include "app/gfx/font.h" |
| 12 #include "base/gfx/rect.h" | 13 #include "base/gfx/rect.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 14 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 14 #include "chrome/browser/extensions/image_loading_tracker.h" | 15 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 15 #include "chrome/browser/location_bar.h" | 16 #include "chrome/browser/location_bar.h" |
| 16 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/browser/toolbar_model.h" | 18 #include "chrome/browser/toolbar_model.h" |
| 18 #include "chrome/browser/views/info_bubble.h" | 19 #include "chrome/browser/views/info_bubble.h" |
| 19 #include "views/controls/image_view.h" | 20 #include "views/controls/image_view.h" |
| 20 #include "views/controls/label.h" | 21 #include "views/controls/label.h" |
| 21 #include "views/controls/native/native_view_host.h" | 22 #include "views/controls/native/native_view_host.h" |
| 22 #include "views/painter.h" | 23 #include "views/painter.h" |
| 23 | 24 |
| 24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 25 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" | 26 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
| 26 #else | 27 #else |
| 27 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 28 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 class BubblePositioner; | 31 class BubblePositioner; |
| 31 class CommandUpdater; | 32 class CommandUpdater; |
| 33 class ExtensionAction2; |
| 32 class GURL; | 34 class GURL; |
| 33 class PageAction; | |
| 34 class Profile; | 35 class Profile; |
| 35 | 36 |
| 36 ///////////////////////////////////////////////////////////////////////////// | 37 ///////////////////////////////////////////////////////////////////////////// |
| 37 // | 38 // |
| 38 // LocationBarView class | 39 // LocationBarView class |
| 39 // | 40 // |
| 40 // The LocationBarView class is a View subclass that paints the background | 41 // The LocationBarView class is a View subclass that paints the background |
| 41 // of the URL bar strip and contains its content. | 42 // of the URL bar strip and contains its content. |
| 42 // | 43 // |
| 43 ///////////////////////////////////////////////////////////////////////////// | 44 ///////////////////////////////////////////////////////////////////////////// |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 DISALLOW_COPY_AND_ASSIGN(SecurityImageView); | 342 DISALLOW_COPY_AND_ASSIGN(SecurityImageView); |
| 342 }; | 343 }; |
| 343 | 344 |
| 344 // PageActionImageView is used to display the icon for a given PageAction | 345 // PageActionImageView is used to display the icon for a given PageAction |
| 345 // and notify the extension when the icon is clicked. | 346 // and notify the extension when the icon is clicked. |
| 346 class PageActionImageView : public LocationBarImageView, | 347 class PageActionImageView : public LocationBarImageView, |
| 347 public ImageLoadingTracker::Observer { | 348 public ImageLoadingTracker::Observer { |
| 348 public: | 349 public: |
| 349 PageActionImageView(LocationBarView* owner, | 350 PageActionImageView(LocationBarView* owner, |
| 350 Profile* profile, | 351 Profile* profile, |
| 351 const ExtensionAction* page_action, | 352 ExtensionAction2* page_action, |
| 352 const BubblePositioner* bubble_positioner); | 353 const BubblePositioner* bubble_positioner); |
| 353 virtual ~PageActionImageView(); | 354 virtual ~PageActionImageView(); |
| 354 | 355 |
| 355 const ExtensionActionState* GetPageActionState(); | 356 ExtensionAction2* page_action() { return page_action_; } |
| 357 |
| 358 int current_tab_id() { return current_tab_id_; } |
| 356 | 359 |
| 357 // Overridden from view for the mouse hovering. | 360 // Overridden from view for the mouse hovering. |
| 358 virtual bool OnMousePressed(const views::MouseEvent& event); | 361 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 359 | 362 |
| 360 // Overridden from LocationBarImageView. | 363 // Overridden from LocationBarImageView. |
| 361 virtual void ShowInfoBubble(); | 364 virtual void ShowInfoBubble(); |
| 362 virtual void Paint(gfx::Canvas* canvas); | |
| 363 | 365 |
| 364 // Overridden from ImageLoadingTracker. | 366 // Overridden from ImageLoadingTracker. |
| 365 virtual void OnImageLoaded(SkBitmap* image, size_t index); | 367 virtual void OnImageLoaded(SkBitmap* image, size_t index); |
| 366 | 368 |
| 367 // Called to notify the PageAction that it should determine whether to be | 369 // Called to notify the PageAction that it should determine whether to be |
| 368 // visible or hidden. |contents| is the TabContents that is active, |url| | 370 // visible or hidden. |contents| is the TabContents that is active, |url| |
| 369 // is the current page URL. | 371 // is the current page URL. |
| 370 void UpdateVisibility(TabContents* contents, const GURL& url); | 372 void UpdateVisibility(TabContents* contents, const GURL& url); |
| 371 | 373 |
| 372 private: | 374 private: |
| 373 // The location bar view that owns us. | 375 // The location bar view that owns us. |
| 374 LocationBarView* owner_; | 376 LocationBarView* owner_; |
| 375 | 377 |
| 376 // The current profile (not owned by us). | 378 // The current profile (not owned by us). |
| 377 Profile* profile_; | 379 Profile* profile_; |
| 378 | 380 |
| 379 // The PageAction that this view represents. The PageAction is not owned by | 381 // The PageAction that this view represents. The PageAction is not owned by |
| 380 // us, it resides in the extension of this particular profile. | 382 // us, it resides in the extension of this particular profile. |
| 381 const ExtensionAction* page_action_; | 383 ExtensionAction2* page_action_; |
| 382 | 384 |
| 383 // The icons representing different states for the page action. | 385 // A cache of bitmaps the page actions might need to show, mapped by path. |
| 384 std::vector<SkBitmap> page_action_icons_; | 386 typedef std::map<std::string, SkBitmap> PageActionMap; |
| 387 PageActionMap page_action_icons_; |
| 385 | 388 |
| 386 // The object that is waiting for the image loading to complete | 389 // The object that is waiting for the image loading to complete |
| 387 // asynchronously. | 390 // asynchronously. |
| 388 ImageLoadingTracker* tracker_; | 391 ImageLoadingTracker* tracker_; |
| 389 | 392 |
| 390 // The tab id we are currently showing the icon for. | 393 // The tab id we are currently showing the icon for. |
| 391 int current_tab_id_; | 394 int current_tab_id_; |
| 392 | 395 |
| 393 // The URL we are currently showing the icon for. | 396 // The URL we are currently showing the icon for. |
| 394 GURL current_url_; | 397 GURL current_url_; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // The positioner that places the omnibox and info bubbles. | 538 // The positioner that places the omnibox and info bubbles. |
| 536 const BubblePositioner* bubble_positioner_; | 539 const BubblePositioner* bubble_positioner_; |
| 537 | 540 |
| 538 // Storage of string needed for accessibility. | 541 // Storage of string needed for accessibility. |
| 539 std::wstring accessible_name_; | 542 std::wstring accessible_name_; |
| 540 | 543 |
| 541 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 544 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
| 542 }; | 545 }; |
| 543 | 546 |
| 544 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ | 547 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ |
| OLD | NEW |