Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / apps / chrome_app_window_client.cc
blob4cb3a1bcc056aa13fcad59f14b8c9625f17532df
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 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)
38 return NULL;
39 #else
40 return new extensions::AppWindow(
41 context,
42 new ChromeAppDelegate(make_scoped_ptr(new ScopedKeepAlive)),
43 extension);
44 #endif
47 extensions::NativeAppWindow* ChromeAppWindowClient::CreateNativeAppWindow(
48 extensions::AppWindow* window,
49 extensions::AppWindow::CreateParams* params) {
50 #if defined(OS_ANDROID)
51 return NULL;
52 #else
53 return CreateNativeAppWindowImpl(window, *params);
54 #endif
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());
66 if (devtools_window)
67 devtools_window->SetLoadCompletedCallback(callback);
68 else
69 callback.Run();
72 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() {
73 return extensions::GetCurrentChannel() > version_info::Channel::DEV;