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

Side by Side Diff: ash/display/display_layout.cc

Issue 1849683003: Do not register invalid layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 8 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 | « no previous file | ash/display/display_layout_store.cc » ('j') | ash/display/display_layout_store.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/display/display_layout.h" 5 #include "ash/display/display_layout.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_pref_util.h" 10 #include "ash/display/display_pref_util.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 converter->RegisterCustomField<int64_t>( 221 converter->RegisterCustomField<int64_t>(
222 kPrimaryIdKey, &DisplayLayout::primary_id, &GetDisplayIdFromString); 222 kPrimaryIdKey, &DisplayLayout::primary_id, &GetDisplayIdFromString);
223 converter->RegisterRepeatedMessage<DisplayPlacement>( 223 converter->RegisterRepeatedMessage<DisplayPlacement>(
224 kDisplayPlacementKey, &DisplayLayout::placement_list); 224 kDisplayPlacementKey, &DisplayLayout::placement_list);
225 } 225 }
226 226
227 // static 227 // static
228 bool DisplayLayout::Validate(const DisplayIdList& list, 228 bool DisplayLayout::Validate(const DisplayIdList& list,
229 const DisplayLayout& layout) { 229 const DisplayLayout& layout) {
230 // The primary display should be in the list. 230 // The primary display should be in the list.
231 DCHECK(IsIdInList(layout.primary_id, list)); 231 if (!IsIdInList(layout.primary_id, list))
232 return false;
232 233
233 // Unified mode, or mirror mode switched from unified mode, 234 // Unified mode, or mirror mode switched from unified mode,
234 // may not have the placement yet. 235 // may not have the placement yet.
235 if (layout.placement_list.size() == 0u) 236 if (layout.placement_list.size() == 0u)
236 return true; 237 return true;
237 238
238 bool has_primary_as_parent = false; 239 bool has_primary_as_parent = false;
239 int64_t id = 0; 240 int64_t id = 0;
240 241
241 for (const auto* placement : layout.placement_list) { 242 for (const auto* placement : layout.placement_list) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 s << (added ? "),(" : " [("); 313 s << (added ? "),(" : " [(");
313 s << placement->ToString(); 314 s << placement->ToString();
314 added = true; 315 added = true;
315 } 316 }
316 if (added) 317 if (added)
317 s << ")]"; 318 s << ")]";
318 return s.str(); 319 return s.str();
319 } 320 }
320 321
321 } // namespace ash 322 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_layout_store.cc » ('j') | ash/display/display_layout_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698