| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int layout, | 60 int layout, |
| 61 int offset) { | 61 int offset) { |
| 62 { | 62 { |
| 63 DictionaryPrefUpdate update(pref_service, prefs::kSecondaryDisplays); | 63 DictionaryPrefUpdate update(pref_service, prefs::kSecondaryDisplays); |
| 64 ash::DisplayLayout display_layout( | 64 ash::DisplayLayout display_layout( |
| 65 static_cast<ash::DisplayLayout::Position>(layout), offset); | 65 static_cast<ash::DisplayLayout::Position>(layout), offset); |
| 66 | 66 |
| 67 aura::DisplayManager* display_manager = | 67 aura::DisplayManager* display_manager = |
| 68 aura::Env::GetInstance()->display_manager(); | 68 aura::Env::GetInstance()->display_manager(); |
| 69 std::string name; | 69 std::string name; |
| 70 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 70 EscapeDisplayName(display_manager->GetDisplayNameFor(display), |
| 71 if (display_manager->GetDisplayAt(i)->id() == display.id()) { | 71 &name); |
| 72 EscapeDisplayName(display_manager->GetDisplayNameAt(i), &name); | |
| 73 break; | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 DCHECK(!name.empty()); | 72 DCHECK(!name.empty()); |
| 78 | 73 |
| 79 base::DictionaryValue* pref_data = update.Get(); | 74 base::DictionaryValue* pref_data = update.Get(); |
| 80 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); | 75 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); |
| 81 if (pref_data->HasKey(name)) { | 76 if (pref_data->HasKey(name)) { |
| 82 base::Value* value = NULL; | 77 base::Value* value = NULL; |
| 83 if (pref_data->Get(name, &value) && value != NULL) | 78 if (pref_data->Get(name, &value) && value != NULL) |
| 84 layout_value.reset(value->DeepCopy()); | 79 layout_value.reset(value->DeepCopy()); |
| 85 } | 80 } |
| 86 if (ash::DisplayLayout::ConvertToValue(display_layout, layout_value.get())) | 81 if (ash::DisplayLayout::ConvertToValue(display_layout, layout_value.get())) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 114 ash::DisplayLayout layout; | 109 ash::DisplayLayout layout; |
| 115 if (!ash::DisplayLayout::ConvertFromValue(*value, &layout)) | 110 if (!ash::DisplayLayout::ConvertFromValue(*value, &layout)) |
| 116 continue; | 111 continue; |
| 117 | 112 |
| 118 display_controller->SetLayoutForDisplayName( | 113 display_controller->SetLayoutForDisplayName( |
| 119 UnescapeDisplayName(*it), layout); | 114 UnescapeDisplayName(*it), layout); |
| 120 } | 115 } |
| 121 } | 116 } |
| 122 | 117 |
| 123 } // namespace chromeos | 118 } // namespace chromeos |
| OLD | NEW |