Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/display_util.h" | 10 #include "ash/display/display_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 void DisplayLayoutStore::SetDefaultDisplayPlacement( | 43 void DisplayLayoutStore::SetDefaultDisplayPlacement( |
| 44 const DisplayPlacement& placement) { | 44 const DisplayPlacement& placement) { |
| 45 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 45 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 46 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) | 46 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) |
| 47 default_display_placement_ = placement; | 47 default_display_placement_ = placement; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void DisplayLayoutStore::RegisterLayoutForDisplayIdList( | 50 void DisplayLayoutStore::RegisterLayoutForDisplayIdList( |
| 51 const DisplayIdList& list, | 51 const DisplayIdList& list, |
| 52 scoped_ptr<DisplayLayout> layout) { | 52 scoped_ptr<DisplayLayout> layout) { |
| 53 // A dev/beta channel may have a bad layout data saved in local state. | |
|
stevenjb
2016/03/24 18:08:29
nit: s/a bad/bad/
oshima
2016/03/24 20:37:19
Done.
| |
| 54 // TODO(oshima): Consider removing this a coulpe of milestones later. | |
|
stevenjb
2016/03/24 18:08:29
nit: /a couple of milestones later/after M52/ (or
oshima
2016/03/24 20:37:19
Done.
| |
| 55 if (list.size() == 2 && layout->placement_list.size() > 1) | |
| 56 return; | |
| 53 | 57 |
| 54 // Do not overwrite the valid data with old invalid date. | 58 // Do not overwrite the valid data with old invalid date. |
| 55 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) | 59 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) |
| 56 return; | 60 return; |
| 57 | 61 |
| 58 // Old data may not have the display_id/parent_display_id. | 62 // Old data may not have the display_id/parent_display_id. |
| 59 // Guess these values based on the saved primary_id. | 63 // Guess these values based on the saved primary_id. |
| 60 if (layout->placement_list.size() >= 1 && | 64 if (layout->placement_list.size() >= 1 && |
| 61 layout->placement_list[0].display_id == gfx::Display::kInvalidDisplayID) { | 65 layout->placement_list[0].display_id == gfx::Display::kInvalidDisplayID) { |
| 62 if (layout->primary_id == list[1]) { | 66 if (layout->primary_id == list[1]) { |
| 63 layout->placement_list[0].display_id = list[0]; | 67 layout->placement_list[0].display_id = list[0]; |
| 64 layout->placement_list[0].parent_display_id = list[1]; | 68 layout->placement_list[0].parent_display_id = list[1]; |
| 65 } else { | 69 } else { |
| 66 layout->placement_list[0].display_id = list[1]; | 70 layout->placement_list[0].display_id = list[1]; |
| 67 layout->placement_list[0].parent_display_id = list[0]; | 71 layout->placement_list[0].parent_display_id = list[0]; |
| 68 } | 72 } |
| 69 } | 73 } |
| 70 DCHECK(DisplayLayout::Validate(list, *layout.get())) << layout->ToString(); | 74 DCHECK(DisplayLayout::Validate(list, *layout.get())) |
| 75 << "ids=" << DisplayIdListToString(list) | |
| 76 << ", layout=" << layout->ToString(); | |
| 71 layouts_[list] = std::move(layout); | 77 layouts_[list] = std::move(layout); |
| 72 } | 78 } |
| 73 | 79 |
| 74 const DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout( | 80 const DisplayLayout& DisplayLayoutStore::GetRegisteredDisplayLayout( |
| 75 const DisplayIdList& list) { | 81 const DisplayIdList& list) { |
| 76 DCHECK_NE(1u, list.size()); | 82 DCHECK_NE(1u, list.size()); |
| 77 const auto iter = layouts_.find(list); | 83 const auto iter = layouts_.find(list); |
| 78 const DisplayLayout* layout = iter != layouts_.end() | 84 const DisplayLayout* layout = iter != layouts_.end() |
| 79 ? iter->second.get() | 85 ? iter->second.get() |
| 80 : CreateDefaultDisplayLayout(list); | 86 : CreateDefaultDisplayLayout(list); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 105 placement.display_id = list[i + 1]; | 111 placement.display_id = list[i + 1]; |
| 106 placement.parent_display_id = list[i]; | 112 placement.parent_display_id = list[i]; |
| 107 layout->placement_list.push_back(placement); | 113 layout->placement_list.push_back(placement); |
| 108 } | 114 } |
| 109 layouts_[list] = std::move(layout); | 115 layouts_[list] = std::move(layout); |
| 110 auto iter = layouts_.find(list); | 116 auto iter = layouts_.find(list); |
| 111 return iter->second.get(); | 117 return iter->second.get(); |
| 112 } | 118 } |
| 113 | 119 |
| 114 } // namespace ash | 120 } // namespace ash |
| OLD | NEW |