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 "apps/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 "apps/app_window.h" | |
11 #include "apps/ui/apps_client.h" | |
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
13 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
14 #include "content/public/browser/devtools_agent_host.h" | 12 #include "content/public/browser/devtools_agent_host.h" |
15 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/site_instance.h" | 15 #include "content/public/browser/site_instance.h" |
18 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "extensions/browser/app_window/app_window.h" |
| 18 #include "extensions/browser/app_window/apps_client.h" |
19 #include "extensions/browser/app_window/native_app_window.h" | 19 #include "extensions/browser/app_window/native_app_window.h" |
20 #include "extensions/browser/extensions_browser_client.h" | 20 #include "extensions/browser/extensions_browser_client.h" |
21 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
22 | 22 |
| 23 namespace extensions { |
| 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 // Create a key that identifies a AppWindow in a RenderViewHost across App | 27 // Create a key that identifies a AppWindow in a RenderViewHost across App |
26 // reloads. If the window was given an id in CreateParams, the key is the | 28 // reloads. If the window was given an id in CreateParams, the key is the |
27 // extension id, a colon separator, and the AppWindow's |id|. If there is no | 29 // extension id, a colon separator, and the AppWindow's |id|. If there is no |
28 // |id|, the chrome-extension://extension-id/page.html URL will be used. If the | 30 // |id|, the chrome-extension://extension-id/page.html URL will be used. If the |
29 // RenderViewHost is not for a AppWindow, return an empty string. | 31 // RenderViewHost is not for a AppWindow, return an empty string. |
30 std::string GetWindowKeyForRenderViewHost( | 32 std::string GetWindowKeyForRenderViewHost( |
31 const apps::AppWindowRegistry* registry, | 33 const AppWindowRegistry* registry, |
32 content::RenderViewHost* render_view_host) { | 34 content::RenderViewHost* render_view_host) { |
33 apps::AppWindow* app_window = | 35 AppWindow* app_window = |
34 registry->GetAppWindowForRenderViewHost(render_view_host); | 36 registry->GetAppWindowForRenderViewHost(render_view_host); |
35 if (!app_window) | 37 if (!app_window) |
36 return std::string(); // Not a AppWindow. | 38 return std::string(); // Not a AppWindow. |
37 | 39 |
38 if (app_window->window_key().empty()) | 40 if (app_window->window_key().empty()) |
39 return app_window->web_contents()->GetURL().possibly_invalid_spec(); | 41 return app_window->web_contents()->GetURL().possibly_invalid_spec(); |
40 | 42 |
41 std::string key = app_window->extension_id(); | 43 std::string key = app_window->extension_id(); |
42 key += ':'; | 44 key += ':'; |
43 key += app_window->window_key(); | 45 key += app_window->window_key(); |
44 return key; | 46 return key; |
45 } | 47 } |
46 | 48 |
47 } // namespace | 49 } // namespace |
48 | 50 |
49 namespace apps { | |
50 | |
51 void AppWindowRegistry::Observer::OnAppWindowAdded(AppWindow* app_window) { | 51 void AppWindowRegistry::Observer::OnAppWindowAdded(AppWindow* app_window) { |
52 } | 52 } |
53 | 53 |
54 void AppWindowRegistry::Observer::OnAppWindowIconChanged( | 54 void AppWindowRegistry::Observer::OnAppWindowIconChanged( |
55 AppWindow* app_window) { | 55 AppWindow* app_window) { |
56 } | 56 } |
57 | 57 |
58 void AppWindowRegistry::Observer::OnAppWindowRemoved(AppWindow* app_window) { | 58 void AppWindowRegistry::Observer::OnAppWindowRemoved(AppWindow* app_window) { |
59 } | 59 } |
60 | 60 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 bool AppWindowRegistry::Factory::ServiceIsCreatedWithBrowserContext() const { | 339 bool AppWindowRegistry::Factory::ServiceIsCreatedWithBrowserContext() const { |
340 return true; | 340 return true; |
341 } | 341 } |
342 | 342 |
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 extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( | 349 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
350 context); | |
351 } | 350 } |
352 | 351 |
353 } // namespace apps | 352 } // namespace extensions |
OLD | NEW |