| 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_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 <map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "app/gfx/font.h" | 12 #include "app/gfx/font.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 14 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 15 #include "chrome/browser/extensions/image_loading_tracker.h" | 15 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 16 #include "chrome/browser/location_bar.h" | 16 #include "chrome/browser/location_bar.h" |
| 17 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/toolbar_model.h" | 18 #include "chrome/browser/toolbar_model.h" |
| 19 #include "chrome/browser/views/browser_bubble.h" | 19 #include "chrome/browser/views/browser_bubble.h" |
| 20 #include "chrome/browser/views/extensions/extension_action_context_menu.h" | 20 #include "chrome/browser/views/extensions/extension_action_context_menu.h" |
| 21 #include "chrome/browser/views/extensions/extension_popup.h" |
| 21 #include "chrome/browser/views/info_bubble.h" | 22 #include "chrome/browser/views/info_bubble.h" |
| 22 #include "chrome/common/content_settings_types.h" | 23 #include "chrome/common/content_settings_types.h" |
| 23 #include "chrome/common/notification_observer.h" | 24 #include "chrome/common/notification_observer.h" |
| 24 #include "chrome/common/notification_registrar.h" | 25 #include "chrome/common/notification_registrar.h" |
| 25 #include "gfx/rect.h" | 26 #include "gfx/rect.h" |
| 26 #include "views/controls/image_view.h" | 27 #include "views/controls/image_view.h" |
| 27 #include "views/controls/label.h" | 28 #include "views/controls/label.h" |
| 28 #include "views/controls/native/native_view_host.h" | 29 #include "views/controls/native/native_view_host.h" |
| 29 #include "views/painter.h" | 30 #include "views/painter.h" |
| 30 | 31 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // caller maintains ownership of this and must ensure it's kept alive. | 403 // caller maintains ownership of this and must ensure it's kept alive. |
| 403 const BubblePositioner* bubble_positioner_; | 404 const BubblePositioner* bubble_positioner_; |
| 404 | 405 |
| 405 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); | 406 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); |
| 406 }; | 407 }; |
| 407 typedef std::vector<ContentSettingImageView*> ContentSettingViews; | 408 typedef std::vector<ContentSettingImageView*> ContentSettingViews; |
| 408 | 409 |
| 409 // PageActionImageView is used to display the icon for a given PageAction | 410 // PageActionImageView is used to display the icon for a given PageAction |
| 410 // and notify the extension when the icon is clicked. | 411 // and notify the extension when the icon is clicked. |
| 411 class PageActionImageView : public LocationBarImageView, | 412 class PageActionImageView : public LocationBarImageView, |
| 412 public ImageLoadingTracker::Observer, | 413 public ImageLoadingTracker::Observer, |
| 413 public NotificationObserver, | 414 public ExtensionActionContextMenuModel::MenuDelegate, |
| 414 public BrowserBubble::Delegate { | 415 public ExtensionPopup::Observer { |
| 415 public: | 416 public: |
| 416 PageActionImageView(LocationBarView* owner, | 417 PageActionImageView(LocationBarView* owner, |
| 417 Profile* profile, | 418 Profile* profile, |
| 418 ExtensionAction* page_action, | 419 ExtensionAction* page_action, |
| 419 const BubblePositioner* bubble_positioner); | 420 const BubblePositioner* bubble_positioner); |
| 420 virtual ~PageActionImageView(); | 421 virtual ~PageActionImageView(); |
| 421 | 422 |
| 422 ExtensionAction* page_action() { return page_action_; } | 423 ExtensionAction* page_action() { return page_action_; } |
| 423 | 424 |
| 424 int current_tab_id() { return current_tab_id_; } | 425 int current_tab_id() { return current_tab_id_; } |
| 425 | 426 |
| 426 void set_preview_enabled(bool preview_enabled) { | 427 void set_preview_enabled(bool preview_enabled) { |
| 427 preview_enabled_ = preview_enabled; | 428 preview_enabled_ = preview_enabled; |
| 428 } | 429 } |
| 429 | 430 |
| 430 // Overridden from view. | 431 // Overridden from view. |
| 431 virtual void OnMouseMoved(const views::MouseEvent& event); | 432 virtual void OnMouseMoved(const views::MouseEvent& event); |
| 432 virtual bool OnMousePressed(const views::MouseEvent& event); | 433 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 433 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | 434 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); |
| 434 | 435 |
| 435 // Overridden from LocationBarImageView. | 436 // Overridden from LocationBarImageView. |
| 436 virtual void ShowInfoBubble(); | 437 virtual void ShowInfoBubble(); |
| 437 | 438 |
| 438 // Overridden from ImageLoadingTracker. | 439 // Overridden from ImageLoadingTracker. |
| 439 virtual void OnImageLoaded(SkBitmap* image, size_t index); | 440 virtual void OnImageLoaded(SkBitmap* image, size_t index); |
| 440 | 441 |
| 441 // Overridden from BrowserBubble::Delegate | 442 // Overridden from ExtensionActionContextMenuModel::MenuDelegate |
| 442 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); | 443 virtual void ShowPopupForDevToolsWindow(Extension* extension, |
| 443 virtual void BubbleLostFocus(BrowserBubble* bubble, | 444 ExtensionAction* extension_action); |
| 444 bool lost_focus_to_child); | 445 |
| 446 // Overriden from ExtensionPopup::Observer |
| 447 virtual void ExtensionPopupClosed(ExtensionPopup* popup); |
| 445 | 448 |
| 446 // Called to notify the PageAction that it should determine whether to be | 449 // Called to notify the PageAction that it should determine whether to be |
| 447 // visible or hidden. |contents| is the TabContents that is active, |url| | 450 // visible or hidden. |contents| is the TabContents that is active, |url| |
| 448 // is the current page URL. | 451 // is the current page URL. |
| 449 void UpdateVisibility(TabContents* contents, const GURL& url); | 452 void UpdateVisibility(TabContents* contents, const GURL& url); |
| 450 | 453 |
| 451 // Either notify listeners or show a popup depending on the page action. | 454 // Either notify listeners or show a popup depending on the page action. |
| 452 void ExecuteAction(int button); | 455 void ExecuteAction(int button, bool inspect_with_devtools); |
| 453 | 456 |
| 454 private: | 457 private: |
| 455 // Hides the active popup, if there is one. | 458 // Hides the active popup, if there is one. |
| 456 void HidePopup(); | 459 void HidePopup(); |
| 457 | 460 |
| 458 // Overridden from NotificationObserver: | |
| 459 virtual void Observe(NotificationType type, | |
| 460 const NotificationSource& source, | |
| 461 const NotificationDetails& details); | |
| 462 | |
| 463 // The location bar view that owns us. | 461 // The location bar view that owns us. |
| 464 LocationBarView* owner_; | 462 LocationBarView* owner_; |
| 465 | 463 |
| 466 // The current profile (not owned by us). | 464 // The current profile (not owned by us). |
| 467 Profile* profile_; | 465 Profile* profile_; |
| 468 | 466 |
| 469 // The PageAction that this view represents. The PageAction is not owned by | 467 // The PageAction that this view represents. The PageAction is not owned by |
| 470 // us, it resides in the extension of this particular profile. | 468 // us, it resides in the extension of this particular profile. |
| 471 ExtensionAction* page_action_; | 469 ExtensionAction* page_action_; |
| 472 | 470 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 490 // The string to show for a tooltip; | 488 // The string to show for a tooltip; |
| 491 std::string tooltip_; | 489 std::string tooltip_; |
| 492 | 490 |
| 493 // This is used for post-install visual feedback. The page_action icon | 491 // This is used for post-install visual feedback. The page_action icon |
| 494 // is briefly shown even if it hasn't been enabled by it's extension. | 492 // is briefly shown even if it hasn't been enabled by it's extension. |
| 495 bool preview_enabled_; | 493 bool preview_enabled_; |
| 496 | 494 |
| 497 // The current popup and the button it came from. NULL if no popup. | 495 // The current popup and the button it came from. NULL if no popup. |
| 498 ExtensionPopup* popup_; | 496 ExtensionPopup* popup_; |
| 499 | 497 |
| 500 ScopedRunnableMethodFactory<PageActionImageView> method_factory_; | |
| 501 | |
| 502 NotificationRegistrar registrar_; | |
| 503 | |
| 504 DISALLOW_COPY_AND_ASSIGN(PageActionImageView); | 498 DISALLOW_COPY_AND_ASSIGN(PageActionImageView); |
| 505 }; | 499 }; |
| 506 friend class PageActionImageView; | 500 friend class PageActionImageView; |
| 507 | 501 |
| 508 class PageActionWithBadgeView; | 502 class PageActionWithBadgeView; |
| 509 friend class PageActionWithBadgeView; | 503 friend class PageActionWithBadgeView; |
| 510 typedef std::vector<PageActionWithBadgeView*> PageActionViews; | 504 typedef std::vector<PageActionWithBadgeView*> PageActionViews; |
| 511 | 505 |
| 512 // Both Layout and OnChanged call into this. This updates the contents | 506 // Both Layout and OnChanged call into this. This updates the contents |
| 513 // of the 3 views: selected_keyword, keyword_hint and type_search_view. If | 507 // of the 3 views: selected_keyword, keyword_hint and type_search_view. If |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // The positioner that places the omnibox and info bubbles. | 643 // The positioner that places the omnibox and info bubbles. |
| 650 const BubblePositioner* bubble_positioner_; | 644 const BubblePositioner* bubble_positioner_; |
| 651 | 645 |
| 652 // Storage of string needed for accessibility. | 646 // Storage of string needed for accessibility. |
| 653 std::wstring accessible_name_; | 647 std::wstring accessible_name_; |
| 654 | 648 |
| 655 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 649 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
| 656 }; | 650 }; |
| 657 | 651 |
| 658 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ | 652 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ |
| OLD | NEW |