| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_UI_GTK_AVATAR_MENU_BUBBLE_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUBBLE_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUBBLE_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUBBLE_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include <gtk/gtk.h> | 11 #include <gtk/gtk.h> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "chrome/browser/profiles/avatar_menu_model_observer.h" | 16 #include "chrome/browser/profiles/avatar_menu_model_observer.h" |
| 17 #include "chrome/browser/ui/gtk/avatar_menu_item_gtk.h" | 17 #include "chrome/browser/ui/gtk/avatar_menu_item_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 18 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 19 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" |
| 19 #include "ui/base/gtk/gtk_signal.h" | 21 #include "ui/base/gtk/gtk_signal.h" |
| 20 | 22 |
| 21 class AvatarMenuModel; | 23 class AvatarMenuModel; |
| 22 class Browser; | 24 class Browser; |
| 23 class GtkThemeService; | 25 class GtkThemeService; |
| 24 | 26 |
| 25 // This bubble is displayed when the user clicks on the avatar button. | 27 // This bubble is displayed when the user clicks on the avatar button. |
| 26 // It displays a list of profiles and allows users to switch between profiles. | 28 // It displays a list of profiles and allows users to switch between profiles. |
| 27 class AvatarMenuBubbleGtk : public BubbleDelegateGtk, | 29 class AvatarMenuBubbleGtk : public BubbleDelegateGtk, |
| 28 public AvatarMenuModelObserver, | 30 public AvatarMenuModelObserver, |
| 29 public AvatarMenuItemGtk::Delegate { | 31 public AvatarMenuItemGtk::Delegate, |
| 32 public content::NotificationObserver { |
| 30 public: | 33 public: |
| 31 AvatarMenuBubbleGtk(Browser* browser, | 34 AvatarMenuBubbleGtk(Browser* browser, |
| 32 GtkWidget* anchor, | 35 GtkWidget* anchor, |
| 33 BubbleGtk::ArrowLocationGtk arrow, | 36 BubbleGtk::ArrowLocationGtk arrow, |
| 34 const gfx::Rect* rect); | 37 const gfx::Rect* rect); |
| 35 virtual ~AvatarMenuBubbleGtk(); | 38 virtual ~AvatarMenuBubbleGtk(); |
| 36 | 39 |
| 37 // BubbleDelegateGtk implementation. | 40 // BubbleDelegateGtk implementation. |
| 38 virtual void BubbleClosing(BubbleGtk* bubble, | 41 virtual void BubbleClosing(BubbleGtk* bubble, |
| 39 bool closed_by_escape) OVERRIDE; | 42 bool closed_by_escape) OVERRIDE; |
| 40 | 43 |
| 41 // AvatarMenuModelObserver implementation. | 44 // AvatarMenuModelObserver implementation. |
| 42 virtual void OnAvatarMenuModelChanged( | 45 virtual void OnAvatarMenuModelChanged( |
| 43 AvatarMenuModel* avatar_menu_model) OVERRIDE; | 46 AvatarMenuModel* avatar_menu_model) OVERRIDE; |
| 44 | 47 |
| 45 // AvatarMenuItemGtk::Delegate implementation. | 48 // AvatarMenuItemGtk::Delegate implementation. |
| 46 virtual void OpenProfile(size_t profile_index); | 49 virtual void OpenProfile(size_t profile_index) OVERRIDE; |
| 50 virtual void EditProfile(size_t profile_index) OVERRIDE; |
| 47 | 51 |
| 48 virtual void EditProfile(size_t profile_index); | 52 // content::NotificationObserver implementation. |
| 53 virtual void Observe(int type, |
| 54 const content::NotificationSource& source, |
| 55 const content::NotificationDetails& details) OVERRIDE; |
| 49 | 56 |
| 50 private: | 57 private: |
| 51 // Notified when |contents_| is destroyed so we can delete our instance. | 58 // Notified when |contents_| is destroyed so we can delete our instance. |
| 52 CHROMEGTK_CALLBACK_0(AvatarMenuBubbleGtk, void, OnDestroy); | 59 CHROMEGTK_CALLBACK_0(AvatarMenuBubbleGtk, void, OnDestroy); |
| 53 CHROMEGTK_CALLBACK_1(AvatarMenuBubbleGtk, void, OnSizeRequest, | 60 CHROMEGTK_CALLBACK_1(AvatarMenuBubbleGtk, void, OnSizeRequest, |
| 54 GtkRequisition*); | 61 GtkRequisition*); |
| 55 CHROMEGTK_CALLBACK_0(AvatarMenuBubbleGtk, void, OnNewProfileLinkClicked); | 62 CHROMEGTK_CALLBACK_0(AvatarMenuBubbleGtk, void, OnNewProfileLinkClicked); |
| 56 | 63 |
| 57 // Create all widgets in this bubble. | 64 // Create all widgets in this bubble. |
| 58 void InitContents(); | 65 void InitContents(); |
| 59 | 66 |
| 60 // A model of all the profile information to be displayed in the menu. | 67 // A model of all the profile information to be displayed in the menu. |
| 61 scoped_ptr<AvatarMenuModel> avatar_menu_model_; | 68 scoped_ptr<AvatarMenuModel> avatar_menu_model_; |
| 62 | 69 |
| 63 // A weak pointer to the parent widget of all widgets in the bubble. | 70 // A weak pointer to the parent widget of all widgets in the bubble. |
| 64 GtkWidget* contents_; | 71 GtkWidget* contents_; |
| 65 | 72 |
| 66 // A weak pointer to the bubble window. | 73 // A weak pointer to the bubble window. |
| 67 BubbleGtk* bubble_; | 74 BubbleGtk* bubble_; |
| 68 | 75 |
| 69 // A weak pointer to the theme service. | 76 // A weak pointer to the theme service. |
| 70 GtkThemeService* theme_service_; | 77 GtkThemeService* theme_service_; |
| 71 | 78 |
| 79 // A weak pointer to the new proifle link to keep its theme information |
| 80 // updated. |
| 81 GtkWidget* new_profile_link_; |
| 82 |
| 72 // A vector of all profile items in the menu. | 83 // A vector of all profile items in the menu. |
| 73 std::vector<AvatarMenuItemGtk*> items_; | 84 std::vector<AvatarMenuItemGtk*> items_; |
| 74 | 85 |
| 75 // The minimum width to display the bubble. This is used to prevent the bubble | 86 // The minimum width to display the bubble. This is used to prevent the bubble |
| 76 // from automatically reducing its size when hovering over a profile item. | 87 // from automatically reducing its size when hovering over a profile item. |
| 77 int minimum_width_; | 88 int minimum_width_; |
| 78 | 89 |
| 90 content::NotificationRegistrar registrar_; |
| 91 |
| 79 DISALLOW_COPY_AND_ASSIGN(AvatarMenuBubbleGtk); | 92 DISALLOW_COPY_AND_ASSIGN(AvatarMenuBubbleGtk); |
| 80 }; | 93 }; |
| 81 | 94 |
| 82 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUBBLE_GTK_H_ | 95 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUBBLE_GTK_H_ |
| OLD | NEW |