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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/apps/chrome_app_window_client.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/apps/scoped_keep_alive.h"
9 #include "chrome/browser/devtools/devtools_window.h"
10 #include "chrome/common/extensions/features/feature_channel.h"
11 #include "components/version_info/version_info.h"
12 #include "content/public/browser/devtools_agent_host.h"
13 #include "extensions/browser/app_window/app_window.h"
14 #include "extensions/common/extension.h"
16 // TODO(jamescook): We probably shouldn't compile this class at all on Android.
17 // See http://crbug.com/343612
18 #if !defined(OS_ANDROID)
19 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
22 ChromeAppWindowClient::ChromeAppWindowClient() {
25 ChromeAppWindowClient::~ChromeAppWindowClient() {
29 ChromeAppWindowClient
* ChromeAppWindowClient::GetInstance() {
30 return Singleton
<ChromeAppWindowClient
,
31 LeakySingletonTraits
<ChromeAppWindowClient
> >::get();
34 extensions::AppWindow
* ChromeAppWindowClient::CreateAppWindow(
35 content::BrowserContext
* context
,
36 const extensions::Extension
* extension
) {
37 #if defined(OS_ANDROID)
40 return new extensions::AppWindow(
42 new ChromeAppDelegate(make_scoped_ptr(new ScopedKeepAlive
)),
47 extensions::NativeAppWindow
* ChromeAppWindowClient::CreateNativeAppWindow(
48 extensions::AppWindow
* window
,
49 extensions::AppWindow::CreateParams
* params
) {
50 #if defined(OS_ANDROID)
53 return CreateNativeAppWindowImpl(window
, *params
);
57 void ChromeAppWindowClient::OpenDevToolsWindow(
58 content::WebContents
* web_contents
,
59 const base::Closure
& callback
) {
60 scoped_refptr
<content::DevToolsAgentHost
> agent(
61 content::DevToolsAgentHost::GetOrCreateFor(web_contents
));
62 DevToolsWindow::OpenDevToolsWindow(web_contents
);
64 DevToolsWindow
* devtools_window
=
65 DevToolsWindow::FindDevToolsWindow(agent
.get());
67 devtools_window
->SetLoadCompletedCallback(callback
);
72 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() {
73 return extensions::GetCurrentChannel() > version_info::Channel::DEV
;