| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, | 65 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, |
| 66 base::Unretained(ResourceDispatcherHost::Get()), | 66 base::Unretained(ResourceDispatcherHost::Get()), |
| 67 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 67 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 ShellWindow::CreateParams::CreateParams() | 72 ShellWindow::CreateParams::CreateParams() |
| 73 : frame(ShellWindow::CreateParams::FRAME_CHROME), | 73 : frame(ShellWindow::CreateParams::FRAME_CHROME), |
| 74 bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN), | 74 bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN), |
| 75 restore_position(true), restore_size(true), | |
| 76 creator_process_id(0), hidden(false) { | 75 creator_process_id(0), hidden(false) { |
| 77 } | 76 } |
| 78 | 77 |
| 79 ShellWindow::CreateParams::~CreateParams() { | 78 ShellWindow::CreateParams::~CreateParams() { |
| 80 } | 79 } |
| 81 | 80 |
| 82 ShellWindow* ShellWindow::Create(Profile* profile, | 81 ShellWindow* ShellWindow::Create(Profile* profile, |
| 83 const extensions::Extension* extension, | 82 const extensions::Extension* extension, |
| 84 const GURL& url, | 83 const GURL& url, |
| 85 const ShellWindow::CreateParams& params) { | 84 const ShellWindow::CreateParams& params) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 bounds.set_width(kDefaultWidth); | 120 bounds.set_width(kDefaultWidth); |
| 122 if (bounds.height() == INT_MIN) | 121 if (bounds.height() == INT_MIN) |
| 123 bounds.set_height(kDefaultHeight); | 122 bounds.set_height(kDefaultHeight); |
| 124 | 123 |
| 125 // If left and top are left undefined, the native shell window will center | 124 // If left and top are left undefined, the native shell window will center |
| 126 // the window on the main screen in a platform-defined manner. | 125 // the window on the main screen in a platform-defined manner. |
| 127 | 126 |
| 128 if (!params.window_key.empty()) { | 127 if (!params.window_key.empty()) { |
| 129 window_key_ = params.window_key; | 128 window_key_ = params.window_key; |
| 130 | 129 |
| 131 if (params.restore_position || params.restore_size) { | 130 extensions::ShellWindowGeometryCache* cache = |
| 132 extensions::ShellWindowGeometryCache* cache = | 131 extensions::ExtensionSystem::Get(profile())-> |
| 133 extensions::ExtensionSystem::Get(profile())-> | 132 shell_window_geometry_cache(); |
| 134 shell_window_geometry_cache(); | 133 gfx::Rect cached_bounds; |
| 135 gfx::Rect cached_bounds; | 134 if (cache->GetGeometry(extension()->id(), params.window_key, |
| 136 if (cache->GetGeometry(extension()->id(), params.window_key, | 135 &cached_bounds)) |
| 137 &cached_bounds)) { | 136 bounds = cached_bounds; |
| 138 if (params.restore_position) | |
| 139 bounds.set_origin(cached_bounds.origin()); | |
| 140 if (params.restore_size) | |
| 141 bounds.set_size(cached_bounds.size()); | |
| 142 } | |
| 143 } | |
| 144 } | 137 } |
| 145 | 138 |
| 146 ShellWindow::CreateParams new_params = params; | 139 ShellWindow::CreateParams new_params = params; |
| 147 new_params.bounds = bounds; | 140 new_params.bounds = bounds; |
| 148 | 141 |
| 149 native_window_.reset(NativeShellWindow::Create(this, new_params)); | 142 native_window_.reset(NativeShellWindow::Create(this, new_params)); |
| 150 SaveWindowPosition(); | 143 SaveWindowPosition(); |
| 151 | 144 |
| 152 if (!params.hidden) | 145 if (!params.hidden) |
| 153 GetBaseWindow()->Show(); | 146 GetBaseWindow()->Show(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 const extensions::DraggableRegion& region = *iter; | 478 const extensions::DraggableRegion& region = *iter; |
| 486 sk_region->op( | 479 sk_region->op( |
| 487 region.bounds.x(), | 480 region.bounds.x(), |
| 488 region.bounds.y(), | 481 region.bounds.y(), |
| 489 region.bounds.right(), | 482 region.bounds.right(), |
| 490 region.bounds.bottom(), | 483 region.bounds.bottom(), |
| 491 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 484 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 492 } | 485 } |
| 493 return sk_region; | 486 return sk_region; |
| 494 } | 487 } |
| OLD | NEW |