Chromium Code Reviews| Index: chrome/browser/ui/extensions/shell_window.cc |
| diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc |
| index da858acec0c294be43baf41133ee3a0245abfac7..c9fa4a6dbc55d1f39c9bd6bcaf6c39419881e0d9 100644 |
| --- a/chrome/browser/ui/extensions/shell_window.cc |
| +++ b/chrome/browser/ui/extensions/shell_window.cc |
| @@ -6,6 +6,8 @@ |
| #include "base/utf_string_conversions.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" |
| #include "chrome/browser/extensions/shell_window_registry.h" |
| #include "chrome/browser/file_select_helper.h" |
| #include "chrome/browser/infobars/infobar_tab_helper.h" |
| @@ -63,7 +65,11 @@ void SuspendRenderViewHost(RenderViewHost* rvh) { |
| ShellWindow::CreateParams::CreateParams() |
| : frame(ShellWindow::CreateParams::FRAME_CHROME), |
| - bounds(10, 10, kDefaultWidth, kDefaultHeight) { |
| + bounds(-1, -1, kDefaultWidth, kDefaultHeight), |
| + restorePosition(true), restoreSize(true) { |
| +} |
| + |
| +ShellWindow::CreateParams::~CreateParams() { |
| } |
| ShellWindow* ShellWindow::Create(Profile* profile, |
| @@ -101,6 +107,30 @@ void ShellWindow::Init(const GURL& url, |
| native_window_.reset(NativeShellWindow::Create(this, params)); |
| + if (!params.window_key.empty()) { |
| + window_key_ = params.window_key; |
| + |
| + if (params.restorePosition || params.restoreSize) { |
| + // restore geometry |
|
Mihai Parparita -not on Chrome
2012/08/29 21:39:14
Extraneous comment.
Marijn Kruisselbrink
2012/08/29 22:31:33
Done.
|
| + extensions::ShellWindowGeometryCache* cache = |
| + extensions::ExtensionSystem::Get(profile())-> |
| + shell_window_geometry_cache(); |
| + gfx::Rect cached_bounds; |
| + if (cache->GetGeometry(extension()->id(), params.window_key, |
| + &cached_bounds)) { |
| + gfx::Rect bounds = native_window_->GetBounds(); |
| + |
| + if (params.restorePosition) |
| + bounds.set_origin(cached_bounds.origin()); |
| + if (params.restoreSize) |
| + bounds.set_size(cached_bounds.size()); |
| + |
| + native_window_->SetBounds(bounds); |
| + } |
| + } |
| + } |
| + |
| + |
| // Block the created RVH from loading anything until the background page |
| // has had a chance to do any initialization it wants. |
| SuspendRenderViewHost(web_contents_->GetRenderViewHost()); |
| @@ -376,3 +406,16 @@ void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
| rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| rvh->GetRoutingID(), level, message)); |
| } |
| + |
| +void ShellWindow::SaveWindowPosition() |
| +{ |
| + if (!window_key_.empty()) { |
|
Mihai Parparita -not on Chrome
2012/08/29 21:39:14
Nit: turn this into an early return, so that the b
Marijn Kruisselbrink
2012/08/29 22:31:33
Done.
|
| + extensions::ShellWindowGeometryCache* cache = |
| + extensions::ExtensionSystem::Get(profile())-> |
| + shell_window_geometry_cache(); |
| + |
| + gfx::Rect bounds = native_window_->GetBounds(); |
| + cache->SaveGeometry(extension()->id(), window_key_, bounds); |
| + } |
| +} |
| + |