| 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 #ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_REGISTRY_H_ | 5 #ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_REGISTRY_H_ |
| 6 #define EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_REGISTRY_H_ | 6 #define EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 16 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "content/public/browser/devtools_agent_host_observer.h" |
| 18 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class BrowserContext; | 22 class BrowserContext; |
| 22 class DevToolsAgentHost; | 23 class DevToolsAgentHost; |
| 23 class WebContents; | 24 class WebContents; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace extensions { | 27 namespace extensions { |
| 27 | 28 |
| 28 class AppWindow; | 29 class AppWindow; |
| 29 | 30 |
| 30 // The AppWindowRegistry tracks the AppWindows for all platform apps for a | 31 // The AppWindowRegistry tracks the AppWindows for all platform apps for a |
| 31 // particular browser context. | 32 // particular browser context. |
| 32 class AppWindowRegistry : public KeyedService { | 33 class AppWindowRegistry : public KeyedService, |
| 34 public content::DevToolsAgentHostObserver { |
| 33 public: | 35 public: |
| 34 class Observer { | 36 class Observer { |
| 35 public: | 37 public: |
| 36 // Called just after a app window was added. | 38 // Called just after a app window was added. |
| 37 virtual void OnAppWindowAdded(AppWindow* app_window); | 39 virtual void OnAppWindowAdded(AppWindow* app_window); |
| 38 // Called when the window icon changes. | 40 // Called when the window icon changes. |
| 39 virtual void OnAppWindowIconChanged(AppWindow* app_window); | 41 virtual void OnAppWindowIconChanged(AppWindow* app_window); |
| 40 // Called just after a app window was removed. | 42 // Called just after a app window was removed. |
| 41 virtual void OnAppWindowRemoved(AppWindow* app_window); | 43 virtual void OnAppWindowRemoved(AppWindow* app_window); |
| 42 // Called just after a app window was hidden. This is different from | 44 // Called just after a app window was hidden. This is different from |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 120 |
| 119 // BrowserContextKeyedServiceFactory | 121 // BrowserContextKeyedServiceFactory |
| 120 KeyedService* BuildServiceInstanceFor( | 122 KeyedService* BuildServiceInstanceFor( |
| 121 content::BrowserContext* context) const override; | 123 content::BrowserContext* context) const override; |
| 122 bool ServiceIsCreatedWithBrowserContext() const override; | 124 bool ServiceIsCreatedWithBrowserContext() const override; |
| 123 bool ServiceIsNULLWhileTesting() const override; | 125 bool ServiceIsNULLWhileTesting() const override; |
| 124 content::BrowserContext* GetBrowserContextToUse( | 126 content::BrowserContext* GetBrowserContextToUse( |
| 125 content::BrowserContext* context) const override; | 127 content::BrowserContext* context) const override; |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 protected: | |
| 129 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); | |
| 130 | |
| 131 private: | 130 private: |
| 132 // Ensures the specified |app_window| is included in |app_windows_|. | 131 // Ensures the specified |app_window| is included in |app_windows_|. |
| 133 // Otherwise adds |app_window| to the back of |app_windows_|. | 132 // Otherwise adds |app_window| to the back of |app_windows_|. |
| 134 void AddAppWindowToList(AppWindow* app_window); | 133 void AddAppWindowToList(AppWindow* app_window); |
| 135 | 134 |
| 136 // Bring |app_window| to the front of |app_windows_|. If it is not in the | 135 // Bring |app_window| to the front of |app_windows_|. If it is not in the |
| 137 // list, add it first. | 136 // list, add it first. |
| 138 void BringToFront(AppWindow* app_window); | 137 void BringToFront(AppWindow* app_window); |
| 139 | 138 |
| 140 // Create a key that identifies an AppWindow across App reloads. If the window | 139 // Create a key that identifies an AppWindow across App reloads. If the window |
| 141 // was given an id in CreateParams, the key is the extension id, a colon | 140 // was given an id in CreateParams, the key is the extension id, a colon |
| 142 // separator, and the AppWindow's |id|. If there is no |id|, the | 141 // separator, and the AppWindow's |id|. If there is no |id|, the |
| 143 // chrome-extension://extension-id/page.html URL will be used. If the | 142 // chrome-extension://extension-id/page.html URL will be used. If the |
| 144 // WebContents is not for a AppWindow, return an empty string. | 143 // WebContents is not for a AppWindow, return an empty string. |
| 145 std::string GetWindowKeyForWebContents( | 144 std::string GetWindowKeyForWebContents( |
| 146 content::WebContents* web_contents) const; | 145 content::WebContents* web_contents) const; |
| 146 std::string GetWindowKeyForAgentHost( |
| 147 content::DevToolsAgentHost* agent_host) const; |
| 148 |
| 149 // content::DevToolsAgentHostObserver overrides. |
| 150 void DevToolsAgentHostAttached( |
| 151 content::DevToolsAgentHost* agent_host) override; |
| 152 void DevToolsAgentHostDetached( |
| 153 content::DevToolsAgentHost* agent_host) override; |
| 147 | 154 |
| 148 content::BrowserContext* context_; | 155 content::BrowserContext* context_; |
| 149 AppWindowList app_windows_; | 156 AppWindowList app_windows_; |
| 150 InspectedWindowSet inspected_windows_; | 157 InspectedWindowSet inspected_windows_; |
| 151 base::ObserverList<Observer> observers_; | 158 base::ObserverList<Observer> observers_; |
| 152 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; | |
| 153 }; | 159 }; |
| 154 | 160 |
| 155 } // namespace extensions | 161 } // namespace extensions |
| 156 | 162 |
| 157 #endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_REGISTRY_H_ | 163 #endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_REGISTRY_H_ |
| OLD | NEW |