| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/apps/chrome_apps_client.h" | 5 #include "chrome/browser/apps/chrome_apps_client.h" |
| 6 | 6 |
| 7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/ui/apps/app_metro_infobar_delegate_win.h" | |
| 12 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 13 | 12 |
| 14 #if defined(OS_WIN) | |
| 15 #include "win8/util/win8_util.h" | |
| 16 #endif | |
| 17 | |
| 18 // TODO(jamescook): We probably shouldn't compile this class at all on Android. | 13 // TODO(jamescook): We probably shouldn't compile this class at all on Android. |
| 19 // See http://crbug.com/343612 | 14 // See http://crbug.com/343612 |
| 20 #if !defined(OS_ANDROID) | 15 #if !defined(OS_ANDROID) |
| 21 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 22 #include "chrome/browser/ui/apps/chrome_app_window_delegate.h" | 17 #include "chrome/browser/ui/apps/chrome_app_window_delegate.h" |
| 23 #endif | 18 #endif |
| 24 | 19 |
| 25 ChromeAppsClient::ChromeAppsClient() {} | 20 ChromeAppsClient::ChromeAppsClient() {} |
| 26 | 21 |
| 27 ChromeAppsClient::~ChromeAppsClient() {} | 22 ChromeAppsClient::~ChromeAppsClient() {} |
| 28 | 23 |
| 29 // static | 24 // static |
| 30 ChromeAppsClient* ChromeAppsClient::GetInstance() { | 25 ChromeAppsClient* ChromeAppsClient::GetInstance() { |
| 31 return Singleton<ChromeAppsClient, | 26 return Singleton<ChromeAppsClient, |
| 32 LeakySingletonTraits<ChromeAppsClient> >::get(); | 27 LeakySingletonTraits<ChromeAppsClient> >::get(); |
| 33 } | 28 } |
| 34 | 29 |
| 35 std::vector<content::BrowserContext*> | 30 std::vector<content::BrowserContext*> |
| 36 ChromeAppsClient::GetLoadedBrowserContexts() { | 31 ChromeAppsClient::GetLoadedBrowserContexts() { |
| 37 std::vector<Profile*> profiles = | 32 std::vector<Profile*> profiles = |
| 38 g_browser_process->profile_manager()->GetLoadedProfiles(); | 33 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 39 return std::vector<content::BrowserContext*>(profiles.begin(), | 34 return std::vector<content::BrowserContext*>(profiles.begin(), |
| 40 profiles.end()); | 35 profiles.end()); |
| 41 } | 36 } |
| 42 | 37 |
| 43 bool ChromeAppsClient::CheckAppLaunch(content::BrowserContext* context, | |
| 44 const extensions::Extension* extension) { | |
| 45 #if defined(OS_WIN) | |
| 46 // On Windows 8's single window Metro mode we can not launch platform apps. | |
| 47 // Offer to switch Chrome to desktop mode. | |
| 48 if (win8::IsSingleWindowMetroMode()) { | |
| 49 AppMetroInfoBarDelegateWin::Create( | |
| 50 Profile::FromBrowserContext(context), | |
| 51 AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP, | |
| 52 extension->id()); | |
| 53 return false; | |
| 54 } | |
| 55 #endif | |
| 56 return true; | |
| 57 } | |
| 58 | |
| 59 apps::AppWindow* ChromeAppsClient::CreateAppWindow( | 38 apps::AppWindow* ChromeAppsClient::CreateAppWindow( |
| 60 content::BrowserContext* context, | 39 content::BrowserContext* context, |
| 61 const extensions::Extension* extension) { | 40 const extensions::Extension* extension) { |
| 62 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 63 return NULL; | 42 return NULL; |
| 64 #else | 43 #else |
| 65 return new apps::AppWindow(context, new ChromeAppWindowDelegate, extension); | 44 return new apps::AppWindow(context, new ChromeAppWindowDelegate, extension); |
| 66 #endif | 45 #endif |
| 67 } | 46 } |
| 68 | 47 |
| 69 void ChromeAppsClient::IncrementKeepAliveCount() { | 48 void ChromeAppsClient::IncrementKeepAliveCount() { |
| 70 #if !defined(OS_ANDROID) | 49 #if !defined(OS_ANDROID) |
| 71 chrome::IncrementKeepAliveCount(); | 50 chrome::IncrementKeepAliveCount(); |
| 72 #endif | 51 #endif |
| 73 } | 52 } |
| 74 | 53 |
| 75 void ChromeAppsClient::DecrementKeepAliveCount() { | 54 void ChromeAppsClient::DecrementKeepAliveCount() { |
| 76 #if !defined(OS_ANDROID) | 55 #if !defined(OS_ANDROID) |
| 77 chrome::DecrementKeepAliveCount(); | 56 chrome::DecrementKeepAliveCount(); |
| 78 #endif | 57 #endif |
| 79 } | 58 } |
| OLD | NEW |