OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/wm_overview_controller.h" | 5 #include "chrome/browser/chromeos/wm_overview_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/linked_ptr.h" | 10 #include "base/linked_ptr.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 for (SnapshotVector::size_type i = start_index; i < snapshots_.size(); ++i) { | 446 for (SnapshotVector::size_type i = start_index; i < snapshots_.size(); ++i) { |
447 if (snapshots_[i].snapshot->index() != static_cast<int>(i)) | 447 if (snapshots_[i].snapshot->index() != static_cast<int>(i)) |
448 snapshots_[i].snapshot->UpdateIndex(browser_, i); | 448 snapshots_[i].snapshot->UpdateIndex(browser_, i); |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 /////////////////////////////////// | 452 /////////////////////////////////// |
453 // WmOverviewController methods | 453 // WmOverviewController methods |
454 | 454 |
455 // static | 455 // static |
456 WmOverviewController* WmOverviewController::instance() { | 456 WmOverviewController* WmOverviewController::GetInstance() { |
457 static WmOverviewController* instance = NULL; | 457 static WmOverviewController* instance = NULL; |
458 if (!instance) { | 458 if (!instance) { |
459 instance = Singleton<WmOverviewController>::get(); | 459 instance = Singleton<WmOverviewController>::get(); |
460 } | 460 } |
461 return instance; | 461 return instance; |
462 } | 462 } |
463 | 463 |
464 WmOverviewController::WmOverviewController() | 464 WmOverviewController::WmOverviewController() |
465 : layout_mode_(ACTIVE_MODE), | 465 : layout_mode_(ACTIVE_MODE), |
466 updating_snapshots_(false), | 466 updating_snapshots_(false), |
467 browser_listener_index_(0), | 467 browser_listener_index_(0), |
468 tab_contents_index_(-1) { | 468 tab_contents_index_(-1) { |
469 AddAllBrowsers(); | 469 AddAllBrowsers(); |
470 | 470 |
471 if (registrar_.IsEmpty()) { | 471 if (registrar_.IsEmpty()) { |
472 // Make sure we get notifications for when the tab contents are | 472 // Make sure we get notifications for when the tab contents are |
473 // connected, so we know when a new browser has been created. | 473 // connected, so we know when a new browser has been created. |
474 registrar_.Add(this, | 474 registrar_.Add(this, |
475 NotificationType::TAB_CONTENTS_CONNECTED, | 475 NotificationType::TAB_CONTENTS_CONNECTED, |
476 NotificationService::AllSources()); | 476 NotificationService::AllSources()); |
477 | 477 |
478 // Ask for notification when the snapshot source image has changed | 478 // Ask for notification when the snapshot source image has changed |
479 // and needs to be refreshed. | 479 // and needs to be refreshed. |
480 registrar_.Add(this, | 480 registrar_.Add(this, |
481 NotificationType::THUMBNAIL_GENERATOR_SNAPSHOT_CHANGED, | 481 NotificationType::THUMBNAIL_GENERATOR_SNAPSHOT_CHANGED, |
482 NotificationService::AllSources()); | 482 NotificationService::AllSources()); |
483 } | 483 } |
484 | 484 |
485 BrowserList::AddObserver(this); | 485 BrowserList::AddObserver(this); |
486 WmMessageListener::instance()->AddObserver(this); | 486 WmMessageListener::GetInstance()->AddObserver(this); |
487 } | 487 } |
488 | 488 |
489 WmOverviewController::~WmOverviewController() { | 489 WmOverviewController::~WmOverviewController() { |
490 WmMessageListener::instance()->RemoveObserver(this); | 490 WmMessageListener::GetInstance()->RemoveObserver(this); |
491 BrowserList::RemoveObserver(this); | 491 BrowserList::RemoveObserver(this); |
492 listeners_.clear(); | 492 listeners_.clear(); |
493 } | 493 } |
494 | 494 |
495 void WmOverviewController::Observe(NotificationType type, | 495 void WmOverviewController::Observe(NotificationType type, |
496 const NotificationSource& source, | 496 const NotificationSource& source, |
497 const NotificationDetails& details) { | 497 const NotificationDetails& details) { |
498 switch (type.value) { | 498 switch (type.value) { |
499 // Now that the tab contents are ready, we create the listeners | 499 // Now that the tab contents are ready, we create the listeners |
500 // and snapshots for any new browsers out there. This actually | 500 // and snapshots for any new browsers out there. This actually |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 if (item.get() == NULL) { | 735 if (item.get() == NULL) { |
736 item = BrowserListenerVector::value_type( | 736 item = BrowserListenerVector::value_type( |
737 new BrowserListener(*iterator, this)); | 737 new BrowserListener(*iterator, this)); |
738 } | 738 } |
739 listeners_.push_back(item); | 739 listeners_.push_back(item); |
740 ++iterator; | 740 ++iterator; |
741 } | 741 } |
742 } | 742 } |
743 | 743 |
744 } // namespace chromeos | 744 } // namespace chromeos |
OLD | NEW |