| 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 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" | 14 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/image_utils.h" | 16 #import "chrome/browser/ui/cocoa/image_utils.h" |
| 17 #import "chrome/browser/ui/cocoa/menu_controller.h" | 17 #import "chrome/browser/ui/cocoa/menu_controller.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "content/common/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/base/l10n/l10n_util_mac.h" | 23 #include "ui/base/l10n/l10n_util_mac.h" |
| 24 #include "ui/gfx/image/image.h" | 24 #include "ui/gfx/image/image.h" |
| 25 #include "ui/gfx/mac/nsimage_cache.h" | 25 #include "ui/gfx/mac/nsimage_cache.h" |
| 26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 27 | 27 |
| 28 @interface AvatarButtonController (Private) | 28 @interface AvatarButtonController (Private) |
| 29 - (void)setOpenMenuOnClick:(BOOL)flag; | 29 - (void)setOpenMenuOnClick:(BOOL)flag; |
| 30 - (IBAction)buttonClicked:(id)sender; | 30 - (IBAction)buttonClicked:(id)sender; |
| 31 - (void)bubbleWillClose:(NSNotification*)notif; | 31 - (void)bubbleWillClose:(NSNotification*)notif; |
| 32 - (NSImage*)compositeImageWithShadow:(NSImage*)image; | 32 - (NSImage*)compositeImageWithShadow:(NSImage*)image; |
| 33 - (void)updateAvatar; | 33 - (void)updateAvatar; |
| 34 - (void)addOrRemoveButtonIfNecessary; | 34 - (void)addOrRemoveButtonIfNecessary; |
| 35 @end | 35 @end |
| 36 | 36 |
| 37 namespace AvatarButtonControllerInternal { | 37 namespace AvatarButtonControllerInternal { |
| 38 | 38 |
| 39 class Observer : public content::NotificationObserver { | 39 class Observer : public content::NotificationObserver { |
| 40 public: | 40 public: |
| 41 Observer(AvatarButtonController* button) : button_(button) { | 41 Observer(AvatarButtonController* button) : button_(button) { |
| 42 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 42 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 43 NotificationService::AllSources()); | 43 content::NotificationService::AllSources()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // NotificationObserver: | 46 // NotificationObserver: |
| 47 void Observe(int type, | 47 void Observe(int type, |
| 48 const content::NotificationSource& source, | 48 const content::NotificationSource& source, |
| 49 const content::NotificationDetails& details) OVERRIDE { | 49 const content::NotificationDetails& details) OVERRIDE { |
| 50 switch (type) { | 50 switch (type) { |
| 51 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 51 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
| 52 [button_ updateAvatar]; | 52 [button_ updateAvatar]; |
| 53 [button_ addOrRemoveButtonIfNecessary]; | 53 [button_ addOrRemoveButtonIfNecessary]; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 [static_cast<BrowserWindowController*>(wc) layoutSubviews]; | 237 [static_cast<BrowserWindowController*>(wc) layoutSubviews]; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Testing ///////////////////////////////////////////////////////////////////// | 240 // Testing ///////////////////////////////////////////////////////////////////// |
| 241 | 241 |
| 242 - (AvatarMenuBubbleController*)menuController { | 242 - (AvatarMenuBubbleController*)menuController { |
| 243 return menuController_; | 243 return menuController_; |
| 244 } | 244 } |
| 245 | 245 |
| 246 @end | 246 @end |
| OLD | NEW |