Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_bubble.h" | 5 #include "ash/system/tray/system_tray_bubble.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/session/session_controller.h" | 10 #include "ash/session/session_controller.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 : tray_(tray), | 77 : tray_(tray), |
| 78 bubble_view_(nullptr), | 78 bubble_view_(nullptr), |
| 79 items_(items), | 79 items_(items), |
| 80 bubble_type_(bubble_type), | 80 bubble_type_(bubble_type), |
| 81 autoclose_delay_(0) {} | 81 autoclose_delay_(0) {} |
| 82 | 82 |
| 83 SystemTrayBubble::~SystemTrayBubble() { | 83 SystemTrayBubble::~SystemTrayBubble() { |
| 84 DestroyItemViews(); | 84 DestroyItemViews(); |
| 85 // Reset the host pointer in bubble_view_ in case its destruction is deferred. | 85 // Reset the host pointer in bubble_view_ in case its destruction is deferred. |
| 86 if (bubble_view_) | 86 if (bubble_view_) |
| 87 bubble_view_->reset_delegate(); | 87 bubble_view_->ResetDelegate(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SystemTrayBubble::UpdateView( | 90 void SystemTrayBubble::UpdateView( |
| 91 const std::vector<ash::SystemTrayItem*>& items, | 91 const std::vector<ash::SystemTrayItem*>& items, |
| 92 BubbleType bubble_type) { | 92 BubbleType bubble_type) { |
| 93 std::unique_ptr<ui::Layer> scoped_layer; | 93 std::unique_ptr<ui::Layer> scoped_layer; |
| 94 if (bubble_type != bubble_type_) { | 94 if (bubble_type != bubble_type_) { |
| 95 base::TimeDelta swipe_duration = | 95 base::TimeDelta swipe_duration = |
| 96 base::TimeDelta::FromMilliseconds(kSwipeDelayMS); | 96 base::TimeDelta::FromMilliseconds(kSwipeDelayMS); |
| 97 scoped_layer = bubble_view_->RecreateLayer(); | 97 scoped_layer = bubble_view_->RecreateLayer(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator()); | 176 ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator()); |
| 177 settings.AddObserver( | 177 settings.AddObserver( |
| 178 new AnimationObserverDeleteLayer(scoped_layer.release())); | 178 new AnimationObserverDeleteLayer(scoped_layer.release())); |
| 179 settings.SetTransitionDuration( | 179 settings.SetTransitionDuration( |
| 180 base::TimeDelta::FromMilliseconds(kSwipeDelayMS)); | 180 base::TimeDelta::FromMilliseconds(kSwipeDelayMS)); |
| 181 settings.SetTweenType(gfx::Tween::EASE_OUT); | 181 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 182 new_layer->SetTransform(gfx::Transform()); | 182 new_layer->SetTransform(gfx::Transform()); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | |
| 187 // Update bubble as size might have changed. | |
| 188 bubble_view_->UpdateBubble(); | |
|
yawano
2017/06/26 04:02:30
It is necessary to call here.
TrayBubbleView::Upd
| |
| 186 } | 189 } |
| 187 | 190 |
| 188 void SystemTrayBubble::InitView(views::View* anchor, | 191 void SystemTrayBubble::InitView(views::View* anchor, |
| 189 LoginStatus login_status, | 192 LoginStatus login_status, |
| 190 TrayBubbleView::InitParams* init_params) { | 193 TrayBubbleView::InitParams* init_params) { |
| 191 DCHECK(anchor); | 194 DCHECK(anchor); |
| 192 DCHECK(!bubble_view_); | 195 DCHECK(!bubble_view_); |
| 193 | 196 |
| 194 if (bubble_type_ == BUBBLE_TYPE_DETAILED && | 197 if (bubble_type_ == BUBBLE_TYPE_DETAILED && |
| 195 init_params->max_height < GetDetailedBubbleMaxHeight()) { | 198 init_params->max_height < GetDetailedBubbleMaxHeight()) { |
| 196 init_params->max_height = GetDetailedBubbleMaxHeight(); | 199 init_params->max_height = GetDetailedBubbleMaxHeight(); |
| 197 } | 200 } |
| 198 | 201 |
| 199 init_params->delegate = tray_; | 202 init_params->delegate = tray_; |
| 200 // Place the bubble on same display as this system tray. | 203 // Place the bubble on same display as this system tray. |
| 201 init_params->parent_window = tray_->GetBubbleWindowContainer(); | 204 init_params->parent_window = tray_->GetBubbleWindowContainer(); |
| 202 init_params->anchor_view = anchor; | 205 init_params->anchor_view = anchor; |
| 203 bubble_view_ = new TrayBubbleView(*init_params); | 206 bubble_view_ = new TrayBubbleView(*init_params); |
| 204 UpdateBottomPadding(); | 207 UpdateBottomPadding(); |
| 205 bubble_view_->set_adjust_if_offscreen(false); | 208 bubble_view_->set_adjust_if_offscreen(false); |
| 206 CreateItemViews(login_status); | 209 CreateItemViews(login_status); |
| 207 | 210 |
| 208 if (bubble_view_->CanActivate()) { | 211 if (bubble_view_->CanActivate()) { |
| 209 bubble_view_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 212 bubble_view_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 210 } | 213 } |
| 211 } | 214 } |
| 212 | 215 |
| 213 void SystemTrayBubble::FocusDefaultIfNeeded() { | |
| 214 views::FocusManager* manager = bubble_view_->GetFocusManager(); | |
| 215 if (!manager || manager->GetFocusedView()) | |
| 216 return; | |
| 217 | |
| 218 views::View* view = | |
| 219 manager->GetNextFocusableView(nullptr, nullptr, false, false); | |
| 220 if (view) | |
| 221 view->RequestFocus(); | |
| 222 } | |
| 223 | |
| 224 void SystemTrayBubble::DestroyItemViews() { | 216 void SystemTrayBubble::DestroyItemViews() { |
| 225 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); | 217 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); |
| 226 it != items_.end(); ++it) { | 218 it != items_.end(); ++it) { |
| 227 switch (bubble_type_) { | 219 switch (bubble_type_) { |
| 228 case BUBBLE_TYPE_DEFAULT: | 220 case BUBBLE_TYPE_DEFAULT: |
| 229 (*it)->OnDefaultViewDestroyed(); | 221 (*it)->OnDefaultViewDestroyed(); |
| 230 break; | 222 break; |
| 231 case BUBBLE_TYPE_DETAILED: | 223 case BUBBLE_TYPE_DETAILED: |
| 232 (*it)->OnDetailedViewDestroyed(); | 224 (*it)->OnDetailedViewDestroyed(); |
| 233 break; | 225 break; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 } | 326 } |
| 335 } | 327 } |
| 336 | 328 |
| 337 if (focus_view) { | 329 if (focus_view) { |
| 338 tray_->ActivateBubble(); | 330 tray_->ActivateBubble(); |
| 339 focus_view->RequestFocus(); | 331 focus_view->RequestFocus(); |
| 340 } | 332 } |
| 341 } | 333 } |
| 342 | 334 |
| 343 } // namespace ash | 335 } // namespace ash |
| OLD | NEW |