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/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" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/json/json_value_converter.h" | 13 #include "base/json/json_value_converter.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/stringprintf.h" | |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chromeos/display/output_configurator.h" | 20 #include "chromeos/display/output_configurator.h" |
| 20 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| 23 #include "ui/aura/display_manager.h" | 24 #include "ui/aura/display_manager.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 40 | 41 |
| 41 void DisplayOptionsHandler::GetLocalizedValues( | 42 void DisplayOptionsHandler::GetLocalizedValues( |
| 42 DictionaryValue* localized_strings) { | 43 DictionaryValue* localized_strings) { |
| 43 DCHECK(localized_strings); | 44 DCHECK(localized_strings); |
| 44 RegisterTitle(localized_strings, "displayOptionsPage", | 45 RegisterTitle(localized_strings, "displayOptionsPage", |
| 45 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_TAB_TITLE); | 46 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_TAB_TITLE); |
| 46 localized_strings->SetString("startMirroring", l10n_util::GetStringUTF16( | 47 localized_strings->SetString("startMirroring", l10n_util::GetStringUTF16( |
| 47 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_START_MIRRORING)); | 48 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_START_MIRRORING)); |
| 48 localized_strings->SetString("stopMirroring", l10n_util::GetStringUTF16( | 49 localized_strings->SetString("stopMirroring", l10n_util::GetStringUTF16( |
| 49 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STOP_MIRRORING)); | 50 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STOP_MIRRORING)); |
| 51 localized_strings->SetString("applyButton", l10n_util::GetStringUTF16( | |
| 52 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_APPLY_BUTTON)); | |
| 53 localized_strings->SetString("resolution", l10n_util::GetStringUTF16( | |
| 54 IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION)); | |
| 50 } | 55 } |
| 51 | 56 |
| 52 void DisplayOptionsHandler::InitializeHandler() { | 57 void DisplayOptionsHandler::InitializeHandler() { |
| 53 DCHECK(web_ui()); | 58 DCHECK(web_ui()); |
| 54 UpdateDisplaySectionVisibility(); | 59 UpdateDisplaySectionVisibility(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 void DisplayOptionsHandler::RegisterMessages() { | 62 void DisplayOptionsHandler::RegisterMessages() { |
| 58 web_ui()->RegisterMessageCallback( | 63 web_ui()->RegisterMessageCallback( |
| 59 "getDisplayInfo", | 64 "getDisplayInfo", |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 base::ListValue displays; | 112 base::ListValue displays; |
| 108 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 113 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 109 const gfx::Display* display = display_manager->GetDisplayAt(i); | 114 const gfx::Display* display = display_manager->GetDisplayAt(i); |
| 110 const gfx::Rect& bounds = display->bounds(); | 115 const gfx::Rect& bounds = display->bounds(); |
| 111 base::DictionaryValue* js_display = new base::DictionaryValue(); | 116 base::DictionaryValue* js_display = new base::DictionaryValue(); |
| 112 js_display->SetDouble("id", display->id()); | 117 js_display->SetDouble("id", display->id()); |
| 113 js_display->SetDouble("x", bounds.x()); | 118 js_display->SetDouble("x", bounds.x()); |
| 114 js_display->SetDouble("y", bounds.y()); | 119 js_display->SetDouble("y", bounds.y()); |
| 115 js_display->SetDouble("width", bounds.width()); | 120 js_display->SetDouble("width", bounds.width()); |
| 116 js_display->SetDouble("height", bounds.height()); | 121 js_display->SetDouble("height", bounds.height()); |
| 122 // We do not have good data for displays such like vendor/model names. | |
|
James Hawkins
2012/08/03 18:08:23
s/We/.../
Jun Mukai
2012/08/06 08:07:32
Done.
| |
| 123 // So here just uses 'Display 1' or 'Display 2' for their names. | |
| 124 // TODO(mukai,oshima): support vendor/model names and use it. | |
| 125 js_display->SetString("name", base::StringPrintf( | |
| 126 "Display %d", static_cast<int>(i) + 1)); | |
| 117 displays.Set(i, js_display); | 127 displays.Set(i, js_display); |
| 118 } | 128 } |
| 119 | 129 |
| 120 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 130 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 121 base::FundamentalValue layout( | 131 base::FundamentalValue layout( |
| 122 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); | 132 pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); |
| 123 | 133 |
| 124 web_ui()->CallJavascriptFunction( | 134 web_ui()->CallJavascriptFunction( |
| 125 "options.DisplayOptions.setDisplayInfo", | 135 "options.DisplayOptions.setDisplayInfo", |
| 126 mirroring, displays, layout); | 136 mirroring, displays, layout); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 DCHECK_GE(DisplayController::LEFT, layout); | 180 DCHECK_GE(DisplayController::LEFT, layout); |
| 171 ash::Shell::GetInstance()->output_configurator_animation()-> | 181 ash::Shell::GetInstance()->output_configurator_animation()-> |
| 172 StartFadeOutAnimation(base::Bind( | 182 StartFadeOutAnimation(base::Bind( |
| 173 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished, | 183 &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished, |
| 174 base::Unretained(this), | 184 base::Unretained(this), |
| 175 static_cast<int>(layout))); | 185 static_cast<int>(layout))); |
| 176 } | 186 } |
| 177 | 187 |
| 178 } // namespace options2 | 188 } // namespace options2 |
| 179 } // namespace chromeos | 189 } // namespace chromeos |
| OLD | NEW |