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

Side by Side Diff: chrome/browser/ui/test/test_app_window_observer.cc

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: nits rebase Created 3 years, 6 months 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
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #include "chrome/browser/ui/test/test_app_window_observer.h"
6
7 #include "base/run_loop.h"
8 #include "extensions/browser/app_window/app_window.h"
9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/window.h"
11
12 TestAppWindowObserver::TestAppWindowObserver(content::BrowserContext* context)
13 : context_(context) {
14 extensions::AppWindowRegistry::Get(context_)->AddObserver(this);
15 }
16
17 TestAppWindowObserver::~TestAppWindowObserver() {
18 extensions::AppWindowRegistry::Get(context_)->RemoveObserver(this);
19 for (aura::Window* window : windows_)
20 window->RemoveObserver(this);
21 }
22
23 void TestAppWindowObserver::WaitForIconUpdate() {
24 WaitForIconUpdates(1);
25 }
26
27 void TestAppWindowObserver::WaitForIconUpdates(int updates) {
28 base::RunLoop run_loop;
29 expected_icon_updates_ = updates + icon_updates_;
30 icon_updated_callback_ = run_loop.QuitClosure();
31 run_loop.Run();
32 }
33
34 void TestAppWindowObserver::OnAppWindowAdded(
35 extensions::AppWindow* app_window) {
36 aura::Window* window = app_window->GetNativeWindow();
37 window->AddObserver(this);
38 windows_.push_back(window);
39 }
40
41 void TestAppWindowObserver::OnAppWindowRemoved(
42 extensions::AppWindow* app_window) {
43 aura::Window* window = app_window->GetNativeWindow();
44 if (window) {
45 windows_.erase(std::find(windows_.begin(), windows_.end(), window));
46 window->RemoveObserver(this);
47 }
48 }
49
50 void TestAppWindowObserver::OnWindowPropertyChanged(aura::Window* window,
51 const void* key,
52 intptr_t old) {
53 if (key == aura::client::kAppIconKey) {
54 ++icon_updates_;
55 if (icon_updates_ == expected_icon_updates_ &&
56 !icon_updated_callback_.is_null()) {
57 base::ResetAndReturn(&icon_updated_callback_).Run();
58 }
59 }
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698