Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / apps / chrome_app_window_client.cc
blob9cf6b046cd21ac02a7846ab5de80b92908c6b0ae
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"
20 #endif
22 ChromeAppWindowClient::ChromeAppWindowClient() {
25 ChromeAppWindowClient::~ChromeAppWindowClient() {
28 // static
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)
39 return NULL;
40 #else
41 return new extensions::AppWindow(
42 context,
43 new ChromeAppDelegate(make_scoped_ptr(new ScopedKeepAlive)),
44 extension);
45 #endif
48 extensions::NativeAppWindow* ChromeAppWindowClient::CreateNativeAppWindow(
49 extensions::AppWindow* window,
50 extensions::AppWindow::CreateParams* params) {
51 #if defined(OS_ANDROID)
52 return NULL;
53 #else
54 return CreateNativeAppWindowImpl(window, *params);
55 #endif
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());
67 if (devtools_window)
68 devtools_window->SetLoadCompletedCallback(callback);
69 else
70 callback.Run();
73 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() {
74 return extensions::GetCurrentChannel() > version_info::Channel::DEV;