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 #include "extensions/browser/app_window/app_window_registry.h" | 5 #include "extensions/browser/app_window/app_window_registry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 AppWindow* AppWindowRegistry::GetAppWindowForRenderViewHost( | 145 AppWindow* AppWindowRegistry::GetAppWindowForRenderViewHost( |
146 content::RenderViewHost* render_view_host) const { | 146 content::RenderViewHost* render_view_host) const { |
147 for (AppWindowList::const_iterator i = app_windows_.begin(); | 147 for (AppWindowList::const_iterator i = app_windows_.begin(); |
148 i != app_windows_.end(); | 148 i != app_windows_.end(); |
149 ++i) { | 149 ++i) { |
150 if ((*i)->web_contents()->GetRenderViewHost() == render_view_host) | 150 if ((*i)->web_contents()->GetRenderViewHost() == render_view_host) |
151 return *i; | 151 return *i; |
152 } | 152 } |
153 | 153 |
154 return NULL; | 154 return nullptr; |
155 } | 155 } |
156 | 156 |
157 AppWindow* AppWindowRegistry::GetAppWindowForNativeWindow( | 157 AppWindow* AppWindowRegistry::GetAppWindowForNativeWindow( |
158 gfx::NativeWindow window) const { | 158 gfx::NativeWindow window) const { |
159 for (AppWindowList::const_iterator i = app_windows_.begin(); | 159 for (AppWindowList::const_iterator i = app_windows_.begin(); |
160 i != app_windows_.end(); | 160 i != app_windows_.end(); |
161 ++i) { | 161 ++i) { |
162 if ((*i)->GetNativeWindow() == window) | 162 if ((*i)->GetNativeWindow() == window) |
163 return *i; | 163 return *i; |
164 } | 164 } |
165 | 165 |
166 return NULL; | 166 return nullptr; |
167 } | 167 } |
168 | 168 |
169 AppWindow* AppWindowRegistry::GetCurrentAppWindowForApp( | 169 AppWindow* AppWindowRegistry::GetCurrentAppWindowForApp( |
170 const std::string& app_id) const { | 170 const std::string& app_id) const { |
171 AppWindow* result = NULL; | 171 AppWindow* result = nullptr; |
172 for (AppWindowList::const_iterator i = app_windows_.begin(); | 172 for (AppWindowList::const_iterator i = app_windows_.begin(); |
173 i != app_windows_.end(); | 173 i != app_windows_.end(); |
174 ++i) { | 174 ++i) { |
175 if ((*i)->extension_id() == app_id) { | 175 if ((*i)->extension_id() == app_id) { |
176 result = *i; | 176 result = *i; |
177 if (result->GetBaseWindow()->IsActive()) | 177 if (result->GetBaseWindow()->IsActive()) |
178 return result; | 178 return result; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 return result; | 182 return result; |
183 } | 183 } |
184 | 184 |
185 AppWindow* AppWindowRegistry::GetAppWindowForAppAndKey( | 185 AppWindow* AppWindowRegistry::GetAppWindowForAppAndKey( |
186 const std::string& app_id, | 186 const std::string& app_id, |
187 const std::string& window_key) const { | 187 const std::string& window_key) const { |
188 AppWindow* result = NULL; | 188 AppWindow* result = nullptr; |
189 for (AppWindowList::const_iterator i = app_windows_.begin(); | 189 for (AppWindowList::const_iterator i = app_windows_.begin(); |
190 i != app_windows_.end(); | 190 i != app_windows_.end(); |
191 ++i) { | 191 ++i) { |
192 if ((*i)->extension_id() == app_id && (*i)->window_key() == window_key) { | 192 if ((*i)->extension_id() == app_id && (*i)->window_key() == window_key) { |
193 result = *i; | 193 result = *i; |
194 if (result->GetBaseWindow()->IsActive()) | 194 if (result->GetBaseWindow()->IsActive()) |
195 return result; | 195 return result; |
196 } | 196 } |
197 } | 197 } |
198 return result; | 198 return result; |
(...skipping 17 matching lines...) Expand all Loading... |
216 AppWindowRegistry* registry = | 216 AppWindowRegistry* registry = |
217 Factory::GetForBrowserContext(*i, false /* create */); | 217 Factory::GetForBrowserContext(*i, false /* create */); |
218 if (!registry) | 218 if (!registry) |
219 continue; | 219 continue; |
220 | 220 |
221 AppWindow* app_window = registry->GetAppWindowForNativeWindow(window); | 221 AppWindow* app_window = registry->GetAppWindowForNativeWindow(window); |
222 if (app_window) | 222 if (app_window) |
223 return app_window; | 223 return app_window; |
224 } | 224 } |
225 | 225 |
226 return NULL; | 226 return nullptr; |
227 } | 227 } |
228 | 228 |
229 // static | 229 // static |
230 bool AppWindowRegistry::IsAppWindowRegisteredInAnyProfile( | 230 bool AppWindowRegistry::IsAppWindowRegisteredInAnyProfile( |
231 int window_type_mask) { | 231 int window_type_mask) { |
232 std::vector<content::BrowserContext*> contexts = | 232 std::vector<content::BrowserContext*> contexts = |
233 AppWindowClient::Get()->GetLoadedBrowserContexts(); | 233 AppWindowClient::Get()->GetLoadedBrowserContexts(); |
234 for (std::vector<content::BrowserContext*>::const_iterator i = | 234 for (std::vector<content::BrowserContext*>::const_iterator i = |
235 contexts.begin(); | 235 contexts.begin(); |
236 i != contexts.end(); | 236 i != contexts.end(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 bool AppWindowRegistry::Factory::ServiceIsNULLWhileTesting() const { | 343 bool AppWindowRegistry::Factory::ServiceIsNULLWhileTesting() const { |
344 return false; | 344 return false; |
345 } | 345 } |
346 | 346 |
347 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( | 347 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( |
348 content::BrowserContext* context) const { | 348 content::BrowserContext* context) const { |
349 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | 349 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
350 } | 350 } |
351 | 351 |
352 } // namespace extensions | 352 } // namespace extensions |
OLD | NEW |