| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "ash/display/display_configuration_controller.h" | 12 #include "ash/display/display_configuration_controller.h" |
| 13 #include "ash/display/display_layout_builder.h" | |
| 14 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/resolution_notification_controller.h" | 14 #include "ash/display/resolution_notification_controller.h" |
| 16 #include "ash/display/window_tree_host_manager.h" | 15 #include "ash/display/window_tree_host_manager.h" |
| 17 #include "ash/screen_util.h" | 16 #include "ash/screen_util.h" |
| 18 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 19 #include "base/bind.h" | 18 #include "base/bind.h" |
| 20 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 21 #include "base/logging.h" | 20 #include "base/logging.h" |
| 22 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 24 #include "base/values.h" | 23 #include "base/values.h" |
| 25 #include "chrome/browser/chromeos/display/display_preferences.h" | 24 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 26 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 27 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
| 28 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
| 29 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
| 30 #include "grit/ash_strings.h" | 29 #include "grit/ash_strings.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/display/manager/display_layout.h" |
| 32 #include "ui/display/manager/display_layout_builder.h" |
| 32 #include "ui/gfx/display.h" | 33 #include "ui/gfx/display.h" |
| 33 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
| 34 #include "ui/gfx/geometry/size_conversions.h" | 35 #include "ui/gfx/geometry/size_conversions.h" |
| 35 #include "ui/gfx/screen.h" | 36 #include "ui/gfx/screen.h" |
| 36 | 37 |
| 37 namespace chromeos { | 38 namespace chromeos { |
| 38 namespace options { | 39 namespace options { |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 ash::DisplayManager* GetDisplayManager() { | 42 ash::DisplayManager* GetDisplayManager() { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 if (profile_name.empty()) | 333 if (profile_name.empty()) |
| 333 continue; | 334 continue; |
| 334 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); | 335 base::DictionaryValue* color_profile_dict = new base::DictionaryValue(); |
| 335 color_profile_dict->SetInteger("profileId", color_profile); | 336 color_profile_dict->SetInteger("profileId", color_profile); |
| 336 color_profile_dict->SetString("name", profile_name); | 337 color_profile_dict->SetString("name", profile_name); |
| 337 available_color_profiles->Append(color_profile_dict); | 338 available_color_profiles->Append(color_profile_dict); |
| 338 } | 339 } |
| 339 js_display->Set("availableColorProfiles", available_color_profiles); | 340 js_display->Set("availableColorProfiles", available_color_profiles); |
| 340 | 341 |
| 341 if (display_manager->GetNumDisplays() > 1) { | 342 if (display_manager->GetNumDisplays() > 1) { |
| 342 const ash::DisplayPlacement placement = | 343 const display::DisplayPlacement placement = |
| 343 display_manager->GetCurrentDisplayLayout().FindPlacementById( | 344 display_manager->GetCurrentDisplayLayout().FindPlacementById( |
| 344 display.id()); | 345 display.id()); |
| 345 if (placement.display_id != gfx::Display::kInvalidDisplayID) { | 346 if (placement.display_id != gfx::Display::kInvalidDisplayID) { |
| 346 js_display->SetString( | 347 js_display->SetString( |
| 347 "parentId", base::Int64ToString(placement.parent_display_id)); | 348 "parentId", base::Int64ToString(placement.parent_display_id)); |
| 348 js_display->SetInteger("layoutType", placement.position); | 349 js_display->SetInteger("layoutType", placement.position); |
| 349 js_display->SetInteger("offset", placement.offset); | 350 js_display->SetInteger("offset", placement.offset); |
| 350 } | 351 } |
| 351 } | 352 } |
| 352 | 353 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 403 } |
| 403 | 404 |
| 404 void DisplayOptionsHandler::HandleSetDisplayLayout( | 405 void DisplayOptionsHandler::HandleSetDisplayLayout( |
| 405 const base::ListValue* args) { | 406 const base::ListValue* args) { |
| 406 const base::ListValue* layouts = nullptr; | 407 const base::ListValue* layouts = nullptr; |
| 407 if (!args->GetList(0, &layouts)) | 408 if (!args->GetList(0, &layouts)) |
| 408 NOTREACHED(); | 409 NOTREACHED(); |
| 409 content::RecordAction(base::UserMetricsAction("Options_DisplayRearrange")); | 410 content::RecordAction(base::UserMetricsAction("Options_DisplayRearrange")); |
| 410 | 411 |
| 411 ash::DisplayManager* display_manager = GetDisplayManager(); | 412 ash::DisplayManager* display_manager = GetDisplayManager(); |
| 412 ash::DisplayLayoutBuilder builder(display_manager->GetCurrentDisplayLayout()); | 413 display::DisplayLayoutBuilder builder( |
| 414 display_manager->GetCurrentDisplayLayout()); |
| 413 builder.ClearPlacements(); | 415 builder.ClearPlacements(); |
| 414 for (const base::Value* layout : *layouts) { | 416 for (const base::Value* layout : *layouts) { |
| 415 const base::DictionaryValue* dictionary; | 417 const base::DictionaryValue* dictionary; |
| 416 if (!layout->GetAsDictionary(&dictionary)) { | 418 if (!layout->GetAsDictionary(&dictionary)) { |
| 417 LOG(ERROR) << "Invalid layout dictionary: " << *dictionary; | 419 LOG(ERROR) << "Invalid layout dictionary: " << *dictionary; |
| 418 continue; | 420 continue; |
| 419 } | 421 } |
| 420 | 422 |
| 421 int64_t parent_id = GetDisplayIdFromDictionary(dictionary, "parentId"); | 423 int64_t parent_id = GetDisplayIdFromDictionary(dictionary, "parentId"); |
| 422 if (parent_id == gfx::Display::kInvalidDisplayID) | 424 if (parent_id == gfx::Display::kInvalidDisplayID) |
| 423 continue; // No placement for root (primary) display. | 425 continue; // No placement for root (primary) display. |
| 424 | 426 |
| 425 int64_t display_id = GetDisplayIdFromDictionary(dictionary, "id"); | 427 int64_t display_id = GetDisplayIdFromDictionary(dictionary, "id"); |
| 426 if (display_id == gfx::Display::kInvalidDisplayID) { | 428 if (display_id == gfx::Display::kInvalidDisplayID) { |
| 427 LOG(ERROR) << "Invalud display id in layout dictionary: " << *dictionary; | 429 LOG(ERROR) << "Invalud display id in layout dictionary: " << *dictionary; |
| 428 continue; | 430 continue; |
| 429 } | 431 } |
| 430 | 432 |
| 431 int position = 0; | 433 int position = 0; |
| 432 dictionary->GetInteger("layoutType", &position); | 434 dictionary->GetInteger("layoutType", &position); |
| 433 int offset = 0; | 435 int offset = 0; |
| 434 dictionary->GetInteger("offset", &offset); | 436 dictionary->GetInteger("offset", &offset); |
| 435 | 437 |
| 436 builder.AddDisplayPlacement( | 438 builder.AddDisplayPlacement( |
| 437 display_id, parent_id, | 439 display_id, parent_id, |
| 438 static_cast<ash::DisplayPlacement::Position>(position), offset); | 440 static_cast<display::DisplayPlacement::Position>(position), offset); |
| 439 } | 441 } |
| 440 scoped_ptr<ash::DisplayLayout> layout = builder.Build(); | 442 scoped_ptr<display::DisplayLayout> layout = builder.Build(); |
| 441 if (!ash::DisplayLayout::Validate(display_manager->GetCurrentDisplayIdList(), | 443 if (!display::DisplayLayout::Validate( |
| 442 *layout)) { | 444 display_manager->GetCurrentDisplayIdList(), *layout)) { |
| 443 LOG(ERROR) << "Invalid layout: " << layout->ToString(); | 445 LOG(ERROR) << "Invalid layout: " << layout->ToString(); |
| 444 return; | 446 return; |
| 445 } | 447 } |
| 446 | 448 |
| 447 VLOG(1) << "Updating display layout: " << layout->ToString(); | 449 VLOG(1) << "Updating display layout: " << layout->ToString(); |
| 448 GetDisplayConfigurationController()->SetDisplayLayout(std::move(layout), | 450 GetDisplayConfigurationController()->SetDisplayLayout(std::move(layout), |
| 449 true /* user_action */); | 451 true /* user_action */); |
| 450 } | 452 } |
| 451 | 453 |
| 452 void DisplayOptionsHandler::HandleSetDisplayMode(const base::ListValue* args) { | 454 void DisplayOptionsHandler::HandleSetDisplayMode(const base::ListValue* args) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 bool enable = false; | 555 bool enable = false; |
| 554 if (!args->GetBoolean(0, &enable)) | 556 if (!args->GetBoolean(0, &enable)) |
| 555 NOTREACHED(); | 557 NOTREACHED(); |
| 556 | 558 |
| 557 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( | 559 GetDisplayManager()->SetDefaultMultiDisplayModeForCurrentDisplays( |
| 558 enable ? ash::DisplayManager::UNIFIED : ash::DisplayManager::EXTENDED); | 560 enable ? ash::DisplayManager::UNIFIED : ash::DisplayManager::EXTENDED); |
| 559 } | 561 } |
| 560 | 562 |
| 561 } // namespace options | 563 } // namespace options |
| 562 } // namespace chromeos | 564 } // namespace chromeos |
| OLD | NEW |