| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, | 69 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, |
| 70 base::Unretained(ResourceDispatcherHost::Get()), | 70 base::Unretained(ResourceDispatcherHost::Get()), |
| 71 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 71 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 ShellWindow::CreateParams::CreateParams() | 76 ShellWindow::CreateParams::CreateParams() |
| 77 : frame(ShellWindow::CreateParams::FRAME_CHROME), | 77 : frame(ShellWindow::CreateParams::FRAME_CHROME), |
| 78 bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN), | 78 bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN), |
| 79 restore_position(true), restore_size(true), | |
| 80 creator_process_id(0), hidden(false) { | 79 creator_process_id(0), hidden(false) { |
| 81 } | 80 } |
| 82 | 81 |
| 83 ShellWindow::CreateParams::~CreateParams() { | 82 ShellWindow::CreateParams::~CreateParams() { |
| 84 } | 83 } |
| 85 | 84 |
| 86 ShellWindow* ShellWindow::Create(Profile* profile, | 85 ShellWindow* ShellWindow::Create(Profile* profile, |
| 87 const extensions::Extension* extension, | 86 const extensions::Extension* extension, |
| 88 const GURL& url, | 87 const GURL& url, |
| 89 const ShellWindow::CreateParams& params) { | 88 const ShellWindow::CreateParams& params) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bounds.set_width(kDefaultWidth); | 125 bounds.set_width(kDefaultWidth); |
| 127 if (bounds.height() == INT_MIN) | 126 if (bounds.height() == INT_MIN) |
| 128 bounds.set_height(kDefaultHeight); | 127 bounds.set_height(kDefaultHeight); |
| 129 | 128 |
| 130 // If left and top are left undefined, the native shell window will center | 129 // If left and top are left undefined, the native shell window will center |
| 131 // the window on the main screen in a platform-defined manner. | 130 // the window on the main screen in a platform-defined manner. |
| 132 | 131 |
| 133 if (!params.window_key.empty()) { | 132 if (!params.window_key.empty()) { |
| 134 window_key_ = params.window_key; | 133 window_key_ = params.window_key; |
| 135 | 134 |
| 136 if (params.restore_position || params.restore_size) { | 135 extensions::ShellWindowGeometryCache* cache = |
| 137 extensions::ShellWindowGeometryCache* cache = | 136 extensions::ExtensionSystem::Get(profile())-> |
| 138 extensions::ExtensionSystem::Get(profile())-> | 137 shell_window_geometry_cache(); |
| 139 shell_window_geometry_cache(); | 138 gfx::Rect cached_bounds; |
| 140 gfx::Rect cached_bounds; | 139 if (cache->GetGeometry(extension()->id(), params.window_key, |
| 141 if (cache->GetGeometry(extension()->id(), params.window_key, | 140 &cached_bounds)) |
| 142 &cached_bounds)) { | 141 bounds = cached_bounds; |
| 143 if (params.restore_position) | |
| 144 bounds.set_origin(cached_bounds.origin()); | |
| 145 if (params.restore_size) | |
| 146 bounds.set_size(cached_bounds.size()); | |
| 147 } | |
| 148 } | |
| 149 } | 142 } |
| 150 | 143 |
| 151 ShellWindow::CreateParams new_params = params; | 144 ShellWindow::CreateParams new_params = params; |
| 152 new_params.bounds = bounds; | 145 new_params.bounds = bounds; |
| 153 | 146 |
| 154 native_window_.reset(NativeShellWindow::Create(this, new_params)); | 147 native_window_.reset(NativeShellWindow::Create(this, new_params)); |
| 155 SaveWindowPosition(); | 148 SaveWindowPosition(); |
| 156 | 149 |
| 157 if (!params.hidden) | 150 if (!params.hidden) |
| 158 GetBaseWindow()->Show(); | 151 GetBaseWindow()->Show(); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 const extensions::DraggableRegion& region = *iter; | 507 const extensions::DraggableRegion& region = *iter; |
| 515 sk_region->op( | 508 sk_region->op( |
| 516 region.bounds.x(), | 509 region.bounds.x(), |
| 517 region.bounds.y(), | 510 region.bounds.y(), |
| 518 region.bounds.right(), | 511 region.bounds.right(), |
| 519 region.bounds.bottom(), | 512 region.bounds.bottom(), |
| 520 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 513 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 521 } | 514 } |
| 522 return sk_region; | 515 return sk_region; |
| 523 } | 516 } |
| OLD | NEW |