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/extension_context_menu_model.h" |
15 #include "chrome/browser/extensions/image_loading_tracker.h" | 16 #include "chrome/browser/extensions/image_loading_tracker.h" |
16 #include "chrome/browser/location_bar.h" | 17 #include "chrome/browser/location_bar.h" |
17 #include "chrome/browser/tab_contents/tab_contents.h" | 18 #include "chrome/browser/tab_contents/tab_contents.h" |
18 #include "chrome/browser/toolbar_model.h" | 19 #include "chrome/browser/toolbar_model.h" |
19 #include "chrome/browser/views/browser_bubble.h" | 20 #include "chrome/browser/views/browser_bubble.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/extensions/extension_popup.h" |
22 #include "chrome/browser/views/info_bubble.h" | 22 #include "chrome/browser/views/info_bubble.h" |
23 #include "chrome/common/content_settings_types.h" | 23 #include "chrome/common/content_settings_types.h" |
24 #include "chrome/common/notification_observer.h" | 24 #include "chrome/common/notification_observer.h" |
25 #include "chrome/common/notification_registrar.h" | 25 #include "chrome/common/notification_registrar.h" |
26 #include "gfx/rect.h" | 26 #include "gfx/rect.h" |
27 #include "views/controls/image_view.h" | 27 #include "views/controls/image_view.h" |
28 #include "views/controls/label.h" | 28 #include "views/controls/label.h" |
| 29 #include "views/controls/menu/menu_2.h" |
29 #include "views/controls/native/native_view_host.h" | 30 #include "views/controls/native/native_view_host.h" |
30 #include "views/painter.h" | 31 #include "views/painter.h" |
31 | 32 |
32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
33 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" | 34 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
34 #else | 35 #else |
35 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 36 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
36 #endif | 37 #endif |
37 | 38 |
| 39 class Browser; |
38 class BubblePositioner; | 40 class BubblePositioner; |
39 class CommandUpdater; | 41 class CommandUpdater; |
40 class ContentSettingImageModel; | 42 class ContentSettingImageModel; |
41 class ExtensionAction; | 43 class ExtensionAction; |
42 class ExtensionPopup; | 44 class ExtensionPopup; |
43 class GURL; | 45 class GURL; |
44 class Profile; | 46 class Profile; |
45 | 47 |
46 ///////////////////////////////////////////////////////////////////////////// | 48 ///////////////////////////////////////////////////////////////////////////// |
47 // | 49 // |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Returns the appropriate color for the desired kind, based on the user's | 97 // Returns the appropriate color for the desired kind, based on the user's |
96 // system theme. | 98 // system theme. |
97 static SkColor GetColor(bool is_secure, ColorKind kind); | 99 static SkColor GetColor(bool is_secure, ColorKind kind); |
98 | 100 |
99 // Updates the location bar. We also reset the bar's permanent text and | 101 // Updates the location bar. We also reset the bar's permanent text and |
100 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore | 102 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore |
101 // saved state that the tab holds. | 103 // saved state that the tab holds. |
102 void Update(const TabContents* tab_for_state_restoring); | 104 void Update(const TabContents* tab_for_state_restoring); |
103 | 105 |
104 void SetProfile(Profile* profile); | 106 void SetProfile(Profile* profile); |
105 Profile* profile() { return profile_; } | 107 Profile* profile() const { return profile_; } |
106 | 108 |
107 // Returns the current TabContents. | 109 // Returns the current TabContents. |
108 TabContents* GetTabContents() const; | 110 TabContents* GetTabContents() const; |
109 | 111 |
110 // Sets |preview_enabled| for the PageAction View associated with this | 112 // Sets |preview_enabled| for the PageAction View associated with this |
111 // |page_action|. If |preview_enabled| is true, the view will display the | 113 // |page_action|. If |preview_enabled| is true, the view will display the |
112 // PageActions icon even though it has not been activated by the extension. | 114 // PageActions icon even though it has not been activated by the extension. |
113 // This is used by the ExtensionInstalledBubble to preview what the icon | 115 // This is used by the ExtensionInstalledBubble to preview what the icon |
114 // will look like for the user upon installation of the extension. | 116 // will look like for the user upon installation of the extension. |
115 void SetPreviewEnabledPageAction(ExtensionAction *page_action, | 117 void SetPreviewEnabledPageAction(ExtensionAction *page_action, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 const BubblePositioner* bubble_positioner_; | 406 const BubblePositioner* bubble_positioner_; |
405 | 407 |
406 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); | 408 DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); |
407 }; | 409 }; |
408 typedef std::vector<ContentSettingImageView*> ContentSettingViews; | 410 typedef std::vector<ContentSettingImageView*> ContentSettingViews; |
409 | 411 |
410 // PageActionImageView is used to display the icon for a given PageAction | 412 // PageActionImageView is used to display the icon for a given PageAction |
411 // and notify the extension when the icon is clicked. | 413 // and notify the extension when the icon is clicked. |
412 class PageActionImageView : public LocationBarImageView, | 414 class PageActionImageView : public LocationBarImageView, |
413 public ImageLoadingTracker::Observer, | 415 public ImageLoadingTracker::Observer, |
414 public ExtensionActionContextMenuModel::MenuDelegate, | 416 public ExtensionContextMenuModel::PopupDelegate, |
415 public ExtensionPopup::Observer { | 417 public ExtensionPopup::Observer { |
416 public: | 418 public: |
417 PageActionImageView(LocationBarView* owner, | 419 PageActionImageView(LocationBarView* owner, |
418 Profile* profile, | 420 Profile* profile, |
419 ExtensionAction* page_action, | 421 ExtensionAction* page_action, |
420 const BubblePositioner* bubble_positioner); | 422 const BubblePositioner* bubble_positioner); |
421 virtual ~PageActionImageView(); | 423 virtual ~PageActionImageView(); |
422 | 424 |
423 ExtensionAction* page_action() { return page_action_; } | 425 ExtensionAction* page_action() { return page_action_; } |
424 | 426 |
425 int current_tab_id() { return current_tab_id_; } | 427 int current_tab_id() { return current_tab_id_; } |
426 | 428 |
427 void set_preview_enabled(bool preview_enabled) { | 429 void set_preview_enabled(bool preview_enabled) { |
428 preview_enabled_ = preview_enabled; | 430 preview_enabled_ = preview_enabled; |
429 } | 431 } |
430 | 432 |
431 // Overridden from view. | 433 // Overridden from view. |
432 virtual void OnMouseMoved(const views::MouseEvent& event); | 434 virtual void OnMouseMoved(const views::MouseEvent& event); |
433 virtual bool OnMousePressed(const views::MouseEvent& event); | 435 virtual bool OnMousePressed(const views::MouseEvent& event); |
434 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | 436 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); |
435 | 437 |
436 // Overridden from LocationBarImageView. | 438 // Overridden from LocationBarImageView. |
437 virtual void ShowInfoBubble(); | 439 virtual void ShowInfoBubble(); |
438 | 440 |
439 // Overridden from ImageLoadingTracker. | 441 // Overridden from ImageLoadingTracker. |
440 virtual void OnImageLoaded(SkBitmap* image, size_t index); | 442 virtual void OnImageLoaded(SkBitmap* image, size_t index); |
441 | 443 |
442 // Overridden from ExtensionActionContextMenuModel::MenuDelegate | 444 // Overridden from ExtensionContextMenuModelModel::Delegate |
443 virtual void ShowPopupForDevToolsWindow(Extension* extension, | 445 virtual void InspectPopup(ExtensionAction* action); |
444 ExtensionAction* extension_action); | |
445 | 446 |
446 // Overriden from ExtensionPopup::Observer | 447 // Overriden from ExtensionPopup::Observer |
447 virtual void ExtensionPopupClosed(ExtensionPopup* popup); | 448 virtual void ExtensionPopupClosed(ExtensionPopup* popup); |
448 | 449 |
449 // Called to notify the PageAction that it should determine whether to be | 450 // Called to notify the PageAction that it should determine whether to be |
450 // visible or hidden. |contents| is the TabContents that is active, |url| | 451 // visible or hidden. |contents| is the TabContents that is active, |url| |
451 // is the current page URL. | 452 // is the current page URL. |
452 void UpdateVisibility(TabContents* contents, const GURL& url); | 453 void UpdateVisibility(TabContents* contents, const GURL& url); |
453 | 454 |
454 // Either notify listeners or show a popup depending on the page action. | 455 // Either notify listeners or show a popup depending on the page action. |
(...skipping 11 matching lines...) Expand all Loading... |
466 | 467 |
467 // The PageAction that this view represents. The PageAction is not owned by | 468 // The PageAction that this view represents. The PageAction is not owned by |
468 // us, it resides in the extension of this particular profile. | 469 // us, it resides in the extension of this particular profile. |
469 ExtensionAction* page_action_; | 470 ExtensionAction* page_action_; |
470 | 471 |
471 // A cache of bitmaps the page actions might need to show, mapped by path. | 472 // A cache of bitmaps the page actions might need to show, mapped by path. |
472 typedef std::map<std::string, SkBitmap> PageActionMap; | 473 typedef std::map<std::string, SkBitmap> PageActionMap; |
473 PageActionMap page_action_icons_; | 474 PageActionMap page_action_icons_; |
474 | 475 |
475 // The context menu for this page action. | 476 // The context menu for this page action. |
476 scoped_ptr<ExtensionActionContextMenu> context_menu_; | 477 scoped_ptr<ExtensionContextMenuModel> context_menu_contents_; |
| 478 scoped_ptr<views::Menu2> context_menu_menu_; |
477 | 479 |
478 // The object that is waiting for the image loading to complete | 480 // The object that is waiting for the image loading to complete |
479 // asynchronously. | 481 // asynchronously. |
480 ImageLoadingTracker* tracker_; | 482 ImageLoadingTracker* tracker_; |
481 | 483 |
482 // The tab id we are currently showing the icon for. | 484 // The tab id we are currently showing the icon for. |
483 int current_tab_id_; | 485 int current_tab_id_; |
484 | 486 |
485 // The URL we are currently showing the icon for. | 487 // The URL we are currently showing the icon for. |
486 GURL current_url_; | 488 GURL current_url_; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 bool ToggleVisibility(bool new_vis, views::View* view); | 567 bool ToggleVisibility(bool new_vis, views::View* view); |
566 | 568 |
567 #if defined(OS_WIN) | 569 #if defined(OS_WIN) |
568 // Helper for the Mouse event handlers that does all the real work. | 570 // Helper for the Mouse event handlers that does all the real work. |
569 void OnMouseEvent(const views::MouseEvent& event, UINT msg); | 571 void OnMouseEvent(const views::MouseEvent& event, UINT msg); |
570 #endif | 572 #endif |
571 | 573 |
572 // Helper to show the first run info bubble. | 574 // Helper to show the first run info bubble. |
573 void ShowFirstRunBubbleInternal(bool use_OEM_bubble); | 575 void ShowFirstRunBubbleInternal(bool use_OEM_bubble); |
574 | 576 |
| 577 // Current browser. Not owned by us. |
| 578 Browser* browser_; |
| 579 |
575 // Current profile. Not owned by us. | 580 // Current profile. Not owned by us. |
576 Profile* profile_; | 581 Profile* profile_; |
577 | 582 |
578 // The Autocomplete Edit field. | 583 // The Autocomplete Edit field. |
579 #if defined(OS_WIN) | 584 #if defined(OS_WIN) |
580 scoped_ptr<AutocompleteEditViewWin> location_entry_; | 585 scoped_ptr<AutocompleteEditViewWin> location_entry_; |
581 #else | 586 #else |
582 scoped_ptr<AutocompleteEditViewGtk> location_entry_; | 587 scoped_ptr<AutocompleteEditViewGtk> location_entry_; |
583 #endif | 588 #endif |
584 | 589 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 // The positioner that places the omnibox and info bubbles. | 648 // The positioner that places the omnibox and info bubbles. |
644 const BubblePositioner* bubble_positioner_; | 649 const BubblePositioner* bubble_positioner_; |
645 | 650 |
646 // Storage of string needed for accessibility. | 651 // Storage of string needed for accessibility. |
647 std::wstring accessible_name_; | 652 std::wstring accessible_name_; |
648 | 653 |
649 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 654 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
650 }; | 655 }; |
651 | 656 |
652 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ | 657 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H_ |
OLD | NEW |