summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-15 05:36:33 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-15 05:36:33 +0000
commitdbb03fbe591bdf4e711af10c3e8233e68b29ee49 (patch)
tree0958d99e8988d6bfd7aefe6bf024b425fbef46af /apps
parent26f8f3aa15d34fd29080889512131b02d933fef5 (diff)
downloadchromium_src-dbb03fbe591bdf4e711af10c3e8233e68b29ee49.zip
chromium_src-dbb03fbe591bdf4e711af10c3e8233e68b29ee49.tar.gz
chromium_src-dbb03fbe591bdf4e711af10c3e8233e68b29ee49.tar.bz2
Rename apps::ShellWindow to apps::AppWindow
* Rename ShellWindowRegistry * Rename ShellWindowGeometryCache * Rename members like shell_window_ to app_window_ * Rename locals like shell_window to app_window BUG=343591 TEST=compiles COLLABORATOR=scheib@chromium.org TBR=skuhne@chromium.org for chrome/browser/ui/ash/launcher TBR=thakis@chromium.org for chrome/browser/ui/cocoa TBR=erg@chromium.org for chrome/browser/ui/gtk TBR=sky@chromium.org for chrome/test Review URL: https://codereview.chromium.org/166573005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251542 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r--apps/app_keep_alive_service_factory.cc2
-rw-r--r--apps/app_lifetime_monitor.cc46
-rw-r--r--apps/app_lifetime_monitor.h12
-rw-r--r--apps/app_lifetime_monitor_factory.cc4
-rw-r--r--apps/app_load_service.cc11
-rw-r--r--apps/app_load_service.h2
-rw-r--r--apps/app_load_service_factory.cc4
-rw-r--r--apps/app_restore_service.cc2
-rw-r--r--apps/app_restore_service.h2
-rw-r--r--apps/app_shim/app_shim_handler_mac.cc18
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac.cc77
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac.h17
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac_unittest.cc20
-rw-r--r--apps/app_window.cc (renamed from apps/shell_window.cc)399
-rw-r--r--apps/app_window.h (renamed from apps/shell_window.h)135
-rw-r--r--apps/app_window_contents.cc40
-rw-r--r--apps/app_window_contents.h22
-rw-r--r--apps/app_window_geometry_cache.cc (renamed from apps/shell_window_geometry_cache.cc)153
-rw-r--r--apps/app_window_geometry_cache.h (renamed from apps/shell_window_geometry_cache.h)29
-rw-r--r--apps/app_window_geometry_cache_unittest.cc (renamed from apps/shell_window_geometry_cache_unittest.cc)111
-rw-r--r--apps/app_window_interactive_uitest.cc (renamed from apps/shell_window_interactive_uitest.cc)72
-rw-r--r--apps/app_window_registry.cc307
-rw-r--r--apps/app_window_registry.h147
-rw-r--r--apps/apps.gypi16
-rw-r--r--apps/shell_window_registry.cc309
-rw-r--r--apps/shell_window_registry.h147
-rw-r--r--apps/ui/native_app_window.h8
-rw-r--r--apps/ui/views/app_window_frame_view.cc (renamed from apps/ui/views/shell_window_frame_view.cc)149
-rw-r--r--apps/ui/views/app_window_frame_view.h (renamed from apps/ui/views/shell_window_frame_view.h)22
29 files changed, 1135 insertions, 1148 deletions
diff --git a/apps/app_keep_alive_service_factory.cc b/apps/app_keep_alive_service_factory.cc
index c33452b..5afe050 100644
--- a/apps/app_keep_alive_service_factory.cc
+++ b/apps/app_keep_alive_service_factory.cc
@@ -6,7 +6,7 @@
#include "apps/app_keep_alive_service.h"
#include "apps/app_lifetime_monitor_factory.h"
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "extensions/browser/extensions_browser_client.h"
diff --git a/apps/app_lifetime_monitor.cc b/apps/app_lifetime_monitor.cc
index f2bb345..b207b04 100644
--- a/apps/app_lifetime_monitor.cc
+++ b/apps/app_lifetime_monitor.cc
@@ -4,7 +4,7 @@
#include "apps/app_lifetime_monitor.h"
-#include "apps/shell_window.h"
+#include "apps/app_window.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/profiles/profile.h"
@@ -29,11 +29,11 @@ AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile)
this, chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources());
- ShellWindowRegistry* shell_window_registry =
- ShellWindowRegistry::Factory::GetForBrowserContext(
- profile_, false /* create */);
- DCHECK(shell_window_registry);
- shell_window_registry->AddObserver(this);
+ AppWindowRegistry* app_window_registry =
+ AppWindowRegistry::Factory::GetForBrowserContext(profile_,
+ false /* create */);
+ DCHECK(app_window_registry);
+ app_window_registry->AddObserver(this);
}
AppLifetimeMonitor::~AppLifetimeMonitor() {}
@@ -77,33 +77,33 @@ void AppLifetimeMonitor::Observe(int type,
}
}
-void AppLifetimeMonitor::OnShellWindowAdded(ShellWindow* shell_window) {
- if (shell_window->window_type() != ShellWindow::WINDOW_TYPE_DEFAULT)
+void AppLifetimeMonitor::OnAppWindowAdded(AppWindow* app_window) {
+ if (app_window->window_type() != AppWindow::WINDOW_TYPE_DEFAULT)
return;
- ShellWindowRegistry::ShellWindowList windows =
- ShellWindowRegistry::Get(shell_window->browser_context())
- ->GetShellWindowsForApp(shell_window->extension_id());
+ AppWindowRegistry::AppWindowList windows =
+ AppWindowRegistry::Get(app_window->browser_context())
+ ->GetAppWindowsForApp(app_window->extension_id());
if (windows.size() == 1)
- NotifyAppActivated(shell_window->extension_id());
+ NotifyAppActivated(app_window->extension_id());
}
-void AppLifetimeMonitor::OnShellWindowIconChanged(ShellWindow* shell_window) {}
+void AppLifetimeMonitor::OnAppWindowIconChanged(AppWindow* app_window) {}
-void AppLifetimeMonitor::OnShellWindowRemoved(ShellWindow* shell_window) {
- ShellWindowRegistry::ShellWindowList windows =
- ShellWindowRegistry::Get(shell_window->browser_context())
- ->GetShellWindowsForApp(shell_window->extension_id());
+void AppLifetimeMonitor::OnAppWindowRemoved(AppWindow* app_window) {
+ AppWindowRegistry::AppWindowList windows =
+ AppWindowRegistry::Get(app_window->browser_context())
+ ->GetAppWindowsForApp(app_window->extension_id());
if (windows.empty())
- NotifyAppDeactivated(shell_window->extension_id());
+ NotifyAppDeactivated(app_window->extension_id());
}
void AppLifetimeMonitor::Shutdown() {
- ShellWindowRegistry* shell_window_registry =
- ShellWindowRegistry::Factory::GetForBrowserContext(
- profile_, false /* create */);
- if (shell_window_registry)
- shell_window_registry->RemoveObserver(this);
+ AppWindowRegistry* app_window_registry =
+ AppWindowRegistry::Factory::GetForBrowserContext(profile_,
+ false /* create */);
+ if (app_window_registry)
+ app_window_registry->RemoveObserver(this);
}
void AppLifetimeMonitor::NotifyAppStart(const std::string& app_id) {
diff --git a/apps/app_lifetime_monitor.h b/apps/app_lifetime_monitor.h
index 2da6550..45ab09a 100644
--- a/apps/app_lifetime_monitor.h
+++ b/apps/app_lifetime_monitor.h
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "base/observer_list.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "content/public/browser/notification_observer.h"
@@ -26,7 +26,7 @@ namespace apps {
// events.
class AppLifetimeMonitor : public BrowserContextKeyedService,
public content::NotificationObserver,
- public ShellWindowRegistry::Observer {
+ public AppWindowRegistry::Observer {
public:
class Observer {
public:
@@ -61,10 +61,10 @@ class AppLifetimeMonitor : public BrowserContextKeyedService,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // ShellWindowRegistry::Observer overrides:
- virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE;
- virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE;
- virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE;
+ // AppWindowRegistry::Observer overrides:
+ virtual void OnAppWindowAdded(AppWindow* app_window) OVERRIDE;
+ virtual void OnAppWindowIconChanged(AppWindow* app_window) OVERRIDE;
+ virtual void OnAppWindowRemoved(AppWindow* app_window) OVERRIDE;
// BrowserContextKeyedService overrides:
virtual void Shutdown() OVERRIDE;
diff --git a/apps/app_lifetime_monitor_factory.cc b/apps/app_lifetime_monitor_factory.cc
index 7d37e4e..b8a813a 100644
--- a/apps/app_lifetime_monitor_factory.cc
+++ b/apps/app_lifetime_monitor_factory.cc
@@ -5,7 +5,7 @@
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_lifetime_monitor.h"
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "extensions/browser/extensions_browser_client.h"
@@ -26,7 +26,7 @@ AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
: BrowserContextKeyedServiceFactory(
"AppLifetimeMonitor",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(ShellWindowRegistry::Factory::GetInstance());
+ DependsOn(AppWindowRegistry::Factory::GetInstance());
}
AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() {}
diff --git a/apps/app_load_service.cc b/apps/app_load_service.cc
index a64cffc..ae60f7f 100644
--- a/apps/app_load_service.cc
+++ b/apps/app_load_service.cc
@@ -5,8 +5,8 @@
#include "apps/app_load_service.h"
#include "apps/app_load_service_factory.h"
+#include "apps/app_window_registry.h"
#include "apps/launcher.h"
-#include "apps/shell_window_registry.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -116,7 +116,7 @@ void AppLoadService::Observe(int type,
break;
if (WasUnloadedForReload(*unload_info) &&
- HasShellWindows(unload_info->extension->id()) &&
+ HasAppWindows(unload_info->extension->id()) &&
!HasPostReloadAction(unload_info->extension->id())) {
post_reload_actions_[unload_info->extension->id()].action_type = LAUNCH;
}
@@ -127,9 +127,10 @@ void AppLoadService::Observe(int type,
}
}
-bool AppLoadService::HasShellWindows(const std::string& extension_id) {
- return !ShellWindowRegistry::Get(profile_)->
- GetShellWindowsForApp(extension_id).empty();
+bool AppLoadService::HasAppWindows(const std::string& extension_id) {
+ return !AppWindowRegistry::Get(profile_)
+ ->GetAppWindowsForApp(extension_id)
+ .empty();
}
bool AppLoadService::WasUnloadedForReload(
diff --git a/apps/app_load_service.h b/apps/app_load_service.h
index 9f0d971..518a30a 100644
--- a/apps/app_load_service.h
+++ b/apps/app_load_service.h
@@ -64,7 +64,7 @@ class AppLoadService : public BrowserContextKeyedService,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- bool HasShellWindows(const std::string& extension_id);
+ bool HasAppWindows(const std::string& extension_id);
bool WasUnloadedForReload(
const extensions::UnloadedExtensionInfo& unload_info);
bool HasPostReloadAction(const std::string& extension_id);
diff --git a/apps/app_load_service_factory.cc b/apps/app_load_service_factory.cc
index 60b0e9f..771db73 100644
--- a/apps/app_load_service_factory.cc
+++ b/apps/app_load_service_factory.cc
@@ -5,7 +5,7 @@
#include "apps/app_load_service_factory.h"
#include "apps/app_load_service.h"
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "extensions/browser/extension_prefs_factory.h"
@@ -31,7 +31,7 @@ AppLoadServiceFactory::AppLoadServiceFactory()
DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
- DependsOn(ShellWindowRegistry::Factory::GetInstance());
+ DependsOn(AppWindowRegistry::Factory::GetInstance());
}
AppLoadServiceFactory::~AppLoadServiceFactory() {
diff --git a/apps/app_restore_service.cc b/apps/app_restore_service.cc
index c9fca85..3193fc6 100644
--- a/apps/app_restore_service.cc
+++ b/apps/app_restore_service.cc
@@ -6,9 +6,9 @@
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_restore_service_factory.h"
+#include "apps/app_window.h"
#include "apps/launcher.h"
#include "apps/saved_files_service.h"
-#include "apps/shell_window.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h"
#include "chrome/browser/extensions/extension_host.h"
diff --git a/apps/app_restore_service.h b/apps/app_restore_service.h
index 425364e..9dd88cf 100644
--- a/apps/app_restore_service.h
+++ b/apps/app_restore_service.h
@@ -9,7 +9,7 @@
#include <vector>
#include "apps/app_lifetime_monitor.h"
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
namespace extensions {
diff --git a/apps/app_shim/app_shim_handler_mac.cc b/apps/app_shim/app_shim_handler_mac.cc
index f50acdb..cfbf4ff 100644
--- a/apps/app_shim/app_shim_handler_mac.cc
+++ b/apps/app_shim/app_shim_handler_mac.cc
@@ -6,7 +6,7 @@
#include <map>
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
@@ -22,11 +22,12 @@ namespace apps {
namespace {
-void TerminateIfNoShellWindows() {
- bool shell_windows_left =
- apps::ShellWindowRegistry::IsShellWindowRegisteredInAnyProfile(0);
- if (!shell_windows_left && !AppListService::Get(
- chrome::HOST_DESKTOP_TYPE_NATIVE)->IsAppListVisible()) {
+void TerminateIfNoAppWindows() {
+ bool app_windows_left =
+ apps::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0);
+ if (!app_windows_left &&
+ !AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)
+ ->IsAppListVisible()) {
chrome::AttemptExit();
}
}
@@ -61,11 +62,10 @@ class AppShimHandlerRegistry : public content::NotificationObserver {
void MaybeTerminate() {
if (!browser_opened_ever_) {
- // Post this to give ShellWindows a chance to remove themselves from the
+ // Post this to give AppWindows a chance to remove themselves from the
// registry.
base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&TerminateIfNoShellWindows));
+ FROM_HERE, base::Bind(&TerminateIfNoAppWindows));
}
}
diff --git a/apps/app_shim/extension_app_shim_handler_mac.cc b/apps/app_shim/extension_app_shim_handler_mac.cc
index d9917bc..2f51e43 100644
--- a/apps/app_shim/extension_app_shim_handler_mac.cc
+++ b/apps/app_shim/extension_app_shim_handler_mac.cc
@@ -7,9 +7,9 @@
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_shim/app_shim_host_manager_mac.h"
#include "apps/app_shim/app_shim_messages.h"
+#include "apps/app_window.h"
+#include "apps/app_window_registry.h"
#include "apps/launcher.h"
-#include "apps/shell_window.h"
-#include "apps/shell_window_registry.h"
#include "apps/ui/native_app_window.h"
#include "base/files/file_path.h"
#include "base/logging.h"
@@ -34,7 +34,7 @@ using extensions::ExtensionRegistry;
namespace {
-typedef apps::ShellWindowRegistry::ShellWindowList ShellWindowList;
+typedef apps::AppWindowRegistry::AppWindowList AppWindowList;
void ProfileLoadedCallback(base::Callback<void(Profile*)> callback,
Profile* profile,
@@ -49,10 +49,11 @@ void ProfileLoadedCallback(base::Callback<void(Profile*)> callback,
}
void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) {
- ShellWindowList windows =
- apps::ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(app_id);
- for (ShellWindowList::const_reverse_iterator it = windows.rbegin();
- it != windows.rend(); ++it) {
+ AppWindowList windows =
+ apps::AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id);
+ for (AppWindowList::const_reverse_iterator it = windows.rbegin();
+ it != windows.rend();
+ ++it) {
if (hidden)
(*it)->GetBaseWindow()->HideWithApp();
else
@@ -60,13 +61,13 @@ void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) {
}
}
-bool FocusWindows(const ShellWindowList& windows) {
+bool FocusWindows(const AppWindowList& windows) {
if (windows.empty())
return false;
std::set<gfx::NativeWindow> native_windows;
- for (ShellWindowList::const_iterator it = windows.begin();
- it != windows.end(); ++it) {
+ for (AppWindowList::const_iterator it = windows.begin(); it != windows.end();
+ ++it) {
native_windows.insert((*it)->GetNativeWindow());
}
// Allow workspace switching. For the browser process, we can reasonably rely
@@ -153,10 +154,10 @@ void ExtensionAppShimHandler::Delegate::LoadProfileAsync(
base::string16(), base::string16(), std::string());
}
-ShellWindowList ExtensionAppShimHandler::Delegate::GetWindows(
+AppWindowList ExtensionAppShimHandler::Delegate::GetWindows(
Profile* profile,
const std::string& extension_id) {
- return ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(extension_id);
+ return AppWindowRegistry::Get(profile)->GetAppWindowsForApp(extension_id);
}
const extensions::Extension*
@@ -226,44 +227,41 @@ AppShimHandler::Host* ExtensionAppShimHandler::FindHost(
}
// static
-void ExtensionAppShimHandler::QuitAppForWindow(ShellWindow* shell_window) {
+void ExtensionAppShimHandler::QuitAppForWindow(AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
Host* host = handler->FindHost(
- Profile::FromBrowserContext(shell_window->browser_context()),
- shell_window->extension_id());
+ Profile::FromBrowserContext(app_window->browser_context()),
+ app_window->extension_id());
if (host) {
handler->OnShimQuit(host);
} else {
// App shims might be disabled or the shim is still starting up.
- ShellWindowRegistry::Get(
- Profile::FromBrowserContext(shell_window->browser_context()))
- ->CloseAllShellWindowsForApp(shell_window->extension_id());
+ AppWindowRegistry::Get(
+ Profile::FromBrowserContext(app_window->browser_context()))
+ ->CloseAllAppWindowsForApp(app_window->extension_id());
}
}
-void ExtensionAppShimHandler::HideAppForWindow(ShellWindow* shell_window) {
+void ExtensionAppShimHandler::HideAppForWindow(AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
- Profile* profile =
- Profile::FromBrowserContext(shell_window->browser_context());
- Host* host = handler->FindHost(profile, shell_window->extension_id());
+ Profile* profile = Profile::FromBrowserContext(app_window->browser_context());
+ Host* host = handler->FindHost(profile, app_window->extension_id());
if (host)
host->OnAppHide();
else
- SetAppHidden(profile, shell_window->extension_id(), true);
+ SetAppHidden(profile, app_window->extension_id(), true);
}
-
-void ExtensionAppShimHandler::FocusAppForWindow(ShellWindow* shell_window) {
+void ExtensionAppShimHandler::FocusAppForWindow(AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
- Profile* profile =
- Profile::FromBrowserContext(shell_window->browser_context());
- const std::string& app_id = shell_window->extension_id();
+ Profile* profile = Profile::FromBrowserContext(app_window->browser_context());
+ const std::string& app_id = app_window->extension_id();
Host* host = handler->FindHost(profile, app_id);
if (host) {
handler->OnShimFocus(host,
@@ -271,27 +269,26 @@ void ExtensionAppShimHandler::FocusAppForWindow(ShellWindow* shell_window) {
std::vector<base::FilePath>());
} else {
FocusWindows(
- apps::ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(app_id));
+ apps::AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id));
}
}
// static
bool ExtensionAppShimHandler::RequestUserAttentionForWindow(
- ShellWindow* shell_window) {
+ AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
- Profile* profile =
- Profile::FromBrowserContext(shell_window->browser_context());
- Host* host = handler->FindHost(profile, shell_window->extension_id());
+ Profile* profile = Profile::FromBrowserContext(app_window->browser_context());
+ Host* host = handler->FindHost(profile, app_window->extension_id());
if (host) {
// Bring the window to the front without showing it.
- ShellWindowRegistry::Get(profile)->ShellWindowActivated(shell_window);
+ AppWindowRegistry::Get(profile)->AppWindowActivated(app_window);
host->OnAppRequestUserAttention();
return true;
} else {
// Just show the app.
- SetAppHidden(profile, shell_window->extension_id(), false);
+ SetAppHidden(profile, app_window->extension_id(), false);
return false;
}
}
@@ -418,7 +415,7 @@ void ExtensionAppShimHandler::OnShimFocus(
DCHECK(delegate_->ProfileExistsForPath(host->GetProfilePath()));
Profile* profile = delegate_->ProfileForPath(host->GetProfilePath());
- const ShellWindowList windows =
+ const AppWindowList windows =
delegate_->GetWindows(profile, host->GetAppId());
bool windows_focused = FocusWindows(windows);
@@ -450,10 +447,10 @@ void ExtensionAppShimHandler::OnShimQuit(Host* host) {
Profile* profile = delegate_->ProfileForPath(host->GetProfilePath());
const std::string& app_id = host->GetAppId();
- const ShellWindowList windows =
- delegate_->GetWindows(profile, app_id);
- for (ShellWindowRegistry::const_iterator it = windows.begin();
- it != windows.end(); ++it) {
+ const AppWindowList windows = delegate_->GetWindows(profile, app_id);
+ for (AppWindowRegistry::const_iterator it = windows.begin();
+ it != windows.end();
+ ++it) {
(*it)->GetBaseWindow()->Close();
}
// Once the last window closes, flow will end up in OnAppDeactivated via
diff --git a/apps/app_shim/extension_app_shim_handler_mac.h b/apps/app_shim/extension_app_shim_handler_mac.h
index c8069ce2..0fc8a84 100644
--- a/apps/app_shim/extension_app_shim_handler_mac.h
+++ b/apps/app_shim/extension_app_shim_handler_mac.h
@@ -11,7 +11,7 @@
#include "apps/app_lifetime_monitor.h"
#include "apps/app_shim/app_shim_handler_mac.h"
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_registry.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/notification_observer.h"
@@ -33,7 +33,7 @@ class Extension;
namespace apps {
-class ShellWindow;
+class AppWindow;
// This app shim handler that handles events for app shims that correspond to an
// extension.
@@ -50,8 +50,9 @@ class ExtensionAppShimHandler : public AppShimHandler,
virtual void LoadProfileAsync(const base::FilePath& path,
base::Callback<void(Profile*)> callback);
- virtual ShellWindowRegistry::ShellWindowList GetWindows(
- Profile* profile, const std::string& extension_id);
+ virtual AppWindowRegistry::AppWindowList GetWindows(
+ Profile* profile,
+ const std::string& extension_id);
virtual const extensions::Extension* GetAppExtension(
Profile* profile, const std::string& extension_id);
@@ -72,15 +73,15 @@ class ExtensionAppShimHandler : public AppShimHandler,
AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id);
- static void QuitAppForWindow(ShellWindow* shell_window);
+ static void QuitAppForWindow(AppWindow* app_window);
- static void HideAppForWindow(ShellWindow* shell_window);
+ static void HideAppForWindow(AppWindow* app_window);
- static void FocusAppForWindow(ShellWindow* shell_window);
+ static void FocusAppForWindow(AppWindow* app_window);
// Brings the window to the front without showing it and instructs the shim to
// request user attention. Returns false if there is no shim for this window.
- static bool RequestUserAttentionForWindow(ShellWindow* shell_window);
+ static bool RequestUserAttentionForWindow(AppWindow* app_window);
// AppShimHandler overrides:
virtual void OnShimLaunch(Host* host,
diff --git a/apps/app_shim/extension_app_shim_handler_mac_unittest.cc b/apps/app_shim/extension_app_shim_handler_mac_unittest.cc
index 4e528f3..753bd516 100644
--- a/apps/app_shim/extension_app_shim_handler_mac_unittest.cc
+++ b/apps/app_shim/extension_app_shim_handler_mac_unittest.cc
@@ -18,7 +18,7 @@
namespace apps {
using extensions::Extension;
-typedef ShellWindowRegistry::ShellWindowList ShellWindowList;
+typedef AppWindowRegistry::AppWindowList AppWindowList;
using ::testing::_;
using ::testing::Invoke;
@@ -35,7 +35,7 @@ class MockDelegate : public ExtensionAppShimHandler::Delegate {
void(const base::FilePath&,
base::Callback<void(Profile*)>));
- MOCK_METHOD2(GetWindows, ShellWindowList(Profile*, const std::string&));
+ MOCK_METHOD2(GetWindows, AppWindowList(Profile*, const std::string&));
MOCK_METHOD2(GetAppExtension, const Extension*(Profile*, const std::string&));
MOCK_METHOD3(EnableExtension, void(Profile*,
@@ -175,10 +175,10 @@ class ExtensionAppShimHandlerTest : public testing::Test {
// In most tests, we don't care about the result of GetWindows, it just
// needs to be non-empty.
- ShellWindowList shell_window_list;
- shell_window_list.push_back(static_cast<ShellWindow*>(NULL));
+ AppWindowList app_window_list;
+ app_window_list.push_back(static_cast<AppWindow*>(NULL));
EXPECT_CALL(*delegate_, GetWindows(_, _))
- .WillRepeatedly(Return(shell_window_list));
+ .WillRepeatedly(Return(app_window_list));
EXPECT_CALL(*delegate_, GetAppExtension(_, kTestAppIdA))
.WillRepeatedly(Return(extension_a_.get()));
@@ -302,10 +302,10 @@ TEST_F(ExtensionAppShimHandlerTest, AppLifetime) {
RegisterOnlyLaunch(&host_aa_);
EXPECT_EQ(&host_aa_, handler_->FindHost(&profile_a_, kTestAppIdA));
- // Return no shell windows for OnShimFocus and OnShimQuit.
- ShellWindowList shell_window_list;
+ // Return no app windows for OnShimFocus and OnShimQuit.
+ AppWindowList app_window_list;
EXPECT_CALL(*delegate_, GetWindows(&profile_a_, kTestAppIdA))
- .WillRepeatedly(Return(shell_window_list));
+ .WillRepeatedly(Return(app_window_list));
// Non-reopen focus does nothing.
EXPECT_CALL(*handler_, OnShimFocus(&host_aa_, APP_SHIM_FOCUS_NORMAL, _))
@@ -351,9 +351,9 @@ TEST_F(ExtensionAppShimHandlerTest, MaybeTerminate) {
EXPECT_EQ(&host_ab_, handler_->FindHost(&profile_a_, kTestAppIdB));
// Return empty window list.
- ShellWindowList shell_window_list;
+ AppWindowList app_window_list;
EXPECT_CALL(*delegate_, GetWindows(_, _))
- .WillRepeatedly(Return(shell_window_list));
+ .WillRepeatedly(Return(app_window_list));
// Quitting when there's another shim should not terminate.
EXPECT_CALL(*delegate_, MaybeTerminate())
diff --git a/apps/shell_window.cc b/apps/app_window.cc
index 8bb6262..d13500d 100644
--- a/apps/shell_window.cc
+++ b/apps/app_window.cc
@@ -1,11 +1,11 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "apps/shell_window.h"
+#include "apps/app_window.h"
-#include "apps/shell_window_geometry_cache.h"
-#include "apps/shell_window_registry.h"
+#include "apps/app_window_geometry_cache.h"
+#include "apps/app_window_registry.h"
#include "apps/ui/native_app_window.h"
#include "base/command_line.h"
#include "base/strings/string_util.h"
@@ -57,26 +57,23 @@ const int kDefaultWidth = 512;
const int kDefaultHeight = 384;
bool IsFullscreen(int fullscreen_types) {
- return fullscreen_types != apps::ShellWindow::FULLSCREEN_TYPE_NONE;
+ return fullscreen_types != apps::AppWindow::FULLSCREEN_TYPE_NONE;
}
} // namespace
namespace apps {
-ShellWindow::SizeConstraints::SizeConstraints()
- : maximum_size_(kUnboundedSize, kUnboundedSize) {
-}
+AppWindow::SizeConstraints::SizeConstraints()
+ : maximum_size_(kUnboundedSize, kUnboundedSize) {}
-ShellWindow::SizeConstraints::SizeConstraints(const gfx::Size& min_size,
- const gfx::Size& max_size)
- : minimum_size_(min_size),
- maximum_size_(max_size) {
-}
+AppWindow::SizeConstraints::SizeConstraints(const gfx::Size& min_size,
+ const gfx::Size& max_size)
+ : minimum_size_(min_size), maximum_size_(max_size) {}
-ShellWindow::SizeConstraints::~SizeConstraints() {}
+AppWindow::SizeConstraints::~SizeConstraints() {}
-gfx::Size ShellWindow::SizeConstraints::ClampSize(gfx::Size size) const {
+gfx::Size AppWindow::SizeConstraints::ClampSize(gfx::Size size) const {
const gfx::Size max_size = GetMaximumSize();
if (max_size.width() != kUnboundedSize)
size.set_width(std::min(size.width(), GetMaximumSize().width()));
@@ -86,62 +83,62 @@ gfx::Size ShellWindow::SizeConstraints::ClampSize(gfx::Size size) const {
return size;
}
-bool ShellWindow::SizeConstraints::HasMinimumSize() const {
+bool AppWindow::SizeConstraints::HasMinimumSize() const {
return GetMinimumSize().width() != kUnboundedSize ||
- GetMinimumSize().height() != kUnboundedSize;
+ GetMinimumSize().height() != kUnboundedSize;
}
-bool ShellWindow::SizeConstraints::HasMaximumSize() const {
+bool AppWindow::SizeConstraints::HasMaximumSize() const {
const gfx::Size max_size = GetMaximumSize();
return max_size.width() != kUnboundedSize ||
- max_size.height() != kUnboundedSize;
+ max_size.height() != kUnboundedSize;
}
-bool ShellWindow::SizeConstraints::HasFixedSize() const {
+bool AppWindow::SizeConstraints::HasFixedSize() const {
return !GetMinimumSize().IsEmpty() && GetMinimumSize() == GetMaximumSize();
}
-gfx::Size ShellWindow::SizeConstraints::GetMinimumSize() const {
+gfx::Size AppWindow::SizeConstraints::GetMinimumSize() const {
return minimum_size_;
}
-gfx::Size ShellWindow::SizeConstraints::GetMaximumSize() const {
+gfx::Size AppWindow::SizeConstraints::GetMaximumSize() const {
return gfx::Size(
- maximum_size_.width() == kUnboundedSize ?
- kUnboundedSize :
- std::max(maximum_size_.width(), minimum_size_.width()),
- maximum_size_.height() == kUnboundedSize ?
- kUnboundedSize :
- std::max(maximum_size_.height(), minimum_size_.height()));
+ maximum_size_.width() == kUnboundedSize
+ ? kUnboundedSize
+ : std::max(maximum_size_.width(), minimum_size_.width()),
+ maximum_size_.height() == kUnboundedSize
+ ? kUnboundedSize
+ : std::max(maximum_size_.height(), minimum_size_.height()));
}
-void ShellWindow::SizeConstraints::set_minimum_size(const gfx::Size& min_size) {
+void AppWindow::SizeConstraints::set_minimum_size(const gfx::Size& min_size) {
minimum_size_ = min_size;
}
-void ShellWindow::SizeConstraints::set_maximum_size(const gfx::Size& max_size) {
+void AppWindow::SizeConstraints::set_maximum_size(const gfx::Size& max_size) {
maximum_size_ = max_size;
}
-ShellWindow::CreateParams::CreateParams()
- : window_type(ShellWindow::WINDOW_TYPE_DEFAULT),
- frame(ShellWindow::FRAME_CHROME),
- transparent_background(false),
- bounds(INT_MIN, INT_MIN, 0, 0),
- creator_process_id(0),
- state(ui::SHOW_STATE_DEFAULT),
- hidden(false),
- resizable(true),
- focused(true),
- always_on_top(false) {}
+AppWindow::CreateParams::CreateParams()
+ : window_type(AppWindow::WINDOW_TYPE_DEFAULT),
+ frame(AppWindow::FRAME_CHROME),
+ transparent_background(false),
+ bounds(INT_MIN, INT_MIN, 0, 0),
+ creator_process_id(0),
+ state(ui::SHOW_STATE_DEFAULT),
+ hidden(false),
+ resizable(true),
+ focused(true),
+ always_on_top(false) {}
-ShellWindow::CreateParams::~CreateParams() {}
+AppWindow::CreateParams::~CreateParams() {}
-ShellWindow::Delegate::~Delegate() {}
+AppWindow::Delegate::~Delegate() {}
-ShellWindow::ShellWindow(BrowserContext* context,
- Delegate* delegate,
- const extensions::Extension* extension)
+AppWindow::AppWindow(BrowserContext* context,
+ Delegate* delegate,
+ const extensions::Extension* extension)
: browser_context_(context),
extension_(extension),
extension_id_(extension->id()),
@@ -158,15 +155,15 @@ ShellWindow::ShellWindow(BrowserContext* context,
<< "Only off the record window may be opened in the guest mode.";
}
-void ShellWindow::Init(const GURL& url,
- ShellWindowContents* shell_window_contents,
- const CreateParams& params) {
+void AppWindow::Init(const GURL& url,
+ AppWindowContents* app_window_contents,
+ const CreateParams& params) {
// Initialize the render interface and web contents
- shell_window_contents_.reset(shell_window_contents);
- shell_window_contents_->Initialize(browser_context(), url);
- WebContents* web_contents = shell_window_contents_->GetWebContents();
+ app_window_contents_.reset(app_window_contents);
+ app_window_contents_->Initialize(browser_context(), url);
+ WebContents* web_contents = app_window_contents_->GetWebContents();
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableAppsShowOnFirstPaint)) {
+ switches::kEnableAppsShowOnFirstPaint)) {
content::WebContentsObserver::Observe(web_contents);
}
delegate_->InitWebContents(web_contents);
@@ -174,16 +171,16 @@ void ShellWindow::Init(const GURL& url,
extensions::ExtensionWebContentsObserver::CreateForWebContents(web_contents);
web_contents->SetDelegate(this);
- WebContentsModalDialogManager::FromWebContents(web_contents)->
- SetDelegate(this);
+ WebContentsModalDialogManager::FromWebContents(web_contents)
+ ->SetDelegate(this);
extensions::SetViewType(web_contents, extensions::VIEW_TYPE_APP_SHELL);
// Initialize the window
CreateParams new_params = LoadDefaultsAndConstrain(params);
window_type_ = new_params.window_type;
window_key_ = new_params.window_key;
- size_constraints_ = SizeConstraints(new_params.minimum_size,
- new_params.maximum_size);
+ size_constraints_ =
+ SizeConstraints(new_params.minimum_size, new_params.maximum_size);
// Windows cannot be always-on-top in fullscreen mode for security reasons.
cached_always_on_top_ = new_params.always_on_top;
@@ -218,13 +215,14 @@ void ShellWindow::Init(const GURL& url,
content::Source<content::BrowserContext>(
client->GetOriginalContext(browser_context_)));
// Close when the browser process is exiting.
- registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
+ registrar_.Add(this,
+ chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources());
- shell_window_contents_->LoadContents(new_params.creator_process_id);
+ app_window_contents_->LoadContents(new_params.creator_process_id);
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableAppsShowOnFirstPaint)) {
+ switches::kEnableAppsShowOnFirstPaint)) {
// We want to show the window only when the content has been painted. For
// that to happen, we need to define a size for the content, otherwise the
// layout will happen in a 0x0 area.
@@ -237,10 +235,10 @@ void ShellWindow::Init(const GURL& url,
UpdateExtensionAppIcon();
- ShellWindowRegistry::Get(browser_context_)->AddShellWindow(this);
+ AppWindowRegistry::Get(browser_context_)->AddAppWindow(this);
}
-ShellWindow::~ShellWindow() {
+AppWindow::~AppWindow() {
// Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
// last window open.
registrar_.RemoveAll();
@@ -249,16 +247,16 @@ ShellWindow::~ShellWindow() {
chrome::EndKeepAlive();
}
-void ShellWindow::RequestMediaAccessPermission(
+void AppWindow::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) {
- delegate_->RequestMediaAccessPermission(web_contents, request, callback,
- extension());
+ delegate_->RequestMediaAccessPermission(
+ web_contents, request, callback, extension());
}
-WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
- const content::OpenURLParams& params) {
+WebContents* AppWindow::OpenURLFromTab(WebContents* source,
+ const content::OpenURLParams& params) {
// Don't allow the current tab to be navigated. It would be nice to map all
// anchor tags (even those without target="_blank") to new tabs, but right
// now we can't distinguish between those and <meta> refreshes or window.href
@@ -293,12 +291,12 @@ WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
return contents;
}
-void ShellWindow::AddNewContents(WebContents* source,
- WebContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture,
- bool* was_blocked) {
+void AppWindow::AddNewContents(WebContents* source,
+ WebContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture,
+ bool* was_blocked) {
DCHECK(new_contents->GetBrowserContext() == browser_context_);
delegate_->AddNewContents(browser_context_,
new_contents,
@@ -308,7 +306,7 @@ void ShellWindow::AddNewContents(WebContents* source,
was_blocked);
}
-bool ShellWindow::PreHandleKeyboardEvent(
+bool AppWindow::PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
@@ -331,7 +329,7 @@ bool ShellWindow::PreHandleKeyboardEvent(
return false;
}
-void ShellWindow::HandleKeyboardEvent(
+void AppWindow::HandleKeyboardEvent(
WebContents* source,
const content::NativeWebKeyboardEvent& event) {
// If the window is currently fullscreen and not forced, ESC should leave
@@ -347,9 +345,9 @@ void ShellWindow::HandleKeyboardEvent(
native_app_window_->HandleKeyboardEvent(event);
}
-void ShellWindow::RequestToLockMouse(WebContents* web_contents,
- bool user_gesture,
- bool last_unlocked_by_target) {
+void AppWindow::RequestToLockMouse(WebContents* web_contents,
+ bool user_gesture,
+ bool last_unlocked_by_target) {
bool has_permission = IsExtensionWithPermissionOrSuggestInConsole(
APIPermission::kPointerLock,
extension_,
@@ -358,16 +356,15 @@ void ShellWindow::RequestToLockMouse(WebContents* web_contents,
web_contents->GotResponseToLockMouseRequest(has_permission);
}
-bool ShellWindow::PreHandleGestureEvent(
- WebContents* source,
- const blink::WebGestureEvent& event) {
- // Disable pinch zooming in shell windows.
+bool AppWindow::PreHandleGestureEvent(WebContents* source,
+ const blink::WebGestureEvent& event) {
+ // Disable pinch zooming in app windows.
return event.type == blink::WebGestureEvent::GesturePinchBegin ||
- event.type == blink::WebGestureEvent::GesturePinchUpdate ||
- event.type == blink::WebGestureEvent::GesturePinchEnd;
+ event.type == blink::WebGestureEvent::GesturePinchUpdate ||
+ event.type == blink::WebGestureEvent::GesturePinchEnd;
}
-void ShellWindow::DidFirstVisuallyNonEmptyPaint(int32 page_id) {
+void AppWindow::DidFirstVisuallyNonEmptyPaint(int32 page_id) {
first_paint_complete_ = true;
if (show_on_first_paint_) {
DCHECK(delayed_show_type_ == SHOW_ACTIVE ||
@@ -376,74 +373,69 @@ void ShellWindow::DidFirstVisuallyNonEmptyPaint(int32 page_id) {
}
}
-void ShellWindow::OnNativeClose() {
- ShellWindowRegistry::Get(browser_context_)->RemoveShellWindow(this);
- if (shell_window_contents_) {
- WebContents* web_contents = shell_window_contents_->GetWebContents();
- WebContentsModalDialogManager::FromWebContents(web_contents)->
- SetDelegate(NULL);
- shell_window_contents_->NativeWindowClosed();
+void AppWindow::OnNativeClose() {
+ AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this);
+ if (app_window_contents_) {
+ WebContents* web_contents = app_window_contents_->GetWebContents();
+ WebContentsModalDialogManager::FromWebContents(web_contents)
+ ->SetDelegate(NULL);
+ app_window_contents_->NativeWindowClosed();
}
delete this;
}
-void ShellWindow::OnNativeWindowChanged() {
+void AppWindow::OnNativeWindowChanged() {
SaveWindowPosition();
#if defined(OS_WIN)
- if (native_app_window_ &&
- cached_always_on_top_ &&
- !IsFullscreen(fullscreen_types_) &&
- !native_app_window_->IsMaximized() &&
+ if (native_app_window_ && cached_always_on_top_ &&
+ !IsFullscreen(fullscreen_types_) && !native_app_window_->IsMaximized() &&
!native_app_window_->IsMinimized()) {
UpdateNativeAlwaysOnTop();
}
#endif
- if (shell_window_contents_ && native_app_window_)
- shell_window_contents_->NativeWindowChanged(native_app_window_.get());
+ if (app_window_contents_ && native_app_window_)
+ app_window_contents_->NativeWindowChanged(native_app_window_.get());
}
-void ShellWindow::OnNativeWindowActivated() {
- ShellWindowRegistry::Get(browser_context_)->ShellWindowActivated(this);
+void AppWindow::OnNativeWindowActivated() {
+ AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this);
}
-content::WebContents* ShellWindow::web_contents() const {
- return shell_window_contents_->GetWebContents();
+content::WebContents* AppWindow::web_contents() const {
+ return app_window_contents_->GetWebContents();
}
-NativeAppWindow* ShellWindow::GetBaseWindow() {
- return native_app_window_.get();
-}
+NativeAppWindow* AppWindow::GetBaseWindow() { return native_app_window_.get(); }
-gfx::NativeWindow ShellWindow::GetNativeWindow() {
+gfx::NativeWindow AppWindow::GetNativeWindow() {
return GetBaseWindow()->GetNativeWindow();
}
-gfx::Rect ShellWindow::GetClientBounds() const {
+gfx::Rect AppWindow::GetClientBounds() const {
gfx::Rect bounds = native_app_window_->GetBounds();
bounds.Inset(native_app_window_->GetFrameInsets());
return bounds;
}
-base::string16 ShellWindow::GetTitle() const {
+base::string16 AppWindow::GetTitle() const {
// WebContents::GetTitle() will return the page's URL if there's no <title>
// specified. However, we'd prefer to show the name of the extension in that
// case, so we directly inspect the NavigationEntry's title.
base::string16 title;
- if (!web_contents() ||
- !web_contents()->GetController().GetActiveEntry() ||
+ if (!web_contents() || !web_contents()->GetController().GetActiveEntry() ||
web_contents()->GetController().GetActiveEntry()->GetTitle().empty()) {
title = base::UTF8ToUTF16(extension()->name());
} else {
title = web_contents()->GetTitle();
}
- const base::char16 kBadChars[] = { '\n', 0 };
+ const base::char16 kBadChars[] = {'\n', 0};
base::RemoveChars(title, kBadChars, &title);
return title;
}
-void ShellWindow::SetAppIconUrl(const GURL& url) {
+void AppWindow::SetAppIconUrl(const GURL& url) {
// If the same url is being used for the badge, ignore it.
if (url == badge_icon_url_)
return;
@@ -458,12 +450,12 @@ void ShellWindow::SetAppIconUrl(const GURL& url) {
web_contents()->DownloadImage(
url,
true, // is a favicon
- 0, // no maximum size
- base::Bind(&ShellWindow::DidDownloadFavicon,
+ 0, // no maximum size
+ base::Bind(&AppWindow::DidDownloadFavicon,
image_loader_ptr_factory_.GetWeakPtr()));
}
-void ShellWindow::SetBadgeIconUrl(const GURL& url) {
+void AppWindow::SetBadgeIconUrl(const GURL& url) {
// Avoid using any previous icons that were being downloaded.
image_loader_ptr_factory_.InvalidateWeakPtrs();
@@ -474,35 +466,35 @@ void ShellWindow::SetBadgeIconUrl(const GURL& url) {
web_contents()->DownloadImage(
url,
true, // is a favicon
- 0, // no maximum size
- base::Bind(&ShellWindow::DidDownloadFavicon,
+ 0, // no maximum size
+ base::Bind(&AppWindow::DidDownloadFavicon,
image_loader_ptr_factory_.GetWeakPtr()));
}
-void ShellWindow::ClearBadge() {
+void AppWindow::ClearBadge() {
badge_icon_image_.reset();
badge_icon_url_ = GURL();
UpdateBadgeIcon(gfx::Image());
}
-void ShellWindow::UpdateShape(scoped_ptr<SkRegion> region) {
+void AppWindow::UpdateShape(scoped_ptr<SkRegion> region) {
native_app_window_->UpdateShape(region.Pass());
}
-void ShellWindow::UpdateDraggableRegions(
+void AppWindow::UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) {
native_app_window_->UpdateDraggableRegions(regions);
}
-void ShellWindow::UpdateAppIcon(const gfx::Image& image) {
+void AppWindow::UpdateAppIcon(const gfx::Image& image) {
if (image.IsEmpty())
return;
app_icon_ = image;
native_app_window_->UpdateWindowIcon();
- ShellWindowRegistry::Get(browser_context_)->ShellWindowIconChanged(this);
+ AppWindowRegistry::Get(browser_context_)->AppWindowIconChanged(this);
}
-void ShellWindow::Fullscreen() {
+void AppWindow::Fullscreen() {
#if !defined(OS_MACOSX)
// Do not enter fullscreen mode if disallowed by pref.
PrefService* prefs =
@@ -515,15 +507,11 @@ void ShellWindow::Fullscreen() {
SetNativeWindowFullscreen();
}
-void ShellWindow::Maximize() {
- GetBaseWindow()->Maximize();
-}
+void AppWindow::Maximize() { GetBaseWindow()->Maximize(); }
-void ShellWindow::Minimize() {
- GetBaseWindow()->Minimize();
-}
+void AppWindow::Minimize() { GetBaseWindow()->Minimize(); }
-void ShellWindow::Restore() {
+void AppWindow::Restore() {
if (IsFullscreen(fullscreen_types_)) {
fullscreen_types_ = FULLSCREEN_TYPE_NONE;
SetNativeWindowFullscreen();
@@ -532,7 +520,7 @@ void ShellWindow::Restore() {
}
}
-void ShellWindow::OSFullscreen() {
+void AppWindow::OSFullscreen() {
#if !defined(OS_MACOSX)
// Do not enter fullscreen mode if disallowed by pref.
PrefService* prefs =
@@ -545,24 +533,24 @@ void ShellWindow::OSFullscreen() {
SetNativeWindowFullscreen();
}
-void ShellWindow::ForcedFullscreen() {
+void AppWindow::ForcedFullscreen() {
fullscreen_types_ |= FULLSCREEN_TYPE_FORCED;
SetNativeWindowFullscreen();
}
-void ShellWindow::SetMinimumSize(const gfx::Size& min_size) {
+void AppWindow::SetMinimumSize(const gfx::Size& min_size) {
size_constraints_.set_minimum_size(min_size);
OnSizeConstraintsChanged();
}
-void ShellWindow::SetMaximumSize(const gfx::Size& max_size) {
+void AppWindow::SetMaximumSize(const gfx::Size& max_size) {
size_constraints_.set_maximum_size(max_size);
OnSizeConstraintsChanged();
}
-void ShellWindow::Show(ShowType show_type) {
+void AppWindow::Show(ShowType show_type) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableAppsShowOnFirstPaint)) {
+ switches::kEnableAppsShowOnFirstPaint)) {
show_on_first_paint_ = true;
if (!first_paint_complete_) {
@@ -581,7 +569,7 @@ void ShellWindow::Show(ShowType show_type) {
}
}
-void ShellWindow::Hide() {
+void AppWindow::Hide() {
// This is there to prevent race conditions with Hide() being called before
// there was a non-empty paint. It should have no effect in a non-racy
// scenario where the application is hiding then showing a window: the second
@@ -590,7 +578,7 @@ void ShellWindow::Hide() {
GetBaseWindow()->Hide();
}
-void ShellWindow::SetAlwaysOnTop(bool always_on_top) {
+void AppWindow::SetAlwaysOnTop(bool always_on_top) {
if (cached_always_on_top_ == always_on_top)
return;
@@ -605,15 +593,13 @@ void ShellWindow::SetAlwaysOnTop(bool always_on_top) {
OnNativeWindowChanged();
}
-bool ShellWindow::IsAlwaysOnTop() const {
- return cached_always_on_top_;
-}
+bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; }
-void ShellWindow::GetSerializedState(base::DictionaryValue* properties) const {
+void AppWindow::GetSerializedState(base::DictionaryValue* properties) const {
DCHECK(properties);
properties->SetBoolean("fullscreen",
- native_app_window_->IsFullscreenOrPending());
+ native_app_window_->IsFullscreenOrPending());
properties->SetBoolean("minimized", native_app_window_->IsMinimized());
properties->SetBoolean("maximized", native_app_window_->IsMaximized());
properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop());
@@ -641,12 +627,12 @@ void ShellWindow::GetSerializedState(base::DictionaryValue* properties) const {
//------------------------------------------------------------------------------
// Private methods
-void ShellWindow::UpdateBadgeIcon(const gfx::Image& image) {
+void AppWindow::UpdateBadgeIcon(const gfx::Image& image) {
badge_icon_ = image;
native_app_window_->UpdateBadgeIcon();
}
-void ShellWindow::DidDownloadFavicon(
+void AppWindow::DidDownloadFavicon(
int id,
int http_status_code,
const GURL& image_url,
@@ -674,13 +660,13 @@ void ShellWindow::DidDownloadFavicon(
UpdateBadgeIcon(gfx::Image::CreateFrom1xBitmap(largest));
}
-void ShellWindow::OnExtensionIconImageChanged(extensions::IconImage* image) {
+void AppWindow::OnExtensionIconImageChanged(extensions::IconImage* image) {
DCHECK_EQ(app_icon_image_.get(), image);
UpdateAppIcon(gfx::Image(app_icon_image_->image_skia()));
}
-void ShellWindow::UpdateExtensionAppIcon() {
+void AppWindow::UpdateExtensionAppIcon() {
// Avoid using any previous app icons were being downloaded.
image_loader_ptr_factory_.InvalidateWeakPtrs();
@@ -697,7 +683,7 @@ void ShellWindow::UpdateExtensionAppIcon() {
app_icon_image_->image_skia().GetRepresentation(1.0f);
}
-void ShellWindow::OnSizeConstraintsChanged() {
+void AppWindow::OnSizeConstraintsChanged() {
native_app_window_->UpdateWindowMinMaxSize();
gfx::Rect bounds = GetClientBounds();
gfx::Size constrained_size = size_constraints_.ClampSize(bounds.size());
@@ -708,21 +694,22 @@ void ShellWindow::OnSizeConstraintsChanged() {
OnNativeWindowChanged();
}
-void ShellWindow::SetNativeWindowFullscreen() {
+void AppWindow::SetNativeWindowFullscreen() {
native_app_window_->SetFullscreen(fullscreen_types_);
if (cached_always_on_top_)
UpdateNativeAlwaysOnTop();
}
-bool ShellWindow::IntersectsWithTaskbar() const {
+bool AppWindow::IntersectsWithTaskbar() const {
#if defined(OS_WIN)
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
gfx::Rect window_bounds = native_app_window_->GetRestoredBounds();
std::vector<gfx::Display> displays = screen->GetAllDisplays();
for (std::vector<gfx::Display>::const_iterator it = displays.begin();
- it != displays.end(); ++it) {
+ it != displays.end();
+ ++it) {
gfx::Rect taskbar_bounds = it->bounds();
taskbar_bounds.Subtract(it->work_area());
if (taskbar_bounds.IsEmpty())
@@ -736,7 +723,7 @@ bool ShellWindow::IntersectsWithTaskbar() const {
return false;
}
-void ShellWindow::UpdateNativeAlwaysOnTop() {
+void AppWindow::UpdateNativeAlwaysOnTop() {
DCHECK(cached_always_on_top_);
bool is_on_top = native_app_window_->IsAlwaysOnTop();
bool fullscreen = IsFullscreen(fullscreen_types_);
@@ -753,23 +740,21 @@ void ShellWindow::UpdateNativeAlwaysOnTop() {
}
}
-void ShellWindow::CloseContents(WebContents* contents) {
+void AppWindow::CloseContents(WebContents* contents) {
native_app_window_->Close();
}
-bool ShellWindow::ShouldSuppressDialogs() {
- return true;
-}
+bool AppWindow::ShouldSuppressDialogs() { return true; }
-content::ColorChooser* ShellWindow::OpenColorChooser(
- WebContents* web_contents,
- SkColor initial_color,
- const std::vector<content::ColorSuggestion>& suggestionss) {
+content::ColorChooser* AppWindow::OpenColorChooser(
+ WebContents* web_contents,
+ SkColor initial_color,
+ const std::vector<content::ColorSuggestion>& suggestionss) {
return delegate_->ShowColorChooser(web_contents, initial_color);
}
-void ShellWindow::RunFileChooser(WebContents* tab,
- const content::FileChooserParams& params) {
+void AppWindow::RunFileChooser(WebContents* tab,
+ const content::FileChooserParams& params) {
if (window_type_is_panel()) {
// Panels can't host a file dialog, abort. TODO(stevenjb): allow file
// dialogs to be unhosted but still close with the owning web contents.
@@ -781,24 +766,22 @@ void ShellWindow::RunFileChooser(WebContents* tab,
delegate_->RunFileChooser(tab, params);
}
-bool ShellWindow::IsPopupOrPanel(const WebContents* source) const {
- return true;
-}
+bool AppWindow::IsPopupOrPanel(const WebContents* source) const { return true; }
-void ShellWindow::MoveContents(WebContents* source, const gfx::Rect& pos) {
+void AppWindow::MoveContents(WebContents* source, const gfx::Rect& pos) {
native_app_window_->SetBounds(pos);
}
-void ShellWindow::NavigationStateChanged(
- const content::WebContents* source, unsigned changed_flags) {
+void AppWindow::NavigationStateChanged(const content::WebContents* source,
+ unsigned changed_flags) {
if (changed_flags & content::INVALIDATE_TYPE_TITLE)
native_app_window_->UpdateWindowTitle();
else if (changed_flags & content::INVALIDATE_TYPE_TAB)
native_app_window_->UpdateWindowIcon();
}
-void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source,
- bool enter_fullscreen) {
+void AppWindow::ToggleFullscreenModeForTab(content::WebContents* source,
+ bool enter_fullscreen) {
#if !defined(OS_MACOSX)
// Do not enter fullscreen mode if disallowed by pref.
// TODO(bartfab): Add a test once it becomes possible to simulate a user
@@ -812,9 +795,9 @@ void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source,
#endif
if (!IsExtensionWithPermissionOrSuggestInConsole(
- APIPermission::kFullscreen,
- extension_,
- source->GetRenderViewHost())) {
+ APIPermission::kFullscreen,
+ extension_,
+ source->GetRenderViewHost())) {
return;
}
@@ -825,19 +808,19 @@ void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source,
SetNativeWindowFullscreen();
}
-bool ShellWindow::IsFullscreenForTabOrPending(
- const content::WebContents* source) const {
+bool AppWindow::IsFullscreenForTabOrPending(const content::WebContents* source)
+ const {
return ((fullscreen_types_ & FULLSCREEN_TYPE_HTML_API) != 0);
}
-void ShellWindow::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void AppWindow::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
const extensions::Extension* unloaded_extension =
- content::Details<extensions::UnloadedExtensionInfo>(
- details)->extension;
+ content::Details<extensions::UnloadedExtensionInfo>(details)
+ ->extension;
if (extension_ == unloaded_extension)
native_app_window_->Close();
break;
@@ -850,54 +833,51 @@ void ShellWindow::Observe(int type,
}
}
-void ShellWindow::SetWebContentsBlocked(content::WebContents* web_contents,
- bool blocked) {
+void AppWindow::SetWebContentsBlocked(content::WebContents* web_contents,
+ bool blocked) {
delegate_->SetWebContentsBlocked(web_contents, blocked);
}
-bool ShellWindow::IsWebContentsVisible(content::WebContents* web_contents) {
+bool AppWindow::IsWebContentsVisible(content::WebContents* web_contents) {
return delegate_->IsWebContentsVisible(web_contents);
}
extensions::ActiveTabPermissionGranter*
- ShellWindow::GetActiveTabPermissionGranter() {
- // Shell windows don't support the activeTab permission.
+AppWindow::GetActiveTabPermissionGranter() {
+ // App windows don't support the activeTab permission.
return NULL;
}
-WebContentsModalDialogHost* ShellWindow::GetWebContentsModalDialogHost() {
+WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() {
return native_app_window_.get();
}
-void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
- const std::string& message) {
+void AppWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
+ const std::string& message) {
content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
rvh->Send(new ExtensionMsg_AddMessageToConsole(
rvh->GetRoutingID(), level, message));
}
-void ShellWindow::SaveWindowPosition() {
+void AppWindow::SaveWindowPosition() {
if (window_key_.empty())
return;
if (!native_app_window_)
return;
- ShellWindowGeometryCache* cache =
- ShellWindowGeometryCache::Get(browser_context());
+ AppWindowGeometryCache* cache =
+ AppWindowGeometryCache::Get(browser_context());
gfx::Rect bounds = native_app_window_->GetRestoredBounds();
bounds.Inset(native_app_window_->GetFrameInsets());
gfx::Rect screen_bounds =
gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area();
ui::WindowShowState window_state = native_app_window_->GetRestoredState();
- cache->SaveGeometry(extension()->id(),
- window_key_,
- bounds,
- screen_bounds,
- window_state);
+ cache->SaveGeometry(
+ extension()->id(), window_key_, bounds, screen_bounds, window_state);
}
-void ShellWindow::AdjustBoundsToBeVisibleOnScreen(
+void AppWindow::AdjustBoundsToBeVisibleOnScreen(
const gfx::Rect& cached_bounds,
const gfx::Rect& cached_screen_bounds,
const gfx::Rect& current_screen_bounds,
@@ -927,26 +907,28 @@ void ShellWindow::AdjustBoundsToBeVisibleOnScreen(
}
}
-ShellWindow::CreateParams ShellWindow::LoadDefaultsAndConstrain(
- CreateParams params) const {
+AppWindow::CreateParams AppWindow::LoadDefaultsAndConstrain(CreateParams params)
+ const {
if (params.bounds.width() == 0)
params.bounds.set_width(kDefaultWidth);
if (params.bounds.height() == 0)
params.bounds.set_height(kDefaultHeight);
- // If left and top are left undefined, the native shell window will center
+ // If left and top are left undefined, the native app window will center
// the window on the main screen in a platform-defined manner.
// Load cached state if it exists.
if (!params.window_key.empty()) {
- ShellWindowGeometryCache* cache =
- ShellWindowGeometryCache::Get(browser_context());
+ AppWindowGeometryCache* cache =
+ AppWindowGeometryCache::Get(browser_context());
gfx::Rect cached_bounds;
gfx::Rect cached_screen_bounds;
ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT;
- if (cache->GetGeometry(extension()->id(), params.window_key,
- &cached_bounds, &cached_screen_bounds,
+ if (cache->GetGeometry(extension()->id(),
+ params.window_key,
+ &cached_bounds,
+ &cached_screen_bounds,
&cached_state)) {
// App window has cached screen bounds, make sure it fits on screen in
// case the screen resolution changed.
@@ -971,12 +953,13 @@ ShellWindow::CreateParams ShellWindow::LoadDefaultsAndConstrain(
}
// static
-SkRegion* ShellWindow::RawDraggableRegionsToSkRegion(
- const std::vector<extensions::DraggableRegion>& regions) {
+SkRegion* AppWindow::RawDraggableRegionsToSkRegion(
+ const std::vector<extensions::DraggableRegion>& regions) {
SkRegion* sk_region = new SkRegion;
for (std::vector<extensions::DraggableRegion>::const_iterator iter =
regions.begin();
- iter != regions.end(); ++iter) {
+ iter != regions.end();
+ ++iter) {
const extensions::DraggableRegion& region = *iter;
sk_region->op(
region.bounds.x(),
diff --git a/apps/shell_window.h b/apps/app_window.h
index 2901376..46933c9 100644
--- a/apps/shell_window.h
+++ b/apps/app_window.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef APPS_SHELL_WINDOW_H_
-#define APPS_SHELL_WINDOW_H_
+#ifndef APPS_APP_WINDOW_H_
+#define APPS_APP_WINDOW_H_
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -48,14 +48,14 @@ namespace apps {
class NativeAppWindow;
-// Manages the web contents for Shell Windows. The implementation for this
+// Manages the web contents for app windows. The implementation for this
// class should create and maintain the WebContents for the window, and handle
// any message passing between the web contents and the extension system or
// native window.
-class ShellWindowContents {
+class AppWindowContents {
public:
- ShellWindowContents() {}
- virtual ~ShellWindowContents() {}
+ AppWindowContents() {}
+ virtual ~AppWindowContents() {}
// Called to initialize the WebContents, before the app window is created.
virtual void Initialize(content::BrowserContext* context,
@@ -73,28 +73,28 @@ class ShellWindowContents {
virtual content::WebContents* GetWebContents() const = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(ShellWindowContents);
+ DISALLOW_COPY_AND_ASSIGN(AppWindowContents);
};
-// ShellWindow is the type of window used by platform apps. Shell windows
+// AppWindow is the type of window used by platform apps. App windows
// have a WebContents but none of the chrome of normal browser windows.
-class ShellWindow : public content::NotificationObserver,
- public content::WebContentsDelegate,
- public content::WebContentsObserver,
- public web_modal::WebContentsModalDialogManagerDelegate,
- public extensions::ExtensionKeybindingRegistry::Delegate,
- public extensions::IconImage::Observer {
+class AppWindow : public content::NotificationObserver,
+ public content::WebContentsDelegate,
+ public content::WebContentsObserver,
+ public web_modal::WebContentsModalDialogManagerDelegate,
+ public extensions::ExtensionKeybindingRegistry::Delegate,
+ public extensions::IconImage::Observer {
public:
enum WindowType {
- WINDOW_TYPE_DEFAULT = 1 << 0, // Default shell window.
- WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only).
+ WINDOW_TYPE_DEFAULT = 1 << 0, // Default app window.
+ WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only).
WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate
// with v1 apps.
};
enum Frame {
FRAME_CHROME, // Chrome-style window frame.
- FRAME_NONE, // Frameless window.
+ FRAME_NONE, // Frameless window.
};
enum FullscreenType {
@@ -197,7 +197,7 @@ class ShellWindow : public content::NotificationObserver,
// General initialization.
virtual void InitWebContents(content::WebContents* web_contents) = 0;
virtual NativeAppWindow* CreateNativeAppWindow(
- ShellWindow* window,
+ AppWindow* window,
const CreateParams& params) = 0;
// Link handling.
@@ -222,7 +222,7 @@ class ShellWindow : public content::NotificationObserver,
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
- const extensions::Extension* extension) = 0;
+ const extensions::Extension* extension) = 0;
virtual int PreferredIconSize() = 0;
// Web contents modal dialog support.
@@ -236,21 +236,20 @@ class ShellWindow : public content::NotificationObserver,
static SkRegion* RawDraggableRegionsToSkRegion(
const std::vector<extensions::DraggableRegion>& regions);
- // The constructor and Init methods are public for constructing a ShellWindow
+ // The constructor and Init methods are public for constructing a AppWindow
// with a non-standard render interface (e.g. v1 apps using Ash Panels).
- // Normally ShellWindow::Create should be used.
- // The constructed shell window takes ownership of |delegate|.
- ShellWindow(content::BrowserContext* context,
- Delegate* delegate,
- const extensions::Extension* extension);
+ // Normally AppWindow::Create should be used.
+ // The constructed app window takes ownership of |delegate|.
+ AppWindow(content::BrowserContext* context,
+ Delegate* delegate,
+ const extensions::Extension* extension);
// Initializes the render interface, web contents, and native window.
- // |shell_window_contents| will become owned by ShellWindow.
+ // |app_window_contents| will become owned by AppWindow.
void Init(const GURL& url,
- ShellWindowContents* shell_window_contents,
+ AppWindowContents* app_window_contents,
const CreateParams& params);
-
const std::string& window_key() const { return window_key_; }
const SessionID& session_id() const { return session_id_; }
const extensions::Extension* extension() const { return extension_; }
@@ -326,10 +325,7 @@ class ShellWindow : public content::NotificationObserver,
void SetMinimumSize(const gfx::Size& min_size);
void SetMaximumSize(const gfx::Size& max_size);
- enum ShowType {
- SHOW_ACTIVE,
- SHOW_INACTIVE
- };
+ enum ShowType { SHOW_ACTIVE, SHOW_INACTIVE };
// Shows the window if its contents have been painted; otherwise flags the
// window to be shown as soon as its contents are painted for the first time.
@@ -339,14 +335,12 @@ class ShellWindow : public content::NotificationObserver,
// first paint, it will be unflagged.
void Hide();
- ShellWindowContents* shell_window_contents_for_test() {
- return shell_window_contents_.get();
+ AppWindowContents* app_window_contents_for_test() {
+ return app_window_contents_.get();
}
// Get the size constraints.
- const SizeConstraints& size_constraints() const {
- return size_constraints_;
- }
+ const SizeConstraints& size_constraints() const { return size_constraints_; }
// Set whether the window should stay above other windows which are not
// configured to be always-on-top.
@@ -362,7 +356,7 @@ class ShellWindow : public content::NotificationObserver,
void GetSerializedState(base::DictionaryValue* properties) const;
protected:
- virtual ~ShellWindow();
+ virtual ~AppWindow();
private:
// PlatformAppBrowserTest needs access to web_contents()
@@ -375,19 +369,19 @@ class ShellWindow : public content::NotificationObserver,
content::WebContents* web_contents,
SkColor color,
const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE;
- virtual void RunFileChooser(
- content::WebContents* tab,
- const content::FileChooserParams& params) OVERRIDE;
- virtual bool IsPopupOrPanel(
- const content::WebContents* source) const OVERRIDE;
- virtual void MoveContents(
- content::WebContents* source, const gfx::Rect& pos) OVERRIDE;
+ virtual void RunFileChooser(content::WebContents* tab,
+ const content::FileChooserParams& params)
+ OVERRIDE;
+ virtual bool IsPopupOrPanel(const content::WebContents* source)
+ const OVERRIDE;
+ virtual void MoveContents(content::WebContents* source,
+ const gfx::Rect& pos) OVERRIDE;
virtual void NavigationStateChanged(const content::WebContents* source,
unsigned changed_flags) OVERRIDE;
virtual void ToggleFullscreenModeForTab(content::WebContents* source,
bool enter_fullscreen) OVERRIDE;
- virtual bool IsFullscreenForTabOrPending(
- const content::WebContents* source) const OVERRIDE;
+ virtual bool IsFullscreenForTabOrPending(const content::WebContents* source)
+ const OVERRIDE;
virtual void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
@@ -405,15 +399,15 @@ class ShellWindow : public content::NotificationObserver,
content::WebContents* source,
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) OVERRIDE;
- virtual void HandleKeyboardEvent(
- content::WebContents* source,
- const content::NativeWebKeyboardEvent& event) OVERRIDE;
+ virtual void HandleKeyboardEvent(content::WebContents* source,
+ const content::NativeWebKeyboardEvent& event)
+ OVERRIDE;
virtual void RequestToLockMouse(content::WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target) OVERRIDE;
- virtual bool PreHandleGestureEvent(
- content::WebContents* source,
- const blink::WebGestureEvent& event) OVERRIDE;
+ virtual bool PreHandleGestureEvent(content::WebContents* source,
+ const blink::WebGestureEvent& event)
+ OVERRIDE;
// content::WebContentsObserver implementation.
virtual void DidFirstVisuallyNonEmptyPaint(int32 page_id) OVERRIDE;
@@ -426,8 +420,8 @@ class ShellWindow : public content::NotificationObserver,
// web_modal::WebContentsModalDialogManagerDelegate implementation.
virtual void SetWebContentsBlocked(content::WebContents* web_contents,
bool blocked) OVERRIDE;
- virtual bool IsWebContentsVisible(
- content::WebContents* web_contents) OVERRIDE;
+ virtual bool IsWebContentsVisible(content::WebContents* web_contents)
+ OVERRIDE;
// Helper method to add a message to the renderer's DevTools console.
void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level,
@@ -438,12 +432,11 @@ class ShellWindow : public content::NotificationObserver,
// Helper method to adjust the cached bounds so that we can make sure it can
// be visible on the screen. See http://crbug.com/145752 .
- void AdjustBoundsToBeVisibleOnScreen(
- const gfx::Rect& cached_bounds,
- const gfx::Rect& cached_screen_bounds,
- const gfx::Rect& current_screen_bounds,
- const gfx::Size& minimum_size,
- gfx::Rect* bounds) const;
+ void AdjustBoundsToBeVisibleOnScreen(const gfx::Rect& cached_bounds,
+ const gfx::Rect& cached_screen_bounds,
+ const gfx::Rect& current_screen_bounds,
+ const gfx::Size& minimum_size,
+ gfx::Rect* bounds) const;
// Loads the appropriate default or cached window bounds and constrains them
// based on screen size and minimum/maximum size. Returns a new CreateParams
@@ -471,8 +464,8 @@ class ShellWindow : public content::NotificationObserver,
GetActiveTabPermissionGranter() OVERRIDE;
// web_modal::WebContentsModalDialogManagerDelegate implementation.
- virtual web_modal::WebContentsModalDialogHost*
- GetWebContentsModalDialogHost() OVERRIDE;
+ virtual web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
+ OVERRIDE;
// Updates the badge to |image|. Called internally from the image loader
// callback.
@@ -486,10 +479,10 @@ class ShellWindow : public content::NotificationObserver,
const std::vector<gfx::Size>& original_bitmap_sizes);
// extensions::IconImage::Observer implementation.
- virtual void OnExtensionIconImageChanged(
- extensions::IconImage* image) OVERRIDE;
+ virtual void OnExtensionIconImageChanged(extensions::IconImage* image)
+ OVERRIDE;
- // The browser context with which this window is associated. ShellWindow does
+ // The browser context with which this window is associated. AppWindow does
// not own this object.
content::BrowserContext* browser_context_;
@@ -525,10 +518,10 @@ class ShellWindow : public content::NotificationObserver,
scoped_ptr<extensions::IconImage> badge_icon_image_;
scoped_ptr<NativeAppWindow> native_app_window_;
- scoped_ptr<ShellWindowContents> shell_window_contents_;
+ scoped_ptr<AppWindowContents> app_window_contents_;
scoped_ptr<Delegate> delegate_;
- base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_;
+ base::WeakPtrFactory<AppWindow> image_loader_ptr_factory_;
// Bit field of FullscreenType.
int fullscreen_types_;
@@ -553,9 +546,9 @@ class ShellWindow : public content::NotificationObserver,
// taskbar.
bool cached_always_on_top_;
- DISALLOW_COPY_AND_ASSIGN(ShellWindow);
+ DISALLOW_COPY_AND_ASSIGN(AppWindow);
};
} // namespace apps
-#endif // APPS_SHELL_WINDOW_H_
+#endif // APPS_APP_WINDOW_H_
diff --git a/apps/app_window_contents.cc b/apps/app_window_contents.cc
index fbe70cc..8fa3c46 100644
--- a/apps/app_window_contents.cc
+++ b/apps/app_window_contents.cc
@@ -21,15 +21,12 @@ namespace app_window = extensions::api::app_window;
namespace apps {
-AppWindowContents::AppWindowContents(ShellWindow* host)
- : host_(host) {
-}
+AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {}
-AppWindowContents::~AppWindowContents() {
-}
+AppWindowContentsImpl::~AppWindowContentsImpl() {}
-void AppWindowContents::Initialize(content::BrowserContext* context,
- const GURL& url) {
+void AppWindowContentsImpl::Initialize(content::BrowserContext* context,
+ const GURL& url) {
url_ = url;
extension_function_dispatcher_.reset(
@@ -45,7 +42,7 @@ void AppWindowContents::Initialize(content::BrowserContext* context,
web_contents_->GetRenderViewHost()->SyncRendererPrefs();
}
-void AppWindowContents::LoadContents(int32 creator_process_id) {
+void AppWindowContentsImpl::LoadContents(int32 creator_process_id) {
// If the new view is in the same process as the creator, block the created
// RVH from loading anything until the background page has had a chance to
// do any initialization it wants. If it's a different process, the new RVH
@@ -54,10 +51,9 @@ void AppWindowContents::LoadContents(int32 creator_process_id) {
creator_process_id) {
SuspendRenderViewHost(web_contents_->GetRenderViewHost());
} else {
- VLOG(1) << "ShellWindow created in new process ("
+ VLOG(1) << "AppWindow created in new process ("
<< web_contents_->GetRenderViewHost()->GetProcess()->GetID()
- << ") != creator (" << creator_process_id
- << "). Routing disabled.";
+ << ") != creator (" << creator_process_id << "). Routing disabled.";
}
// TODO(jeremya): there's a bug where navigating a web contents to an
@@ -76,7 +72,7 @@ void AppWindowContents::LoadContents(int32 creator_process_id) {
registrar_.RemoveAll();
}
-void AppWindowContents::NativeWindowChanged(
+void AppWindowContentsImpl::NativeWindowChanged(
NativeAppWindow* native_app_window) {
base::ListValue args;
base::DictionaryValue* dictionary = new base::DictionaryValue();
@@ -92,16 +88,16 @@ void AppWindowContents::NativeWindowChanged(
false));
}
-void AppWindowContents::NativeWindowClosed() {
+void AppWindowContentsImpl::NativeWindowClosed() {
content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
rvh->Send(new ExtensionMsg_AppWindowClosed(rvh->GetRoutingID()));
}
-content::WebContents* AppWindowContents::GetWebContents() const {
+content::WebContents* AppWindowContentsImpl::GetWebContents() const {
return web_contents_.get();
}
-void AppWindowContents::Observe(
+void AppWindowContentsImpl::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -122,9 +118,9 @@ void AppWindowContents::Observe(
}
}
-bool AppWindowContents::OnMessageReceived(const IPC::Message& message) {
+bool AppWindowContentsImpl::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(AppWindowContents, message)
+ IPC_BEGIN_MESSAGE_MAP(AppWindowContentsImpl, message)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions,
UpdateDraggableRegions)
@@ -134,26 +130,26 @@ bool AppWindowContents::OnMessageReceived(const IPC::Message& message) {
}
extensions::WindowController*
-AppWindowContents::GetExtensionWindowController() const {
+AppWindowContentsImpl::GetExtensionWindowController() const {
return NULL;
}
-content::WebContents* AppWindowContents::GetAssociatedWebContents() const {
+content::WebContents* AppWindowContentsImpl::GetAssociatedWebContents() const {
return web_contents_.get();
}
-void AppWindowContents::OnRequest(
+void AppWindowContentsImpl::OnRequest(
const ExtensionHostMsg_Request_Params& params) {
extension_function_dispatcher_->Dispatch(
params, web_contents_->GetRenderViewHost());
}
-void AppWindowContents::UpdateDraggableRegions(
+void AppWindowContentsImpl::UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) {
host_->UpdateDraggableRegions(regions);
}
-void AppWindowContents::SuspendRenderViewHost(
+void AppWindowContentsImpl::SuspendRenderViewHost(
content::RenderViewHost* rvh) {
DCHECK(rvh);
content::BrowserThread::PostTask(
diff --git a/apps/app_window_contents.h b/apps/app_window_contents.h
index ea09f83..b5c691d 100644
--- a/apps/app_window_contents.h
+++ b/apps/app_window_contents.h
@@ -7,7 +7,7 @@
#include <vector>
-#include "apps/shell_window.h"
+#include "apps/app_window.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
@@ -26,18 +26,18 @@ struct DraggableRegion;
namespace apps {
-// ShellWindowContents class specific to app windows. It maintains a
+// AppWindowContents class specific to app windows. It maintains a
// WebContents instance and observes it for the purpose of passing
// messages to the extensions system.
-class AppWindowContents : public ShellWindowContents,
- public content::NotificationObserver,
- public content::WebContentsObserver,
- public ExtensionFunctionDispatcher::Delegate {
+class AppWindowContentsImpl : public AppWindowContents,
+ public content::NotificationObserver,
+ public content::WebContentsObserver,
+ public ExtensionFunctionDispatcher::Delegate {
public:
- explicit AppWindowContents(ShellWindow* host);
- virtual ~AppWindowContents();
+ explicit AppWindowContentsImpl(AppWindow* host);
+ virtual ~AppWindowContentsImpl();
- // ShellWindowContents
+ // AppWindowContents
virtual void Initialize(content::BrowserContext* context,
const GURL& url) OVERRIDE;
virtual void LoadContents(int32 creator_process_id) OVERRIDE;
@@ -64,13 +64,13 @@ class AppWindowContents : public ShellWindowContents,
const std::vector<extensions::DraggableRegion>& regions);
void SuspendRenderViewHost(content::RenderViewHost* rvh);
- ShellWindow* host_; // This class is owned by |host_|
+ AppWindow* host_; // This class is owned by |host_|
GURL url_;
content::NotificationRegistrar registrar_;
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
- DISALLOW_COPY_AND_ASSIGN(AppWindowContents);
+ DISALLOW_COPY_AND_ASSIGN(AppWindowContentsImpl);
};
} // namespace apps
diff --git a/apps/shell_window_geometry_cache.cc b/apps/app_window_geometry_cache.cc
index 09ad3b3..deefc7a 100644
--- a/apps/shell_window_geometry_cache.cc
+++ b/apps/app_window_geometry_cache.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "apps/shell_window_geometry_cache.h"
+#include "apps/app_window_geometry_cache.h"
#include "base/bind.h"
#include "base/stl_util.h"
@@ -24,35 +24,36 @@ namespace {
// StateStore.
const int kSyncTimeoutMilliseconds = 1000;
-} // namespace
+} // namespace
namespace apps {
-ShellWindowGeometryCache::ShellWindowGeometryCache(
- Profile* profile, extensions::ExtensionPrefs* prefs)
+AppWindowGeometryCache::AppWindowGeometryCache(
+ Profile* profile,
+ extensions::ExtensionPrefs* prefs)
: prefs_(prefs),
sync_delay_(base::TimeDelta::FromMilliseconds(kSyncTimeoutMilliseconds)) {
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
+ registrar_.Add(this,
+ chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile));
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
+ registrar_.Add(this,
+ chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile));
}
-ShellWindowGeometryCache::~ShellWindowGeometryCache() {
-}
+AppWindowGeometryCache::~AppWindowGeometryCache() {}
// static
-ShellWindowGeometryCache* ShellWindowGeometryCache::Get(
+AppWindowGeometryCache* AppWindowGeometryCache::Get(
content::BrowserContext* context) {
return Factory::GetForContext(context, true /* create */);
}
-void ShellWindowGeometryCache::SaveGeometry(
- const std::string& extension_id,
- const std::string& window_id,
- const gfx::Rect& bounds,
- const gfx::Rect& screen_bounds,
- ui::WindowShowState window_state) {
+void AppWindowGeometryCache::SaveGeometry(const std::string& extension_id,
+ const std::string& window_id,
+ const gfx::Rect& bounds,
+ const gfx::Rect& screen_bounds,
+ ui::WindowShowState window_state) {
ExtensionData& extension_data = cache_[extension_id];
// If we don't have any unsynced changes and this is a duplicate of what's
@@ -74,9 +75,11 @@ void ShellWindowGeometryCache::SaveGeometry(
ExtensionData::iterator oldest = extension_data.end();
// Too many windows in the cache, find the oldest one to remove.
for (ExtensionData::iterator it = extension_data.begin();
- it != extension_data.end(); ++it) {
+ it != extension_data.end();
+ ++it) {
// Don't expunge the window that was just added.
- if (it->first == window_id) continue;
+ if (it->first == window_id)
+ continue;
// If time is in the future, reset it to now to minimize weirdness.
if (it->second.last_change > now)
@@ -94,21 +97,25 @@ void ShellWindowGeometryCache::SaveGeometry(
// We don't use Reset() because the timer may not yet be running.
// (In that case Stop() is a no-op.)
sync_timer_.Stop();
- sync_timer_.Start(FROM_HERE, sync_delay_, this,
- &ShellWindowGeometryCache::SyncToStorage);
+ sync_timer_.Start(
+ FROM_HERE, sync_delay_, this, &AppWindowGeometryCache::SyncToStorage);
}
-void ShellWindowGeometryCache::SyncToStorage() {
+void AppWindowGeometryCache::SyncToStorage() {
std::set<std::string> tosync;
tosync.swap(unsynced_extensions_);
for (std::set<std::string>::const_iterator it = tosync.begin(),
- eit = tosync.end(); it != eit; ++it) {
+ eit = tosync.end();
+ it != eit;
+ ++it) {
const std::string& extension_id = *it;
const ExtensionData& extension_data = cache_[extension_id];
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
for (ExtensionData::const_iterator it = extension_data.begin(),
- eit = extension_data.end(); it != eit; ++it) {
+ eit = extension_data.end();
+ it != eit;
+ ++it) {
base::DictionaryValue* value = new base::DictionaryValue;
const gfx::Rect& bounds = it->second.bounds;
const gfx::Rect& screen_bounds = it->second.screen_bounds;
@@ -129,24 +136,23 @@ void ShellWindowGeometryCache::SyncToStorage() {
dict->SetWithoutPathExpansion(it->first, value);
FOR_EACH_OBSERVER(
- Observer,
- observers_,
- OnGeometryCacheChanged(extension_id, it->first, bounds));
+ Observer,
+ observers_,
+ OnGeometryCacheChanged(extension_id, it->first, bounds));
}
prefs_->SetGeometryCache(extension_id, dict.Pass());
}
}
-bool ShellWindowGeometryCache::GetGeometry(
- const std::string& extension_id,
- const std::string& window_id,
- gfx::Rect* bounds,
- gfx::Rect* screen_bounds,
- ui::WindowShowState* window_state) {
+bool AppWindowGeometryCache::GetGeometry(const std::string& extension_id,
+ const std::string& window_id,
+ gfx::Rect* bounds,
+ gfx::Rect* screen_bounds,
+ ui::WindowShowState* window_state) {
- std::map<std::string, ExtensionData>::const_iterator
- extension_data_it = cache_.find(extension_id);
+ std::map<std::string, ExtensionData>::const_iterator extension_data_it =
+ cache_.find(extension_id);
// Not in the map means loading data for the extension didn't finish yet or
// the cache was not constructed until after the extension was loaded.
@@ -157,8 +163,8 @@ bool ShellWindowGeometryCache::GetGeometry(
DCHECK(extension_data_it != cache_.end());
}
- ExtensionData::const_iterator window_data_it = extension_data_it->second.find(
- window_id);
+ ExtensionData::const_iterator window_data_it =
+ extension_data_it->second.find(window_id);
if (window_data_it == extension_data_it->second.end())
return false;
@@ -180,20 +186,16 @@ bool ShellWindowGeometryCache::GetGeometry(
return true;
}
-void ShellWindowGeometryCache::Shutdown() {
- SyncToStorage();
-}
+void AppWindowGeometryCache::Shutdown() { SyncToStorage(); }
+AppWindowGeometryCache::WindowData::WindowData()
+ : window_state(ui::SHOW_STATE_DEFAULT) {}
-ShellWindowGeometryCache::WindowData::WindowData()
- : window_state(ui::SHOW_STATE_DEFAULT) {
-}
+AppWindowGeometryCache::WindowData::~WindowData() {}
-ShellWindowGeometryCache::WindowData::~WindowData() {
-}
-
-void ShellWindowGeometryCache::Observe(
- int type, const content::NotificationSource& source,
+void AppWindowGeometryCache::Observe(
+ int type,
+ const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_EXTENSION_LOADED: {
@@ -204,8 +206,9 @@ void ShellWindowGeometryCache::Observe(
}
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
std::string extension_id =
- content::Details<const extensions::UnloadedExtensionInfo>(details).
- ptr()->extension->id();
+ content::Details<const extensions::UnloadedExtensionInfo>(details)
+ .ptr()
+ ->extension->id();
OnExtensionUnloaded(extension_id);
break;
}
@@ -215,11 +218,11 @@ void ShellWindowGeometryCache::Observe(
}
}
-void ShellWindowGeometryCache::SetSyncDelayForTests(int timeout_ms) {
+void AppWindowGeometryCache::SetSyncDelayForTests(int timeout_ms) {
sync_delay_ = base::TimeDelta::FromMilliseconds(timeout_ms);
}
-void ShellWindowGeometryCache::LoadGeometryFromStorage(
+void AppWindowGeometryCache::LoadGeometryFromStorage(
const std::string& extension_id) {
ExtensionData& extension_data = cache_[extension_id];
@@ -258,8 +261,7 @@ void ShellWindowGeometryCache::LoadGeometryFromStorage(
if (stored_window->GetInteger("screen_bounds_h", &i))
window_data.screen_bounds.set_height(i);
if (stored_window->GetInteger("state", &i)) {
- window_data.window_state =
- static_cast<ui::WindowShowState>(i);
+ window_data.window_state = static_cast<ui::WindowShowState>(i);
}
std::string ts_as_string;
if (stored_window->GetString("ts", &ts_as_string)) {
@@ -273,7 +275,7 @@ void ShellWindowGeometryCache::LoadGeometryFromStorage(
}
}
-void ShellWindowGeometryCache::OnExtensionUnloaded(
+void AppWindowGeometryCache::OnExtensionUnloaded(
const std::string& extension_id) {
SyncToStorage();
cache_.erase(extension_id);
@@ -283,53 +285,52 @@ void ShellWindowGeometryCache::OnExtensionUnloaded(
// Factory boilerplate
// static
-ShellWindowGeometryCache* ShellWindowGeometryCache::Factory::GetForContext(
- content::BrowserContext* context, bool create) {
- return static_cast<ShellWindowGeometryCache*>(
+AppWindowGeometryCache* AppWindowGeometryCache::Factory::GetForContext(
+ content::BrowserContext* context,
+ bool create) {
+ return static_cast<AppWindowGeometryCache*>(
GetInstance()->GetServiceForBrowserContext(context, create));
}
-ShellWindowGeometryCache::Factory*
-ShellWindowGeometryCache::Factory::GetInstance() {
- return Singleton<ShellWindowGeometryCache::Factory>::get();
+AppWindowGeometryCache::Factory*
+AppWindowGeometryCache::Factory::GetInstance() {
+ return Singleton<AppWindowGeometryCache::Factory>::get();
}
-ShellWindowGeometryCache::Factory::Factory()
+AppWindowGeometryCache::Factory::Factory()
: BrowserContextKeyedServiceFactory(
- "ShellWindowGeometryCache",
- BrowserContextDependencyManager::GetInstance()) {
+ "AppWindowGeometryCache",
+ BrowserContextDependencyManager::GetInstance()) {
DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
}
-ShellWindowGeometryCache::Factory::~Factory() {
-}
+AppWindowGeometryCache::Factory::~Factory() {}
BrowserContextKeyedService*
-ShellWindowGeometryCache::Factory::BuildServiceInstanceFor(
+AppWindowGeometryCache::Factory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
- return new ShellWindowGeometryCache(
- profile,
- extensions::ExtensionPrefs::Get(profile));
+ return new AppWindowGeometryCache(profile,
+ extensions::ExtensionPrefs::Get(profile));
}
-bool ShellWindowGeometryCache::Factory::ServiceIsNULLWhileTesting() const {
+bool AppWindowGeometryCache::Factory::ServiceIsNULLWhileTesting() const {
return false;
}
content::BrowserContext*
-ShellWindowGeometryCache::Factory::GetBrowserContextToUse(
+AppWindowGeometryCache::Factory::GetBrowserContextToUse(
content::BrowserContext* context) const {
- return extensions::ExtensionsBrowserClient::Get()->
- GetOriginalContext(context);
+ return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext(
+ context);
}
-void ShellWindowGeometryCache::AddObserver(Observer* observer) {
+void AppWindowGeometryCache::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
-void ShellWindowGeometryCache::RemoveObserver(Observer* observer) {
+void AppWindowGeometryCache::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
-} // namespace apps
+} // namespace apps
diff --git a/apps/shell_window_geometry_cache.h b/apps/app_window_geometry_cache.h
index 6af1886..372be6d 100644
--- a/apps/shell_window_geometry_cache.h
+++ b/apps/app_window_geometry_cache.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
-#define CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
+#ifndef APPS_APP_WINDOW_GEOMETRY_CACHE_H_
+#define APPS_APP_WINDOW_GEOMETRY_CACHE_H_
#include <map>
#include <set>
@@ -30,20 +30,20 @@ class ExtensionPrefs;
namespace apps {
-// A cache for persisted geometry of shell windows, both to not have to wait
+// A cache for persisted geometry of app windows, both to not have to wait
// for IO when creating a new window, and to not cause IO on every window
// geometry change.
-class ShellWindowGeometryCache
- : public BrowserContextKeyedService,
- public content::NotificationObserver {
+class AppWindowGeometryCache : public BrowserContextKeyedService,
+ public content::NotificationObserver {
public:
class Factory : public BrowserContextKeyedServiceFactory {
public:
- static ShellWindowGeometryCache* GetForContext(
+ static AppWindowGeometryCache* GetForContext(
content::BrowserContext* context,
bool create);
static Factory* GetInstance();
+
private:
friend struct DefaultSingletonTraits<Factory>;
@@ -68,13 +68,12 @@ class ShellWindowGeometryCache
virtual ~Observer() {};
};
- ShellWindowGeometryCache(Profile* profile,
- extensions::ExtensionPrefs* prefs);
+ AppWindowGeometryCache(Profile* profile, extensions::ExtensionPrefs* prefs);
- virtual ~ShellWindowGeometryCache();
+ virtual ~AppWindowGeometryCache();
// Returns the instance for the given browsing context.
- static ShellWindowGeometryCache* Get(content::BrowserContext* context);
+ static AppWindowGeometryCache* Get(content::BrowserContext* context);
// Save the geometry and state associated with |extension_id| and |window_id|.
void SaveGeometry(const std::string& extension_id,
@@ -102,7 +101,7 @@ class ShellWindowGeometryCache
static const size_t kMaxCachedWindows = 100;
protected:
- friend class ShellWindowGeometryCacheTest;
+ friend class AppWindowGeometryCacheTest;
// For tests, this modifies the timeout delay for saving changes from calls
// to SaveGeometry. (Note that even if this is set to 0, you still need to
@@ -142,7 +141,7 @@ class ShellWindowGeometryCache
std::set<std::string> unsynced_extensions_;
// The timer used to save the data
- base::OneShotTimer<ShellWindowGeometryCache> sync_timer_;
+ base::OneShotTimer<AppWindowGeometryCache> sync_timer_;
// The timeout value we'll use for |sync_timer_|.
base::TimeDelta sync_delay_;
@@ -153,4 +152,4 @@ class ShellWindowGeometryCache
} // namespace apps
-#endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
+#endif // APPS_APP_WINDOW_GEOMETRY_CACHE_H_
diff --git a/apps/shell_window_geometry_cache_unittest.cc b/apps/app_window_geometry_cache_unittest.cc
index 2b6d15c..deda109 100644
--- a/apps/shell_window_geometry_cache_unittest.cc
+++ b/apps/app_window_geometry_cache_unittest.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "apps/shell_window_geometry_cache.h"
+#include "apps/app_window_geometry_cache.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/mock_pref_change_callback.h"
#include "base/strings/string_number_conversions.h"
@@ -21,22 +21,21 @@ using content::BrowserThread;
namespace apps {
// Base class for tests.
-class ShellWindowGeometryCacheTest : public testing::Test {
+class AppWindowGeometryCacheTest : public testing::Test {
public:
- ShellWindowGeometryCacheTest() :
- ui_thread_(BrowserThread::UI, &ui_message_loop_) {
+ AppWindowGeometryCacheTest()
+ : ui_thread_(BrowserThread::UI, &ui_message_loop_) {
prefs_.reset(new extensions::TestExtensionPrefs(
ui_message_loop_.message_loop_proxy().get()));
- cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs()));
+ cache_.reset(new AppWindowGeometryCache(&profile_, prefs_->prefs()));
cache_->SetSyncDelayForTests(0);
}
- void AddGeometryAndLoadExtension(
- const std::string& extension_id,
- const std::string& window_id,
- const gfx::Rect& bounds,
- const gfx::Rect& screen_bounds,
- ui::WindowShowState state);
+ void AddGeometryAndLoadExtension(const std::string& extension_id,
+ const std::string& window_id,
+ const gfx::Rect& bounds,
+ const gfx::Rect& screen_bounds,
+ ui::WindowShowState state);
// Spins the UI threads' message loops to make sure any task
// posted to sync the geometry to the value store gets a chance to run.
@@ -50,10 +49,10 @@ class ShellWindowGeometryCacheTest : public testing::Test {
base::MessageLoopForUI ui_message_loop_;
content::TestBrowserThread ui_thread_;
scoped_ptr<extensions::TestExtensionPrefs> prefs_;
- scoped_ptr<ShellWindowGeometryCache> cache_;
+ scoped_ptr<AppWindowGeometryCache> cache_;
};
-void ShellWindowGeometryCacheTest::AddGeometryAndLoadExtension(
+void AppWindowGeometryCacheTest::AddGeometryAndLoadExtension(
const std::string& extension_id,
const std::string& window_id,
const gfx::Rect& bounds,
@@ -75,33 +74,34 @@ void ShellWindowGeometryCacheTest::AddGeometryAndLoadExtension(
LoadExtension(extension_id);
}
-void ShellWindowGeometryCacheTest::WaitForSync() {
+void AppWindowGeometryCacheTest::WaitForSync() {
content::RunAllPendingInMessageLoop();
}
-void ShellWindowGeometryCacheTest::LoadExtension(
+void AppWindowGeometryCacheTest::LoadExtension(
const std::string& extension_id) {
cache_->LoadGeometryFromStorage(extension_id);
WaitForSync();
}
-void ShellWindowGeometryCacheTest::UnloadExtension(
+void AppWindowGeometryCacheTest::UnloadExtension(
const std::string& extension_id) {
cache_->OnExtensionUnloaded(extension_id);
WaitForSync();
}
// Test getting geometry from an empty store.
-TEST_F(ShellWindowGeometryCacheTest, GetGeometryEmptyStore) {
+TEST_F(AppWindowGeometryCacheTest, GetGeometryEmptyStore) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
ASSERT_FALSE(cache_->GetGeometry(extension_id, kWindowId, NULL, NULL, NULL));
}
// Test getting geometry for an unknown extension.
-TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownExtension) {
+TEST_F(AppWindowGeometryCacheTest, GetGeometryUnkownExtension) {
const std::string extension_id1 = prefs_->AddExtensionAndReturnId("ext1");
const std::string extension_id2 = prefs_->AddExtensionAndReturnId("ext2");
- AddGeometryAndLoadExtension(extension_id1, kWindowId,
+ AddGeometryAndLoadExtension(extension_id1,
+ kWindowId,
gfx::Rect(4, 5, 31, 43),
gfx::Rect(0, 0, 1600, 900),
ui::SHOW_STATE_NORMAL);
@@ -109,9 +109,10 @@ TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownExtension) {
}
// Test getting geometry for an unknown window in a known extension.
-TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownWindow) {
+TEST_F(AppWindowGeometryCacheTest, GetGeometryUnkownWindow) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
- AddGeometryAndLoadExtension(extension_id, kWindowId,
+ AddGeometryAndLoadExtension(extension_id,
+ kWindowId,
gfx::Rect(4, 5, 31, 43),
gfx::Rect(0, 0, 1600, 900),
ui::SHOW_STATE_NORMAL);
@@ -120,13 +121,13 @@ TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownWindow) {
// Test that loading geometry, screen_bounds and state from the store works
// correctly.
-TEST_F(ShellWindowGeometryCacheTest, GetGeometryAndStateFromStore) {
+TEST_F(AppWindowGeometryCacheTest, GetGeometryAndStateFromStore) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
gfx::Rect bounds(4, 5, 31, 43);
gfx::Rect screen_bounds(0, 0, 1600, 900);
ui::WindowShowState state = ui::SHOW_STATE_NORMAL;
- AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
- screen_bounds, state);
+ AddGeometryAndLoadExtension(
+ extension_id, kWindowId, bounds, screen_bounds, state);
gfx::Rect new_bounds;
gfx::Rect new_screen_bounds;
ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
@@ -138,13 +139,13 @@ TEST_F(ShellWindowGeometryCacheTest, GetGeometryAndStateFromStore) {
}
// Test corrupt bounds will not be loaded.
-TEST_F(ShellWindowGeometryCacheTest, CorruptBounds) {
+TEST_F(AppWindowGeometryCacheTest, CorruptBounds) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
gfx::Rect bounds;
gfx::Rect screen_bounds(0, 0, 1600, 900);
ui::WindowShowState state = ui::SHOW_STATE_NORMAL;
- AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
- screen_bounds, state);
+ AddGeometryAndLoadExtension(
+ extension_id, kWindowId, bounds, screen_bounds, state);
gfx::Rect new_bounds;
gfx::Rect new_screen_bounds;
ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
@@ -156,13 +157,13 @@ TEST_F(ShellWindowGeometryCacheTest, CorruptBounds) {
}
// Test corrupt screen bounds will not be loaded.
-TEST_F(ShellWindowGeometryCacheTest, CorruptScreenBounds) {
+TEST_F(AppWindowGeometryCacheTest, CorruptScreenBounds) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
gfx::Rect bounds(4, 5, 31, 43);
gfx::Rect screen_bounds;
ui::WindowShowState state = ui::SHOW_STATE_NORMAL;
- AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
- screen_bounds, state);
+ AddGeometryAndLoadExtension(
+ extension_id, kWindowId, bounds, screen_bounds, state);
gfx::Rect new_bounds;
gfx::Rect new_screen_bounds;
ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
@@ -174,13 +175,13 @@ TEST_F(ShellWindowGeometryCacheTest, CorruptScreenBounds) {
}
// Test corrupt state will not be loaded.
-TEST_F(ShellWindowGeometryCacheTest, CorruptState) {
+TEST_F(AppWindowGeometryCacheTest, CorruptState) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
gfx::Rect bounds(4, 5, 31, 43);
gfx::Rect screen_bounds(0, 0, 1600, 900);
ui::WindowShowState state = ui::SHOW_STATE_DEFAULT;
- AddGeometryAndLoadExtension(extension_id, kWindowId, bounds,
- screen_bounds, state);
+ AddGeometryAndLoadExtension(
+ extension_id, kWindowId, bounds, screen_bounds, state);
gfx::Rect new_bounds;
gfx::Rect new_screen_bounds;
ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT;
@@ -193,7 +194,7 @@ TEST_F(ShellWindowGeometryCacheTest, CorruptState) {
// Test saving geometry, screen_bounds and state to the cache and state store,
// and reading it back.
-TEST_F(ShellWindowGeometryCacheTest, SaveGeometryAndStateToStore) {
+TEST_F(AppWindowGeometryCacheTest, SaveGeometryAndStateToStore) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
const std::string window_id(kWindowId);
@@ -257,7 +258,7 @@ TEST_F(ShellWindowGeometryCacheTest, SaveGeometryAndStateToStore) {
// Tests that we won't do writes to the state store for SaveGeometry calls
// which don't change the state we already have.
-TEST_F(ShellWindowGeometryCacheTest, NoDuplicateWrites) {
+TEST_F(AppWindowGeometryCacheTest, NoDuplicateWrites) {
using testing::_;
using testing::Mock;
@@ -277,62 +278,68 @@ TEST_F(ShellWindowGeometryCacheTest, NoDuplicateWrites) {
// Write the first bounds - it should do > 0 writes.
EXPECT_CALL(observer, OnPreferenceChanged(_));
- cache_->SaveGeometry(extension_id, kWindowId, bounds1,
- screen_bounds1, ui::SHOW_STATE_NORMAL);
+ cache_->SaveGeometry(
+ extension_id, kWindowId, bounds1, screen_bounds1, ui::SHOW_STATE_NORMAL);
WaitForSync();
Mock::VerifyAndClearExpectations(&observer);
// Write a different bounds - it should also do > 0 writes.
EXPECT_CALL(observer, OnPreferenceChanged(_));
- cache_->SaveGeometry(extension_id, kWindowId, bounds2,
- screen_bounds1, ui::SHOW_STATE_NORMAL);
+ cache_->SaveGeometry(
+ extension_id, kWindowId, bounds2, screen_bounds1, ui::SHOW_STATE_NORMAL);
WaitForSync();
Mock::VerifyAndClearExpectations(&observer);
// Write a different screen bounds - it should also do > 0 writes.
EXPECT_CALL(observer, OnPreferenceChanged(_));
- cache_->SaveGeometry(extension_id, kWindowId, bounds2,
- screen_bounds2, ui::SHOW_STATE_NORMAL);
+ cache_->SaveGeometry(
+ extension_id, kWindowId, bounds2, screen_bounds2, ui::SHOW_STATE_NORMAL);
WaitForSync();
Mock::VerifyAndClearExpectations(&observer);
// Write a different state - it should also do > 0 writes.
EXPECT_CALL(observer, OnPreferenceChanged(_));
- cache_->SaveGeometry(extension_id, kWindowId, bounds2,
- screen_bounds2, ui::SHOW_STATE_MAXIMIZED);
+ cache_->SaveGeometry(extension_id,
+ kWindowId,
+ bounds2,
+ screen_bounds2,
+ ui::SHOW_STATE_MAXIMIZED);
WaitForSync();
Mock::VerifyAndClearExpectations(&observer);
// Write a bounds, screen bounds and state that's a duplicate of what we
// already have. This should not do any writes.
EXPECT_CALL(observer, OnPreferenceChanged(_)).Times(0);
- cache_->SaveGeometry(extension_id, kWindowId, bounds2_duplicate,
- screen_bounds2_duplicate, ui::SHOW_STATE_MAXIMIZED);
+ cache_->SaveGeometry(extension_id,
+ kWindowId,
+ bounds2_duplicate,
+ screen_bounds2_duplicate,
+ ui::SHOW_STATE_MAXIMIZED);
WaitForSync();
Mock::VerifyAndClearExpectations(&observer);
}
// Tests that no more than kMaxCachedWindows windows will be cached.
-TEST_F(ShellWindowGeometryCacheTest, MaxWindows) {
+TEST_F(AppWindowGeometryCacheTest, MaxWindows) {
const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1");
// inform cache of extension
LoadExtension(extension_id);
gfx::Rect bounds(4, 5, 31, 43);
gfx::Rect screen_bounds(0, 0, 1600, 900);
- for (size_t i = 0; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) {
+ for (size_t i = 0; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) {
std::string window_id = "window_" + base::IntToString(i);
- cache_->SaveGeometry(extension_id, window_id, bounds,
- screen_bounds, ui::SHOW_STATE_NORMAL);
+ cache_->SaveGeometry(
+ extension_id, window_id, bounds, screen_bounds, ui::SHOW_STATE_NORMAL);
}
// The first added window should no longer have cached geometry.
EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL));
// All other windows should still exist.
- for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) {
+ for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) {
std::string window_id = "window_" + base::IntToString(i);
EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL));
}
}
-} // namespace extensions
+} // namespace extensions
diff --git a/apps/shell_window_interactive_uitest.cc b/apps/app_window_interactive_uitest.cc
index 69f5563..69d30f9 100644
--- a/apps/shell_window_interactive_uitest.cc
+++ b/apps/app_window_interactive_uitest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,17 +13,18 @@ namespace apps {
namespace {
+// TODO(jamescook): Move this to app_window/generic. http://crbug.com/344073
const char kDefaultTestApp[] = "shell_window/generic";
-class ShellWindowTest : public PlatformAppBrowserTest {
+class AppWindowTest : public PlatformAppBrowserTest {
protected:
// Load the test app and create a window. The window must be closed by the
// caller in order to terminate the test.
// |app_path| is the name of the test.
// |window_create_options| are the options that will be passed to
// chrome.app.window.create() in the test app.
- ShellWindow* OpenWindow(const char* app_path,
- const char* window_create_options) {
+ AppWindow* OpenWindow(const char* app_path,
+ const char* window_create_options) {
ExtensionTestMessageListener launched_listener("launched", true);
ExtensionTestMessageListener loaded_listener("window_loaded", false);
@@ -38,12 +39,12 @@ class ShellWindowTest : public PlatformAppBrowserTest {
// Wait for the window to be opened and loaded.
EXPECT_TRUE(loaded_listener.WaitUntilSatisfied());
- EXPECT_EQ(1U, GetShellWindowCount());
- ShellWindow* shell_window = GetFirstShellWindow();
- return shell_window;
+ EXPECT_EQ(1U, GetAppWindowCount());
+ AppWindow* app_window = GetFirstAppWindow();
+ return app_window;
}
- void CheckAlwaysOnTopToFullscreen(ShellWindow* window) {
+ void CheckAlwaysOnTopToFullscreen(AppWindow* window) {
ASSERT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
// The always-on-top property should be temporarily disabled when the window
@@ -59,7 +60,7 @@ class ShellWindowTest : public PlatformAppBrowserTest {
EXPECT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
}
- void CheckNormalToFullscreen(ShellWindow* window) {
+ void CheckNormalToFullscreen(AppWindow* window) {
// If the always-on-top property is false, it should remain this way when
// entering and exiting fullscreen mode.
ASSERT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
@@ -69,7 +70,7 @@ class ShellWindowTest : public PlatformAppBrowserTest {
EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
}
- void CheckFullscreenToAlwaysOnTop(ShellWindow* window) {
+ void CheckFullscreenToAlwaysOnTop(AppWindow* window) {
ASSERT_TRUE(window->GetBaseWindow()->IsFullscreenOrPending());
// Now enable always-on-top at runtime and ensure the property does not get
@@ -98,36 +99,35 @@ class ShellWindowTest : public PlatformAppBrowserTest {
// Tests a window created with always-on-top enabled and ensures that the
// property is temporarily switched off when entering fullscreen mode.
-IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_InitAlwaysOnTopToFullscreen) {
- ShellWindow* window = OpenWindow(
- kDefaultTestApp, "{ \"alwaysOnTop\": true }");
+IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_InitAlwaysOnTopToFullscreen) {
+ AppWindow* window = OpenWindow(kDefaultTestApp, "{ \"alwaysOnTop\": true }");
ASSERT_TRUE(window);
CheckAlwaysOnTopToFullscreen(window);
window->SetAlwaysOnTop(false);
CheckNormalToFullscreen(window);
- CloseShellWindow(window);
+ CloseAppWindow(window);
}
#if defined(OS_MACOSX)
-#define MAYBE_RuntimeAlwaysOnTopToFullscreen DISABLED_RuntimeAlwaysOnTopToFullscreen
+#define MAYBE_RuntimeAlwaysOnTopToFullscreen \
+ DISABLED_RuntimeAlwaysOnTopToFullscreen
#else
#define MAYBE_RuntimeAlwaysOnTopToFullscreen RuntimeAlwaysOnTopToFullscreen
#endif
// Tests a window with always-on-top enabled at runtime and ensures that the
// property is temporarily switched off when entering fullscreen mode.
-IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_RuntimeAlwaysOnTopToFullscreen) {
- ShellWindow* window = OpenWindow(
- kDefaultTestApp, "{}");
+IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_RuntimeAlwaysOnTopToFullscreen) {
+ AppWindow* window = OpenWindow(kDefaultTestApp, "{}");
ASSERT_TRUE(window);
CheckNormalToFullscreen(window);
window->SetAlwaysOnTop(true);
CheckAlwaysOnTopToFullscreen(window);
- CloseShellWindow(window);
+ CloseAppWindow(window);
}
#if defined(OS_MACOSX)
@@ -138,32 +138,32 @@ IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_RuntimeAlwaysOnTopToFullscreen) {
// Tests a window created initially in fullscreen mode and ensures that the
// always-on-top property does not get applied until it exits fullscreen.
-IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_InitFullscreenToAlwaysOnTop) {
- ShellWindow* window = OpenWindow(
- kDefaultTestApp, "{ \"state\": \"fullscreen\" }");
+IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_InitFullscreenToAlwaysOnTop) {
+ AppWindow* window =
+ OpenWindow(kDefaultTestApp, "{ \"state\": \"fullscreen\" }");
ASSERT_TRUE(window);
CheckFullscreenToAlwaysOnTop(window);
- CloseShellWindow(window);
+ CloseAppWindow(window);
}
#if defined(OS_MACOSX)
-#define MAYBE_RuntimeFullscreenToAlwaysOnTop DISABLED_RuntimeFullscreenToAlwaysOnTop
+#define MAYBE_RuntimeFullscreenToAlwaysOnTop \
+ DISABLED_RuntimeFullscreenToAlwaysOnTop
#else
#define MAYBE_RuntimeFullscreenToAlwaysOnTop RuntimeFullscreenToAlwaysOnTop
#endif
// Tests a window that enters fullscreen mode at runtime and ensures that the
// always-on-top property does not get applied until it exits fullscreen.
-IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_RuntimeFullscreenToAlwaysOnTop) {
- ShellWindow* window = OpenWindow(
- kDefaultTestApp, "{}");
+IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_RuntimeFullscreenToAlwaysOnTop) {
+ AppWindow* window = OpenWindow(kDefaultTestApp, "{}");
ASSERT_TRUE(window);
window->Fullscreen();
CheckFullscreenToAlwaysOnTop(window);
- CloseShellWindow(window);
+ CloseAppWindow(window);
}
#if defined(OS_MACOSX)
@@ -174,8 +174,8 @@ IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_RuntimeFullscreenToAlwaysOnTop) {
// Tests a window created with both fullscreen and always-on-top enabled. Ensure
// that always-on-top is only applied when the window exits fullscreen.
-IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_InitFullscreenAndAlwaysOnTop) {
- ShellWindow* window = OpenWindow(
+IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_InitFullscreenAndAlwaysOnTop) {
+ AppWindow* window = OpenWindow(
kDefaultTestApp, "{ \"alwaysOnTop\": true, \"state\": \"fullscreen\" }");
ASSERT_TRUE(window);
@@ -188,11 +188,12 @@ IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_InitFullscreenAndAlwaysOnTop) {
window->Restore();
EXPECT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
- CloseShellWindow(window);
+ CloseAppWindow(window);
}
#if defined(OS_MACOSX)
-#define MAYBE_DisableAlwaysOnTopInFullscreen DISABLED_DisableAlwaysOnTopInFullscreen
+#define MAYBE_DisableAlwaysOnTopInFullscreen \
+ DISABLED_DisableAlwaysOnTopInFullscreen
#else
#define MAYBE_DisableAlwaysOnTopInFullscreen DisableAlwaysOnTopInFullscreen
#endif
@@ -200,9 +201,8 @@ IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_InitFullscreenAndAlwaysOnTop) {
// Tests a window created with always-on-top enabled, but then disabled while
// in fullscreen mode. After exiting fullscreen, always-on-top should remain
// disabled.
-IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_DisableAlwaysOnTopInFullscreen) {
- ShellWindow* window = OpenWindow(
- kDefaultTestApp, "{ \"alwaysOnTop\": true }");
+IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_DisableAlwaysOnTopInFullscreen) {
+ AppWindow* window = OpenWindow(kDefaultTestApp, "{ \"alwaysOnTop\": true }");
ASSERT_TRUE(window);
// Disable always-on-top while in fullscreen mode.
@@ -215,7 +215,7 @@ IN_PROC_BROWSER_TEST_F(ShellWindowTest, MAYBE_DisableAlwaysOnTopInFullscreen) {
window->Restore();
EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
- CloseShellWindow(window);
+ CloseAppWindow(window);
}
} // namespace apps
diff --git a/apps/app_window_registry.cc b/apps/app_window_registry.cc
new file mode 100644
index 0000000..42b9465
--- /dev/null
+++ b/apps/app_window_registry.cc
@@ -0,0 +1,307 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "apps/app_window.h"
+#include "apps/app_window_registry.h"
+#include "apps/apps_client.h"
+#include "apps/ui/native_app_window.h"
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/devtools_agent_host.h"
+#include "content/public/browser/devtools_manager.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/extensions_browser_client.h"
+#include "extensions/common/extension.h"
+
+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 apps::AppWindowRegistry* registry,
+ content::RenderViewHost* render_view_host) {
+ apps::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
+
+namespace apps {
+
+AppWindowRegistry::AppWindowRegistry(content::BrowserContext* context)
+ : context_(context),
+ devtools_callback_(base::Bind(&AppWindowRegistry::OnDevToolsStateChanged,
+ base::Unretained(this))) {
+ content::DevToolsManager::GetInstance()->AddAgentStateCallback(
+ devtools_callback_);
+}
+
+AppWindowRegistry::~AppWindowRegistry() {
+ content::DevToolsManager::GetInstance()->RemoveAgentStateCallback(
+ devtools_callback_);
+}
+
+// static
+AppWindowRegistry* AppWindowRegistry::Get(content::BrowserContext* context) {
+ return Factory::GetForBrowserContext(context, true /* create */);
+}
+
+void AppWindowRegistry::AddAppWindow(AppWindow* app_window) {
+ BringToFront(app_window);
+ FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowAdded(app_window));
+}
+
+void AppWindowRegistry::AppWindowIconChanged(AppWindow* app_window) {
+ AddAppWindowToList(app_window);
+ FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowIconChanged(app_window));
+}
+
+void AppWindowRegistry::AppWindowActivated(AppWindow* app_window) {
+ BringToFront(app_window);
+}
+
+void AppWindowRegistry::RemoveAppWindow(AppWindow* app_window) {
+ const AppWindowList::iterator it =
+ std::find(app_windows_.begin(), app_windows_.end(), app_window);
+ if (it != app_windows_.end())
+ app_windows_.erase(it);
+ FOR_EACH_OBSERVER(Observer, observers_, OnAppWindowRemoved(app_window));
+}
+
+void AppWindowRegistry::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void AppWindowRegistry::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+AppWindowRegistry::AppWindowList AppWindowRegistry::GetAppWindowsForApp(
+ const std::string& app_id) const {
+ AppWindowList app_windows;
+ for (AppWindowList::const_iterator i = app_windows_.begin();
+ i != app_windows_.end();
+ ++i) {
+ if ((*i)->extension_id() == app_id)
+ app_windows.push_back(*i);
+ }
+ return app_windows;
+}
+
+void AppWindowRegistry::CloseAllAppWindowsForApp(const std::string& app_id) {
+ for (AppWindowList::const_iterator i = app_windows_.begin();
+ i != app_windows_.end();) {
+ AppWindow* app_window = *(i++);
+ if (app_window->extension_id() == app_id)
+ app_window->GetBaseWindow()->Close();
+ }
+}
+
+AppWindow* AppWindowRegistry::GetAppWindowForRenderViewHost(
+ content::RenderViewHost* render_view_host) const {
+ for (AppWindowList::const_iterator i = app_windows_.begin();
+ i != app_windows_.end();
+ ++i) {
+ if ((*i)->web_contents()->GetRenderViewHost() == render_view_host)
+ return *i;
+ }
+
+ return NULL;
+}
+
+AppWindow* AppWindowRegistry::GetAppWindowForNativeWindow(
+ gfx::NativeWindow window) const {
+ for (AppWindowList::const_iterator i = app_windows_.begin();
+ i != app_windows_.end();
+ ++i) {
+ if ((*i)->GetNativeWindow() == window)
+ return *i;
+ }
+
+ return NULL;
+}
+
+AppWindow* AppWindowRegistry::GetCurrentAppWindowForApp(
+ const std::string& app_id) const {
+ AppWindow* result = NULL;
+ for (AppWindowList::const_iterator i = app_windows_.begin();
+ i != app_windows_.end();
+ ++i) {
+ if ((*i)->extension()->id() == app_id) {
+ result = *i;
+ if (result->GetBaseWindow()->IsActive())
+ return result;
+ }
+ }
+
+ return result;
+}
+
+AppWindow* AppWindowRegistry::GetAppWindowForAppAndKey(
+ const std::string& app_id,
+ const std::string& window_key) const {
+ AppWindow* result = NULL;
+ for (AppWindowList::const_iterator i = app_windows_.begin();
+ i != app_windows_.end();
+ ++i) {
+ if ((*i)->extension()->id() == app_id && (*i)->window_key() == window_key) {
+ result = *i;
+ if (result->GetBaseWindow()->IsActive())
+ return result;
+ }
+ }
+ return result;
+}
+
+bool AppWindowRegistry::HadDevToolsAttached(
+ content::RenderViewHost* render_view_host) const {
+ std::string key = GetWindowKeyForRenderViewHost(this, render_view_host);
+ return key.empty() ? false : inspected_windows_.count(key) != 0;
+}
+
+// static
+AppWindow* AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile(
+ gfx::NativeWindow window) {
+ std::vector<content::BrowserContext*> contexts =
+ AppsClient::Get()->GetLoadedBrowserContexts();
+ for (std::vector<content::BrowserContext*>::const_iterator i =
+ contexts.begin();
+ i != contexts.end();
+ ++i) {
+ AppWindowRegistry* registry =
+ Factory::GetForBrowserContext(*i, false /* create */);
+ if (!registry)
+ continue;
+
+ AppWindow* app_window = registry->GetAppWindowForNativeWindow(window);
+ if (app_window)
+ return app_window;
+ }
+
+ return NULL;
+}
+
+// static
+bool AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(
+ int window_type_mask) {
+ std::vector<content::BrowserContext*> contexts =
+ AppsClient::Get()->GetLoadedBrowserContexts();
+ for (std::vector<content::BrowserContext*>::const_iterator i =
+ contexts.begin();
+ i != contexts.end();
+ ++i) {
+ AppWindowRegistry* registry =
+ Factory::GetForBrowserContext(*i, false /* create */);
+ if (!registry)
+ continue;
+
+ const AppWindowList& app_windows = registry->app_windows();
+ if (app_windows.empty())
+ continue;
+
+ if (window_type_mask == 0)
+ return true;
+
+ for (const_iterator j = app_windows.begin(); j != app_windows.end(); ++j) {
+ if ((*j)->window_type() & window_type_mask)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void AppWindowRegistry::OnDevToolsStateChanged(
+ content::DevToolsAgentHost* agent_host,
+ bool attached) {
+ content::RenderViewHost* rvh = agent_host->GetRenderViewHost();
+ // Ignore unrelated notifications.
+ if (!rvh ||
+ rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_)
+ return;
+
+ std::string key = GetWindowKeyForRenderViewHost(this, rvh);
+ if (key.empty())
+ return;
+
+ if (attached)
+ inspected_windows_.insert(key);
+ else
+ inspected_windows_.erase(key);
+}
+
+void AppWindowRegistry::AddAppWindowToList(AppWindow* app_window) {
+ const AppWindowList::iterator it =
+ std::find(app_windows_.begin(), app_windows_.end(), app_window);
+ if (it != app_windows_.end())
+ return;
+ app_windows_.push_back(app_window);
+}
+
+void AppWindowRegistry::BringToFront(AppWindow* app_window) {
+ const AppWindowList::iterator it =
+ std::find(app_windows_.begin(), app_windows_.end(), app_window);
+ if (it != app_windows_.end())
+ app_windows_.erase(it);
+ app_windows_.push_front(app_window);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Factory boilerplate
+
+// static
+AppWindowRegistry* AppWindowRegistry::Factory::GetForBrowserContext(
+ content::BrowserContext* context,
+ bool create) {
+ return static_cast<AppWindowRegistry*>(
+ GetInstance()->GetServiceForBrowserContext(context, create));
+}
+
+AppWindowRegistry::Factory* AppWindowRegistry::Factory::GetInstance() {
+ return Singleton<AppWindowRegistry::Factory>::get();
+}
+
+AppWindowRegistry::Factory::Factory()
+ : BrowserContextKeyedServiceFactory(
+ "AppWindowRegistry",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+AppWindowRegistry::Factory::~Factory() {}
+
+BrowserContextKeyedService* AppWindowRegistry::Factory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ return new AppWindowRegistry(context);
+}
+
+bool AppWindowRegistry::Factory::ServiceIsCreatedWithBrowserContext() const {
+ return true;
+}
+
+bool AppWindowRegistry::Factory::ServiceIsNULLWhileTesting() const {
+ return false;
+}
+
+content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext(
+ context);
+}
+
+} // namespace extensions
diff --git a/apps/app_window_registry.h b/apps/app_window_registry.h
new file mode 100644
index 0000000..2a3dfa5
--- /dev/null
+++ b/apps/app_window_registry.h
@@ -0,0 +1,147 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APPS_APP_WINDOW_REGISTRY_H_
+#define APPS_APP_WINDOW_REGISTRY_H_
+
+#include <list>
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/memory/singleton.h"
+#include "base/observer_list.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace content {
+class BrowserContext;
+class DevToolsAgentHost;
+class RenderViewHost;
+}
+
+namespace apps {
+
+class AppWindow;
+
+// The AppWindowRegistry tracks the AppWindows for all platform apps for a
+// particular browser context.
+class AppWindowRegistry : public BrowserContextKeyedService {
+ public:
+ class Observer {
+ public:
+ // Called just after a app window was added.
+ virtual void OnAppWindowAdded(apps::AppWindow* app_window) = 0;
+ // Called when the window icon changes.
+ virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) = 0;
+ // Called just after a app window was removed.
+ virtual void OnAppWindowRemoved(apps::AppWindow* app_window) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ typedef std::list<apps::AppWindow*> AppWindowList;
+ typedef AppWindowList::const_iterator const_iterator;
+ typedef std::set<std::string> InspectedWindowSet;
+
+ explicit AppWindowRegistry(content::BrowserContext* context);
+ virtual ~AppWindowRegistry();
+
+ // Returns the instance for the given browser context, or NULL if none. This
+ // is a convenience wrapper around
+ // AppWindowRegistry::Factory::GetForBrowserContext().
+ static AppWindowRegistry* Get(content::BrowserContext* context);
+
+ void AddAppWindow(apps::AppWindow* app_window);
+ void AppWindowIconChanged(apps::AppWindow* app_window);
+ // Called by |app_window| when it is activated.
+ void AppWindowActivated(apps::AppWindow* app_window);
+ void RemoveAppWindow(apps::AppWindow* app_window);
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ // Returns a set of windows owned by the application identified by app_id.
+ AppWindowList GetAppWindowsForApp(const std::string& app_id) const;
+ const AppWindowList& app_windows() const { return app_windows_; }
+
+ // Close all app windows associated with an app.
+ void CloseAllAppWindowsForApp(const std::string& app_id);
+
+ // Helper functions to find app windows with particular attributes.
+ apps::AppWindow* GetAppWindowForRenderViewHost(
+ content::RenderViewHost* render_view_host) const;
+ apps::AppWindow* GetAppWindowForNativeWindow(gfx::NativeWindow window) const;
+ // Returns an app window for the given app, or NULL if no app windows are
+ // open. If there is a window for the given app that is active, that one will
+ // be returned, otherwise an arbitrary window will be returned.
+ apps::AppWindow* GetCurrentAppWindowForApp(const std::string& app_id) const;
+ // Returns an app window for the given app and window key, or NULL if no app
+ // window with the key are open. If there is a window for the given app and
+ // key that is active, that one will be returned, otherwise an arbitrary
+ // window will be returned.
+ apps::AppWindow* GetAppWindowForAppAndKey(const std::string& app_id,
+ const std::string& window_key)
+ const;
+
+ // Returns whether a AppWindow's ID was last known to have a DevToolsAgent
+ // attached to it, which should be restored during a reload of a corresponding
+ // newly created |render_view_host|.
+ bool HadDevToolsAttached(content::RenderViewHost* render_view_host) const;
+
+ // Returns the app window for |window|, looking in all browser contexts.
+ static apps::AppWindow* GetAppWindowForNativeWindowAnyProfile(
+ gfx::NativeWindow window);
+
+ // Returns true if the number of app windows registered across all browser
+ // contexts is non-zero. |window_type_mask| is a bitwise OR filter of
+ // AppWindow::WindowType, or 0 for any window type.
+ static bool IsAppWindowRegisteredInAnyProfile(int window_type_mask);
+
+ class Factory : public BrowserContextKeyedServiceFactory {
+ public:
+ static AppWindowRegistry* GetForBrowserContext(
+ content::BrowserContext* context,
+ bool create);
+
+ static Factory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<Factory>;
+
+ Factory();
+ virtual ~Factory();
+
+ // BrowserContextKeyedServiceFactory
+ virtual BrowserContextKeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* context) const OVERRIDE;
+ virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
+ virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+ };
+
+ protected:
+ void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached);
+
+ private:
+ // Ensures the specified |app_window| is included in |app_windows_|.
+ // Otherwise adds |app_window| to the back of |app_windows_|.
+ void AddAppWindowToList(apps::AppWindow* app_window);
+
+ // Bring |app_window| to the front of |app_windows_|. If it is not in the
+ // list, add it first.
+ void BringToFront(apps::AppWindow* app_window);
+
+ content::BrowserContext* context_;
+ AppWindowList app_windows_;
+ InspectedWindowSet inspected_windows_;
+ ObserverList<Observer> observers_;
+ base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
+};
+
+} // namespace extensions
+
+#endif // APPS_APP_WINDOW_REGISTRY_H_
diff --git a/apps/apps.gypi b/apps/apps.gypi
index da93f13..78dcd5f 100644
--- a/apps/apps.gypi
+++ b/apps/apps.gypi
@@ -39,8 +39,14 @@
'app_restore_service.h',
'app_restore_service_factory.cc',
'app_restore_service_factory.h',
+ 'app_window.cc',
+ 'app_window.h',
'app_window_contents.cc',
'app_window_contents.h',
+ 'app_window_geometry_cache.cc',
+ 'app_window_geometry_cache.h',
+ 'app_window_registry.cc',
+ 'app_window_registry.h',
'apps_client.cc',
'apps_client.h',
'launcher.cc',
@@ -54,17 +60,11 @@
'saved_files_service.h',
'saved_files_service_factory.cc',
'saved_files_service_factory.h',
- 'shell_window.cc',
- 'shell_window.h',
- 'shell_window_geometry_cache.cc',
- 'shell_window_geometry_cache.h',
- 'shell_window_registry.cc',
- 'shell_window_registry.h',
'switches.cc',
'switches.h',
'ui/native_app_window.h',
- 'ui/views/shell_window_frame_view.cc',
- 'ui/views/shell_window_frame_view.h',
+ 'ui/views/app_window_frame_view.cc',
+ 'ui/views/app_window_frame_view.h',
],
'conditions': [
['chromeos==1',
diff --git a/apps/shell_window_registry.cc b/apps/shell_window_registry.cc
deleted file mode 100644
index 093263b..0000000
--- a/apps/shell_window_registry.cc
+++ /dev/null
@@ -1,309 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "apps/apps_client.h"
-#include "apps/shell_window.h"
-#include "apps/shell_window_registry.h"
-#include "apps/ui/native_app_window.h"
-#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/devtools_agent_host.h"
-#include "content/public/browser/devtools_manager.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/extensions_browser_client.h"
-#include "extensions/common/extension.h"
-
-namespace {
-
-// Create a key that identifies a ShellWindow 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 ShellWindow'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 ShellWindow, return an empty string.
-std::string GetWindowKeyForRenderViewHost(
- const apps::ShellWindowRegistry* registry,
- content::RenderViewHost* render_view_host) {
- apps::ShellWindow* shell_window =
- registry->GetShellWindowForRenderViewHost(render_view_host);
- if (!shell_window)
- return std::string(); // Not a ShellWindow.
-
- if (shell_window->window_key().empty())
- return shell_window->web_contents()->GetURL().possibly_invalid_spec();
-
- std::string key = shell_window->extension()->id();
- key += ':';
- key += shell_window->window_key();
- return key;
-}
-
-} // namespace
-
-namespace apps {
-
-ShellWindowRegistry::ShellWindowRegistry(content::BrowserContext* context)
- : context_(context),
- devtools_callback_(base::Bind(
- &ShellWindowRegistry::OnDevToolsStateChanged,
- base::Unretained(this))) {
- content::DevToolsManager::GetInstance()->AddAgentStateCallback(
- devtools_callback_);
-}
-
-ShellWindowRegistry::~ShellWindowRegistry() {
- content::DevToolsManager::GetInstance()->RemoveAgentStateCallback(
- devtools_callback_);
-}
-
-// static
-ShellWindowRegistry* ShellWindowRegistry::Get(
- content::BrowserContext* context) {
- return Factory::GetForBrowserContext(context, true /* create */);
-}
-
-void ShellWindowRegistry::AddShellWindow(ShellWindow* shell_window) {
- BringToFront(shell_window);
- FOR_EACH_OBSERVER(Observer, observers_, OnShellWindowAdded(shell_window));
-}
-
-void ShellWindowRegistry::ShellWindowIconChanged(ShellWindow* shell_window) {
- AddShellWindowToList(shell_window);
- FOR_EACH_OBSERVER(Observer, observers_,
- OnShellWindowIconChanged(shell_window));
-}
-
-void ShellWindowRegistry::ShellWindowActivated(ShellWindow* shell_window) {
- BringToFront(shell_window);
-}
-
-void ShellWindowRegistry::RemoveShellWindow(ShellWindow* shell_window) {
- const ShellWindowList::iterator it = std::find(shell_windows_.begin(),
- shell_windows_.end(),
- shell_window);
- if (it != shell_windows_.end())
- shell_windows_.erase(it);
- FOR_EACH_OBSERVER(Observer, observers_, OnShellWindowRemoved(shell_window));
-}
-
-void ShellWindowRegistry::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void ShellWindowRegistry::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-ShellWindowRegistry::ShellWindowList ShellWindowRegistry::GetShellWindowsForApp(
- const std::string& app_id) const {
- ShellWindowList app_windows;
- for (ShellWindowList::const_iterator i = shell_windows_.begin();
- i != shell_windows_.end(); ++i) {
- if ((*i)->extension_id() == app_id)
- app_windows.push_back(*i);
- }
- return app_windows;
-}
-
-void ShellWindowRegistry::CloseAllShellWindowsForApp(
- const std::string& app_id) {
- for (ShellWindowList::const_iterator i = shell_windows_.begin();
- i != shell_windows_.end(); ) {
- ShellWindow* shell_window = *(i++);
- if (shell_window->extension_id() == app_id)
- shell_window->GetBaseWindow()->Close();
- }
-}
-
-ShellWindow* ShellWindowRegistry::GetShellWindowForRenderViewHost(
- content::RenderViewHost* render_view_host) const {
- for (ShellWindowList::const_iterator i = shell_windows_.begin();
- i != shell_windows_.end(); ++i) {
- if ((*i)->web_contents()->GetRenderViewHost() == render_view_host)
- return *i;
- }
-
- return NULL;
-}
-
-ShellWindow* ShellWindowRegistry::GetShellWindowForNativeWindow(
- gfx::NativeWindow window) const {
- for (ShellWindowList::const_iterator i = shell_windows_.begin();
- i != shell_windows_.end(); ++i) {
- if ((*i)->GetNativeWindow() == window)
- return *i;
- }
-
- return NULL;
-}
-
-ShellWindow* ShellWindowRegistry::GetCurrentShellWindowForApp(
- const std::string& app_id) const {
- ShellWindow* result = NULL;
- for (ShellWindowList::const_iterator i = shell_windows_.begin();
- i != shell_windows_.end(); ++i) {
- if ((*i)->extension()->id() == app_id) {
- result = *i;
- if (result->GetBaseWindow()->IsActive())
- return result;
- }
- }
-
- return result;
-}
-
-ShellWindow* ShellWindowRegistry::GetShellWindowForAppAndKey(
- const std::string& app_id,
- const std::string& window_key) const {
- ShellWindow* result = NULL;
- for (ShellWindowList::const_iterator i = shell_windows_.begin();
- i != shell_windows_.end(); ++i) {
- if ((*i)->extension()->id() == app_id && (*i)->window_key() == window_key) {
- result = *i;
- if (result->GetBaseWindow()->IsActive())
- return result;
- }
- }
- return result;
-}
-
-bool ShellWindowRegistry::HadDevToolsAttached(
- content::RenderViewHost* render_view_host) const {
- std::string key = GetWindowKeyForRenderViewHost(this, render_view_host);
- return key.empty() ? false : inspected_windows_.count(key) != 0;
-}
-
-// static
-ShellWindow* ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile(
- gfx::NativeWindow window) {
- std::vector<content::BrowserContext*> contexts =
- AppsClient::Get()->GetLoadedBrowserContexts();
- for (std::vector<content::BrowserContext*>::const_iterator i =
- contexts.begin();
- i != contexts.end(); ++i) {
- ShellWindowRegistry* registry = Factory::GetForBrowserContext(
- *i, false /* create */);
- if (!registry)
- continue;
-
- ShellWindow* shell_window = registry->GetShellWindowForNativeWindow(window);
- if (shell_window)
- return shell_window;
- }
-
- return NULL;
-}
-
-// static
-bool ShellWindowRegistry::IsShellWindowRegisteredInAnyProfile(
- int window_type_mask) {
- std::vector<content::BrowserContext*> contexts =
- AppsClient::Get()->GetLoadedBrowserContexts();
- for (std::vector<content::BrowserContext*>::const_iterator i =
- contexts.begin();
- i != contexts.end(); ++i) {
- ShellWindowRegistry* registry = Factory::GetForBrowserContext(
- *i, false /* create */);
- if (!registry)
- continue;
-
- const ShellWindowList& shell_windows = registry->shell_windows();
- if (shell_windows.empty())
- continue;
-
- if (window_type_mask == 0)
- return true;
-
- for (const_iterator j = shell_windows.begin(); j != shell_windows.end();
- ++j) {
- if ((*j)->window_type() & window_type_mask)
- return true;
- }
- }
-
- return false;
-}
-
-void ShellWindowRegistry::OnDevToolsStateChanged(
- content::DevToolsAgentHost* agent_host, bool attached) {
- content::RenderViewHost* rvh = agent_host->GetRenderViewHost();
- // Ignore unrelated notifications.
- if (!rvh ||
- rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_)
- return;
-
- std::string key = GetWindowKeyForRenderViewHost(this, rvh);
- if (key.empty())
- return;
-
- if (attached)
- inspected_windows_.insert(key);
- else
- inspected_windows_.erase(key);
-}
-
-void ShellWindowRegistry::AddShellWindowToList(ShellWindow* shell_window) {
- const ShellWindowList::iterator it = std::find(shell_windows_.begin(),
- shell_windows_.end(),
- shell_window);
- if (it != shell_windows_.end())
- return;
- shell_windows_.push_back(shell_window);
-}
-
-void ShellWindowRegistry::BringToFront(ShellWindow* shell_window) {
- const ShellWindowList::iterator it = std::find(shell_windows_.begin(),
- shell_windows_.end(),
- shell_window);
- if (it != shell_windows_.end())
- shell_windows_.erase(it);
- shell_windows_.push_front(shell_window);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Factory boilerplate
-
-// static
-ShellWindowRegistry* ShellWindowRegistry::Factory::GetForBrowserContext(
- content::BrowserContext* context, bool create) {
- return static_cast<ShellWindowRegistry*>(
- GetInstance()->GetServiceForBrowserContext(context, create));
-}
-
-ShellWindowRegistry::Factory* ShellWindowRegistry::Factory::GetInstance() {
- return Singleton<ShellWindowRegistry::Factory>::get();
-}
-
-ShellWindowRegistry::Factory::Factory()
- : BrowserContextKeyedServiceFactory(
- "ShellWindowRegistry",
- BrowserContextDependencyManager::GetInstance()) {
-}
-
-ShellWindowRegistry::Factory::~Factory() {
-}
-
-BrowserContextKeyedService*
-ShellWindowRegistry::Factory::BuildServiceInstanceFor(
- content::BrowserContext* context) const {
- return new ShellWindowRegistry(context);
-}
-
-bool ShellWindowRegistry::Factory::ServiceIsCreatedWithBrowserContext() const {
- return true;
-}
-
-bool ShellWindowRegistry::Factory::ServiceIsNULLWhileTesting() const {
- return false;
-}
-
-content::BrowserContext* ShellWindowRegistry::Factory::GetBrowserContextToUse(
- content::BrowserContext* context) const {
- return extensions::ExtensionsBrowserClient::Get()->
- GetOriginalContext(context);
-}
-
-} // namespace extensions
diff --git a/apps/shell_window_registry.h b/apps/shell_window_registry.h
deleted file mode 100644
index f32b39b..0000000
--- a/apps/shell_window_registry.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APPS_SHELL_WINDOW_REGISTRY_H_
-#define APPS_SHELL_WINDOW_REGISTRY_H_
-
-#include <list>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/memory/singleton.h"
-#include "base/observer_list.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
-#include "ui/gfx/native_widget_types.h"
-
-namespace content {
-class BrowserContext;
-class DevToolsAgentHost;
-class RenderViewHost;
-}
-
-namespace apps {
-
-class ShellWindow;
-
-// The ShellWindowRegistry tracks the ShellWindows for all platform apps for a
-// particular browser context.
-class ShellWindowRegistry : public BrowserContextKeyedService {
- public:
- class Observer {
- public:
- // Called just after a shell window was added.
- virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) = 0;
- // Called when the window icon changes.
- virtual void OnShellWindowIconChanged(apps::ShellWindow* shell_window) = 0;
- // Called just after a shell window was removed.
- virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window) = 0;
-
- protected:
- virtual ~Observer() {}
- };
-
- typedef std::list<apps::ShellWindow*> ShellWindowList;
- typedef ShellWindowList::const_iterator const_iterator;
- typedef std::set<std::string> InspectedWindowSet;
-
- explicit ShellWindowRegistry(content::BrowserContext* context);
- virtual ~ShellWindowRegistry();
-
- // Returns the instance for the given browser context, or NULL if none. This
- // is a convenience wrapper around
- // ShellWindowRegistry::Factory::GetForBrowserContext().
- static ShellWindowRegistry* Get(content::BrowserContext* context);
-
- void AddShellWindow(apps::ShellWindow* shell_window);
- void ShellWindowIconChanged(apps::ShellWindow* shell_window);
- // Called by |shell_window| when it is activated.
- void ShellWindowActivated(apps::ShellWindow* shell_window);
- void RemoveShellWindow(apps::ShellWindow* shell_window);
-
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
- // Returns a set of windows owned by the application identified by app_id.
- ShellWindowList GetShellWindowsForApp(const std::string& app_id) const;
- const ShellWindowList& shell_windows() const { return shell_windows_; }
-
- // Close all shell windows associated with an app.
- void CloseAllShellWindowsForApp(const std::string& app_id);
-
- // Helper functions to find shell windows with particular attributes.
- apps::ShellWindow* GetShellWindowForRenderViewHost(
- content::RenderViewHost* render_view_host) const;
- apps::ShellWindow* GetShellWindowForNativeWindow(
- gfx::NativeWindow window) const;
- // Returns an app window for the given app, or NULL if no shell windows are
- // open. If there is a window for the given app that is active, that one will
- // be returned, otherwise an arbitrary window will be returned.
- apps::ShellWindow* GetCurrentShellWindowForApp(
- const std::string& app_id) const;
- // Returns an app window for the given app and window key, or NULL if no shell
- // window with the key are open. If there is a window for the given app and
- // key that is active, that one will be returned, otherwise an arbitrary
- // window will be returned.
- apps::ShellWindow* GetShellWindowForAppAndKey(
- const std::string& app_id,
- const std::string& window_key) const;
-
- // Returns whether a ShellWindow's ID was last known to have a DevToolsAgent
- // attached to it, which should be restored during a reload of a corresponding
- // newly created |render_view_host|.
- bool HadDevToolsAttached(content::RenderViewHost* render_view_host) const;
-
- // Returns the shell window for |window|, looking in all browser contexts.
- static apps::ShellWindow* GetShellWindowForNativeWindowAnyProfile(
- gfx::NativeWindow window);
-
- // Returns true if the number of shell windows registered across all browser
- // contexts is non-zero. |window_type_mask| is a bitwise OR filter of
- // ShellWindow::WindowType, or 0 for any window type.
- static bool IsShellWindowRegisteredInAnyProfile(int window_type_mask);
-
- class Factory : public BrowserContextKeyedServiceFactory {
- public:
- static ShellWindowRegistry* GetForBrowserContext(
- content::BrowserContext* context, bool create);
-
- static Factory* GetInstance();
- private:
- friend struct DefaultSingletonTraits<Factory>;
-
- Factory();
- virtual ~Factory();
-
- // BrowserContextKeyedServiceFactory
- virtual BrowserContextKeyedService* BuildServiceInstanceFor(
- content::BrowserContext* context) const OVERRIDE;
- virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
- virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
- virtual content::BrowserContext* GetBrowserContextToUse(
- content::BrowserContext* context) const OVERRIDE;
- };
-
- protected:
- void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached);
-
- private:
- // Ensures the specified |shell_window| is included in |shell_windows_|.
- // Otherwise adds |shell_window| to the back of |shell_windows_|.
- void AddShellWindowToList(apps::ShellWindow* shell_window);
-
- // Bring |shell_window| to the front of |shell_windows_|. If it is not in the
- // list, add it first.
- void BringToFront(apps::ShellWindow* shell_window);
-
- content::BrowserContext* context_;
- ShellWindowList shell_windows_;
- InspectedWindowSet inspected_windows_;
- ObserverList<Observer> observers_;
- base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
-};
-
-} // namespace extensions
-
-#endif // APPS_SHELL_WINDOW_REGISTRY_H_
diff --git a/apps/ui/native_app_window.h b/apps/ui/native_app_window.h
index 0cc1e99..1668916 100644
--- a/apps/ui/native_app_window.h
+++ b/apps/ui/native_app_window.h
@@ -5,21 +5,21 @@
#ifndef APPS_UI_NATIVE_APP_WINDOW_H_
#define APPS_UI_NATIVE_APP_WINDOW_H_
-#include "apps/shell_window.h"
+#include "apps/app_window.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "ui/base/base_window.h"
#include "ui/gfx/insets.h"
namespace apps {
-// This is an interface to a native implementation of a shell window, used for
-// new-style packaged apps. Shell windows contain a web contents, but no tabs
+// This is an interface to a native implementation of a app window, used for
+// new-style packaged apps. App windows contain a web contents, but no tabs
// or URL bar.
class NativeAppWindow : public ui::BaseWindow,
public web_modal::WebContentsModalDialogHost {
public:
// Sets whether the window is fullscreen and the type of fullscreen.
- // |fullscreen_types| is a bit field of ShellWindow::FullscreenType.
+ // |fullscreen_types| is a bit field of AppWindow::FullscreenType.
virtual void SetFullscreen(int fullscreen_types) = 0;
// Returns whether the window is fullscreen or about to enter fullscreen.
diff --git a/apps/ui/views/shell_window_frame_view.cc b/apps/ui/views/app_window_frame_view.cc
index fba321d..a74f9e1 100644
--- a/apps/ui/views/shell_window_frame_view.cc
+++ b/apps/ui/views/app_window_frame_view.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "apps/ui/views/shell_window_frame_view.h"
+#include "apps/ui/views/app_window_frame_view.h"
#include "apps/ui/native_app_window.h"
#include "base/strings/utf_string_conversions.h"
@@ -34,10 +34,10 @@ const int kCaptionHeight = 25;
namespace apps {
-const char ShellWindowFrameView::kViewClassName[] =
- "browser/ui/views/extensions/ShellWindowFrameView";
+const char AppWindowFrameView::kViewClassName[] =
+ "browser/ui/views/extensions/AppWindowFrameView";
-ShellWindowFrameView::ShellWindowFrameView(NativeAppWindow* window)
+AppWindowFrameView::AppWindowFrameView(NativeAppWindow* window)
: window_(window),
frame_(NULL),
close_button_(NULL),
@@ -46,17 +46,15 @@ ShellWindowFrameView::ShellWindowFrameView(NativeAppWindow* window)
minimize_button_(NULL),
resize_inside_bounds_size_(0),
resize_outside_bounds_size_(0),
- resize_area_corner_size_(0) {
-}
+ resize_area_corner_size_(0) {}
-ShellWindowFrameView::~ShellWindowFrameView() {
-}
+AppWindowFrameView::~AppWindowFrameView() {}
-void ShellWindowFrameView::Init(views::Widget* frame,
- int resize_inside_bounds_size,
- int resize_outside_bounds_size,
- int resize_outside_scale_for_touch,
- int resize_area_corner_size) {
+void AppWindowFrameView::Init(views::Widget* frame,
+ int resize_inside_bounds_size,
+ int resize_outside_bounds_size,
+ int resize_outside_scale_for_touch,
+ int resize_area_corner_size) {
frame_ = frame;
resize_inside_bounds_size_ = resize_inside_bounds_size;
resize_outside_bounds_size_ = resize_outside_bounds_size;
@@ -65,43 +63,56 @@ void ShellWindowFrameView::Init(views::Widget* frame,
if (!window_->IsFrameless()) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
close_button_ = new views::ImageButton(this);
- close_button_->SetImage(views::CustomButton::STATE_NORMAL,
+ close_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia());
- close_button_->SetImage(views::CustomButton::STATE_HOVERED,
+ close_button_->SetImage(
+ views::CustomButton::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_H).ToImageSkia());
- close_button_->SetImage(views::CustomButton::STATE_PRESSED,
+ close_button_->SetImage(
+ views::CustomButton::STATE_PRESSED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_P).ToImageSkia());
close_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
AddChildView(close_button_);
maximize_button_ = new views::ImageButton(this);
- maximize_button_->SetImage(views::CustomButton::STATE_NORMAL,
+ maximize_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE).ToImageSkia());
- maximize_button_->SetImage(views::CustomButton::STATE_HOVERED,
+ maximize_button_->SetImage(
+ views::CustomButton::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_H).ToImageSkia());
- maximize_button_->SetImage(views::CustomButton::STATE_PRESSED,
+ maximize_button_->SetImage(
+ views::CustomButton::STATE_PRESSED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_P).ToImageSkia());
- maximize_button_->SetImage(views::CustomButton::STATE_DISABLED,
+ maximize_button_->SetImage(
+ views::CustomButton::STATE_DISABLED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_D).ToImageSkia());
maximize_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE));
AddChildView(maximize_button_);
restore_button_ = new views::ImageButton(this);
- restore_button_->SetImage(views::CustomButton::STATE_NORMAL,
+ restore_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE).ToImageSkia());
- restore_button_->SetImage(views::CustomButton::STATE_HOVERED,
+ restore_button_->SetImage(
+ views::CustomButton::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE_H).ToImageSkia());
- restore_button_->SetImage(views::CustomButton::STATE_PRESSED,
+ restore_button_->SetImage(
+ views::CustomButton::STATE_PRESSED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE_P).ToImageSkia());
restore_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_RESTORE));
AddChildView(restore_button_);
minimize_button_ = new views::ImageButton(this);
- minimize_button_->SetImage(views::CustomButton::STATE_NORMAL,
+ minimize_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE).ToImageSkia());
- minimize_button_->SetImage(views::CustomButton::STATE_HOVERED,
+ minimize_button_->SetImage(
+ views::CustomButton::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia());
- minimize_button_->SetImage(views::CustomButton::STATE_PRESSED,
+ minimize_button_->SetImage(
+ views::CustomButton::STATE_PRESSED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_P).ToImageSkia());
minimize_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE));
@@ -113,22 +124,24 @@ void ShellWindowFrameView::Init(views::Widget* frame,
// Ensure we get resize cursors just inside our bounds as well.
// TODO(jeremya): do we need to update these when in fullscreen/maximized?
window->set_hit_test_bounds_override_inner(
- gfx::Insets(resize_inside_bounds_size_, resize_inside_bounds_size_,
- resize_inside_bounds_size_, resize_inside_bounds_size_));
+ gfx::Insets(resize_inside_bounds_size_,
+ resize_inside_bounds_size_,
+ resize_inside_bounds_size_,
+ resize_inside_bounds_size_));
#endif
}
// views::NonClientFrameView implementation.
-gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const {
+gfx::Rect AppWindowFrameView::GetBoundsForClientView() const {
if (window_->IsFrameless() || frame_->IsFullscreen())
return bounds();
- return gfx::Rect(0, kCaptionHeight, width(),
- std::max(0, height() - kCaptionHeight));
+ return gfx::Rect(
+ 0, kCaptionHeight, width(), std::max(0, height() - kCaptionHeight));
}
-gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds(
- const gfx::Rect& client_bounds) const {
+gfx::Rect AppWindowFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
if (window_->IsFrameless()) {
gfx::Rect window_bounds = client_bounds;
// Enforce minimum size (1, 1) in case that client_bounds is passed with
@@ -141,8 +154,7 @@ gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds(
return window_bounds;
}
- int closeButtonOffsetX =
- (kCaptionHeight - close_button_->height()) / 2;
+ int closeButtonOffsetX = (kCaptionHeight - close_button_->height()) / 2;
int header_width = close_button_->width() + closeButtonOffsetX * 2;
return gfx::Rect(client_bounds.x(),
std::max(0, client_bounds.y() - kCaptionHeight),
@@ -150,7 +162,7 @@ gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds(
client_bounds.height() + kCaptionHeight);
}
-int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) {
+int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) {
if (frame_->IsFullscreen())
return HTCLIENT;
@@ -166,14 +178,14 @@ int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) {
// Check the frame first, as we allow a small area overlapping the contents
// to be used for resize handles.
- bool can_ever_resize = frame_->widget_delegate() ?
- frame_->widget_delegate()->CanResize() :
- false;
+ bool can_ever_resize = frame_->widget_delegate()
+ ? frame_->widget_delegate()->CanResize()
+ : false;
// Don't allow overlapping resize handles when the window is maximized or
// fullscreen, as it can't be resized in those states.
- int resize_border =
- (frame_->IsMaximized() || frame_->IsFullscreen()) ? 0 :
- resize_inside_bounds_size_;
+ int resize_border = (frame_->IsMaximized() || frame_->IsFullscreen())
+ ? 0
+ : resize_inside_bounds_size_;
int frame_component = GetHTComponentForFrame(point,
resize_border,
resize_border,
@@ -215,21 +227,22 @@ int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) {
return HTCAPTION;
}
-void ShellWindowFrameView::GetWindowMask(const gfx::Size& size,
- gfx::Path* window_mask) {
+void AppWindowFrameView::GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) {
// We got nothing to say about no window mask.
}
// views::View implementation.
-gfx::Size ShellWindowFrameView::GetPreferredSize() {
+gfx::Size AppWindowFrameView::GetPreferredSize() {
gfx::Size pref = frame_->client_view()->GetPreferredSize();
gfx::Rect bounds(0, 0, pref.width(), pref.height());
- return frame_->non_client_view()->GetWindowBoundsForClientBounds(
- bounds).size();
+ return frame_->non_client_view()
+ ->GetWindowBoundsForClientBounds(bounds)
+ .size();
}
-void ShellWindowFrameView::Layout() {
+void AppWindowFrameView::Layout() {
if (window_->IsFrameless())
return;
gfx::Size close_size = close_button_->GetPreferredSize();
@@ -237,15 +250,14 @@ void ShellWindowFrameView::Layout() {
const int kButtonSpacing = 1;
const int kRightMargin = 3;
- close_button_->SetBounds(
- width() - kRightMargin - close_size.width(),
- kButtonOffsetY,
- close_size.width(),
- close_size.height());
+ close_button_->SetBounds(width() - kRightMargin - close_size.width(),
+ kButtonOffsetY,
+ close_size.width(),
+ close_size.height());
- bool can_ever_resize = frame_->widget_delegate() ?
- frame_->widget_delegate()->CanResize() :
- false;
+ bool can_ever_resize = frame_->widget_delegate()
+ ? frame_->widget_delegate()->CanResize()
+ : false;
maximize_button_->SetEnabled(can_ever_resize);
gfx::Size maximize_size = maximize_button_->GetPreferredSize();
maximize_button_->SetBounds(
@@ -276,16 +288,18 @@ void ShellWindowFrameView::Layout() {
minimize_size.height());
}
-void ShellWindowFrameView::OnPaint(gfx::Canvas* canvas) {
+void AppWindowFrameView::OnPaint(gfx::Canvas* canvas) {
if (window_->IsFrameless())
return;
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (ShouldPaintAsActive()) {
- close_button_->SetImage(views::CustomButton::STATE_NORMAL,
+ close_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia());
} else {
- close_button_->SetImage(views::CustomButton::STATE_NORMAL,
+ close_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia());
}
@@ -303,11 +317,9 @@ void ShellWindowFrameView::OnPaint(gfx::Canvas* canvas) {
canvas->DrawPath(path, paint);
}
-const char* ShellWindowFrameView::GetClassName() const {
- return kViewClassName;
-}
+const char* AppWindowFrameView::GetClassName() const { return kViewClassName; }
-gfx::Size ShellWindowFrameView::GetMinimumSize() {
+gfx::Size AppWindowFrameView::GetMinimumSize() {
gfx::Size min_size = frame_->client_view()->GetMinimumSize();
if (window_->IsFrameless())
return min_size;
@@ -317,15 +329,14 @@ gfx::Size ShellWindowFrameView::GetMinimumSize() {
min_size.Enlarge(0, client_bounds.y());
// Ensure we have enough space for the window icon and buttons. We allow
// the title string to collapse to zero width.
- int closeButtonOffsetX =
- (kCaptionHeight - close_button_->height()) / 2;
+ int closeButtonOffsetX = (kCaptionHeight - close_button_->height()) / 2;
int header_width = close_button_->width() + closeButtonOffsetX * 2;
if (header_width > min_size.width())
min_size.set_width(header_width);
return min_size;
}
-gfx::Size ShellWindowFrameView::GetMaximumSize() {
+gfx::Size AppWindowFrameView::GetMaximumSize() {
gfx::Size max_size = frame_->client_view()->GetMaximumSize();
// Add to the client maximum size the height of any title bar and borders.
@@ -340,8 +351,8 @@ gfx::Size ShellWindowFrameView::GetMaximumSize() {
// views::ButtonListener implementation.
-void ShellWindowFrameView::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
+void AppWindowFrameView::ButtonPressed(views::Button* sender,
+ const ui::Event& event) {
DCHECK(!window_->IsFrameless());
if (sender == close_button_)
frame_->Close();
diff --git a/apps/ui/views/shell_window_frame_view.h b/apps/ui/views/app_window_frame_view.h
index 31b7857..77c3859 100644
--- a/apps/ui/views/shell_window_frame_view.h
+++ b/apps/ui/views/app_window_frame_view.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef APPS_UI_VIEWS_SHELL_WINDOW_FRAME_VIEW_H_
-#define APPS_UI_VIEWS_SHELL_WINDOW_FRAME_VIEW_H_
+#ifndef APPS_UI_VIEWS_APP_WINDOW_FRAME_VIEW_H_
+#define APPS_UI_VIEWS_APP_WINDOW_FRAME_VIEW_H_
#include <string>
@@ -32,13 +32,13 @@ namespace apps {
class NativeAppWindow;
// A frameless or non-Ash, non-panel NonClientFrameView for app windows.
-class ShellWindowFrameView : public views::NonClientFrameView,
- public views::ButtonListener {
+class AppWindowFrameView : public views::NonClientFrameView,
+ public views::ButtonListener {
public:
static const char kViewClassName[];
- explicit ShellWindowFrameView(NativeAppWindow* window);
- virtual ~ShellWindowFrameView();
+ explicit AppWindowFrameView(NativeAppWindow* window);
+ virtual ~AppWindowFrameView();
// Initializes this for the window |frame|. Sets the number of pixels for
// which a click is interpreted as a resize for the inner and outer border of
@@ -70,8 +70,8 @@ class ShellWindowFrameView : public views::NonClientFrameView,
virtual gfx::Size GetMaximumSize() OVERRIDE;
// views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender, const ui::Event& event)
- OVERRIDE;
+ virtual void ButtonPressed(views::Button* sender,
+ const ui::Event& event) OVERRIDE;
NativeAppWindow* window_;
views::Widget* frame_;
@@ -89,9 +89,9 @@ class ShellWindowFrameView : public views::NonClientFrameView,
// Size in pixels of the lower-right corner resize handle.
int resize_area_corner_size_;
- DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView);
+ DISALLOW_COPY_AND_ASSIGN(AppWindowFrameView);
};
} // namespace apps
-#endif // APPS_UI_VIEWS_SHELL_WINDOW_FRAME_VIEW_H_
+#endif // APPS_UI_VIEWS_APP_WINDOW_FRAME_VIEW_H_