Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: extensions/browser/api/app_window/app_window_api.cc

Issue 2934513003: Changes in app.window and app.runtime to support lock screen note taking (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
70 #if !defined(OS_CHROMEOS) 71 #if !defined(OS_CHROMEOS)
71 const char kImeWindowUnsupportedPlatform[] = 72 const char kImeWindowUnsupportedPlatform[] =
72 "The \"ime\" option can only be used on ChromeOS."; 73 "The \"ime\" option can only be used on ChromeOS.";
73 #else 74 #else
74 const char kImeWindowMustBeImeWindowOrPanel[] = 75 const char kImeWindowMustBeImeWindowOrPanel[] =
75 "IME extensions must create ime window ( with \"ime: true\" and " 76 "IME extensions must create ime window ( with \"ime: true\" and "
76 "\"frame: 'none'\") or panel window (with \"type: panel\")."; 77 "\"frame: 'none'\") or panel window (with \"type: panel\").";
77 #endif 78 #endif
78 const char kShowInShelfWindowKeyNotSet[] = 79 const char kShowInShelfWindowKeyNotSet[] =
79 "The \"showInShelf\" option requires the \"id\" option to be set."; 80 "The \"showInShelf\" option requires the \"id\" option to be set.";
81 const char kLockScreenActionRequiresLockScreenContext[] =
82 "The lockScreenAction option requires lock screen app context.";
83 const char kLockScreenActionRequiresLockScreenPermission[] =
84 "The lockScreenAction option requires lockScreen permission.";
85 const char kAppWindowCreationFailed[] = "Failed to create the app window.";
80 } // namespace app_window_constants 86 } // namespace app_window_constants
81 87
82 const char kNoneFrameOption[] = "none"; 88 const char kNoneFrameOption[] = "none";
83 89
84 namespace { 90 namespace {
85 91
86 // If the same property is specified for the inner and outer bounds, raise an 92 // If the same property is specified for the inner and outer bounds, raise an
87 // error. 93 // error.
88 bool CheckBoundsConflict(const std::unique_ptr<int>& inner_property, 94 bool CheckBoundsConflict(const std::unique_ptr<int>& inner_property,
89 const std::unique_ptr<int>& outer_property, 95 const std::unique_ptr<int>& outer_property,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 case app_window::STATE_MAXIMIZED: 355 case app_window::STATE_MAXIMIZED:
350 create_params.state = ui::SHOW_STATE_MAXIMIZED; 356 create_params.state = ui::SHOW_STATE_MAXIMIZED;
351 break; 357 break;
352 case app_window::STATE_MINIMIZED: 358 case app_window::STATE_MINIMIZED:
353 create_params.state = ui::SHOW_STATE_MINIMIZED; 359 create_params.state = ui::SHOW_STATE_MINIMIZED;
354 break; 360 break;
355 } 361 }
356 } 362 }
357 } 363 }
358 364
365 api::app_runtime::ActionType action_type = api::app_runtime::ACTION_TYPE_NONE;
366 if (options &&
367 options->lock_screen_action != api::app_runtime::ACTION_TYPE_NONE) {
368 if (source_context_type() != Feature::LOCK_SCREEN_EXTENSION_CONTEXT) {
369 return RespondNow(Error(
370 app_window_constants::kLockScreenActionRequiresLockScreenContext));
371 }
372
373 if (!extension()->permissions_data()->HasAPIPermission(
374 APIPermission::kLockScreen)) {
375 return RespondNow(Error(
376 app_window_constants::kLockScreenActionRequiresLockScreenPermission));
377 }
378
379 action_type = options->lock_screen_action;
380 create_params.show_on_lock_screen = true;
381 }
382
359 create_params.creator_process_id = 383 create_params.creator_process_id =
360 render_frame_host()->GetProcess()->GetID(); 384 render_frame_host()->GetProcess()->GetID();
361 385
362 AppWindow* app_window = 386 AppWindow* app_window = nullptr;
363 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension()); 387 if (action_type == api::app_runtime::ACTION_TYPE_NONE) {
388 app_window =
389 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension());
390 } else {
391 app_window = AppWindowClient::Get()->CreateAppWindowForLockScreenAction(
392 browser_context(), extension(), action_type);
393 }
394
395 // App window client might refuse to create an app window, e.g. when the app
396 // attempts to create a lock screen action handler window when the action was
397 // not requested.
398 if (!app_window)
399 return RespondNow(Error(app_window_constants::kAppWindowCreationFailed));
400
364 app_window->Init(url, new AppWindowContentsImpl(app_window), 401 app_window->Init(url, new AppWindowContentsImpl(app_window),
365 render_frame_host(), create_params); 402 render_frame_host(), create_params);
366 403
367 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() && 404 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() &&
368 !app_window->is_ime_window()) { 405 !app_window->is_ime_window()) {
369 app_window->ForcedFullscreen(); 406 app_window->ForcedFullscreen();
370 } 407 }
371 408
372 content::RenderFrameHost* created_frame = 409 content::RenderFrameHost* created_frame =
373 app_window->web_contents()->GetMainFrame(); 410 app_window->web_contents()->GetMainFrame();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 607
571 if (options.frame->as_frame_options->inactive_color.get()) { 608 if (options.frame->as_frame_options->inactive_color.get()) {
572 *error = app_window_constants::kInactiveColorWithoutColor; 609 *error = app_window_constants::kInactiveColorWithoutColor;
573 return false; 610 return false;
574 } 611 }
575 612
576 return true; 613 return true;
577 } 614 }
578 615
579 } // namespace extensions 616 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc ('k') | extensions/browser/app_window/app_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698