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 "extensions/browser/api/app_current_window_internal/app_current_window_
internal_api.h" | 5 #include "extensions/browser/api/app_current_window_internal/app_current_window_
internal_api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "components/native_app_window/native_app_window.h" |
| 9 #include "components/native_app_window/size_constraints.h" |
8 #include "extensions/browser/app_window/app_window.h" | 10 #include "extensions/browser/app_window/app_window.h" |
9 #include "extensions/browser/app_window/app_window_client.h" | 11 #include "extensions/browser/app_window/app_window_client.h" |
10 #include "extensions/browser/app_window/app_window_registry.h" | 12 #include "extensions/browser/app_window/app_window_registry.h" |
11 #include "extensions/browser/app_window/native_app_window.h" | |
12 #include "extensions/browser/app_window/size_constraints.h" | |
13 #include "extensions/common/api/app_current_window_internal.h" | 13 #include "extensions/common/api/app_current_window_internal.h" |
14 #include "extensions/common/features/simple_feature.h" | 14 #include "extensions/common/features/simple_feature.h" |
15 #include "extensions/common/permissions/permissions_data.h" | 15 #include "extensions/common/permissions/permissions_data.h" |
16 #include "extensions/common/switches.h" | 16 #include "extensions/common/switches.h" |
17 #include "third_party/skia/include/core/SkRegion.h" | 17 #include "third_party/skia/include/core/SkRegion.h" |
18 | 18 |
19 namespace app_current_window_internal = | 19 namespace app_current_window_internal = |
20 extensions::core_api::app_current_window_internal; | 20 extensions::core_api::app_current_window_internal; |
21 | 21 |
22 namespace Show = app_current_window_internal::Show; | 22 namespace Show = app_current_window_internal::Show; |
23 namespace SetBounds = app_current_window_internal::SetBounds; | 23 namespace SetBounds = app_current_window_internal::SetBounds; |
24 namespace SetSizeConstraints = app_current_window_internal::SetSizeConstraints; | 24 namespace SetSizeConstraints = app_current_window_internal::SetSizeConstraints; |
25 namespace SetIcon = app_current_window_internal::SetIcon; | 25 namespace SetIcon = app_current_window_internal::SetIcon; |
26 namespace SetBadgeIcon = app_current_window_internal::SetBadgeIcon; | 26 namespace SetBadgeIcon = app_current_window_internal::SetBadgeIcon; |
27 namespace SetShape = app_current_window_internal::SetShape; | 27 namespace SetShape = app_current_window_internal::SetShape; |
28 namespace SetAlwaysOnTop = app_current_window_internal::SetAlwaysOnTop; | 28 namespace SetAlwaysOnTop = app_current_window_internal::SetAlwaysOnTop; |
29 namespace SetVisibleOnAllWorkspaces = | 29 namespace SetVisibleOnAllWorkspaces = |
30 app_current_window_internal::SetVisibleOnAllWorkspaces; | 30 app_current_window_internal::SetVisibleOnAllWorkspaces; |
31 | 31 |
32 using app_current_window_internal::Bounds; | 32 using app_current_window_internal::Bounds; |
33 using app_current_window_internal::Region; | 33 using app_current_window_internal::Region; |
34 using app_current_window_internal::RegionRect; | 34 using app_current_window_internal::RegionRect; |
35 using app_current_window_internal::SizeConstraints; | |
36 | 35 |
37 namespace extensions { | 36 namespace extensions { |
38 | 37 |
39 namespace { | 38 namespace { |
40 | 39 |
41 const char kNoAssociatedAppWindow[] = | 40 const char kNoAssociatedAppWindow[] = |
42 "The context from which the function was called did not have an " | 41 "The context from which the function was called did not have an " |
43 "associated app window."; | 42 "associated app window."; |
44 | 43 |
45 const char kDevChannelOnly[] = | 44 const char kDevChannelOnly[] = |
46 "This function is currently only available in the Dev channel."; | 45 "This function is currently only available in the Dev channel."; |
47 | 46 |
48 const char kRequiresFramelessWindow[] = | 47 const char kRequiresFramelessWindow[] = |
49 "This function requires a frameless window (frame:none)."; | 48 "This function requires a frameless window (frame:none)."; |
50 | 49 |
51 const char kAlwaysOnTopPermission[] = | 50 const char kAlwaysOnTopPermission[] = |
52 "The \"app.window.alwaysOnTop\" permission is required."; | 51 "The \"app.window.alwaysOnTop\" permission is required."; |
53 | 52 |
54 const char kInvalidParameters[] = "Invalid parameters."; | 53 const char kInvalidParameters[] = "Invalid parameters."; |
55 | 54 |
56 const int kUnboundedSize = SizeConstraints::kUnboundedSize; | 55 const int kUnboundedSize = native_app_window::SizeConstraints::kUnboundedSize; |
57 | 56 |
58 void GetBoundsFields(const Bounds& bounds_spec, gfx::Rect* bounds) { | 57 void GetBoundsFields(const Bounds& bounds_spec, gfx::Rect* bounds) { |
59 if (bounds_spec.left) | 58 if (bounds_spec.left) |
60 bounds->set_x(*bounds_spec.left); | 59 bounds->set_x(*bounds_spec.left); |
61 if (bounds_spec.top) | 60 if (bounds_spec.top) |
62 bounds->set_y(*bounds_spec.top); | 61 bounds->set_y(*bounds_spec.top); |
63 if (bounds_spec.width) | 62 if (bounds_spec.width) |
64 bounds->set_width(*bounds_spec.width); | 63 bounds->set_width(*bounds_spec.width); |
65 if (bounds_spec.height) | 64 if (bounds_spec.height) |
66 bounds->set_height(*bounds_spec.height); | 65 bounds->set_height(*bounds_spec.height); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 GetBoundsFields(bounds_spec, &window_bounds); | 230 GetBoundsFields(bounds_spec, &window_bounds); |
232 window_bounds.Inset(-frame_insets); | 231 window_bounds.Inset(-frame_insets); |
233 break; | 232 break; |
234 } | 233 } |
235 default: | 234 default: |
236 NOTREACHED(); | 235 NOTREACHED(); |
237 } | 236 } |
238 | 237 |
239 if (original_window_bounds != window_bounds) { | 238 if (original_window_bounds != window_bounds) { |
240 if (original_window_bounds.size() != window_bounds.size()) { | 239 if (original_window_bounds.size() != window_bounds.size()) { |
241 SizeConstraints constraints( | 240 native_app_window::SizeConstraints constraints( |
242 SizeConstraints::AddFrameToConstraints( | 241 native_app_window::SizeConstraints::AddFrameToConstraints( |
243 window->GetBaseWindow()->GetContentMinimumSize(), frame_insets), | 242 window->GetBaseWindow()->GetContentMinimumSize(), frame_insets), |
244 SizeConstraints::AddFrameToConstraints( | 243 native_app_window::SizeConstraints::AddFrameToConstraints( |
245 window->GetBaseWindow()->GetContentMaximumSize(), frame_insets)); | 244 window->GetBaseWindow()->GetContentMaximumSize(), frame_insets)); |
246 | 245 |
247 window_bounds.set_size(constraints.ClampSize(window_bounds.size())); | 246 window_bounds.set_size(constraints.ClampSize(window_bounds.size())); |
248 } | 247 } |
249 | 248 |
250 window->GetBaseWindow()->SetBounds(window_bounds); | 249 window->GetBaseWindow()->SetBounds(window_bounds); |
251 } | 250 } |
252 | 251 |
253 return true; | 252 return true; |
254 } | 253 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 405 } |
407 | 406 |
408 scoped_ptr<SetVisibleOnAllWorkspaces::Params> params( | 407 scoped_ptr<SetVisibleOnAllWorkspaces::Params> params( |
409 SetVisibleOnAllWorkspaces::Params::Create(*args_)); | 408 SetVisibleOnAllWorkspaces::Params::Create(*args_)); |
410 CHECK(params.get()); | 409 CHECK(params.get()); |
411 window->GetBaseWindow()->SetVisibleOnAllWorkspaces(params->always_visible); | 410 window->GetBaseWindow()->SetVisibleOnAllWorkspaces(params->always_visible); |
412 return true; | 411 return true; |
413 } | 412 } |
414 | 413 |
415 } // namespace extensions | 414 } // namespace extensions |
OLD | NEW |