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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 2186913003: Eliminate ash::Shell access in ShelfView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « ash/mus/bridge/wm_shell_mus.cc ('k') | no next file » | 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/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/aura/wm_window_aura.h" 10 #include "ash/aura/wm_window_aura.h"
11 #include "ash/common/ash_constants.h" 11 #include "ash/common/ash_constants.h"
12 #include "ash/common/ash_switches.h" 12 #include "ash/common/ash_switches.h"
13 #include "ash/common/shelf/app_list_button.h" 13 #include "ash/common/shelf/app_list_button.h"
14 #include "ash/common/shelf/overflow_bubble.h" 14 #include "ash/common/shelf/overflow_bubble.h"
15 #include "ash/common/shelf/overflow_bubble_view.h" 15 #include "ash/common/shelf/overflow_bubble_view.h"
16 #include "ash/common/shelf/overflow_button.h" 16 #include "ash/common/shelf/overflow_button.h"
17 #include "ash/common/shelf/shelf_button.h" 17 #include "ash/common/shelf/shelf_button.h"
18 #include "ash/common/shelf/shelf_constants.h" 18 #include "ash/common/shelf/shelf_constants.h"
19 #include "ash/common/shelf/shelf_delegate.h" 19 #include "ash/common/shelf/shelf_delegate.h"
20 #include "ash/common/shelf/shelf_menu_model.h" 20 #include "ash/common/shelf/shelf_menu_model.h"
21 #include "ash/common/shelf/shelf_model.h" 21 #include "ash/common/shelf/shelf_model.h"
22 #include "ash/common/shelf/wm_shelf.h"
22 #include "ash/common/shell_delegate.h" 23 #include "ash/common/shell_delegate.h"
23 #include "ash/common/wm/root_window_finder.h" 24 #include "ash/common/wm/root_window_finder.h"
24 #include "ash/common/wm_shell.h" 25 #include "ash/common/wm_shell.h"
25 #include "ash/drag_drop/drag_image_view.h" 26 #include "ash/drag_drop/drag_image_view.h"
26 #include "ash/scoped_target_root_window.h" 27 #include "ash/scoped_target_root_window.h"
27 #include "ash/shelf/shelf.h" 28 #include "ash/shelf/shelf.h"
28 #include "ash/shelf/shelf_icon_observer.h" 29 #include "ash/shelf/shelf_icon_observer.h"
29 #include "ash/shelf/shelf_widget.h" 30 #include "ash/shelf/shelf_widget.h"
30 #include "ash/shell.h"
31 #include "base/auto_reset.h" 31 #include "base/auto_reset.h"
32 #include "base/metrics/histogram.h" 32 #include "base/metrics/histogram.h"
33 #include "grit/ash_strings.h" 33 #include "grit/ash_strings.h"
34 #include "ui/accessibility/ax_view_state.h" 34 #include "ui/accessibility/ax_view_state.h"
35 #include "ui/aura/client/screen_position_client.h" 35 #include "ui/aura/client/screen_position_client.h"
36 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
37 #include "ui/aura/window_event_dispatcher.h" 37 #include "ui/aura/window_event_dispatcher.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/models/simple_menu_model.h" 39 #include "ui/base/models/simple_menu_model.h"
40 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 new ShelfView(model_, delegate_, wm_shelf_, shelf_); 1373 new ShelfView(model_, delegate_, wm_shelf_, shelf_);
1374 overflow_view->overflow_mode_ = true; 1374 overflow_view->overflow_mode_ = true;
1375 overflow_view->Init(); 1375 overflow_view->Init();
1376 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); 1376 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get());
1377 overflow_view->OnShelfAlignmentChanged(); 1377 overflow_view->OnShelfAlignmentChanged();
1378 overflow_view->main_shelf_ = this; 1378 overflow_view->main_shelf_ = this;
1379 UpdateOverflowRange(overflow_view); 1379 UpdateOverflowRange(overflow_view);
1380 1380
1381 overflow_bubble_->Show(overflow_button_, overflow_view); 1381 overflow_bubble_->Show(overflow_button_, overflow_view);
1382 1382
1383 Shell::GetInstance()->UpdateShelfVisibility(); 1383 wm_shelf_->UpdateVisibilityState();
msw 2016/07/27 22:45:11 q: ok to only update this shelf, not all (like She
James Cook 2016/07/27 22:54:01 Yes. The overflow bubble is only associated with t
1384 } 1384 }
1385 1385
1386 void ShelfView::OnFadeOutAnimationEnded() { 1386 void ShelfView::OnFadeOutAnimationEnded() {
1387 AnimateToIdealBounds(); 1387 AnimateToIdealBounds();
1388 StartFadeInLastVisibleItem(); 1388 StartFadeInLastVisibleItem();
1389 } 1389 }
1390 1390
1391 void ShelfView::StartFadeInLastVisibleItem() { 1391 void ShelfView::StartFadeInLastVisibleItem() {
1392 // If overflow button is visible and there is a valid new last item, fading 1392 // If overflow button is visible and there is a valid new last item, fading
1393 // the new last item in after sliding animation is finished. 1393 // the new last item in after sliding animation is finished.
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 return true; 1774 return true;
1775 } 1775 }
1776 1776
1777 void ShelfView::ShowContextMenuForView(views::View* source, 1777 void ShelfView::ShowContextMenuForView(views::View* source,
1778 const gfx::Point& point, 1778 const gfx::Point& point,
1779 ui::MenuSourceType source_type) { 1779 ui::MenuSourceType source_type) {
1780 last_pressed_index_ = -1; 1780 last_pressed_index_ = -1;
1781 1781
1782 const ShelfItem* item = ShelfItemForView(source); 1782 const ShelfItem* item = ShelfItemForView(source);
1783 if (!item) { 1783 if (!item) {
1784 Shell::GetInstance()->ShowContextMenu(point, source_type); 1784 WmShell::Get()->ShowContextMenu(point, source_type);
1785 return; 1785 return;
1786 } 1786 }
1787 1787
1788 std::unique_ptr<ui::MenuModel> context_menu_model( 1788 std::unique_ptr<ui::MenuModel> context_menu_model(
1789 WmShell::Get()->delegate()->CreateContextMenu(wm_shelf_, item)); 1789 WmShell::Get()->delegate()->CreateContextMenu(wm_shelf_, item));
1790 if (!context_menu_model) 1790 if (!context_menu_model)
1791 return; 1791 return;
1792 1792
1793 context_menu_id_ = item ? item->id : 0; 1793 context_menu_id_ = item ? item->id : 0;
1794 ShowMenu(std::move(context_menu_model), source, point, true, source_type, 1794 ShowMenu(std::move(context_menu_model), source, point, true, source_type,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 closing_event_time_ = launcher_menu_runner_->closing_event_time(); 1854 closing_event_time_ = launcher_menu_runner_->closing_event_time();
1855 1855
1856 if (ink_drop) 1856 if (ink_drop)
1857 ink_drop->AnimateToState(views::InkDropState::DEACTIVATED); 1857 ink_drop->AnimateToState(views::InkDropState::DEACTIVATED);
1858 1858
1859 launcher_menu_runner_.reset(); 1859 launcher_menu_runner_.reset();
1860 menu_model_adapter_.reset(); 1860 menu_model_adapter_.reset();
1861 menu_model_.reset(); 1861 menu_model_.reset();
1862 scoped_target_root_window_.reset(); 1862 scoped_target_root_window_.reset();
1863 1863
1864 Shell::GetInstance()->UpdateShelfVisibility(); 1864 // Auto-hide or alignment might have changed, but only for this shelf.
1865 wm_shelf_->UpdateVisibilityState();
1865 } 1866 }
1866 1867
1867 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { 1868 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) {
1868 FOR_EACH_OBSERVER(ShelfIconObserver, observers_, 1869 FOR_EACH_OBSERVER(ShelfIconObserver, observers_,
1869 OnShelfIconPositionsChanged()); 1870 OnShelfIconPositionsChanged());
1870 PreferredSizeChanged(); 1871 PreferredSizeChanged();
1871 } 1872 }
1872 1873
1873 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { 1874 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
1874 if (snap_back_from_rip_off_view_ && animator == bounds_animator_.get()) { 1875 if (snap_back_from_rip_off_view_ && animator == bounds_animator_.get()) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 1908
1908 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1909 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1909 const gfx::Rect bounds = GetBoundsInScreen(); 1910 const gfx::Rect bounds = GetBoundsInScreen();
1910 int distance = shelf_->SelectValueForShelfAlignment( 1911 int distance = shelf_->SelectValueForShelfAlignment(
1911 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1912 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1912 bounds.x() - coordinate.x()); 1913 bounds.x() - coordinate.x());
1913 return distance > 0 ? distance : 0; 1914 return distance > 0 ? distance : 0;
1914 } 1915 }
1915 1916
1916 } // namespace ash 1917 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/bridge/wm_shell_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698