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

Side by Side Diff: components/mus/ws/window_tree_impl.cc

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: rebase Created 4 years, 11 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 | « components/mus/ws/window_tree_host_impl.cc ('k') | components/mus/ws/window_tree_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/mus/ws/window_tree_impl.h" 5 #include "components/mus/ws/window_tree_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 event_source_host_(nullptr), 72 event_source_host_(nullptr),
73 is_embed_root_(false), 73 is_embed_root_(false),
74 window_manager_internal_(nullptr) { 74 window_manager_internal_(nullptr) {
75 CHECK(root); 75 CHECK(root);
76 roots_.insert(root); 76 roots_.insert(root);
77 if (root->GetRoot() == root) { 77 if (root->GetRoot() == root) {
78 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); 78 access_policy_.reset(new WindowManagerAccessPolicy(id_, this));
79 is_embed_root_ = true; 79 is_embed_root_ = true;
80 } else { 80 } else {
81 access_policy_.reset(new DefaultAccessPolicy(id_, this)); 81 access_policy_.reset(new DefaultAccessPolicy(id_, this));
82 is_embed_root_ = 82 is_embed_root_ = (policy_bitmask & WindowTree::kAccessPolicyEmbedRoot) != 0;
83 (policy_bitmask & WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0;
84 } 83 }
85 } 84 }
86 85
87 WindowTreeImpl::~WindowTreeImpl() { 86 WindowTreeImpl::~WindowTreeImpl() {
88 DestroyWindows(); 87 DestroyWindows();
89 } 88 }
90 89
91 void WindowTreeImpl::Init(mojom::WindowTreeClient* client, 90 void WindowTreeImpl::Init(mojom::WindowTreeClient* client,
92 mojom::WindowTreePtr tree) { 91 mojom::WindowTreePtr tree) {
93 DCHECK(!client_); 92 DCHECK(!client_);
94 client_ = client; 93 client_ = client;
95 std::vector<const ServerWindow*> to_send; 94 std::vector<const ServerWindow*> to_send;
96 CHECK_EQ(1u, roots_.size()); 95 CHECK_EQ(1u, roots_.size());
97 GetUnknownWindowsFrom(*roots_.begin(), &to_send); 96 GetUnknownWindowsFrom(*roots_.begin(), &to_send);
98 97
99 WindowTreeHostImpl* host = GetHost(*roots_.begin()); 98 WindowTreeHostImpl* host = GetHost(*roots_.begin());
100 const ServerWindow* focused_window = 99 const ServerWindow* focused_window =
101 host ? host->GetFocusedWindow() : nullptr; 100 host ? host->GetFocusedWindow() : nullptr;
102 if (focused_window) 101 if (focused_window)
103 focused_window = access_policy_->GetWindowForFocusChange(focused_window); 102 focused_window = access_policy_->GetWindowForFocusChange(focused_window);
104 const Id focused_window_transport_id(MapWindowIdToClient(focused_window)); 103 const Id focused_window_transport_id(MapWindowIdToClient(focused_window));
105 104
106 client->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), 105 client->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree),
107 focused_window_transport_id, 106 focused_window_transport_id,
108 is_embed_root_ ? WindowTree::ACCESS_POLICY_EMBED_ROOT 107 is_embed_root_ ? WindowTree::kAccessPolicyEmbedRoot
109 : WindowTree::ACCESS_POLICY_DEFAULT); 108 : WindowTree::kAccessPolicyDefault);
110 } 109 }
111 110
112 const ServerWindow* WindowTreeImpl::GetWindow(const WindowId& id) const { 111 const ServerWindow* WindowTreeImpl::GetWindow(const WindowId& id) const {
113 if (id_ == id.connection_id) { 112 if (id_ == id.connection_id) {
114 WindowMap::const_iterator i = window_map_.find(id.window_id); 113 WindowMap::const_iterator i = window_map_.find(id.window_id);
115 return i == window_map_.end() ? NULL : i->second; 114 return i == window_map_.end() ? NULL : i->second;
116 } 115 }
117 return connection_manager_->GetWindow(id); 116 return connection_manager_->GetWindow(id);
118 } 117 }
119 118
(...skipping 24 matching lines...) Expand all
144 void WindowTreeImpl::OnWillDestroyWindowTreeHost( 143 void WindowTreeImpl::OnWillDestroyWindowTreeHost(
145 WindowTreeHostImpl* tree_host) { 144 WindowTreeHostImpl* tree_host) {
146 if (event_source_host_ == tree_host) 145 if (event_source_host_ == tree_host)
147 event_source_host_ = nullptr; 146 event_source_host_ = nullptr;
148 } 147 }
149 148
150 void WindowTreeImpl::NotifyChangeCompleted( 149 void WindowTreeImpl::NotifyChangeCompleted(
151 uint32_t change_id, 150 uint32_t change_id,
152 mojom::WindowManagerErrorCode error_code) { 151 mojom::WindowManagerErrorCode error_code) {
153 client_->OnChangeCompleted( 152 client_->OnChangeCompleted(
154 change_id, error_code == mojom::WINDOW_MANAGER_ERROR_CODE_SUCCESS); 153 change_id, error_code == mojom::WindowManagerErrorCode::SUCCESS);
155 } 154 }
156 155
157 bool WindowTreeImpl::NewWindow( 156 bool WindowTreeImpl::NewWindow(
158 const WindowId& window_id, 157 const WindowId& window_id,
159 const std::map<std::string, std::vector<uint8_t>>& properties) { 158 const std::map<std::string, std::vector<uint8_t>>& properties) {
160 if (!IsValidIdForNewWindow(window_id)) 159 if (!IsValidIdForNewWindow(window_id))
161 return false; 160 return false;
162 window_map_[window_id.window_id] = 161 window_map_[window_id.window_id] =
163 connection_manager_->CreateServerWindow(window_id, properties); 162 connection_manager_->CreateServerWindow(window_id, properties);
164 known_windows_.insert(WindowIdToTransportId(window_id)); 163 known_windows_.insert(WindowIdToTransportId(window_id));
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 569
571 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) 570 if (!access_policy_->CanReorderWindow(window, relative_window, direction))
572 return false; 571 return false;
573 572
574 std::vector<const ServerWindow*> children = window->parent()->GetChildren(); 573 std::vector<const ServerWindow*> children = window->parent()->GetChildren();
575 const size_t child_i = 574 const size_t child_i =
576 std::find(children.begin(), children.end(), window) - children.begin(); 575 std::find(children.begin(), children.end(), window) - children.begin();
577 const size_t target_i = 576 const size_t target_i =
578 std::find(children.begin(), children.end(), relative_window) - 577 std::find(children.begin(), children.end(), relative_window) -
579 children.begin(); 578 children.begin();
580 if ((direction == mojom::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || 579 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) ||
581 (direction == mojom::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { 580 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) {
582 return false; 581 return false;
583 } 582 }
584 583
585 return true; 584 return true;
586 } 585 }
587 586
588 bool WindowTreeImpl::DeleteWindowImpl(WindowTreeImpl* source, 587 bool WindowTreeImpl::DeleteWindowImpl(WindowTreeImpl* source,
589 ServerWindow* window) { 588 ServerWindow* window) {
590 DCHECK(window); 589 DCHECK(window);
591 DCHECK_EQ(window->id().connection_id, id_); 590 DCHECK_EQ(window->id().connection_id, id_);
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1157
1159 for (const auto* root : roots_) { 1158 for (const auto* root : roots_) {
1160 if (root->Contains(window)) 1159 if (root->Contains(window))
1161 return true; 1160 return true;
1162 } 1161 }
1163 return false; 1162 return false;
1164 } 1163 }
1165 1164
1166 } // namespace ws 1165 } // namespace ws
1167 } // namespace mus 1166 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree_host_impl.cc ('k') | components/mus/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698