| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 15 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 15 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 16 #include "ui/gfx/native_widget_types.h" |
| 16 | 17 |
| 17 class Profile; | 18 class Profile; |
| 18 class ShellWindow; | 19 class ShellWindow; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class RenderViewHost; | 22 class RenderViewHost; |
| 22 } | 23 } |
| 23 | 24 |
| 24 // The ShellWindowRegistry tracks the ShellWindows for all platform apps for a | 25 // The ShellWindowRegistry tracks the ShellWindows for all platform apps for a |
| 25 // particular profile. | 26 // particular profile. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 void AddShellWindow(ShellWindow* shell_window); | 55 void AddShellWindow(ShellWindow* shell_window); |
| 55 void RemoveShellWindow(ShellWindow* shell_window); | 56 void RemoveShellWindow(ShellWindow* shell_window); |
| 56 | 57 |
| 57 void AddObserver(Observer* observer); | 58 void AddObserver(Observer* observer); |
| 58 void RemoveObserver(Observer* observer); | 59 void RemoveObserver(Observer* observer); |
| 59 | 60 |
| 60 // Returns a set of windows owned by the application identified by app_id. | 61 // Returns a set of windows owned by the application identified by app_id. |
| 61 ShellWindowSet GetShellWindowsForApp(const std::string app_id) const; | 62 ShellWindowSet GetShellWindowsForApp(const std::string app_id) const; |
| 62 const ShellWindowSet& shell_windows() const { return shell_windows_; } | 63 const ShellWindowSet& shell_windows() const { return shell_windows_; } |
| 63 | 64 |
| 65 // Helper functions to find shell windows with particular attributes. |
| 64 ShellWindow* GetShellWindowForRenderViewHost( | 66 ShellWindow* GetShellWindowForRenderViewHost( |
| 65 content::RenderViewHost* render_view_host) const; | 67 content::RenderViewHost* render_view_host) const; |
| 68 ShellWindow* GetShellWindowForNativeWindow(gfx::NativeWindow window) const; |
| 66 | 69 |
| 67 private: | 70 private: |
| 68 class Factory : public ProfileKeyedServiceFactory { | 71 class Factory : public ProfileKeyedServiceFactory { |
| 69 public: | 72 public: |
| 70 static ShellWindowRegistry* GetForProfile(Profile* profile); | 73 static ShellWindowRegistry* GetForProfile(Profile* profile); |
| 71 | 74 |
| 72 static Factory* GetInstance(); | 75 static Factory* GetInstance(); |
| 73 private: | 76 private: |
| 74 friend struct DefaultSingletonTraits<Factory>; | 77 friend struct DefaultSingletonTraits<Factory>; |
| 75 | 78 |
| 76 Factory(); | 79 Factory(); |
| 77 virtual ~Factory(); | 80 virtual ~Factory(); |
| 78 | 81 |
| 79 // ProfileKeyedServiceFactory | 82 // ProfileKeyedServiceFactory |
| 80 virtual ProfileKeyedService* BuildServiceInstanceFor( | 83 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 81 Profile* profile) const OVERRIDE; | 84 Profile* profile) const OVERRIDE; |
| 82 virtual bool ServiceIsCreatedWithProfile() OVERRIDE; | 85 virtual bool ServiceIsCreatedWithProfile() OVERRIDE; |
| 83 virtual bool ServiceIsNULLWhileTesting() OVERRIDE; | 86 virtual bool ServiceIsNULLWhileTesting() OVERRIDE; |
| 84 }; | 87 }; |
| 85 | 88 |
| 86 ShellWindowSet shell_windows_; | 89 ShellWindowSet shell_windows_; |
| 87 ObserverList<Observer> observers_; | 90 ObserverList<Observer> observers_; |
| 88 }; | 91 }; |
| 89 | 92 |
| 90 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ | 93 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ |
| OLD | NEW |