OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_REGISTRY_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <set> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/singleton.h" |
| 13 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 14 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 15 |
| 16 class Profile; |
| 17 class ShellWindow; |
| 18 |
| 19 // The PlatformAppRegistry tracks the ShellWindows for all platform apps for a |
| 20 // particular profile. |
| 21 // This class is planned to evolve into tracking all PlatformApps for a |
| 22 // particular profile, with a PlatformApp encapsulating all views (background |
| 23 // page, shell windows, tray view, panels etc.) and other app level behaviour |
| 24 // (e.g. notifications the app is interested in, lifetime of the background |
| 25 // page). |
| 26 class PlatformAppRegistry : public ProfileKeyedService { |
| 27 public: |
| 28 typedef std::set<ShellWindow*> ShellWindowSet; |
| 29 typedef ShellWindowSet::const_iterator const_iterator; |
| 30 |
| 31 virtual ~PlatformAppRegistry(); |
| 32 |
| 33 // Returns the instance for the given profile, or NULL if none. This is |
| 34 // a convenience wrapper around PlatformAppRegistryFactory::GetForProfile. |
| 35 static PlatformAppRegistry* Get(Profile* profile); |
| 36 |
| 37 void AddShellWindow(ShellWindow* shell_window); |
| 38 void RemoveShellWindow(ShellWindow* shell_window); |
| 39 |
| 40 const ShellWindowSet& shell_windows() const { return shell_windows_; } |
| 41 |
| 42 private: |
| 43 class Factory : public ProfileKeyedServiceFactory { |
| 44 public: |
| 45 static PlatformAppRegistry* GetForProfile(Profile* profile); |
| 46 |
| 47 static Factory* GetInstance(); |
| 48 private: |
| 49 friend struct DefaultSingletonTraits<Factory>; |
| 50 |
| 51 Factory(); |
| 52 virtual ~Factory(); |
| 53 |
| 54 // ProfileKeyedServiceFactory |
| 55 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 56 Profile* profile) const OVERRIDE; |
| 57 virtual bool ServiceIsCreatedWithProfile() OVERRIDE; |
| 58 virtual bool ServiceIsNULLWhileTesting() OVERRIDE; |
| 59 }; |
| 60 |
| 61 ShellWindowSet shell_windows_; |
| 62 }; |
| 63 |
| 64 #endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_REGISTRY_H_ |
OLD | NEW |