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

Side by Side Diff: ash/common/test/test_shelf_item_delegate.cc

Issue 2479353003: Revert of Window prerequisites for ShelfWindowWatcher panel support. (Closed)
Patch Set: Created 4 years, 1 month 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/aura/wm_window_aura.cc ('k') | ash/common/wm_window.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/test/test_shelf_item_delegate.h" 5 #include "ash/common/test/test_shelf_item_delegate.h"
6 6
7 #include "ash/common/wm_lookup.h"
7 #include "ash/common/wm_window.h" 8 #include "ash/common/wm_window.h"
9 #include "ui/events/event.h"
10 #include "ui/views/view.h"
11 #include "ui/views/widget/widget.h"
8 12
9 namespace ash { 13 namespace ash {
10 namespace test { 14 namespace test {
11 15
16 namespace {
17
18 // Moves |window| to the root window where the |event| occurred.
19 // Note: This was forked from ash/wm/window_util.h's wm::MoveWindowToEventRoot.
20 void MoveWindowToEventRoot(WmWindow* window, const ui::Event& event) {
21 views::View* target = static_cast<views::View*>(event.target());
22 if (!target)
23 return;
24 WmWindow* target_root =
25 WmLookup::Get()->GetWindowForWidget(target->GetWidget())->GetRootWindow();
26 if (!target_root || target_root == window->GetRootWindow())
27 return;
28 WmWindow* window_container = target_root->GetChildByShellWindowId(
29 window->GetParent()->GetShellWindowId());
30 window_container->AddChild(window);
31 }
32
33 } // namespace
34
12 TestShelfItemDelegate::TestShelfItemDelegate(WmWindow* window) 35 TestShelfItemDelegate::TestShelfItemDelegate(WmWindow* window)
13 : window_(window), is_draggable_(true) {} 36 : window_(window), is_draggable_(true) {}
14 37
15 TestShelfItemDelegate::~TestShelfItemDelegate() {} 38 TestShelfItemDelegate::~TestShelfItemDelegate() {}
16 39
17 ShelfItemDelegate::PerformedAction TestShelfItemDelegate::ItemSelected( 40 ShelfItemDelegate::PerformedAction TestShelfItemDelegate::ItemSelected(
18 const ui::Event& event) { 41 const ui::Event& event) {
19 if (window_) { 42 if (window_) {
20 if (window_->GetType() == ui::wm::WINDOW_TYPE_PANEL) 43 if (window_->GetType() == ui::wm::WINDOW_TYPE_PANEL)
21 window_->MoveToEventRoot(event); 44 MoveWindowToEventRoot(window_, event);
22 window_->Show(); 45 window_->Show();
23 window_->Activate(); 46 window_->Activate();
24 return kExistingWindowActivated; 47 return kExistingWindowActivated;
25 } 48 }
26 return kNoAction; 49 return kNoAction;
27 } 50 }
28 51
29 base::string16 TestShelfItemDelegate::GetTitle() { 52 base::string16 TestShelfItemDelegate::GetTitle() {
30 return window_ ? window_->GetTitle() : base::string16(); 53 return window_ ? window_->GetTitle() : base::string16();
31 } 54 }
(...skipping 11 matching lines...) Expand all
43 } 66 }
44 67
45 bool TestShelfItemDelegate::ShouldShowTooltip() { 68 bool TestShelfItemDelegate::ShouldShowTooltip() {
46 return true; 69 return true;
47 } 70 }
48 71
49 void TestShelfItemDelegate::Close() {} 72 void TestShelfItemDelegate::Close() {}
50 73
51 } // namespace test 74 } // namespace test
52 } // namespace ash 75 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/wm_window_aura.cc ('k') | ash/common/wm_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698