| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/api/system_info_display/display_info_provide
r.h" | 5 #include "chrome/browser/extensions/api/system_info_display/display_info_provide
r.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 UpdateDisplayLayout(primary.bounds(), primary.id(), | 404 UpdateDisplayLayout(primary.bounds(), primary.id(), |
| 405 target_bounds, target.id()); | 405 target_bounds, target.id()); |
| 406 } | 406 } |
| 407 | 407 |
| 408 return true; | 408 return true; |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace | 411 } // namespace |
| 412 | 412 |
| 413 void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { | 413 void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { |
| 414 DisplayInfo requested_info; | 414 bool success = QueryInfo(); |
| 415 bool success = QueryInfo(&requested_info); | |
| 416 | 415 |
| 417 base::MessageLoopProxy::current()->PostTask( | 416 base::MessageLoopProxy::current()->PostTask( |
| 418 FROM_HERE, | 417 FROM_HERE, |
| 419 base::Bind(callback, requested_info, success)); | 418 base::Bind(callback, success)); |
| 420 } | 419 } |
| 421 | 420 |
| 422 void DisplayInfoProvider::SetInfo(const std::string& display_id, | 421 void DisplayInfoProvider::SetInfo(const std::string& display_id, |
| 423 const DisplayProperties& info, | 422 const DisplayProperties& info, |
| 424 const SetInfoCallback& callback) { | 423 const SetInfoCallback& callback) { |
| 425 std::string error; | 424 std::string error; |
| 426 bool success = SetInfoImpl(display_id, info, &error); | 425 bool success = SetInfoImpl(display_id, info, &error); |
| 427 base::MessageLoopProxy::current()->PostTask( | 426 base::MessageLoopProxy::current()->PostTask( |
| 428 FROM_HERE, | 427 FROM_HERE, |
| 429 base::Bind(callback, success, error)); | 428 base::Bind(callback, success, error)); |
| 430 } | 429 } |
| 431 | 430 |
| 432 bool DisplayInfoProvider::QueryInfo(DisplayInfo* info) { | 431 bool DisplayInfoProvider::QueryInfo() { |
| 433 DCHECK(info); | 432 info_.clear(); |
| 434 info->clear(); | |
| 435 | 433 |
| 436 DisplayManager* display_manager = | 434 DisplayManager* display_manager = |
| 437 ash::Shell::GetInstance()->display_manager(); | 435 ash::Shell::GetInstance()->display_manager(); |
| 438 DCHECK(display_manager); | 436 DCHECK(display_manager); |
| 439 | 437 |
| 440 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); | 438 int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 441 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 439 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 442 AddInfoForDisplay(*display_manager->GetDisplayAt(i), display_manager, | 440 AddInfoForDisplay(*display_manager->GetDisplayAt(i), display_manager, |
| 443 primary_id, info); | 441 primary_id, &info_); |
| 444 } | 442 } |
| 445 | 443 |
| 446 return true; | 444 return true; |
| 447 } | 445 } |
| 448 | 446 |
| 449 } // namespace extensions | 447 } // namespace extensions |
| OLD | NEW |