| 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 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 | 27 |
| 28 // The ShellWindowRegistry tracks the ShellWindows for all platform apps for a | 28 // The ShellWindowRegistry tracks the ShellWindows for all platform apps for a |
| 29 // particular profile. | 29 // particular profile. |
| 30 // This class is planned to evolve into tracking all PlatformApps for a | 30 // This class is planned to evolve into tracking all PlatformApps for a |
| 31 // particular profile, with a PlatformApp encapsulating all views (background | 31 // particular profile, with a PlatformApp encapsulating all views (background |
| 32 // page, shell windows, tray view, panels etc.) and other app level behaviour | 32 // page, shell windows, tray view, panels etc.) and other app level behaviour |
| 33 // (e.g. notifications the app is interested in, lifetime of the background | 33 // (e.g. notifications the app is interested in, lifetime of the background |
| 34 // page). | 34 // page). |
| 35 class ShellWindowRegistry : public ProfileKeyedService { | 35 class ShellWindowRegistry : public BrowserContextKeyedService { |
| 36 public: | 36 public: |
| 37 class Observer { | 37 class Observer { |
| 38 public: | 38 public: |
| 39 // Called just after a shell window was added. | 39 // Called just after a shell window was added. |
| 40 virtual void OnShellWindowAdded(ShellWindow* shell_window) = 0; | 40 virtual void OnShellWindowAdded(ShellWindow* shell_window) = 0; |
| 41 // Called when the window icon changes. | 41 // Called when the window icon changes. |
| 42 virtual void OnShellWindowIconChanged(ShellWindow* shell_window) = 0; | 42 virtual void OnShellWindowIconChanged(ShellWindow* shell_window) = 0; |
| 43 // Called just after a shell window was removed. | 43 // Called just after a shell window was removed. |
| 44 virtual void OnShellWindowRemoved(ShellWindow* shell_window) = 0; | 44 virtual void OnShellWindowRemoved(ShellWindow* shell_window) = 0; |
| 45 | 45 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 // Returns the shell window for |window|, looking in all profiles. | 94 // Returns the shell window for |window|, looking in all profiles. |
| 95 static ShellWindow* GetShellWindowForNativeWindowAnyProfile( | 95 static ShellWindow* GetShellWindowForNativeWindowAnyProfile( |
| 96 gfx::NativeWindow window); | 96 gfx::NativeWindow window); |
| 97 | 97 |
| 98 // Returns true if the number of shell windows registered across all profiles | 98 // Returns true if the number of shell windows registered across all profiles |
| 99 // is non-zero. |window_type_mask| is a bitwise OR filter of | 99 // is non-zero. |window_type_mask| is a bitwise OR filter of |
| 100 // ShellWindow::WindowType, or 0 for any window type. | 100 // ShellWindow::WindowType, or 0 for any window type. |
| 101 static bool IsShellWindowRegisteredInAnyProfile(int window_type_mask); | 101 static bool IsShellWindowRegisteredInAnyProfile(int window_type_mask); |
| 102 | 102 |
| 103 class Factory : public ProfileKeyedServiceFactory { | 103 class Factory : public BrowserContextKeyedServiceFactory { |
| 104 public: | 104 public: |
| 105 static ShellWindowRegistry* GetForProfile(Profile* profile, bool create); | 105 static ShellWindowRegistry* GetForProfile(Profile* profile, bool create); |
| 106 | 106 |
| 107 static Factory* GetInstance(); | 107 static Factory* GetInstance(); |
| 108 private: | 108 private: |
| 109 friend struct DefaultSingletonTraits<Factory>; | 109 friend struct DefaultSingletonTraits<Factory>; |
| 110 | 110 |
| 111 Factory(); | 111 Factory(); |
| 112 virtual ~Factory(); | 112 virtual ~Factory(); |
| 113 | 113 |
| 114 // ProfileKeyedServiceFactory | 114 // BrowserContextKeyedServiceFactory |
| 115 virtual ProfileKeyedService* BuildServiceInstanceFor( | 115 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
| 116 content::BrowserContext* profile) const OVERRIDE; | 116 content::BrowserContext* profile) const OVERRIDE; |
| 117 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE; | 117 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; |
| 118 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; | 118 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; |
| 119 virtual content::BrowserContext* GetBrowserContextToUse( | 119 virtual content::BrowserContext* GetBrowserContextToUse( |
| 120 content::BrowserContext* context) const OVERRIDE; | 120 content::BrowserContext* context) const OVERRIDE; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 protected: | 123 protected: |
| 124 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); | 124 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 // Ensures the specified |shell_window| is included in |shell_windows_|. | 127 // Ensures the specified |shell_window| is included in |shell_windows_|. |
| 128 // Otherwise adds |shell_window| to the back of |shell_windows_|. | 128 // Otherwise adds |shell_window| to the back of |shell_windows_|. |
| 129 void AddShellWindowToList(ShellWindow* shell_window); | 129 void AddShellWindowToList(ShellWindow* shell_window); |
| 130 | 130 |
| 131 // Bring |shell_window| to the front of |shell_windows_|. If it is not in the | 131 // Bring |shell_window| to the front of |shell_windows_|. If it is not in the |
| 132 // list, add it first. | 132 // list, add it first. |
| 133 void BringToFront(ShellWindow* shell_window); | 133 void BringToFront(ShellWindow* shell_window); |
| 134 | 134 |
| 135 Profile* profile_; | 135 Profile* profile_; |
| 136 ShellWindowList shell_windows_; | 136 ShellWindowList shell_windows_; |
| 137 InspectedWindowSet inspected_windows_; | 137 InspectedWindowSet inspected_windows_; |
| 138 ObserverList<Observer> observers_; | 138 ObserverList<Observer> observers_; |
| 139 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; | 139 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 } // namespace extensions | 142 } // namespace extensions |
| 143 | 143 |
| 144 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ | 144 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_REGISTRY_H_ |
| OLD | NEW |