| 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 2a960c2d3758dc9da7da38e8d236bf4fe9f83671..a5651b33f5ed3adb71374aa9fb5a390a97e509d6 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,8 @@ 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* ShellWindow::Create(Profile* profile,
|
| @@ -101,6 +104,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
|
| + extensions::ShellWindowGeometryCache* cache =
|
| + extensions::ExtensionSystem::Get(profile())->
|
| + shell_window_geometry_cache();
|
| + gfx::Rect cached_bounds;
|
| + if (cache->GetWindowGeometry(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());
|
| @@ -369,3 +396,16 @@ void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
|
| rvh->Send(new ExtensionMsg_AddMessageToConsole(
|
| rvh->GetRoutingID(), level, message));
|
| }
|
| +
|
| +void ShellWindow::SaveWindowPosition()
|
| +{
|
| + if (!window_key_.empty()) {
|
| + extensions::ShellWindowGeometryCache* cache =
|
| + extensions::ExtensionSystem::Get(profile())->
|
| + shell_window_geometry_cache();
|
| +
|
| + gfx::Rect bounds = native_window_->GetBounds();
|
| + cache->SaveWindowGeometry(extension()->id(), window_key_, bounds);
|
| + }
|
| +}
|
| +
|
|
|