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 "athena/extensions/chrome/athena_apps_client.h" | 5 #include "athena/extensions/athena_apps_client_base.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/extensions/chrome/athena_app_delegate.h" | 9 #include "athena/extensions/athena_native_app_window_views.h" |
10 #include "base/memory/singleton.h" | |
11 #include "chrome/browser/browser_process.h" | |
12 #include "chrome/browser/devtools/devtools_window.h" | |
13 #include "chrome/browser/profiles/profile_manager.h" | |
14 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" | |
15 #include "chrome/common/extensions/features/feature_channel.h" | |
16 #include "extensions/browser/app_window/app_window.h" | |
17 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
18 | 11 |
19 namespace athena { | 12 namespace athena { |
20 namespace { | |
21 | 13 |
22 // A short term hack to get WebView from ChromeNativeAppWindowViews. | 14 AthenaAppsClientBase::AthenaAppsClientBase() { |
23 // TODO(oshima): Implement athena's NativeAppWindow. | |
24 class AthenaNativeAppWindowViews : public ChromeNativeAppWindowViews { | |
25 public: | |
26 AthenaNativeAppWindowViews() {} | |
27 virtual ~AthenaNativeAppWindowViews() {} | |
28 | |
29 views::WebView* GetWebView() { | |
30 return web_view(); | |
31 } | |
32 | |
33 private: | |
34 DISALLOW_COPY_AND_ASSIGN(AthenaNativeAppWindowViews); | |
35 }; | |
36 | |
37 } // namespace | |
38 | |
39 AthenaAppsClient::AthenaAppsClient() { | |
40 } | 15 } |
41 | 16 |
42 AthenaAppsClient::~AthenaAppsClient() { | 17 AthenaAppsClientBase::~AthenaAppsClientBase() { |
43 } | 18 } |
44 | 19 |
45 std::vector<content::BrowserContext*> | 20 extensions::NativeAppWindow* AthenaAppsClientBase::CreateNativeAppWindow( |
46 AthenaAppsClient::GetLoadedBrowserContexts() { | |
47 std::vector<Profile*> profiles = | |
48 g_browser_process->profile_manager()->GetLoadedProfiles(); | |
49 return std::vector<content::BrowserContext*>(profiles.begin(), | |
50 profiles.end()); | |
51 } | |
52 | |
53 extensions::AppWindow* AthenaAppsClient::CreateAppWindow( | |
54 content::BrowserContext* context, | |
55 const extensions::Extension* extension) { | |
56 return new extensions::AppWindow(context, new AthenaAppDelegate, extension); | |
57 } | |
58 | |
59 extensions::NativeAppWindow* AthenaAppsClient::CreateNativeAppWindow( | |
60 extensions::AppWindow* app_window, | 21 extensions::AppWindow* app_window, |
61 const extensions::AppWindow::CreateParams& params) { | 22 const extensions::AppWindow::CreateParams& params) { |
62 AthenaNativeAppWindowViews* native_window = new AthenaNativeAppWindowViews; | 23 AthenaNativeAppWindowViews* native_window = new AthenaNativeAppWindowViews; |
63 native_window->Init(app_window, params); | 24 native_window->Init(app_window, params); |
64 Activity* app_activity = ActivityFactory::Get()->CreateAppActivity( | 25 Activity* app_activity = ActivityFactory::Get()->CreateAppActivity( |
65 app_window, native_window->GetWebView()); | 26 app_window, native_window->GetWebView()); |
66 ActivityManager::Get()->AddActivity(app_activity); | 27 ActivityManager::Get()->AddActivity(app_activity); |
67 return native_window; | 28 return native_window; |
68 } | 29 } |
69 | 30 |
70 void AthenaAppsClient::IncrementKeepAliveCount() { | 31 void AthenaAppsClientBase::IncrementKeepAliveCount() { |
71 // No need to keep track of KeepAlive count on ChromeOS. | 32 // No need to keep track of KeepAlive count on ChromeOS. |
72 } | 33 } |
73 | 34 |
74 void AthenaAppsClient::DecrementKeepAliveCount() { | 35 void AthenaAppsClientBase::DecrementKeepAliveCount() { |
75 // No need to keep track of KeepAlive count on ChromeOS. | 36 // No need to keep track of KeepAlive count on ChromeOS. |
76 } | 37 } |
77 | 38 |
78 void AthenaAppsClient::OpenDevToolsWindow(content::WebContents* web_contents, | |
79 const base::Closure& callback) { | |
80 // TODO(oshima): Figure out what to do. | |
81 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( | |
82 web_contents, DevToolsToggleAction::ShowConsole()); | |
83 devtools_window->SetLoadCompletedCallback(callback); | |
84 } | |
85 | |
86 bool AthenaAppsClient::IsCurrentChannelOlderThanDev() { | |
87 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; | |
88 } | |
89 | |
90 } // namespace athena | 39 } // namespace athena |
OLD | NEW |