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

Side by Side Diff: ash/display/display_manager.cc

Issue 11411291: Fixes wrong logic for display names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 return matching ? *matching : DisplayController::GetPrimaryDisplay(); 383 return matching ? *matching : DisplayController::GetPrimaryDisplay();
384 } 384 }
385 385
386 std::string DisplayManager::GetDisplayNameFor( 386 std::string DisplayManager::GetDisplayNameFor(
387 const gfx::Display& display) { 387 const gfx::Display& display) {
388 if (!display.is_valid()) 388 if (!display.is_valid())
389 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); 389 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
390 390
391 std::map<int64, DisplayInfo>::const_iterator iter = 391 std::map<int64, DisplayInfo>::const_iterator iter =
392 display_info_.find(display.id()); 392 display_info_.find(display.id());
393 if (iter != display_info_.end()) 393 if (iter != display_info_.end() && !iter->second.name.empty())
394 return iter->second.name; 394 return iter->second.name;
395 395
396 return base::StringPrintf("Display %d", static_cast<int>(display.id())); 396 return base::StringPrintf("Display %d", static_cast<int>(display.id()));
397 } 397 }
398 398
399 void DisplayManager::OnRootWindowResized(const aura::RootWindow* root, 399 void DisplayManager::OnRootWindowResized(const aura::RootWindow* root,
400 const gfx::Size& old_size) { 400 const gfx::Size& old_size) {
401 if (!aura::UseFullscreenHostWindow()) { 401 if (!aura::UseFullscreenHostWindow()) {
402 gfx::Display& display = FindDisplayForRootWindow(root); 402 gfx::Display& display = FindDisplayForRootWindow(root);
403 if (display.size() != root->GetHostSize()) { 403 if (display.size() != root->GetHostSize()) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 #if defined(USE_X11) 552 #if defined(USE_X11)
553 std::vector<XID> outputs; 553 std::vector<XID> outputs;
554 if (!ui::GetOutputDeviceHandles(&outputs)) 554 if (!ui::GetOutputDeviceHandles(&outputs))
555 return; 555 return;
556 556
557 for (size_t i = 0; i < outputs.size(); ++i) { 557 for (size_t i = 0; i < outputs.size(); ++i) {
558 uint16 manufacturer_id = 0; 558 uint16 manufacturer_id = 0;
559 uint32 serial_number = 0; 559 uint32 serial_number = 0;
560 std::string name; 560 std::string name;
561 if (ui::GetOutputDeviceData( 561 ui::GetOutputDeviceData(
562 outputs[i], &manufacturer_id, &serial_number, &name)) { 562 outputs[i], &manufacturer_id, &serial_number, &name);
563 int64 id = gfx::Display::GetID(manufacturer_id, serial_number); 563 int64 id = gfx::Display::GetID(manufacturer_id, serial_number);
564 if (IsInternalDisplayId(id)) { 564 if (IsInternalDisplayId(id)) {
565 display_info_[id].name = 565 display_info_[id].name =
566 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); 566 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME);
567 } else { 567 } else if (!name.empty()) {
568 display_info_[id].name = name; 568 display_info_[id].name = name;
569 }
570 } 569 }
571 } 570 }
572 #endif 571 #endif
573 } 572 }
574 573
575 void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { 574 void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
576 DisplayList::iterator iter_to_update = to_update->begin(); 575 DisplayList::iterator iter_to_update = to_update->begin();
577 DisplayList::const_iterator iter = displays_.begin(); 576 DisplayList::const_iterator iter = displays_.begin();
578 for (; iter != displays_.end() && iter_to_update != to_update->end(); 577 for (; iter != displays_.end() && iter_to_update != to_update->end();
579 ++iter, ++iter_to_update) { 578 ++iter, ++iter_to_update) {
580 (*iter_to_update).set_id((*iter).id()); 579 (*iter_to_update).set_id((*iter).id());
581 } 580 }
582 } 581 }
583 582
584 } // namespace internal 583 } // namespace internal
585 } // namespace ash 584 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698