Chromium Code Reviews| 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/options/chromeos/display_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/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/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 localized_strings->SetString( | 68 localized_strings->SetString( |
| 69 "finishCalibratingOverscan", l10n_util::GetStringUTF16( | 69 "finishCalibratingOverscan", l10n_util::GetStringUTF16( |
| 70 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_FINISH_CALIBRATING_OVERSCAN)); | 70 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_FINISH_CALIBRATING_OVERSCAN)); |
| 71 localized_strings->SetString( | 71 localized_strings->SetString( |
| 72 "clearCalibratingOverscan", l10n_util::GetStringUTF16( | 72 "clearCalibratingOverscan", l10n_util::GetStringUTF16( |
| 73 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_CLEAR_CALIBRATING_OVERSCAN)); | 73 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_CLEAR_CALIBRATING_OVERSCAN)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void DisplayOptionsHandler::InitializePage() { | 76 void DisplayOptionsHandler::InitializePage() { |
| 77 DCHECK(web_ui()); | 77 DCHECK(web_ui()); |
| 78 UpdateDisplaySectionVisibility(GetDisplayManager()->GetNumDisplays()); | 78 std::vector<const gfx::Display*> displays; |
| 79 DisplayManager* display_manager = GetDisplayManager(); | |
| 80 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | |
| 81 displays.push_back(display_manager->GetDisplayAt(i)); | |
| 82 } | |
| 83 UpdateDisplaySectionVisibility(displays); | |
| 79 } | 84 } |
| 80 | 85 |
| 81 void DisplayOptionsHandler::RegisterMessages() { | 86 void DisplayOptionsHandler::RegisterMessages() { |
| 82 web_ui()->RegisterMessageCallback( | 87 web_ui()->RegisterMessageCallback( |
| 83 "getDisplayInfo", | 88 "getDisplayInfo", |
| 84 base::Bind(&DisplayOptionsHandler::HandleDisplayInfo, | 89 base::Bind(&DisplayOptionsHandler::HandleDisplayInfo, |
| 85 base::Unretained(this))); | 90 base::Unretained(this))); |
| 86 web_ui()->RegisterMessageCallback( | 91 web_ui()->RegisterMessageCallback( |
| 87 "setMirroring", | 92 "setMirroring", |
| 88 base::Bind(&DisplayOptionsHandler::HandleMirroring, | 93 base::Bind(&DisplayOptionsHandler::HandleMirroring, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 111 "updateOverscanCalibration", | 116 "updateOverscanCalibration", |
| 112 base::Bind(&DisplayOptionsHandler::HandleUpdateOverscanCalibration, | 117 base::Bind(&DisplayOptionsHandler::HandleUpdateOverscanCalibration, |
| 113 base::Unretained(this))); | 118 base::Unretained(this))); |
| 114 } | 119 } |
| 115 | 120 |
| 116 void DisplayOptionsHandler::OnDisplayBoundsChanged( | 121 void DisplayOptionsHandler::OnDisplayBoundsChanged( |
| 117 const gfx::Display& display) { | 122 const gfx::Display& display) { |
| 118 } | 123 } |
| 119 | 124 |
| 120 void DisplayOptionsHandler::OnDisplayAdded(const gfx::Display& new_display) { | 125 void DisplayOptionsHandler::OnDisplayAdded(const gfx::Display& new_display) { |
| 121 UpdateDisplaySectionVisibility(GetDisplayManager()->GetNumDisplays()); | 126 std::vector<const gfx::Display*> displays; |
| 127 DisplayManager* display_manager = GetDisplayManager(); | |
| 128 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | |
| 129 displays.push_back(display_manager->GetDisplayAt(i)); | |
| 130 } | |
| 131 UpdateDisplaySectionVisibility(displays); | |
| 122 SendAllDisplayInfo(); | 132 SendAllDisplayInfo(); |
| 123 } | 133 } |
| 124 | 134 |
| 125 void DisplayOptionsHandler::OnDisplayRemoved(const gfx::Display& old_display) { | 135 void DisplayOptionsHandler::OnDisplayRemoved(const gfx::Display& old_display) { |
| 126 DisplayManager* display_manager = GetDisplayManager(); | 136 DisplayManager* display_manager = GetDisplayManager(); |
| 127 UpdateDisplaySectionVisibility(display_manager->GetNumDisplays() - 1); | |
| 128 | 137 |
| 129 std::vector<const gfx::Display*> displays; | 138 std::vector<const gfx::Display*> displays; |
| 130 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 139 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 131 const gfx::Display* display = display_manager->GetDisplayAt(i); | 140 const gfx::Display* display = display_manager->GetDisplayAt(i); |
| 132 if (display->id() != old_display.id()) | 141 if (display->id() != old_display.id()) |
| 133 displays.push_back(display); | 142 displays.push_back(display); |
| 134 } | 143 } |
| 144 UpdateDisplaySectionVisibility(displays); | |
| 135 SendDisplayInfo(displays); | 145 SendDisplayInfo(displays); |
| 136 } | 146 } |
| 137 | 147 |
| 138 void DisplayOptionsHandler::UpdateDisplaySectionVisibility( | 148 void DisplayOptionsHandler::UpdateDisplaySectionVisibility( |
| 139 size_t num_displays) { | 149 const std::vector<const gfx::Display*>& displays) { |
| 150 DisplayManager* display_manager = GetDisplayManager(); | |
| 151 bool has_external = false; | |
| 152 for (size_t i = 0; i < displays.size(); i++) { | |
| 153 if (!display_manager->IsInternalDisplayId(displays[i]->id())) { | |
| 154 has_external = true; | |
| 155 break; | |
| 156 } | |
| 157 } | |
|
oshima
2013/01/31 02:32:40
You should be able to tell if there is an external
Jun Mukai
2013/01/31 02:40:10
indeed. done.
| |
| 158 | |
| 140 chromeos::OutputState output_state = | 159 chromeos::OutputState output_state = |
| 141 ash::Shell::GetInstance()->output_configurator()->output_state(); | 160 ash::Shell::GetInstance()->output_configurator()->output_state(); |
| 142 base::FundamentalValue show_options( | 161 base::FundamentalValue show_options( |
| 143 num_displays > 1 || output_state == chromeos::STATE_DUAL_MIRROR); | 162 has_external || output_state == chromeos::STATE_DUAL_MIRROR); |
| 144 web_ui()->CallJavascriptFunction( | 163 web_ui()->CallJavascriptFunction( |
| 145 "options.BrowserOptions.showDisplayOptions", show_options); | 164 "options.BrowserOptions.showDisplayOptions", show_options); |
| 146 } | 165 } |
| 147 | 166 |
| 148 void DisplayOptionsHandler::SendAllDisplayInfo() { | 167 void DisplayOptionsHandler::SendAllDisplayInfo() { |
| 149 DisplayManager* display_manager = GetDisplayManager(); | 168 DisplayManager* display_manager = GetDisplayManager(); |
| 150 | 169 |
| 151 std::vector<const gfx::Display*> displays; | 170 std::vector<const gfx::Display*> displays; |
| 152 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 171 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 153 displays.push_back(display_manager->GetDisplayAt(i)); | 172 displays.push_back(display_manager->GetDisplayAt(i)); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 !args->GetDouble(2, &bottom) || !args->GetDouble(3, &right)) { | 353 !args->GetDouble(2, &bottom) || !args->GetDouble(3, &right)) { |
| 335 LOG(ERROR) << "Can't find overscan insets data."; | 354 LOG(ERROR) << "Can't find overscan insets data."; |
| 336 return; | 355 return; |
| 337 } | 356 } |
| 338 | 357 |
| 339 overscan_calibrator_->UpdateInsets(gfx::Insets(top, left, bottom, right)); | 358 overscan_calibrator_->UpdateInsets(gfx::Insets(top, left, bottom, right)); |
| 340 } | 359 } |
| 341 | 360 |
| 342 } // namespace options | 361 } // namespace options |
| 343 } // namespace chromeos | 362 } // namespace chromeos |
| OLD | NEW |