OLD | NEW |
| (Empty) |
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 "athena/extensions/chrome/athena_apps_client.h" | |
6 | |
7 #include "athena/activity/public/activity_factory.h" | |
8 #include "athena/activity/public/activity_manager.h" | |
9 #include "athena/extensions/chrome/athena_app_delegate.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" | |
18 | |
19 namespace athena { | |
20 namespace { | |
21 | |
22 // A short term hack to get WebView from ChromeNativeAppWindowViews. | |
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 } | |
41 | |
42 AthenaAppsClient::~AthenaAppsClient() { | |
43 } | |
44 | |
45 std::vector<content::BrowserContext*> | |
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, | |
61 const extensions::AppWindow::CreateParams& params) { | |
62 AthenaNativeAppWindowViews* native_window = new AthenaNativeAppWindowViews; | |
63 native_window->Init(app_window, params); | |
64 Activity* app_activity = ActivityFactory::Get()->CreateAppActivity( | |
65 app_window, native_window->GetWebView()); | |
66 ActivityManager::Get()->AddActivity(app_activity); | |
67 return native_window; | |
68 } | |
69 | |
70 void AthenaAppsClient::IncrementKeepAliveCount() { | |
71 // No need to keep track of KeepAlive count on ChromeOS. | |
72 } | |
73 | |
74 void AthenaAppsClient::DecrementKeepAliveCount() { | |
75 // No need to keep track of KeepAlive count on ChromeOS. | |
76 } | |
77 | |
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 | |
OLD | NEW |