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" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/common/browser_side_navigation_policy.h" | 22 #include "content/public/common/browser_side_navigation_policy.h" |
23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
24 #include "extensions/browser/app_window/app_window.h" | 24 #include "extensions/browser/app_window/app_window.h" |
25 #include "extensions/browser/app_window/app_window_client.h" | 25 #include "extensions/browser/app_window/app_window_client.h" |
26 #include "extensions/browser/app_window/app_window_contents.h" | 26 #include "extensions/browser/app_window/app_window_contents.h" |
27 #include "extensions/browser/app_window/app_window_registry.h" | 27 #include "extensions/browser/app_window/app_window_registry.h" |
28 #include "extensions/browser/app_window/native_app_window.h" | 28 #include "extensions/browser/app_window/native_app_window.h" |
29 #include "extensions/browser/extensions_browser_client.h" | 29 #include "extensions/browser/extensions_browser_client.h" |
| 30 #include "extensions/common/api/app_runtime.h" |
30 #include "extensions/common/api/app_window.h" | 31 #include "extensions/common/api/app_window.h" |
31 #include "extensions/common/features/simple_feature.h" | 32 #include "extensions/common/features/simple_feature.h" |
32 #include "extensions/common/image_util.h" | 33 #include "extensions/common/image_util.h" |
33 #include "extensions/common/manifest.h" | 34 #include "extensions/common/manifest.h" |
34 #include "extensions/common/permissions/permissions_data.h" | 35 #include "extensions/common/permissions/permissions_data.h" |
35 #include "extensions/common/switches.h" | 36 #include "extensions/common/switches.h" |
36 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
37 #include "ui/base/ui_base_types.h" | 38 #include "ui/base/ui_base_types.h" |
38 #include "ui/gfx/geometry/rect.h" | 39 #include "ui/gfx/geometry/rect.h" |
39 #include "url/gurl.h" | 40 #include "url/gurl.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 case app_window::STATE_MAXIMIZED: | 350 case app_window::STATE_MAXIMIZED: |
350 create_params.state = ui::SHOW_STATE_MAXIMIZED; | 351 create_params.state = ui::SHOW_STATE_MAXIMIZED; |
351 break; | 352 break; |
352 case app_window::STATE_MINIMIZED: | 353 case app_window::STATE_MINIMIZED: |
353 create_params.state = ui::SHOW_STATE_MINIMIZED; | 354 create_params.state = ui::SHOW_STATE_MINIMIZED; |
354 break; | 355 break; |
355 } | 356 } |
356 } | 357 } |
357 } | 358 } |
358 | 359 |
| 360 api::app_runtime::ActionType action_type = api::app_runtime::ACTION_TYPE_NONE; |
| 361 if (options && |
| 362 options->lock_screen_action != api::app_runtime::ACTION_TYPE_NONE) { |
| 363 if (source_context_type() != Feature::LOCK_SCREEN_EXTENSION_CONTEXT) { |
| 364 return RespondNow(Error( |
| 365 "The lockScreenAction option requires lock screen app context.")); |
| 366 } |
| 367 |
| 368 if (!extension()->permissions_data()->HasAPIPermission( |
| 369 APIPermission::kLockScreen)) { |
| 370 return RespondNow( |
| 371 Error("The lockScreenAction option requires lockScreen permission.")); |
| 372 } |
| 373 |
| 374 action_type = options->lock_screen_action; |
| 375 create_params.show_on_lock_screen = true; |
| 376 } |
| 377 |
359 create_params.creator_process_id = | 378 create_params.creator_process_id = |
360 render_frame_host()->GetProcess()->GetID(); | 379 render_frame_host()->GetProcess()->GetID(); |
361 | 380 |
362 AppWindow* app_window = | 381 AppWindow* app_window = nullptr; |
363 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension()); | 382 if (action_type == api::app_runtime::ACTION_TYPE_NONE) { |
| 383 app_window = |
| 384 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension()); |
| 385 } else { |
| 386 app_window = AppWindowClient::Get()->CreateAppWindowForLockScreenAction( |
| 387 browser_context(), extension(), action_type); |
| 388 } |
| 389 |
| 390 // App window client might refuse to create an app window, e.g. when the app |
| 391 // attempts to create a lock screen action handler window when the action was |
| 392 // not requested. |
| 393 if (!app_window) |
| 394 return RespondNow(Error("Failed to create the app window.")); |
| 395 |
364 app_window->Init(url, new AppWindowContentsImpl(app_window), | 396 app_window->Init(url, new AppWindowContentsImpl(app_window), |
365 render_frame_host(), create_params); | 397 render_frame_host(), create_params); |
366 | 398 |
367 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() && | 399 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() && |
368 !app_window->is_ime_window()) { | 400 !app_window->is_ime_window()) { |
369 app_window->ForcedFullscreen(); | 401 app_window->ForcedFullscreen(); |
370 } | 402 } |
371 | 403 |
372 content::RenderFrameHost* created_frame = | 404 content::RenderFrameHost* created_frame = |
373 app_window->web_contents()->GetMainFrame(); | 405 app_window->web_contents()->GetMainFrame(); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 602 |
571 if (options.frame->as_frame_options->inactive_color.get()) { | 603 if (options.frame->as_frame_options->inactive_color.get()) { |
572 *error = app_window_constants::kInactiveColorWithoutColor; | 604 *error = app_window_constants::kInactiveColorWithoutColor; |
573 return false; | 605 return false; |
574 } | 606 } |
575 | 607 |
576 return true; | 608 return true; |
577 } | 609 } |
578 | 610 |
579 } // namespace extensions | 611 } // namespace extensions |
OLD | NEW |