Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/ui/gtk/avatar_menu_button_gtk.cc

Issue 9500003: Add a button to exit managed mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" 5 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/command_updater.h"
10 #include "chrome/browser/managed_mode.h"
8 #include "chrome/browser/profiles/profile_metrics.h" 11 #include "chrome/browser/profiles/profile_metrics.h"
9 #include "chrome/browser/profiles/profile_info_util.h" 12 #include "chrome/browser/profiles/profile_info_util.h"
13 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" 14 #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h"
11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 15 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
12 #include "ui/gfx/gtk_util.h" 16 #include "ui/gfx/gtk_util.h"
13 17
14 AvatarMenuButtonGtk::AvatarMenuButtonGtk(Browser* browser) 18 AvatarMenuButtonGtk::AvatarMenuButtonGtk(Browser* browser)
15 : image_(NULL), 19 : image_(NULL),
16 browser_(browser), 20 browser_(browser),
17 arrow_location_(BubbleGtk::ARROW_LOCATION_TOP_LEFT), 21 arrow_location_(BubbleGtk::ARROW_LOCATION_TOP_LEFT),
18 is_gaia_picture_(false), 22 is_gaia_picture_(false),
19 old_height_(0) { 23 old_height_(0) {
(...skipping 19 matching lines...) Expand all
39 icon_.reset(new gfx::Image(image)); 43 icon_.reset(new gfx::Image(image));
40 is_gaia_picture_ = is_gaia_picture; 44 is_gaia_picture_ = is_gaia_picture;
41 UpdateButtonIcon(); 45 UpdateButtonIcon();
42 } 46 }
43 47
44 gboolean AvatarMenuButtonGtk::OnButtonPressed(GtkWidget* widget, 48 gboolean AvatarMenuButtonGtk::OnButtonPressed(GtkWidget* widget,
45 GdkEventButton* event) { 49 GdkEventButton* event) {
46 if (event->button != 1) 50 if (event->button != 1)
47 return FALSE; 51 return FALSE;
48 52
53 if (ManagedMode::IsInManagedMode()) {
54 ManagedMode::LeaveManagedMode();
55 return TRUE;
56 }
57
49 ShowAvatarBubble(); 58 ShowAvatarBubble();
50 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); 59 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE);
51 return TRUE; 60 return TRUE;
52 } 61 }
53 62
54 void AvatarMenuButtonGtk::OnSizeAllocate(GtkWidget* widget, 63 void AvatarMenuButtonGtk::OnSizeAllocate(GtkWidget* widget,
55 GtkAllocation* allocation) { 64 GtkAllocation* allocation) {
56 if (allocation->height != old_height_) 65 if (allocation->height != old_height_)
57 UpdateButtonIcon(); 66 UpdateButtonIcon();
58 } 67 }
59 68
60 void AvatarMenuButtonGtk::ShowAvatarBubble() { 69 void AvatarMenuButtonGtk::ShowAvatarBubble() {
70 DCHECK(browser_->command_updater()->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
61 // Only show the avatar bubble if the avatar button is in the title bar. 71 // Only show the avatar bubble if the avatar button is in the title bar.
62 if (gtk_widget_get_parent_window(widget_.get())) 72 if (gtk_widget_get_parent_window(widget_.get()))
63 new AvatarMenuBubbleGtk(browser_, widget_.get(), arrow_location_, NULL); 73 new AvatarMenuBubbleGtk(browser_, widget_.get(), arrow_location_, NULL);
64 } 74 }
65 75
66 void AvatarMenuButtonGtk::UpdateButtonIcon() { 76 void AvatarMenuButtonGtk::UpdateButtonIcon() {
67 if (!icon_.get()) 77 if (!icon_.get())
68 return; 78 return;
69 79
70 GtkAllocation allocation; 80 GtkAllocation allocation;
71 gtk_widget_get_allocation(widget(), &allocation); 81 gtk_widget_get_allocation(widget(), &allocation);
72 old_height_ = allocation.height; 82 old_height_ = allocation.height;
73 gfx::Image icon = profiles::GetAvatarIconForTitleBar(*icon_, is_gaia_picture_, 83 gfx::Image icon = profiles::GetAvatarIconForTitleBar(*icon_, is_gaia_picture_,
74 profiles::kAvatarIconWidth, old_height_); 84 profiles::kAvatarIconWidth, old_height_);
75 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), icon.ToGdkPixbuf()); 85 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), icon.ToGdkPixbuf());
76 gtk_misc_set_alignment(GTK_MISC(image_), 0.0, 1.0); 86 gtk_misc_set_alignment(GTK_MISC(image_), 0.0, 1.0);
77 gtk_widget_set_size_request(image_, -1, 0); 87 gtk_widget_set_size_request(image_, -1, 0);
78 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698