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 = |
363 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension()); | 382 action_type != api::app_runtime::ACTION_TYPE_NONE |
benwells
2017/06/13 10:30:46
This ternary is a bit out of control. I think it w
tbarzic
2017/06/13 19:17:59
Done.
| |
383 ? AppWindowClient::Get()->CreateAppWindowForLockScreenAction( | |
384 browser_context(), extension(), action_type) | |
385 : AppWindowClient::Get()->CreateAppWindow(browser_context(), | |
386 extension()); | |
387 | |
388 if (!app_window) | |
389 return RespondNow(Error("Failed to create the app window.")); | |
390 | |
364 app_window->Init(url, new AppWindowContentsImpl(app_window), | 391 app_window->Init(url, new AppWindowContentsImpl(app_window), |
365 render_frame_host(), create_params); | 392 render_frame_host(), create_params); |
366 | 393 |
367 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() && | 394 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() && |
368 !app_window->is_ime_window()) { | 395 !app_window->is_ime_window()) { |
369 app_window->ForcedFullscreen(); | 396 app_window->ForcedFullscreen(); |
370 } | 397 } |
371 | 398 |
372 content::RenderFrameHost* created_frame = | 399 content::RenderFrameHost* created_frame = |
373 app_window->web_contents()->GetMainFrame(); | 400 app_window->web_contents()->GetMainFrame(); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 | 597 |
571 if (options.frame->as_frame_options->inactive_color.get()) { | 598 if (options.frame->as_frame_options->inactive_color.get()) { |
572 *error = app_window_constants::kInactiveColorWithoutColor; | 599 *error = app_window_constants::kInactiveColorWithoutColor; |
573 return false; | 600 return false; |
574 } | 601 } |
575 | 602 |
576 return true; | 603 return true; |
577 } | 604 } |
578 | 605 |
579 } // namespace extensions | 606 } // namespace extensions |
OLD | NEW |