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

Unified Diff: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc

Issue 11195036: Overscan calibration UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
index ea08f4a97b16b2890e08a1c74a45a8d953479e7d..fb2d6596b649b5d40f52a4c499f1b304142db902 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
@@ -11,12 +11,12 @@
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "base/bind.h"
-#include "base/json/json_value_converter.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/chromeos/display/display_preferences.h"
+#include "chrome/browser/chromeos/display/overscan_calibrator.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chromeos/display/output_configurator.h"
@@ -55,6 +55,15 @@ void DisplayOptionsHandler::GetLocalizedValues(
IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_APPLY_RESULT));
localized_strings->SetString("resolution", l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION));
+ localized_strings->SetString(
+ "startCalibratingOverscan", l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_START_CALIBRATING_OVERSCAN));
+ localized_strings->SetString(
+ "finishCalibratingOverscan", l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_FINISH_CALIBRATING_OVERSCAN));
+ localized_strings->SetString(
+ "clearCalibratingOverscan", l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_CLEAR_CALIBRATING_OVERSCAN));
}
void DisplayOptionsHandler::InitializePage() {
@@ -79,6 +88,22 @@ void DisplayOptionsHandler::RegisterMessages() {
"setDisplayLayout",
base::Bind(&DisplayOptionsHandler::HandleDisplayLayout,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "startOverscanCalibration",
+ base::Bind(&DisplayOptionsHandler::HandleStartOverscanCalibration,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "finishOverscanCalibration",
+ base::Bind(&DisplayOptionsHandler::HandleFinishOverscanCalibration,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "clearOverscanCalibration",
+ base::Bind(&DisplayOptionsHandler::HandleClearOverscanCalibration,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "updateOverscanCalibration",
+ base::Bind(&DisplayOptionsHandler::HandleUpdateOverscanCalibration,
+ base::Unretained(this)));
}
void DisplayOptionsHandler::OnDisplayBoundsChanged(
@@ -131,6 +156,14 @@ void DisplayOptionsHandler::SendDisplayInfo() {
js_display->SetString("name",
display_manager->GetDisplayNameFor(*display));
js_display->SetBoolean("isPrimary", display->id() == primary_id);
+ base::DictionaryValue* js_insets = new base::DictionaryValue();
+ const gfx::Insets& insets =
+ display_controller->GetOverscanInsets(display->id());
+ js_insets->SetInteger("top", insets.top());
+ js_insets->SetInteger("left", insets.left());
+ js_insets->SetInteger("bottom", insets.bottom());
+ js_insets->SetInteger("right", insets.right());
+ js_display->Set("overscan", js_insets);
displays.Set(i, js_display);
}
@@ -231,5 +264,57 @@ void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) {
static_cast<int>(offset)));
}
+void DisplayOptionsHandler::HandleStartOverscanCalibration(
+ const base::ListValue* args) {
+ int64 display_id = gfx::Display::kInvalidDisplayID;
+ std::string id_value;
+ if (!args->GetString(0, &id_value)) {
+ LOG(ERROR) << "Can't find ID";
+ return;
+ }
+ if (!base::StringToInt64(id_value, &display_id) ||
+ display_id == gfx::Display::kInvalidDisplayID) {
+ LOG(ERROR) << "Invalid parameter: " << id_value;
+ return;
+ }
+
+ const gfx::Display& display = ash::ScreenAsh::GetDisplayForId(display_id);
+ DCHECK(display.is_valid());
+ ash::DisplayController* display_controller =
+ ash::Shell::GetInstance()->display_controller();
+ overscan_calibrator_.reset(new OverscanCalibrator(
+ display,
+ display_controller->GetOverscanInsets(display_id)));
+}
+
+void DisplayOptionsHandler::HandleFinishOverscanCalibration(
+ const base::ListValue* args) {
+ DCHECK(overscan_calibrator_.get());
+ overscan_calibrator_->Commit();
+ overscan_calibrator_.reset();
+ SendDisplayInfo();
+}
+
+void DisplayOptionsHandler::HandleClearOverscanCalibration(
+ const base::ListValue* args) {
+ DCHECK(overscan_calibrator_.get());
+ overscan_calibrator_->UpdateInsets(gfx::Insets());
+ overscan_calibrator_->Commit();
+ SendDisplayInfo();
+}
+
+void DisplayOptionsHandler::HandleUpdateOverscanCalibration(
+ const base::ListValue* args) {
+ DCHECK(overscan_calibrator_.get());
+ double top = 0, left = 0, bottom = 0, right = 0;
+ if (!args->GetDouble(0, &top) || !args->GetDouble(1, &left) ||
+ !args->GetDouble(2, &bottom) || !args->GetDouble(3, &right)) {
+ LOG(ERROR) << "Can't find overscan insets data.";
+ return;
+ }
+
+ overscan_calibrator_->UpdateInsets(gfx::Insets(top, left, bottom, right));
+}
+
} // namespace options
} // namespace chromeos
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/display_options_handler.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698