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_window/app_window_api.h" | 5 #include "extensions/browser/api/app_window/app_window_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 create_params.window_key); | 180 create_params.window_key); |
181 if (existing_window) { | 181 if (existing_window) { |
182 content::RenderFrameHost* existing_frame = | 182 content::RenderFrameHost* existing_frame = |
183 existing_window->web_contents()->GetMainFrame(); | 183 existing_window->web_contents()->GetMainFrame(); |
184 int frame_id = MSG_ROUTING_NONE; | 184 int frame_id = MSG_ROUTING_NONE; |
185 if (render_frame_host()->GetProcess()->GetID() == | 185 if (render_frame_host()->GetProcess()->GetID() == |
186 existing_frame->GetProcess()->GetID()) { | 186 existing_frame->GetProcess()->GetID()) { |
187 frame_id = existing_frame->GetRoutingID(); | 187 frame_id = existing_frame->GetRoutingID(); |
188 } | 188 } |
189 | 189 |
190 if (!options->hidden.get() || !*options->hidden.get()) { | 190 if (!options->hidden.get() || !*options->hidden) { |
191 if (options->focused.get() && !*options->focused.get()) | 191 if (options->focused.get() && !*options->focused) |
192 existing_window->Show(AppWindow::SHOW_INACTIVE); | 192 existing_window->Show(AppWindow::SHOW_INACTIVE); |
193 else | 193 else |
194 existing_window->Show(AppWindow::SHOW_ACTIVE); | 194 existing_window->Show(AppWindow::SHOW_ACTIVE); |
195 } | 195 } |
196 | 196 |
197 std::unique_ptr<base::DictionaryValue> result( | 197 std::unique_ptr<base::DictionaryValue> result( |
198 new base::DictionaryValue); | 198 new base::DictionaryValue); |
199 result->Set("frameId", new base::FundamentalValue(frame_id)); | 199 result->Set("frameId", new base::FundamentalValue(frame_id)); |
200 existing_window->GetSerializedState(result.get()); | 200 existing_window->GetSerializedState(result.get()); |
201 result->SetBoolean("existingWindow", true); | 201 result->SetBoolean("existingWindow", true); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 290 } |
291 #if defined(USE_AURA) | 291 #if defined(USE_AURA) |
292 create_params.alpha_enabled = *options->alpha_enabled; | 292 create_params.alpha_enabled = *options->alpha_enabled; |
293 #else | 293 #else |
294 // Transparency is only supported on Aura. | 294 // Transparency is only supported on Aura. |
295 // Fallback to creating an opaque window (by ignoring alphaEnabled). | 295 // Fallback to creating an opaque window (by ignoring alphaEnabled). |
296 #endif | 296 #endif |
297 } | 297 } |
298 | 298 |
299 if (options->hidden.get()) | 299 if (options->hidden.get()) |
300 create_params.hidden = *options->hidden.get(); | 300 create_params.hidden = *options->hidden; |
301 | 301 |
302 if (options->resizable.get()) | 302 if (options->resizable.get()) |
303 create_params.resizable = *options->resizable.get(); | 303 create_params.resizable = *options->resizable; |
304 | 304 |
305 if (options->always_on_top.get()) { | 305 if (options->always_on_top.get()) { |
306 create_params.always_on_top = *options->always_on_top.get(); | 306 create_params.always_on_top = *options->always_on_top; |
307 | 307 |
308 if (create_params.always_on_top && | 308 if (create_params.always_on_top && |
309 !extension()->permissions_data()->HasAPIPermission( | 309 !extension()->permissions_data()->HasAPIPermission( |
310 APIPermission::kAlwaysOnTopWindows)) { | 310 APIPermission::kAlwaysOnTopWindows)) { |
311 error_ = app_window_constants::kAlwaysOnTopPermission; | 311 error_ = app_window_constants::kAlwaysOnTopPermission; |
312 return false; | 312 return false; |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 if (options->focused.get()) | 316 if (options->focused.get()) |
317 create_params.focused = *options->focused.get(); | 317 create_params.focused = *options->focused; |
318 | 318 |
319 if (options->visible_on_all_workspaces.get()) { | 319 if (options->visible_on_all_workspaces.get()) { |
320 create_params.visible_on_all_workspaces = | 320 create_params.visible_on_all_workspaces = |
321 *options->visible_on_all_workspaces.get(); | 321 *options->visible_on_all_workspaces; |
322 } | 322 } |
323 | 323 |
324 if (options->type != app_window::WINDOW_TYPE_PANEL) { | 324 if (options->type != app_window::WINDOW_TYPE_PANEL) { |
325 switch (options->state) { | 325 switch (options->state) { |
326 case app_window::STATE_NONE: | 326 case app_window::STATE_NONE: |
327 case app_window::STATE_NORMAL: | 327 case app_window::STATE_NORMAL: |
328 break; | 328 break; |
329 case app_window::STATE_FULLSCREEN: | 329 case app_window::STATE_FULLSCREEN: |
330 create_params.state = ui::SHOW_STATE_FULLSCREEN; | 330 create_params.state = ui::SHOW_STATE_FULLSCREEN; |
331 break; | 331 break; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 448 |
449 CopyBoundsSpec(inner_bounds, &(params->content_spec)); | 449 CopyBoundsSpec(inner_bounds, &(params->content_spec)); |
450 CopyBoundsSpec(outer_bounds, &(params->window_spec)); | 450 CopyBoundsSpec(outer_bounds, &(params->window_spec)); |
451 } else { | 451 } else { |
452 // Parse deprecated fields. | 452 // Parse deprecated fields. |
453 // Due to a bug in NativeAppWindow::GetFrameInsets() on Windows and ChromeOS | 453 // Due to a bug in NativeAppWindow::GetFrameInsets() on Windows and ChromeOS |
454 // the bounds set the position of the window and the size of the content. | 454 // the bounds set the position of the window and the size of the content. |
455 // This will be preserved as apps may be relying on this behavior. | 455 // This will be preserved as apps may be relying on this behavior. |
456 | 456 |
457 if (options.default_width.get()) | 457 if (options.default_width.get()) |
458 params->content_spec.bounds.set_width(*options.default_width.get()); | 458 params->content_spec.bounds.set_width(*options.default_width); |
459 if (options.default_height.get()) | 459 if (options.default_height.get()) |
460 params->content_spec.bounds.set_height(*options.default_height.get()); | 460 params->content_spec.bounds.set_height(*options.default_height); |
461 if (options.default_left.get()) | 461 if (options.default_left.get()) |
462 params->window_spec.bounds.set_x(*options.default_left.get()); | 462 params->window_spec.bounds.set_x(*options.default_left); |
463 if (options.default_top.get()) | 463 if (options.default_top.get()) |
464 params->window_spec.bounds.set_y(*options.default_top.get()); | 464 params->window_spec.bounds.set_y(*options.default_top); |
465 | 465 |
466 if (options.width.get()) | 466 if (options.width.get()) |
467 params->content_spec.bounds.set_width(*options.width.get()); | 467 params->content_spec.bounds.set_width(*options.width); |
468 if (options.height.get()) | 468 if (options.height.get()) |
469 params->content_spec.bounds.set_height(*options.height.get()); | 469 params->content_spec.bounds.set_height(*options.height); |
470 if (options.left.get()) | 470 if (options.left.get()) |
471 params->window_spec.bounds.set_x(*options.left.get()); | 471 params->window_spec.bounds.set_x(*options.left); |
472 if (options.top.get()) | 472 if (options.top.get()) |
473 params->window_spec.bounds.set_y(*options.top.get()); | 473 params->window_spec.bounds.set_y(*options.top); |
474 | 474 |
475 if (options.bounds.get()) { | 475 if (options.bounds.get()) { |
476 app_window::ContentBounds* bounds = options.bounds.get(); | 476 app_window::ContentBounds* bounds = options.bounds.get(); |
477 if (bounds->width.get()) | 477 if (bounds->width.get()) |
478 params->content_spec.bounds.set_width(*bounds->width.get()); | 478 params->content_spec.bounds.set_width(*bounds->width); |
479 if (bounds->height.get()) | 479 if (bounds->height.get()) |
480 params->content_spec.bounds.set_height(*bounds->height.get()); | 480 params->content_spec.bounds.set_height(*bounds->height); |
481 if (bounds->left.get()) | 481 if (bounds->left.get()) |
482 params->window_spec.bounds.set_x(*bounds->left.get()); | 482 params->window_spec.bounds.set_x(*bounds->left); |
483 if (bounds->top.get()) | 483 if (bounds->top.get()) |
484 params->window_spec.bounds.set_y(*bounds->top.get()); | 484 params->window_spec.bounds.set_y(*bounds->top); |
485 } | 485 } |
486 | 486 |
487 gfx::Size& minimum_size = params->content_spec.minimum_size; | 487 gfx::Size& minimum_size = params->content_spec.minimum_size; |
488 if (options.min_width.get()) | 488 if (options.min_width.get()) |
489 minimum_size.set_width(*options.min_width); | 489 minimum_size.set_width(*options.min_width); |
490 if (options.min_height.get()) | 490 if (options.min_height.get()) |
491 minimum_size.set_height(*options.min_height); | 491 minimum_size.set_height(*options.min_height); |
492 gfx::Size& maximum_size = params->content_spec.maximum_size; | 492 gfx::Size& maximum_size = params->content_spec.maximum_size; |
493 if (options.max_width.get()) | 493 if (options.max_width.get()) |
494 maximum_size.set_width(*options.max_width); | 494 maximum_size.set_width(*options.max_width); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 553 |
554 if (options.frame->as_frame_options->inactive_color.get()) { | 554 if (options.frame->as_frame_options->inactive_color.get()) { |
555 error_ = app_window_constants::kInactiveColorWithoutColor; | 555 error_ = app_window_constants::kInactiveColorWithoutColor; |
556 return false; | 556 return false; |
557 } | 557 } |
558 | 558 |
559 return true; | 559 return true; |
560 } | 560 } |
561 | 561 |
562 } // namespace extensions | 562 } // namespace extensions |
OLD | NEW |