| 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/extensions/api/app_window/app_window_api.h" | 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h" |
| 6 | 6 |
| 7 #include "apps/app_window_contents.h" | 7 #include "apps/app_window_contents.h" |
| 8 #include "apps/shell_window.h" | 8 #include "apps/shell_window.h" |
| 9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
| 10 #include "apps/ui/native_app_window.h" | 10 #include "apps/ui/native_app_window.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 namespace app_window_constants { | 45 namespace app_window_constants { |
| 46 const char kInvalidWindowId[] = | 46 const char kInvalidWindowId[] = |
| 47 "The window id can not be more than 256 characters long."; | 47 "The window id can not be more than 256 characters long."; |
| 48 } | 48 } |
| 49 | 49 |
| 50 const char kNoneFrameOption[] = "none"; | 50 const char kNoneFrameOption[] = "none"; |
| 51 const char kHtmlFrameOption[] = "experimental-html"; | 51 const char kHtmlFrameOption[] = "experimental-html"; |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 const int kUnboundedSize = apps::ShellWindow::SizeConstraints::kUnboundedSize; |
| 56 |
| 55 // Opens an inspector window and delays the response to the | 57 // Opens an inspector window and delays the response to the |
| 56 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is | 58 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is |
| 57 // ready to stop on breakpoints in the callback. | 59 // ready to stop on breakpoints in the callback. |
| 58 class DevToolsRestorer : public content::NotificationObserver { | 60 class DevToolsRestorer : public content::NotificationObserver { |
| 59 public: | 61 public: |
| 60 DevToolsRestorer(AppWindowCreateFunction* delayed_create_function, | 62 DevToolsRestorer(AppWindowCreateFunction* delayed_create_function, |
| 61 content::RenderViewHost* created_view) | 63 content::RenderViewHost* created_view) |
| 62 : delayed_create_function_(delayed_create_function) { | 64 : delayed_create_function_(delayed_create_function) { |
| 63 DevToolsWindow* devtools_window = | 65 DevToolsWindow* devtools_window = |
| 64 DevToolsWindow::ToggleDevToolsWindow( | 66 DevToolsWindow::ToggleDevToolsWindow( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 result->SetBoolean("minimized", window->GetBaseWindow()->IsMinimized()); | 96 result->SetBoolean("minimized", window->GetBaseWindow()->IsMinimized()); |
| 95 result->SetBoolean("maximized", window->GetBaseWindow()->IsMaximized()); | 97 result->SetBoolean("maximized", window->GetBaseWindow()->IsMaximized()); |
| 96 result->SetBoolean("alwaysOnTop", window->GetBaseWindow()->IsAlwaysOnTop()); | 98 result->SetBoolean("alwaysOnTop", window->GetBaseWindow()->IsAlwaysOnTop()); |
| 97 base::DictionaryValue* boundsValue = new base::DictionaryValue(); | 99 base::DictionaryValue* boundsValue = new base::DictionaryValue(); |
| 98 gfx::Rect bounds = window->GetClientBounds(); | 100 gfx::Rect bounds = window->GetClientBounds(); |
| 99 boundsValue->SetInteger("left", bounds.x()); | 101 boundsValue->SetInteger("left", bounds.x()); |
| 100 boundsValue->SetInteger("top", bounds.y()); | 102 boundsValue->SetInteger("top", bounds.y()); |
| 101 boundsValue->SetInteger("width", bounds.width()); | 103 boundsValue->SetInteger("width", bounds.width()); |
| 102 boundsValue->SetInteger("height", bounds.height()); | 104 boundsValue->SetInteger("height", bounds.height()); |
| 103 result->Set("bounds", boundsValue); | 105 result->Set("bounds", boundsValue); |
| 106 |
| 107 const ShellWindow::SizeConstraints& size_constraints = |
| 108 window->size_constraints(); |
| 109 gfx::Size min_size = size_constraints.GetMinimumSize(); |
| 110 gfx::Size max_size = size_constraints.GetMaximumSize(); |
| 111 if (min_size.width() != kUnboundedSize) |
| 112 result->SetInteger("minWidth", min_size.width()); |
| 113 if (min_size.height() != kUnboundedSize) |
| 114 result->SetInteger("minHeight", min_size.height()); |
| 115 if (max_size.width() != kUnboundedSize) |
| 116 result->SetInteger("maxWidth", max_size.width()); |
| 117 if (max_size.height() != kUnboundedSize) |
| 118 result->SetInteger("maxHeight", max_size.height()); |
| 104 } | 119 } |
| 105 | 120 |
| 106 } // namespace | 121 } // namespace |
| 107 | 122 |
| 108 void AppWindowCreateFunction::SendDelayedResponse() { | 123 void AppWindowCreateFunction::SendDelayedResponse() { |
| 109 SendResponse(true); | 124 SendResponse(true); |
| 110 } | 125 } |
| 111 | 126 |
| 112 bool AppWindowCreateFunction::RunImpl() { | 127 bool AppWindowCreateFunction::RunImpl() { |
| 113 // Don't create app window if the system is shutting down. | 128 // Don't create app window if the system is shutting down. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 ->HadDevToolsAttached(created_view)) { | 315 ->HadDevToolsAttached(created_view)) { |
| 301 new DevToolsRestorer(this, created_view); | 316 new DevToolsRestorer(this, created_view); |
| 302 return true; | 317 return true; |
| 303 } | 318 } |
| 304 | 319 |
| 305 SendResponse(true); | 320 SendResponse(true); |
| 306 return true; | 321 return true; |
| 307 } | 322 } |
| 308 | 323 |
| 309 } // namespace extensions | 324 } // namespace extensions |
| OLD | NEW |