summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/extensions/shell_window.cc
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 04:42:43 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 04:42:43 +0000
commit99d8f096aa417b8b94f0d0dafb4350bd19607758 (patch)
treeb54cc08ca43f0776dbe497d8c9caa72e414c4b0c /chrome/browser/ui/extensions/shell_window.cc
parent7240505e7e7c1aa3e866c13ef614bf1409c17eeb (diff)
downloadchromium_src-99d8f096aa417b8b94f0d0dafb4350bd19607758.zip
chromium_src-99d8f096aa417b8b94f0d0dafb4350bd19607758.tar.gz
chromium_src-99d8f096aa417b8b94f0d0dafb4350bd19607758.tar.bz2
Add app window property change events
This adds onBoundsChanged, onMinimized, onMaximized, and onRestored events. BUG=134070 Review URL: https://codereview.chromium.org/11364230 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/extensions/shell_window.cc')
-rw-r--r--chrome/browser/ui/extensions/shell_window.cc51
1 files changed, 30 insertions, 21 deletions
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index 7406536..71e9459 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/extensions/shell_window.h"
#include "base/utf_string_conversions.h"
+#include "base/values.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/shell_window_geometry_cache.h"
@@ -143,7 +144,7 @@ void ShellWindow::Init(const GURL& url,
new_params.bounds = bounds;
native_window_.reset(NativeShellWindow::Create(this, new_params));
- SaveWindowPosition();
+ OnNativeWindowChanged();
if (!params.hidden)
GetBaseWindow()->Show();
@@ -287,6 +288,34 @@ void ShellWindow::OnNativeClose() {
delete this;
}
+void ShellWindow::OnNativeWindowChanged() {
+ SaveWindowPosition();
+ if (!native_window_ || !web_contents_)
+ return;
+ ListValue args;
+ DictionaryValue* dictionary = new DictionaryValue();
+ args.Append(dictionary);
+
+ gfx::Rect bounds = native_window_->GetBounds();
+ app_window::Bounds update;
+ update.left.reset(new int(bounds.x()));
+ update.top.reset(new int(bounds.y()));
+ update.width.reset(new int(bounds.width()));
+ update.height.reset(new int(bounds.height()));
+ dictionary->Set("bounds", update.ToValue().release());
+ dictionary->SetBoolean("minimized", native_window_->IsMinimized());
+ dictionary->SetBoolean("maximized", native_window_->IsMaximized());
+
+ content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
+ rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
+ extension_->id(),
+ "updateAppWindowProperties",
+ args,
+ GURL(),
+ false));
+}
+
+
BaseWindow* ShellWindow::GetBaseWindow() {
return native_window_.get();
}
@@ -460,28 +489,8 @@ void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
rvh->GetRoutingID(), level, message));
}
-void ShellWindow::SendBoundsUpdate() {
- if (!native_window_ || !web_contents_)
- return;
- gfx::Rect bounds = native_window_->GetBounds();
- content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
- ListValue args;
- app_window::Bounds update;
- update.left.reset(new int(bounds.x()));
- update.top.reset(new int(bounds.y()));
- update.width.reset(new int(bounds.width()));
- update.height.reset(new int(bounds.height()));
- args.Append(update.ToValue().release());
- rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
- extension_->id(),
- "updateAppWindowBounds",
- args,
- GURL(),
- false));
-}
void ShellWindow::SaveWindowPosition() {
- SendBoundsUpdate();
if (window_key_.empty())
return;
if (!native_window_)