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..5146ea18c056597119d7458e7e310409833d6ccb 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), |
| + restore_position(true), restore_size(true) { |
| +} |
| + |
| +ShellWindow::CreateParams::~CreateParams() { |
| } |
| ShellWindow* ShellWindow::Create(Profile* profile, |
| @@ -101,6 +107,29 @@ 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.restore_position || params.restore_size) { |
| + 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)) { |
|
jeremya
2012/08/30 04:49:33
nit: indentation
Marijn Kruisselbrink
2012/08/30 17:15:05
Done.
|
| + gfx::Rect bounds = native_window_->GetBounds(); |
| + |
| + if (params.restore_position) |
| + bounds.set_origin(cached_bounds.origin()); |
| + if (params.restore_size) |
| + bounds.set_size(cached_bounds.size()); |
| + |
| + native_window_->SetBounds(bounds); |
|
jeremya
2012/08/30 04:49:33
Will this set the bounds after the window has alre
Marijn Kruisselbrink
2012/08/30 17:15:05
In theory I guess this could indeed result in the
jeremya
2012/08/31 04:36:12
Yes, this should be fixed :) (please add a TODO he
|
| + } |
| + } |
| + } |
| + |
| + |
| // 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 +405,17 @@ void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
| rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| rvh->GetRoutingID(), level, message)); |
| } |
| + |
| +void ShellWindow::SaveWindowPosition() |
| +{ |
| + if (window_key_.empty()) |
| + return; |
| + |
| + extensions::ShellWindowGeometryCache* cache = |
| + extensions::ExtensionSystem::Get(profile())-> |
| + shell_window_geometry_cache(); |
|
jeremya
2012/08/30 04:49:33
nit: 4 spaces here too, i believe
Marijn Kruisselbrink
2012/08/30 17:15:05
Yeah, I wasn't sure about indentation here. Is tha
jeremya
2012/08/31 04:36:12
I meant 2 more :)
|
| + |
| + gfx::Rect bounds = native_window_->GetBounds(); |
| + cache->SaveGeometry(extension()->id(), window_key_, bounds); |
| +} |
| + |