Add default implementations for AppWindowRegistry::Observer notifications.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / test / app_window_waiter.cc
blobf9be212488b5d241543b8ec4bbeda8f039b37ac6
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/test/app_window_waiter.h"
7 #include "apps/app_window.h"
9 namespace chromeos {
11 AppWindowWaiter::AppWindowWaiter(apps::AppWindowRegistry* registry,
12 const std::string& app_id)
13 : registry_(registry), app_id_(app_id), window_(NULL) {
14 registry_->AddObserver(this);
17 AppWindowWaiter::~AppWindowWaiter() {
18 registry_->RemoveObserver(this);
21 apps::AppWindow* AppWindowWaiter::Wait() {
22 window_ = registry_->GetCurrentAppWindowForApp(app_id_);
23 if (window_)
24 return window_;
26 run_loop_.Run();
28 return window_;
31 void AppWindowWaiter::OnAppWindowAdded(apps::AppWindow* app_window) {
32 if (!run_loop_.running())
33 return;
35 if (app_window->extension_id() == app_id_) {
36 window_ = app_window;
37 run_loop_.Quit();
41 } // namespace chromeos