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

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

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: Rebased to resolve merge conflicts, Refactored to use observers, addressed comments, and disabled a… Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.h" 5 #include "ash/shelf/shelf.h"
6 6
7 #include "ash/public/cpp/config.h" 7 #include "ash/public/cpp/config.h"
8 #include "ash/public/cpp/shelf_item_delegate.h" 8 #include "ash/public/cpp/shelf_item_delegate.h"
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/session/session_controller.h" 11 #include "ash/session/session_controller.h"
12 #include "ash/shelf/app_list_button.h"
12 #include "ash/shelf/shelf_bezel_event_handler.h" 13 #include "ash/shelf/shelf_bezel_event_handler.h"
13 #include "ash/shelf/shelf_controller.h" 14 #include "ash/shelf/shelf_controller.h"
14 #include "ash/shelf/shelf_layout_manager.h" 15 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_model.h" 16 #include "ash/shelf/shelf_model.h"
16 #include "ash/shelf/shelf_observer.h" 17 #include "ash/shelf/shelf_observer.h"
17 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
18 #include "ash/shell.h" 19 #include "ash/shell.h"
19 #include "base/logging.h" 20 #include "base/logging.h"
20 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "ui/app_list/app_list_features.h"
21 #include "ui/display/types/display_constants.h" 23 #include "ui/display/types/display_constants.h"
22 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
23 25
24 namespace ash { 26 namespace ash {
25 27
26 namespace { 28 namespace {
27 29
28 // A callback that does nothing after shelf item selection handling. 30 // A callback that does nothing after shelf item selection handling.
29 void NoopCallback(ShelfAction, 31 void NoopCallback(ShelfAction,
30 base::Optional<std::vector<mojom::MenuItemPtr>>) {} 32 base::Optional<std::vector<mojom::MenuItemPtr>>) {}
(...skipping 29 matching lines...) Expand all
60 DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler); 62 DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler);
61 }; 63 };
62 64
63 // Shelf --------------------------------------------------------------------- 65 // Shelf ---------------------------------------------------------------------
64 66
65 Shelf::Shelf() : shelf_locking_manager_(this) { 67 Shelf::Shelf() : shelf_locking_manager_(this) {
66 // TODO: ShelfBezelEventHandler needs to work with mus too. 68 // TODO: ShelfBezelEventHandler needs to work with mus too.
67 // http://crbug.com/636647 69 // http://crbug.com/636647
68 if (Shell::GetAshConfig() != Config::MASH) 70 if (Shell::GetAshConfig() != Config::MASH)
69 bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this); 71 bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this);
72 Shell::Get()->AddShellObserver(this);
70 } 73 }
71 74
72 Shelf::~Shelf() {} 75 Shelf::~Shelf() {
76 Shell::Get()->RemoveShellObserver(this);
77 }
73 78
74 // static 79 // static
75 Shelf* Shelf::ForWindow(aura::Window* window) { 80 Shelf* Shelf::ForWindow(aura::Window* window) {
76 return GetRootWindowController(window->GetRootWindow())->shelf(); 81 return GetRootWindowController(window->GetRootWindow())->shelf();
77 } 82 }
78 83
79 // static 84 // static
80 bool Shelf::CanChangeShelfAlignment() { 85 bool Shelf::CanChangeShelfAlignment() {
81 if (Shell::Get()->session_controller()->IsUserSupervised()) 86 if (Shell::Get()->session_controller()->IsUserSupervised())
82 return false; 87 return false;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 321 }
317 322
318 ShelfLockingManager* Shelf::GetShelfLockingManagerForTesting() { 323 ShelfLockingManager* Shelf::GetShelfLockingManagerForTesting() {
319 return &shelf_locking_manager_; 324 return &shelf_locking_manager_;
320 } 325 }
321 326
322 ShelfView* Shelf::GetShelfViewForTesting() { 327 ShelfView* Shelf::GetShelfViewForTesting() {
323 return shelf_widget_->shelf_view_for_testing(); 328 return shelf_widget_->shelf_view_for_testing();
324 } 329 }
325 330
331 void Shelf::OnAppListIsActive() {
332 shelf_layout_manager()->OnAppListIsActive();
333 }
334
326 void Shelf::WillDeleteShelfLayoutManager() { 335 void Shelf::WillDeleteShelfLayoutManager() {
327 if (Shell::GetAshConfig() == Config::MASH) { 336 if (Shell::GetAshConfig() == Config::MASH) {
328 // TODO(sky): this should be removed once Shell is used everywhere. 337 // TODO(sky): this should be removed once Shell is used everywhere.
329 ShutdownShelfWidget(); 338 ShutdownShelfWidget();
330 } 339 }
331 340
332 // Clear event handlers that might forward events to the destroyed instance. 341 // Clear event handlers that might forward events to the destroyed instance.
333 auto_hide_event_handler_.reset(); 342 auto_hide_event_handler_.reset();
334 bezel_event_handler_.reset(); 343 bezel_event_handler_.reset();
335 344
(...skipping 20 matching lines...) Expand all
356 } 365 }
357 366
358 void Shelf::OnBackgroundUpdated(ShelfBackgroundType background_type, 367 void Shelf::OnBackgroundUpdated(ShelfBackgroundType background_type,
359 AnimationChangeType change_type) { 368 AnimationChangeType change_type) {
360 if (background_type == GetBackgroundType()) 369 if (background_type == GetBackgroundType())
361 return; 370 return;
362 for (auto& observer : observers_) 371 for (auto& observer : observers_)
363 observer.OnBackgroundTypeChanged(background_type, change_type); 372 observer.OnBackgroundTypeChanged(background_type, change_type);
364 } 373 }
365 374
375 void Shelf::OnAppListShownOrDismissed(bool shown, aura::Window* root_window) {
376 // Check if the AppList was shown on this display.
377 if (shelf_widget() == Shelf::ForWindow(root_window)->shelf_widget()) {
378 if (shown) {
379 shelf_widget()->GetAppListButton()->OnAppListShown();
380 } else {
381 shelf_widget()->GetAppListButton()->OnAppListDismissed();
382 }
383 if (app_list::features::IsFullscreenAppListEnabled())
384 OnAppListIsActive();
385 }
386 }
387
366 } // namespace ash 388 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698