Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc

Issue 10836046: Allow offset for secondary display position in chrome://settings/display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 js_display->SetDouble("x", bounds.x()); 113 js_display->SetDouble("x", bounds.x());
114 js_display->SetDouble("y", bounds.y()); 114 js_display->SetDouble("y", bounds.y());
115 js_display->SetDouble("width", bounds.width()); 115 js_display->SetDouble("width", bounds.width());
116 js_display->SetDouble("height", bounds.height()); 116 js_display->SetDouble("height", bounds.height());
117 displays.Set(i, js_display); 117 displays.Set(i, js_display);
118 } 118 }
119 119
120 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 120 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
121 base::FundamentalValue layout( 121 base::FundamentalValue layout(
122 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); 122 pref_service->GetInteger(prefs::kSecondaryDisplayLayout));
123 base::FundamentalValue offset(
124 pref_service->GetInteger(prefs::kSecondaryDisplayOffset));
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, offset);
127 } 129 }
128 130
129 void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) { 131 void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) {
130 // We use 'PRIMARY_ONLY' for non-mirroring state for now. 132 // We use 'PRIMARY_ONLY' for non-mirroring state for now.
131 // TODO(mukai): fix this and support multiple display modes. 133 // TODO(mukai): fix this and support multiple display modes.
132 chromeos::OutputState new_state = 134 chromeos::OutputState new_state =
133 is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; 135 is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY;
134 ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); 136 ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state);
135 SendDisplayInfo(); 137 SendDisplayInfo();
136 // Not necessary to start fade-in animation. OutputConfigurator will do that. 138 // Not necessary to start fade-in animation. OutputConfigurator will do that.
137 } 139 }
138 140
139 void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished(int layout) { 141 void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished(
142 int layout, int offset) {
140 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 143 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
141 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout); 144 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout);
145 pref_service->SetInteger(prefs::kSecondaryDisplayOffset, offset);
142 SendDisplayInfo(); 146 SendDisplayInfo();
143 ash::Shell::GetInstance()->output_configurator_animation()-> 147 ash::Shell::GetInstance()->output_configurator_animation()->
144 StartFadeInAnimation(); 148 StartFadeInAnimation();
145 } 149 }
146 150
147 void DisplayOptionsHandler::HandleDisplayInfo( 151 void DisplayOptionsHandler::HandleDisplayInfo(
148 const base::ListValue* unused_args) { 152 const base::ListValue* unused_args) {
149 SendDisplayInfo(); 153 SendDisplayInfo();
150 } 154 }
151 155
152 void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) { 156 void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) {
153 DCHECK(!args->empty()); 157 DCHECK(!args->empty());
154 bool is_mirroring = false; 158 bool is_mirroring = false;
155 args->GetBoolean(0, &is_mirroring); 159 args->GetBoolean(0, &is_mirroring);
156 ash::Shell::GetInstance()->output_configurator_animation()-> 160 ash::Shell::GetInstance()->output_configurator_animation()->
157 StartFadeOutAnimation(base::Bind( 161 StartFadeOutAnimation(base::Bind(
158 &DisplayOptionsHandler::FadeOutForMirroringFinished, 162 &DisplayOptionsHandler::FadeOutForMirroringFinished,
159 base::Unretained(this), 163 base::Unretained(this),
160 is_mirroring)); 164 is_mirroring));
161 } 165 }
162 166
163 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { 167 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) {
164 double layout = -1; 168 double layout = -1;
165 if (!args->GetDouble(0, &layout)) { 169 double offset = -1;
170 if (!args->GetDouble(0, &layout) || !args->GetDouble(1, &offset)) {
166 LOG(ERROR) << "Invalid parameter"; 171 LOG(ERROR) << "Invalid parameter";
167 return; 172 return;
168 } 173 }
169 DCHECK_LE(DisplayController::TOP, layout); 174 DCHECK_LE(DisplayController::TOP, layout);
170 DCHECK_GE(DisplayController::LEFT, layout); 175 DCHECK_GE(DisplayController::LEFT, layout);
171 ash::Shell::GetInstance()->output_configurator_animation()-> 176 ash::Shell::GetInstance()->output_configurator_animation()->
172 StartFadeOutAnimation(base::Bind( 177 StartFadeOutAnimation(base::Bind(
173 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished, 178 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished,
174 base::Unretained(this), 179 base::Unretained(this),
175 static_cast<int>(layout))); 180 static_cast<int>(layout),
181 static_cast<int>(offset)));
176 } 182 }
177 183
178 } // namespace options2 184 } // namespace options2
179 } // namespace chromeos 185 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698