Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / apps / chrome_apps_client.cc
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.
4
5 #include "chrome/browser/ui/apps/chrome_apps_client.h"
6
7 #include "apps/app_window.h"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "extensions/common/extension.h"
12
13 // TODO(jamescook): We probably shouldn't compile this class at all on Android.
14 // See http://crbug.com/343612
15 #if !defined(OS_ANDROID)
16 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
18 #endif
19
20 ChromeAppsClient::ChromeAppsClient() {
21 }
22
23 ChromeAppsClient::~ChromeAppsClient() {
24 }
25
26 // static
27 ChromeAppsClient* ChromeAppsClient::GetInstance() {
28   return Singleton<ChromeAppsClient,
29                    LeakySingletonTraits<ChromeAppsClient> >::get();
30 }
31
32 std::vector<content::BrowserContext*>
33 ChromeAppsClient::GetLoadedBrowserContexts() {
34   std::vector<Profile*> profiles =
35       g_browser_process->profile_manager()->GetLoadedProfiles();
36   return std::vector<content::BrowserContext*>(profiles.begin(),
37                                                profiles.end());
38 }
39
40 apps::AppWindow* ChromeAppsClient::CreateAppWindow(
41     content::BrowserContext* context,
42     const extensions::Extension* extension) {
43 #if defined(OS_ANDROID)
44   return NULL;
45 #else
46   return new apps::AppWindow(context, new ChromeAppDelegate, extension);
47 #endif
48 }
49
50 apps::NativeAppWindow* ChromeAppsClient::CreateNativeAppWindow(
51     apps::AppWindow* window,
52     const apps::AppWindow::CreateParams& params) {
53 #if defined(OS_ANDROID)
54   return NULL;
55 #else
56   return CreateNativeAppWindowImpl(window, params);
57 #endif
58 }
59
60 void ChromeAppsClient::IncrementKeepAliveCount() {
61 #if !defined(OS_ANDROID)
62   chrome::IncrementKeepAliveCount();
63 #endif
64 }
65
66 void ChromeAppsClient::DecrementKeepAliveCount() {
67 #if !defined(OS_ANDROID)
68   chrome::DecrementKeepAliveCount();
69 #endif
70 }