OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ui/apps/chrome_app_window_client.h" | 5 #include "chrome/browser/ui/apps/chrome_app_window_client.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/apps/scoped_keep_alive.h" |
8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/devtools/devtools_window.h" | 10 #include "chrome/browser/devtools/devtools_window.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
11 #include "chrome/common/extensions/features/feature_channel.h" | 12 #include "chrome/common/extensions/features/feature_channel.h" |
12 #include "extensions/browser/app_window/app_window.h" | 13 #include "extensions/browser/app_window/app_window.h" |
13 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
14 | 15 |
15 // TODO(jamescook): We probably shouldn't compile this class at all on Android. | 16 // TODO(jamescook): We probably shouldn't compile this class at all on Android. |
16 // See http://crbug.com/343612 | 17 // See http://crbug.com/343612 |
17 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
18 #include "chrome/browser/lifetime/application_lifetime.h" | |
19 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 19 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
20 #endif | 20 #endif |
21 | 21 |
22 ChromeAppWindowClient::ChromeAppWindowClient() { | 22 ChromeAppWindowClient::ChromeAppWindowClient() { |
23 } | 23 } |
24 | 24 |
25 ChromeAppWindowClient::~ChromeAppWindowClient() { | 25 ChromeAppWindowClient::~ChromeAppWindowClient() { |
26 } | 26 } |
27 | 27 |
28 // static | 28 // static |
29 ChromeAppWindowClient* ChromeAppWindowClient::GetInstance() { | 29 ChromeAppWindowClient* ChromeAppWindowClient::GetInstance() { |
30 return Singleton<ChromeAppWindowClient, | 30 return Singleton<ChromeAppWindowClient, |
31 LeakySingletonTraits<ChromeAppWindowClient> >::get(); | 31 LeakySingletonTraits<ChromeAppWindowClient> >::get(); |
32 } | 32 } |
33 | 33 |
34 std::vector<content::BrowserContext*> | 34 std::vector<content::BrowserContext*> |
35 ChromeAppWindowClient::GetLoadedBrowserContexts() { | 35 ChromeAppWindowClient::GetLoadedBrowserContexts() { |
36 std::vector<Profile*> profiles = | 36 std::vector<Profile*> profiles = |
37 g_browser_process->profile_manager()->GetLoadedProfiles(); | 37 g_browser_process->profile_manager()->GetLoadedProfiles(); |
38 return std::vector<content::BrowserContext*>(profiles.begin(), | 38 return std::vector<content::BrowserContext*>(profiles.begin(), |
39 profiles.end()); | 39 profiles.end()); |
40 } | 40 } |
41 | 41 |
42 extensions::AppWindow* ChromeAppWindowClient::CreateAppWindow( | 42 extensions::AppWindow* ChromeAppWindowClient::CreateAppWindow( |
43 content::BrowserContext* context, | 43 content::BrowserContext* context, |
44 const extensions::Extension* extension) { | 44 const extensions::Extension* extension) { |
45 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
46 return NULL; | 46 return NULL; |
47 #else | 47 #else |
48 return new extensions::AppWindow(context, new ChromeAppDelegate, extension); | 48 return new extensions::AppWindow( |
| 49 context, |
| 50 new ChromeAppDelegate(make_scoped_ptr(new ScopedKeepAlive)), |
| 51 extension); |
49 #endif | 52 #endif |
50 } | 53 } |
51 | 54 |
52 extensions::NativeAppWindow* ChromeAppWindowClient::CreateNativeAppWindow( | 55 extensions::NativeAppWindow* ChromeAppWindowClient::CreateNativeAppWindow( |
53 extensions::AppWindow* window, | 56 extensions::AppWindow* window, |
54 const extensions::AppWindow::CreateParams& params) { | 57 const extensions::AppWindow::CreateParams& params) { |
55 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
56 return NULL; | 59 return NULL; |
57 #else | 60 #else |
58 return CreateNativeAppWindowImpl(window, params); | 61 return CreateNativeAppWindowImpl(window, params); |
59 #endif | 62 #endif |
60 } | 63 } |
61 | 64 |
62 void ChromeAppWindowClient::IncrementKeepAliveCount() { | |
63 #if !defined(OS_ANDROID) | |
64 chrome::IncrementKeepAliveCount(); | |
65 #endif | |
66 } | |
67 | |
68 void ChromeAppWindowClient::DecrementKeepAliveCount() { | |
69 #if !defined(OS_ANDROID) | |
70 chrome::DecrementKeepAliveCount(); | |
71 #endif | |
72 } | |
73 | |
74 void ChromeAppWindowClient::OpenDevToolsWindow( | 65 void ChromeAppWindowClient::OpenDevToolsWindow( |
75 content::WebContents* web_contents, | 66 content::WebContents* web_contents, |
76 const base::Closure& callback) { | 67 const base::Closure& callback) { |
77 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( | 68 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( |
78 web_contents, DevToolsToggleAction::ShowConsole()); | 69 web_contents, DevToolsToggleAction::ShowConsole()); |
79 devtools_window->SetLoadCompletedCallback(callback); | 70 devtools_window->SetLoadCompletedCallback(callback); |
80 } | 71 } |
81 | 72 |
82 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() { | 73 bool ChromeAppWindowClient::IsCurrentChannelOlderThanDev() { |
83 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; | 74 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; |
84 } | 75 } |
OLD | NEW |