Index: extensions/browser/app_window/app_window_registry.cc |
diff --git a/extensions/browser/app_window/app_window_registry.cc b/extensions/browser/app_window/app_window_registry.cc |
index d07249956a79daa63e98ada08721486b7398e32c..d7ab8621d6b9edf985d0c9ca2977b0c4001965c1 100644 |
--- a/extensions/browser/app_window/app_window_registry.cc |
+++ b/extensions/browser/app_window/app_window_registry.cc |
@@ -7,11 +7,11 @@ |
#include <string> |
#include <vector> |
+#include "base/strings/stringprintf.h" |
#include "components/keyed_service/content/browser_context_dependency_manager.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/devtools_agent_host.h" |
#include "content/public/browser/render_process_host.h" |
-#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/site_instance.h" |
#include "content/public/browser/web_contents.h" |
#include "extensions/browser/app_window/app_window.h" |
@@ -21,32 +21,6 @@ |
namespace extensions { |
-namespace { |
- |
-// Create a key that identifies a AppWindow in a RenderViewHost across App |
-// reloads. If the window was given an id in CreateParams, the key is the |
-// extension id, a colon separator, and the AppWindow's |id|. If there is no |
-// |id|, the chrome-extension://extension-id/page.html URL will be used. If the |
-// RenderViewHost is not for a AppWindow, return an empty string. |
-std::string GetWindowKeyForRenderViewHost( |
- const AppWindowRegistry* registry, |
- content::RenderViewHost* render_view_host) { |
- AppWindow* app_window = |
- registry->GetAppWindowForRenderViewHost(render_view_host); |
- if (!app_window) |
- return std::string(); // Not a AppWindow. |
- |
- if (app_window->window_key().empty()) |
- return app_window->web_contents()->GetURL().possibly_invalid_spec(); |
- |
- std::string key = app_window->extension_id(); |
- key += ':'; |
- key += app_window->window_key(); |
- return key; |
-} |
- |
-} // namespace |
- |
void AppWindowRegistry::Observer::OnAppWindowAdded(AppWindow* app_window) { |
} |
@@ -148,7 +122,7 @@ void AppWindowRegistry::CloseAllAppWindowsForApp(const std::string& app_id) { |
} |
AppWindow* AppWindowRegistry::GetAppWindowForWebContents( |
- content::WebContents* web_contents) const { |
+ const content::WebContents* web_contents) const { |
for (AppWindow* window : app_windows_) { |
if (window->web_contents() == web_contents) |
return window; |
@@ -156,12 +130,6 @@ AppWindow* AppWindowRegistry::GetAppWindowForWebContents( |
return nullptr; |
} |
-AppWindow* AppWindowRegistry::GetAppWindowForRenderViewHost( |
- content::RenderViewHost* render_view_host) const { |
- return GetAppWindowForWebContents( |
- content::WebContents::FromRenderViewHost(render_view_host)); |
-} |
- |
AppWindow* AppWindowRegistry::GetAppWindowForNativeWindow( |
gfx::NativeWindow window) const { |
for (AppWindowList::const_iterator i = app_windows_.begin(); |
@@ -207,8 +175,8 @@ AppWindow* AppWindowRegistry::GetAppWindowForAppAndKey( |
} |
bool AppWindowRegistry::HadDevToolsAttached( |
- content::RenderViewHost* render_view_host) const { |
- std::string key = GetWindowKeyForRenderViewHost(this, render_view_host); |
+ content::WebContents* web_contents) const { |
+ std::string key = GetWindowKeyForWebContents(web_contents); |
return key.empty() ? false : inspected_windows_.count(key) != 0; |
} |
@@ -220,8 +188,7 @@ void AppWindowRegistry::OnDevToolsStateChanged( |
if (!web_contents || web_contents->GetBrowserContext() != context_) |
return; |
- std::string key = |
- GetWindowKeyForRenderViewHost(this, web_contents->GetRenderViewHost()); |
+ std::string key = GetWindowKeyForWebContents(web_contents); |
if (key.empty()) |
return; |
@@ -247,6 +214,19 @@ void AppWindowRegistry::BringToFront(AppWindow* app_window) { |
app_windows_.push_front(app_window); |
} |
+std::string AppWindowRegistry::GetWindowKeyForWebContents( |
+ content::WebContents* web_contents) const { |
+ AppWindow* app_window = GetAppWindowForWebContents(web_contents); |
+ if (!app_window) |
+ return std::string(); // Not a AppWindow. |
not at google - send to devlin
2015/07/08 20:22:20
an AppWindow
Devlin
2015/07/08 21:08:46
vim yank apparently doesn't also grammar check :P
|
+ |
+ if (app_window->window_key().empty()) |
+ return web_contents->GetURL().possibly_invalid_spec(); |
+ |
+ return base::StringPrintf("%s:%s", app_window->extension_id().c_str(), |
+ app_window->window_key().c_str()); |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
// Factory boilerplate |