Home | History | Annotate | Download | only in apps
      1 // Copyright 2013 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/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_window_delegate.h"
     18 #endif
     19 
     20 ChromeAppsClient::ChromeAppsClient() {}
     21 
     22 ChromeAppsClient::~ChromeAppsClient() {}
     23 
     24 // static
     25 ChromeAppsClient* ChromeAppsClient::GetInstance() {
     26   return Singleton<ChromeAppsClient,
     27                    LeakySingletonTraits<ChromeAppsClient> >::get();
     28 }
     29 
     30 std::vector<content::BrowserContext*>
     31     ChromeAppsClient::GetLoadedBrowserContexts() {
     32   std::vector<Profile*> profiles =
     33       g_browser_process->profile_manager()->GetLoadedProfiles();
     34   return std::vector<content::BrowserContext*>(profiles.begin(),
     35                                                profiles.end());
     36 }
     37 
     38 apps::AppWindow* ChromeAppsClient::CreateAppWindow(
     39     content::BrowserContext* context,
     40     const extensions::Extension* extension) {
     41 #if defined(OS_ANDROID)
     42   return NULL;
     43 #else
     44   return new apps::AppWindow(context, new ChromeAppWindowDelegate, extension);
     45 #endif
     46 }
     47 
     48 void ChromeAppsClient::IncrementKeepAliveCount() {
     49 #if !defined(OS_ANDROID)
     50   chrome::IncrementKeepAliveCount();
     51 #endif
     52 }
     53 
     54 void ChromeAppsClient::DecrementKeepAliveCount() {
     55 #if !defined(OS_ANDROID)
     56   chrome::DecrementKeepAliveCount();
     57 #endif
     58 }
     59