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 base::Singleton
<
31 ChromeAppWindowClient
,
32 base::LeakySingletonTraits
<ChromeAppWindowClient
>>::get();
35 extensions::AppWindow
* ChromeAppWindowClient::CreateAppWindow(
36 content::BrowserContext
* context
,
37 const extensions::Extension
* extension
) {
38 #if defined(OS_ANDROID)
41 return new extensions::AppWindow(
43 new ChromeAppDelegate(make_scoped_ptr(new ScopedKeepAlive
)),
48 extensions::NativeAppWindow
* ChromeAppWindowClient::CreateNativeAppWindow(
49 extensions::AppWindow
* window
,
50 extensions::AppWindow::CreateParams
* params
) {
51 #if defined(OS_ANDROID)
54 return CreateNativeAppWindowImpl(window
, *params
);
58 void ChromeAppWindowClient::OpenDevToolsWindow(
59 content::WebContents
* web_contents
,
60 const base::Closure
& callback
) {
61 scoped_refptr
<content::DevToolsAgentHost
> agent(
62 content::DevToolsAgentHost::GetOrCreateFor(web_contents
));
63 DevToolsWindow::OpenDevToolsWindow(web_contents
);
65 DevToolsWindow
* devtools_window
=
66 DevToolsWindow::FindDevToolsWindow(agent
.get());
68 devtools_window
->SetLoadCompletedCallback(callback
);
73 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() {
74 return extensions::GetCurrentChannel() > version_info::Channel::DEV
;