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

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

Issue 10837331: Options: s/options2/options/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wut 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc
diff --git a/chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc
deleted file mode 100644
index 4d78f46b8d07a52ffb77246e1a12ff0200fa127b..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/options2/chromeos/display_options_handler.h"
-
-#include <string>
-
-#include "ash/display/display_controller.h"
-#include "ash/display/output_configurator_animation.h"
-#include "ash/shell.h"
-#include "base/bind.h"
-#include "base/json/json_value_converter.h"
-#include "base/logging.h"
-#include "base/stringprintf.h"
-#include "base/values.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
-#include "chromeos/display/output_configurator.h"
-#include "content/public/browser/web_ui.h"
-#include "grit/generated_resources.h"
-#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/rect.h"
-
-namespace chromeos {
-namespace options {
-
-using ash::internal::DisplayController;
-
-DisplayOptionsHandler::DisplayOptionsHandler() {
- aura::Env::GetInstance()->display_manager()->AddObserver(this);
-}
-
-DisplayOptionsHandler::~DisplayOptionsHandler() {
- aura::Env::GetInstance()->display_manager()->RemoveObserver(this);
-}
-
-void DisplayOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- RegisterTitle(localized_strings, "displayOptionsPage",
- IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_TAB_TITLE);
- localized_strings->SetString("startMirroring", l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_START_MIRRORING));
- localized_strings->SetString("stopMirroring", l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STOP_MIRRORING));
- localized_strings->SetString("applyResult", l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_APPLY_RESULT));
- localized_strings->SetString("resolution", l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION));
-}
-
-void DisplayOptionsHandler::InitializePage() {
- DCHECK(web_ui());
- UpdateDisplaySectionVisibility();
-}
-
-void DisplayOptionsHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "getDisplayInfo",
- base::Bind(&DisplayOptionsHandler::HandleDisplayInfo,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "setMirroring",
- base::Bind(&DisplayOptionsHandler::HandleMirroring,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "setDisplayLayout",
- base::Bind(&DisplayOptionsHandler::HandleDisplayLayout,
- base::Unretained(this)));
-}
-
-void DisplayOptionsHandler::OnDisplayBoundsChanged(
- const gfx::Display& display) {
- SendDisplayInfo();
-}
-
-void DisplayOptionsHandler::OnDisplayAdded(const gfx::Display& new_display) {
- UpdateDisplaySectionVisibility();
- SendDisplayInfo();
-}
-
-void DisplayOptionsHandler::OnDisplayRemoved(const gfx::Display& old_display) {
- UpdateDisplaySectionVisibility();
- SendDisplayInfo();
-}
-
-void DisplayOptionsHandler::UpdateDisplaySectionVisibility() {
- chromeos::OutputState output_state =
- ash::Shell::GetInstance()->output_configurator()->output_state();
- base::FundamentalValue show_options(
- DisplayController::IsExtendedDesktopEnabled() &&
- output_state != chromeos::STATE_INVALID &&
- output_state != chromeos::STATE_HEADLESS &&
- output_state != chromeos::STATE_SINGLE);
- web_ui()->CallJavascriptFunction(
- "options.BrowserOptions.showDisplayOptions", show_options);
-}
-
-void DisplayOptionsHandler::SendDisplayInfo() {
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
- chromeos::OutputConfigurator* output_configurator =
- ash::Shell::GetInstance()->output_configurator();
- base::FundamentalValue mirroring(
- output_configurator->output_state() == chromeos::STATE_DUAL_MIRROR);
-
- base::ListValue displays;
- for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
- const gfx::Display* display = display_manager->GetDisplayAt(i);
- const gfx::Rect& bounds = display->bounds();
- base::DictionaryValue* js_display = new base::DictionaryValue();
- js_display->SetDouble("id", display->id());
- js_display->SetDouble("x", bounds.x());
- js_display->SetDouble("y", bounds.y());
- js_display->SetDouble("width", bounds.width());
- js_display->SetDouble("height", bounds.height());
- // Do not have good data for displays such like vendor/model names.
- // So here just uses 'Display 1' or 'Display 2' for their names.
- // TODO(mukai,oshima): support vendor/model names and use it.
- js_display->SetString("name", base::StringPrintf(
- "Display %d", static_cast<int>(i) + 1));
- displays.Set(i, js_display);
- }
-
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
- base::FundamentalValue layout(
- pref_service->GetInteger(prefs::kSecondaryDisplayLayout));
- base::FundamentalValue offset(
- pref_service->GetInteger(prefs::kSecondaryDisplayOffset));
-
- web_ui()->CallJavascriptFunction(
- "options.DisplayOptions.setDisplayInfo",
- mirroring, displays, layout, offset);
-}
-
-void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) {
- // We use 'PRIMARY_ONLY' for non-mirroring state for now.
- // TODO(mukai): fix this and support multiple display modes.
- chromeos::OutputState new_state =
- is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY;
- ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state);
- SendDisplayInfo();
- // Not necessary to start fade-in animation. OutputConfigurator will do that.
-}
-
-void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished(
- int layout, int offset) {
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
- pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout);
- pref_service->SetInteger(prefs::kSecondaryDisplayOffset, offset);
- SendDisplayInfo();
- ash::Shell::GetInstance()->output_configurator_animation()->
- StartFadeInAnimation();
-}
-
-void DisplayOptionsHandler::HandleDisplayInfo(
- const base::ListValue* unused_args) {
- SendDisplayInfo();
-}
-
-void DisplayOptionsHandler::HandleMirroring(const base::ListValue* args) {
- DCHECK(!args->empty());
- bool is_mirroring = false;
- args->GetBoolean(0, &is_mirroring);
- ash::Shell::GetInstance()->output_configurator_animation()->
- StartFadeOutAnimation(base::Bind(
- &DisplayOptionsHandler::FadeOutForMirroringFinished,
- base::Unretained(this),
- is_mirroring));
-}
-
-void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) {
- double layout = -1;
- double offset = -1;
- if (!args->GetDouble(0, &layout) || !args->GetDouble(1, &offset)) {
- LOG(ERROR) << "Invalid parameter";
- SendDisplayInfo();
- return;
- }
- DCHECK_LE(DisplayController::TOP, layout);
- DCHECK_GE(DisplayController::LEFT, layout);
- ash::Shell::GetInstance()->output_configurator_animation()->
- StartFadeOutAnimation(base::Bind(
- &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished,
- base::Unretained(this),
- static_cast<int>(layout),
- static_cast<int>(offset)));
-}
-
-} // namespace options
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698