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

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 9596002: ash uber tray: Make it work in ash_shell, and a couple more fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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
« no previous file with comments | « ash/status_area/status_area_view.cc ('k') | ash/wm/activation_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/system/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell/panel_window.h" 8 #include "ash/shell/panel_window.h"
9 #include "ash/shell_window_ids.h"
9 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/system_tray_item.h" 11 #include "ash/system/tray/system_tray_item.h"
11 #include "ash/system/user/login_status.h" 12 #include "ash/system/user/login_status.h"
12 #include "ash/wm/shadow_types.h" 13 #include "ash/wm/shadow_types.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/views/border.h" 17 #include "ui/views/border.h"
17 #include "ui/views/bubble/bubble_delegate.h" 18 #include "ui/views/bubble/bubble_delegate.h"
18 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
19 #include "ui/views/layout/box_layout.h" 20 #include "ui/views/layout/box_layout.h"
20 #include "ui/views/view.h" 21 #include "ui/views/view.h"
21 22
22 namespace { 23 namespace {
23 24
24 const int kTrayIconHeight = 50; 25 const int kTrayIconHeight = 50;
25 const int kPadding = 5; 26 const int kPadding = 5;
26 27
27 class SystemTrayBubble : public views::BubbleDelegateView { 28 class SystemTrayBubble : public views::BubbleDelegateView {
28 public: 29 public:
29 SystemTrayBubble(ash::SystemTray* tray, 30 SystemTrayBubble(ash::SystemTray* tray,
30 std::vector<ash::SystemTrayItem*>& items, 31 std::vector<ash::SystemTrayItem*>& items,
31 bool detailed) 32 bool detailed)
32 : views::BubbleDelegateView(tray, views::BubbleBorder::BOTTOM_RIGHT), 33 : views::BubbleDelegateView(tray, views::BubbleBorder::BOTTOM_RIGHT),
33 tray_(tray), 34 tray_(tray),
34 items_(items), 35 items_(items),
35 detailed_(detailed) { 36 detailed_(detailed) {
36 set_margin(0); 37 set_margin(0);
38 set_parent_window(ash::Shell::GetInstance()->GetContainer(
39 ash::internal::kShellWindowId_SettingBubbleContainer));
37 } 40 }
38 41
39 virtual ~SystemTrayBubble() { 42 virtual ~SystemTrayBubble() {
40 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); 43 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin();
41 it != items_.end(); 44 it != items_.end();
42 ++it) { 45 ++it) {
43 if (detailed_) 46 if (detailed_)
44 (*it)->DestroyDetailedView(); 47 (*it)->DestroyDetailedView();
45 else 48 else
46 (*it)->DestroyDefaultView(); 49 (*it)->DestroyDefaultView();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (view) 146 if (view)
144 AddChildViewAt(view, 0); 147 AddChildViewAt(view, 0);
145 } 148 }
146 PreferredSizeChanged(); 149 PreferredSizeChanged();
147 } 150 }
148 151
149 void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) { 152 void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) {
150 CHECK(!popup_); 153 CHECK(!popup_);
151 SystemTrayBubble* bubble = new SystemTrayBubble(this, items, detailed); 154 SystemTrayBubble* bubble = new SystemTrayBubble(this, items, detailed);
152 popup_ = views::BubbleDelegateView::CreateBubble(bubble); 155 popup_ = views::BubbleDelegateView::CreateBubble(bubble);
156 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
153 popup_->AddObserver(this); 157 popup_->AddObserver(this);
154 bubble->Show(); 158 bubble->Show();
155 } 159 }
156 160
157 bool SystemTray::OnMousePressed(const views::MouseEvent& event) { 161 bool SystemTray::OnMousePressed(const views::MouseEvent& event) {
158 if (popup_) 162 if (popup_)
159 popup_->Show(); 163 popup_->Show();
160 else 164 else
161 ShowItems(items_, false); 165 ShowItems(items_, false);
162 return true; 166 return true;
163 } 167 }
164 168
165 void SystemTray::OnWidgetClosing(views::Widget* widget) { 169 void SystemTray::OnWidgetClosing(views::Widget* widget) {
166 CHECK_EQ(popup_, widget); 170 CHECK_EQ(popup_, widget);
167 popup_ = NULL; 171 popup_ = NULL;
168 } 172 }
169 173
170 } // namespace ash 174 } // namespace ash
OLDNEW
« no previous file with comments | « ash/status_area/status_area_view.cc ('k') | ash/wm/activation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698