| 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/ui/webui/options2/chromeos/display_options_handler.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/display_options_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_value_converter.h" | 12 #include "base/json/json_value_converter.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/common/pref_names.h" |
| 15 #include "chromeos/display/output_configurator.h" | 18 #include "chromeos/display/output_configurator.h" |
| 16 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| 17 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 18 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
| 19 #include "ui/aura/display_manager.h" | 22 #include "ui/aura/display_manager.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
| 22 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 23 | 26 |
| 24 namespace chromeos { | 27 namespace chromeos { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 const gfx::Rect& bounds = display->bounds(); | 112 const gfx::Rect& bounds = display->bounds(); |
| 110 base::DictionaryValue* js_display = new base::DictionaryValue(); | 113 base::DictionaryValue* js_display = new base::DictionaryValue(); |
| 111 js_display->SetDouble("id", display->id()); | 114 js_display->SetDouble("id", display->id()); |
| 112 js_display->SetDouble("x", bounds.x()); | 115 js_display->SetDouble("x", bounds.x()); |
| 113 js_display->SetDouble("y", bounds.y()); | 116 js_display->SetDouble("y", bounds.y()); |
| 114 js_display->SetDouble("width", bounds.width()); | 117 js_display->SetDouble("width", bounds.width()); |
| 115 js_display->SetDouble("height", bounds.height()); | 118 js_display->SetDouble("height", bounds.height()); |
| 116 displays.Set(i, js_display); | 119 displays.Set(i, js_display); |
| 117 } | 120 } |
| 118 | 121 |
| 119 DisplayController* display_controller = | 122 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 120 ash::Shell::GetInstance()->display_controller(); | 123 base::FundamentalValue layout( |
| 121 base::FundamentalValue layout(static_cast<int>( | 124 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); |
| 122 display_controller->secondary_display_layout())); | |
| 123 | 125 |
| 124 web_ui()->CallJavascriptFunction( | 126 web_ui()->CallJavascriptFunction( |
| 125 "options.DisplayOptions.setDisplayInfo", | 127 "options.DisplayOptions.setDisplayInfo", |
| 126 mirroring, displays, layout); | 128 mirroring, displays, layout); |
| 127 } | 129 } |
| 128 | 130 |
| 129 void DisplayOptionsHandler::HandleDisplayInfo( | 131 void DisplayOptionsHandler::HandleDisplayInfo( |
| 130 const base::ListValue* unused_args) { | 132 const base::ListValue* unused_args) { |
| 131 SendDisplayInfo(); | 133 SendDisplayInfo(); |
| 132 } | 134 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 145 | 147 |
| 146 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { | 148 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { |
| 147 double layout = -1; | 149 double layout = -1; |
| 148 if (!args->GetDouble(0, &layout)) { | 150 if (!args->GetDouble(0, &layout)) { |
| 149 LOG(ERROR) << "Invalid parameter"; | 151 LOG(ERROR) << "Invalid parameter"; |
| 150 return; | 152 return; |
| 151 } | 153 } |
| 152 DCHECK_LE(DisplayController::TOP, layout); | 154 DCHECK_LE(DisplayController::TOP, layout); |
| 153 DCHECK_GE(DisplayController::LEFT, layout); | 155 DCHECK_GE(DisplayController::LEFT, layout); |
| 154 | 156 |
| 155 ash::Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 157 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 156 static_cast<DisplayController::SecondaryDisplayLayout>(layout)); | 158 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout); |
| 157 SendDisplayInfo(); | 159 SendDisplayInfo(); |
| 158 } | 160 } |
| 159 | 161 |
| 160 } // namespace options2 | 162 } // namespace options2 |
| 161 } // namespace chromeos | 163 } // namespace chromeos |
| OLD | NEW |