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 #include "apps/shell_window.h" |
5 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
6 #include "chrome/browser/extensions/shell_window_registry.h" | 7 #include "chrome/browser/extensions/shell_window_registry.h" |
7 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/extensions/native_app_window.h" | 10 #include "chrome/browser/ui/extensions/native_app_window.h" |
10 #include "chrome/browser/ui/extensions/shell_window.h" | |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 12 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
13 #include "content/public/browser/devtools_agent_host.h" | 13 #include "content/public/browser/devtools_agent_host.h" |
14 #include "content/public/browser/devtools_manager.h" | 14 #include "content/public/browser/devtools_manager.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/site_instance.h" | 17 #include "content/public/browser/site_instance.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 | 19 |
| 20 using apps::ShellWindow; |
| 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 // Create a key that identifies a ShellWindow in a RenderViewHost across App | 24 // Create a key that identifies a ShellWindow in a RenderViewHost across App |
23 // reloads. If the window was given an id in CreateParams, the key is the | 25 // reloads. If the window was given an id in CreateParams, the key is the |
24 // extension id, a colon separator, and the ShellWindow's |id|. If there is no | 26 // extension id, a colon separator, and the ShellWindow's |id|. If there is no |
25 // |id|, the chrome-extension://extension-id/page.html URL will be used. If the | 27 // |id|, the chrome-extension://extension-id/page.html URL will be used. If the |
26 // RenderViewHost is not for a ShellWindow, return an empty string. | 28 // RenderViewHost is not for a ShellWindow, return an empty string. |
27 std::string GetWindowKeyForRenderViewHost( | 29 std::string GetWindowKeyForRenderViewHost( |
28 const extensions::ShellWindowRegistry* registry, | 30 const extensions::ShellWindowRegistry* registry, |
29 content::RenderViewHost* render_view_host) { | 31 content::RenderViewHost* render_view_host) { |
30 ShellWindow* shell_window = | 32 ShellWindow* shell_window = |
31 registry->GetShellWindowForRenderViewHost(render_view_host); | 33 registry->GetShellWindowForRenderViewHost(render_view_host); |
32 if (!shell_window) | 34 if (!shell_window) |
33 return std::string(); // Not a ShellWindow. | 35 return std::string(); // Not a ShellWindow. |
34 | 36 |
35 if (shell_window->window_key().empty()) | 37 if (shell_window->window_key().empty()) |
36 return shell_window->web_contents()->GetURL().possibly_invalid_spec(); | 38 return shell_window->web_contents()->GetURL().possibly_invalid_spec(); |
37 | 39 |
38 std::string key = shell_window->extension()->id(); | 40 std::string key = shell_window->extension()->id(); |
39 key += ':'; | 41 key += ':'; |
40 key += shell_window->window_key(); | 42 key += shell_window->window_key(); |
41 return key; | 43 return key; |
42 } | 44 } |
43 | 45 |
44 } | 46 } // namespace |
45 | 47 |
46 namespace extensions { | 48 namespace extensions { |
47 | 49 |
48 ShellWindowRegistry::ShellWindowRegistry(Profile* profile) | 50 ShellWindowRegistry::ShellWindowRegistry(Profile* profile) |
49 : profile_(profile), | 51 : profile_(profile), |
50 devtools_callback_(base::Bind( | 52 devtools_callback_(base::Bind( |
51 &ShellWindowRegistry::OnDevToolsStateChanged, | 53 &ShellWindowRegistry::OnDevToolsStateChanged, |
52 base::Unretained(this))) { | 54 base::Unretained(this))) { |
53 content::DevToolsManager::GetInstance()->AddAgentStateCallback( | 55 content::DevToolsManager::GetInstance()->AddAgentStateCallback( |
54 devtools_callback_); | 56 devtools_callback_); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 bool ShellWindowRegistry::Factory::ServiceIsNULLWhileTesting() const { | 287 bool ShellWindowRegistry::Factory::ServiceIsNULLWhileTesting() const { |
286 return false; | 288 return false; |
287 } | 289 } |
288 | 290 |
289 content::BrowserContext* ShellWindowRegistry::Factory::GetBrowserContextToUse( | 291 content::BrowserContext* ShellWindowRegistry::Factory::GetBrowserContextToUse( |
290 content::BrowserContext* context) const { | 292 content::BrowserContext* context) const { |
291 return chrome::GetBrowserContextRedirectedInIncognito(context); | 293 return chrome::GetBrowserContextRedirectedInIncognito(context); |
292 } | 294 } |
293 | 295 |
294 } // namespace extensions | 296 } // namespace extensions |
OLD | NEW |