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

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

Issue 10817028: Add Fade-out/Fade-in animation during output-configuration change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/shell.h" 11 #include "ash/shell.h"
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/json/json_value_converter.h" 13 #include "base/json/json_value_converter.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chromeos/display/output_configurator.h" 19 #include "chromeos/display/output_configurator.h"
19 #include "content/public/browser/web_ui.h" 20 #include "content/public/browser/web_ui.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 120 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
120 base::FundamentalValue layout( 121 base::FundamentalValue layout(
121 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); 122 pref_service->GetInteger(prefs::kSecondaryDisplayLayout));
122 123
123 web_ui()->CallJavascriptFunction( 124 web_ui()->CallJavascriptFunction(
124 "options.DisplayOptions.setDisplayInfo", 125 "options.DisplayOptions.setDisplayInfo",
125 mirroring, displays, layout); 126 mirroring, displays, layout);
126 } 127 }
127 128
129 void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) {
130 // We use 'PRIMARY_ONLY' for non-mirroring state for now.
131 // TODO(mukai): fix this and support multiple display modes.
132 chromeos::OutputState new_state =
133 is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY;
134 ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state);
135 SendDisplayInfo();
136 // Not necessary to start fade-in animation. OutputConfigurator will do that.
137 }
138
139 void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished(int layout) {
140 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
141 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout);
142 SendDisplayInfo();
143 ash::Shell::GetInstance()->output_configurator_animation()->
144 StartFadeInAnimation();
145 }
146
128 void DisplayOptionsHandler::HandleDisplayInfo( 147 void DisplayOptionsHandler::HandleDisplayInfo(
129 const base::ListValue* unused_args) { 148 const base::ListValue* unused_args) {
130 SendDisplayInfo(); 149 SendDisplayInfo();
131 } 150 }
132 151
133 void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) { 152 void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) {
134 DCHECK(!args->empty()); 153 DCHECK(!args->empty());
135 bool is_mirroring = false; 154 bool is_mirroring = false;
136 args->GetBoolean(0, &is_mirroring); 155 args->GetBoolean(0, &is_mirroring);
137 // We use 'PRIMARY_ONLY' for non-mirroring state for now. 156 ash::Shell::GetInstance()->output_configurator_animation()->
138 // TODO(mukai): fix this and support multiple display modes. 157 StartFadeOutAnimation(base::Bind(
139 chromeos::OutputState new_state = 158 &DisplayOptionsHandler::FadeOutForMirroringFinished,
140 is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; 159 base::Unretained(this),
141 ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); 160 is_mirroring));
142 SendDisplayInfo();
143 } 161 }
144 162
145 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { 163 void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) {
146 double layout = -1; 164 double layout = -1;
147 if (!args->GetDouble(0, &layout)) { 165 if (!args->GetDouble(0, &layout)) {
148 LOG(ERROR) << "Invalid parameter"; 166 LOG(ERROR) << "Invalid parameter";
149 return; 167 return;
150 } 168 }
151 DCHECK_LE(DisplayController::TOP, layout); 169 DCHECK_LE(DisplayController::TOP, layout);
152 DCHECK_GE(DisplayController::LEFT, layout); 170 DCHECK_GE(DisplayController::LEFT, layout);
153 171 ash::Shell::GetInstance()->output_configurator_animation()->
154 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 172 StartFadeOutAnimation(base::Bind(
155 pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout); 173 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished,
156 SendDisplayInfo(); 174 base::Unretained(this),
175 static_cast<int>(layout)));
157 } 176 }
158 177
159 } // namespace options2 178 } // namespace options2
160 } // namespace chromeos 179 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/chromeos/display_options_handler.h ('k') | chromeos/display/output_configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698