| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "apps/app_lifetime_monitor_factory.h" | 8 #include "apps/app_lifetime_monitor_factory.h" |
| 9 #include "apps/switches.h" | 9 #include "apps/switches.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 bool observed_removed_; | 171 bool observed_removed_; |
| 172 std::unique_ptr<base::RunLoop> run_loop_; | 172 std::unique_ptr<base::RunLoop> run_loop_; |
| 173 | 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(HostedAppBrowserListObserver); | 174 DISALLOW_COPY_AND_ASSIGN(HostedAppBrowserListObserver); |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 class AppLifetimeMonitorObserver : public apps::AppLifetimeMonitor::Observer { | 177 class AppLifetimeMonitorObserver : public apps::AppLifetimeMonitor::Observer { |
| 178 public: | 178 public: |
| 179 AppLifetimeMonitorObserver(Profile* profile) | 179 AppLifetimeMonitorObserver(Profile* profile) |
| 180 : profile_(profile), activated_count_(0), deactivated_count_(0) { | 180 : profile_(profile), activated_count_(0), deactivated_count_(0) { |
| 181 apps::AppLifetimeMonitorFactory::GetForProfile(profile_)->AddObserver(this); | 181 apps::AppLifetimeMonitorFactory::GetForBrowserContext(profile_) |
| 182 ->AddObserver(this); |
| 182 } | 183 } |
| 183 ~AppLifetimeMonitorObserver() override { | 184 ~AppLifetimeMonitorObserver() override { |
| 184 apps::AppLifetimeMonitorFactory::GetForProfile(profile_) | 185 apps::AppLifetimeMonitorFactory::GetForBrowserContext(profile_) |
| 185 ->RemoveObserver(this); | 186 ->RemoveObserver(this); |
| 186 } | 187 } |
| 187 | 188 |
| 188 int activated_count() { return activated_count_; } | 189 int activated_count() { return activated_count_; } |
| 189 int deactivated_count() { return deactivated_count_; } | 190 int deactivated_count() { return deactivated_count_; } |
| 190 | 191 |
| 191 protected: | 192 protected: |
| 192 // AppLifetimeMonitor::Observer overrides: | 193 // AppLifetimeMonitor::Observer overrides: |
| 193 void OnAppActivated(Profile* profile, const std::string& app_id) override { | 194 void OnAppActivated(content::BrowserContext* context, |
| 195 const std::string& app_id) override { |
| 194 ++activated_count_; | 196 ++activated_count_; |
| 195 } | 197 } |
| 196 void OnAppDeactivated(Profile* profile, const std::string& app_id) override { | 198 void OnAppDeactivated(content::BrowserContext* context, |
| 199 const std::string& app_id) override { |
| 197 ++deactivated_count_; | 200 ++deactivated_count_; |
| 198 } | 201 } |
| 199 | 202 |
| 200 private: | 203 private: |
| 201 Profile* profile_; | 204 Profile* profile_; |
| 202 int activated_count_; | 205 int activated_count_; |
| 203 int deactivated_count_; | 206 int deactivated_count_; |
| 204 | 207 |
| 205 DISALLOW_COPY_AND_ASSIGN(AppLifetimeMonitorObserver); | 208 DISALLOW_COPY_AND_ASSIGN(AppLifetimeMonitorObserver); |
| 206 }; | 209 }; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 // the shim is rebuilt. | 624 // the shim is rebuilt. |
| 622 WindowedAppShimLaunchObserver(app->id()).Wait(); | 625 WindowedAppShimLaunchObserver(app->id()).Wait(); |
| 623 | 626 |
| 624 EXPECT_TRUE(GetFirstAppWindow()); | 627 EXPECT_TRUE(GetFirstAppWindow()); |
| 625 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); | 628 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
| 626 } | 629 } |
| 627 | 630 |
| 628 #endif // defined(ARCH_CPU_64_BITS) | 631 #endif // defined(ARCH_CPU_64_BITS) |
| 629 | 632 |
| 630 } // namespace apps | 633 } // namespace apps |
| OLD | NEW |