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/display/output_configurator_animation.h" | 10 #include "ash/display/output_configurator_animation.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 // So here just uses 'Display 1' or 'Display 2' for their names. | 123 // So here just uses 'Display 1' or 'Display 2' for their names. |
124 // TODO(mukai,oshima): support vendor/model names and use it. | 124 // TODO(mukai,oshima): support vendor/model names and use it. |
125 js_display->SetString("name", base::StringPrintf( | 125 js_display->SetString("name", base::StringPrintf( |
126 "Display %d", static_cast<int>(i) + 1)); | 126 "Display %d", static_cast<int>(i) + 1)); |
127 displays.Set(i, js_display); | 127 displays.Set(i, js_display); |
128 } | 128 } |
129 | 129 |
130 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 130 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
131 base::FundamentalValue layout( | 131 base::FundamentalValue layout( |
132 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); | 132 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); |
133 base::FundamentalValue offset( | |
134 pref_service->GetInteger(prefs::kSecondaryDisplayOffset)); | |
133 | 135 |
134 web_ui()->CallJavascriptFunction( | 136 web_ui()->CallJavascriptFunction( |
135 "options.DisplayOptions.setDisplayInfo", | 137 "options.DisplayOptions.setDisplayInfo", |
136 mirroring, displays, layout); | 138 mirroring, displays, layout, offset); |
137 } | 139 } |
138 | 140 |
139 void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) { | 141 void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) { |
140 // We use 'PRIMARY_ONLY' for non-mirroring state for now. | 142 // We use 'PRIMARY_ONLY' for non-mirroring state for now. |
141 // TODO(mukai): fix this and support multiple display modes. | 143 // TODO(mukai): fix this and support multiple display modes. |
142 chromeos::OutputState new_state = | 144 chromeos::OutputState new_state = |
143 is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; | 145 is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; |
144 ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); | 146 ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); |
145 SendDisplayInfo(); | 147 SendDisplayInfo(); |
146 // Not necessary to start fade-in animation. OutputConfigurator will do that. | 148 // Not necessary to start fade-in animation. OutputConfigurator will do that. |
147 } | 149 } |
148 | 150 |
149 void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished(int layout) { | 151 void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished( |
152 int layout, int offset) { | |
150 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 153 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
151 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout); | 154 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout); |
155 pref_service->SetInteger(prefs::kSecondaryDisplayOffset, offset); | |
152 SendDisplayInfo(); | 156 SendDisplayInfo(); |
153 ash::Shell::GetInstance()->output_configurator_animation()-> | 157 ash::Shell::GetInstance()->output_configurator_animation()-> |
154 StartFadeInAnimation(); | 158 StartFadeInAnimation(); |
155 } | 159 } |
156 | 160 |
157 void DisplayOptionsHandler::HandleDisplayInfo( | 161 void DisplayOptionsHandler::HandleDisplayInfo( |
158 const base::ListValue* unused_args) { | 162 const base::ListValue* unused_args) { |
159 SendDisplayInfo(); | 163 SendDisplayInfo(); |
160 } | 164 } |
161 | 165 |
162 void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) { | 166 void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) { |
163 DCHECK(!args->empty()); | 167 DCHECK(!args->empty()); |
164 bool is_mirroring = false; | 168 bool is_mirroring = false; |
165 args->GetBoolean(0, &is_mirroring); | 169 args->GetBoolean(0, &is_mirroring); |
166 ash::Shell::GetInstance()->output_configurator_animation()-> | 170 ash::Shell::GetInstance()->output_configurator_animation()-> |
167 StartFadeOutAnimation(base::Bind( | 171 StartFadeOutAnimation(base::Bind( |
168 &DisplayOptionsHandler::FadeOutForMirroringFinished, | 172 &DisplayOptionsHandler::FadeOutForMirroringFinished, |
169 base::Unretained(this), | 173 base::Unretained(this), |
170 is_mirroring)); | 174 is_mirroring)); |
171 } | 175 } |
172 | 176 |
173 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { | 177 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { |
174 double layout = -1; | 178 double layout = -1; |
175 if (!args->GetDouble(0, &layout)) { | 179 double offset = -1; |
180 if (!args->GetDouble(0, &layout) || !args->GetDouble(1, &offset)) { | |
176 LOG(ERROR) << "Invalid parameter"; | 181 LOG(ERROR) << "Invalid parameter"; |
177 return; | 182 return; |
James Hawkins
2012/08/11 17:37:42
When does this happen?
Jun Mukai
2012/08/13 05:33:25
Good point. Added "SendDisplayInfo" to refresh th
| |
178 } | 183 } |
179 DCHECK_LE(DisplayController::TOP, layout); | 184 DCHECK_LE(DisplayController::TOP, layout); |
180 DCHECK_GE(DisplayController::LEFT, layout); | 185 DCHECK_GE(DisplayController::LEFT, layout); |
181 ash::Shell::GetInstance()->output_configurator_animation()-> | 186 ash::Shell::GetInstance()->output_configurator_animation()-> |
182 StartFadeOutAnimation(base::Bind( | 187 StartFadeOutAnimation(base::Bind( |
183 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished, | 188 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished, |
184 base::Unretained(this), | 189 base::Unretained(this), |
185 static_cast<int>(layout))); | 190 static_cast<int>(layout), |
191 static_cast<int>(offset))); | |
186 } | 192 } |
187 | 193 |
188 } // namespace options2 | 194 } // namespace options2 |
189 } // namespace chromeos | 195 } // namespace chromeos |
OLD | NEW |