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

Side by Side Diff: chrome/browser/ui/apps/chrome_app_window_client.cc

Issue 2934513003: Changes in app.window and app.runtime to support lock screen note taking (Closed)
Patch Set: split out browsertests 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/apps/chrome_app_window_client.h" 5 #include "chrome/browser/ui/apps/chrome_app_window_client.h"
6 6
7 #include <memory>
8
9 #include "base/memory/ptr_util.h"
7 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
8 #include "build/build_config.h" 11 #include "build/build_config.h"
9 #include "chrome/browser/devtools/devtools_window.h" 12 #include "chrome/browser/devtools/devtools_window.h"
10 #include "components/version_info/version_info.h" 13 #include "components/version_info/version_info.h"
11 #include "content/public/browser/devtools_agent_host.h" 14 #include "content/public/browser/devtools_agent_host.h"
12 #include "extensions/browser/app_window/app_window.h" 15 #include "extensions/browser/app_window/app_window.h"
13 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
14 #include "extensions/common/features/feature_channel.h" 17 #include "extensions/common/features/feature_channel.h"
15 18
19 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/chromeos/lock_screen_apps/state_controller.h"
21 #endif
22
16 // TODO(jamescook): We probably shouldn't compile this class at all on Android. 23 // TODO(jamescook): We probably shouldn't compile this class at all on Android.
17 // See http://crbug.com/343612 24 // See http://crbug.com/343612
18 #if !defined(OS_ANDROID) 25 #if !defined(OS_ANDROID)
19 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 26 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
20 #endif 27 #endif
21 28
22 ChromeAppWindowClient::ChromeAppWindowClient() { 29 ChromeAppWindowClient::ChromeAppWindowClient() {
23 } 30 }
24 31
25 ChromeAppWindowClient::~ChromeAppWindowClient() { 32 ChromeAppWindowClient::~ChromeAppWindowClient() {
(...skipping 10 matching lines...) Expand all
36 content::BrowserContext* context, 43 content::BrowserContext* context,
37 const extensions::Extension* extension) { 44 const extensions::Extension* extension) {
38 #if defined(OS_ANDROID) 45 #if defined(OS_ANDROID)
39 return NULL; 46 return NULL;
40 #else 47 #else
41 return new extensions::AppWindow(context, new ChromeAppDelegate(true), 48 return new extensions::AppWindow(context, new ChromeAppDelegate(true),
42 extension); 49 extension);
43 #endif 50 #endif
44 } 51 }
45 52
53 extensions::AppWindow*
54 ChromeAppWindowClient::CreateAppWindowForLockScreenAction(
55 content::BrowserContext* context,
56 const extensions::Extension* extension,
57 extensions::api::app_runtime::ActionType action) {
58 #if defined(OS_CHROMEOS)
59 if (!lock_screen_apps::StateController::IsEnabled())
60 return nullptr;
61
62 if (!lock_screen_apps::StateController::Get()->CanCreateAppWindowForAction(
63 context, extension, action)) {
64 return nullptr;
65 }
66
67 extensions::AppWindow* window = CreateAppWindow(context, extension);
68
69 if (!lock_screen_apps::StateController::Get()->RegisterAppWindowForAction(
70 window, action)) {
71 NOTREACHED() << "Failed to register app window for lock screen action";
72 return nullptr;
73 }
74
75 return window;
76 #else
77 return nullptr;
78 #endif
79 }
80
46 extensions::NativeAppWindow* ChromeAppWindowClient::CreateNativeAppWindow( 81 extensions::NativeAppWindow* ChromeAppWindowClient::CreateNativeAppWindow(
47 extensions::AppWindow* window, 82 extensions::AppWindow* window,
48 extensions::AppWindow::CreateParams* params) { 83 extensions::AppWindow::CreateParams* params) {
49 #if defined(OS_ANDROID) 84 #if defined(OS_ANDROID)
50 return NULL; 85 return nullptr;
51 #else 86 #else
52 return CreateNativeAppWindowImpl(window, *params); 87 return CreateNativeAppWindowImpl(window, *params);
53 #endif 88 #endif
54 } 89 }
55 90
56 void ChromeAppWindowClient::OpenDevToolsWindow( 91 void ChromeAppWindowClient::OpenDevToolsWindow(
57 content::WebContents* web_contents, 92 content::WebContents* web_contents,
58 const base::Closure& callback) { 93 const base::Closure& callback) {
59 scoped_refptr<content::DevToolsAgentHost> agent( 94 scoped_refptr<content::DevToolsAgentHost> agent(
60 content::DevToolsAgentHost::GetOrCreateFor(web_contents)); 95 content::DevToolsAgentHost::GetOrCreateFor(web_contents));
61 DevToolsWindow::OpenDevToolsWindow(web_contents); 96 DevToolsWindow::OpenDevToolsWindow(web_contents);
62 97
63 DevToolsWindow* devtools_window = 98 DevToolsWindow* devtools_window =
64 DevToolsWindow::FindDevToolsWindow(agent.get()); 99 DevToolsWindow::FindDevToolsWindow(agent.get());
65 if (devtools_window) 100 if (devtools_window)
66 devtools_window->SetLoadCompletedCallback(callback); 101 devtools_window->SetLoadCompletedCallback(callback);
67 else 102 else
68 callback.Run(); 103 callback.Run();
69 } 104 }
70 105
71 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() { 106 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() {
72 return extensions::GetCurrentChannel() > version_info::Channel::DEV; 107 return extensions::GetCurrentChannel() > version_info::Channel::DEV;
73 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698