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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 void DisplayLayoutStore::SetDefaultDisplayPlacement( | 43 void DisplayLayoutStore::SetDefaultDisplayPlacement( |
44 const display::DisplayPlacement& placement) { | 44 const display::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 display::DisplayIdList& list, | 51 const display::DisplayIdList& list, |
52 scoped_ptr<display::DisplayLayout> layout) { | 52 std::unique_ptr<display::DisplayLayout> layout) { |
53 // m50/51 dev/beta channel may have bad layout data saved in local state. | 53 // m50/51 dev/beta channel may have bad layout data saved in local state. |
54 // TODO(oshima): Consider removing this after m53. | 54 // TODO(oshima): Consider removing this after m53. |
55 if (list.size() == 2 && layout->placement_list.size() > 1) | 55 if (list.size() == 2 && layout->placement_list.size() > 1) |
56 return; | 56 return; |
57 | 57 |
58 // Do not overwrite the valid data with old invalid date. | 58 // Do not overwrite the valid data with old invalid date. |
59 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) | 59 if (layouts_.count(list) && !CompareDisplayIds(list[0], list[1])) |
60 return; | 60 return; |
61 | 61 |
62 // Old data may not have the display_id/parent_display_id. | 62 // Old data may not have the display_id/parent_display_id. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DCHECK(layouts_.find(list) != layouts_.end()); | 96 DCHECK(layouts_.find(list) != layouts_.end()); |
97 if (layouts_.find(list) == layouts_.end()) | 97 if (layouts_.find(list) == layouts_.end()) |
98 CreateDefaultDisplayLayout(list); | 98 CreateDefaultDisplayLayout(list); |
99 | 99 |
100 layouts_[list]->mirrored = mirrored; | 100 layouts_[list]->mirrored = mirrored; |
101 layouts_[list]->default_unified = default_unified; | 101 layouts_[list]->default_unified = default_unified; |
102 } | 102 } |
103 | 103 |
104 display::DisplayLayout* DisplayLayoutStore::CreateDefaultDisplayLayout( | 104 display::DisplayLayout* DisplayLayoutStore::CreateDefaultDisplayLayout( |
105 const display::DisplayIdList& list) { | 105 const display::DisplayIdList& list) { |
106 scoped_ptr<display::DisplayLayout> layout(new display::DisplayLayout); | 106 std::unique_ptr<display::DisplayLayout> layout(new display::DisplayLayout); |
107 // The first display is the primary by default. | 107 // The first display is the primary by default. |
108 layout->primary_id = list[0]; | 108 layout->primary_id = list[0]; |
109 layout->placement_list.clear(); | 109 layout->placement_list.clear(); |
110 for (size_t i = 0; i < list.size() - 1; i++) { | 110 for (size_t i = 0; i < list.size() - 1; i++) { |
111 display::DisplayPlacement placement(default_display_placement_); | 111 display::DisplayPlacement placement(default_display_placement_); |
112 placement.display_id = list[i + 1]; | 112 placement.display_id = list[i + 1]; |
113 placement.parent_display_id = list[i]; | 113 placement.parent_display_id = list[i]; |
114 layout->placement_list.push_back(placement); | 114 layout->placement_list.push_back(placement); |
115 } | 115 } |
116 layouts_[list] = std::move(layout); | 116 layouts_[list] = std::move(layout); |
117 auto iter = layouts_.find(list); | 117 auto iter = layouts_.find(list); |
118 return iter->second.get(); | 118 return iter->second.get(); |
119 } | 119 } |
120 | 120 |
121 } // namespace ash | 121 } // namespace ash |
OLD | NEW |