| 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/chrome/athena_chrome_apps_client.h" |
| 6 | 6 |
| 7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/extensions/chrome/athena_chrome_app_delegate.h" |
| 8 #include "athena/activity/public/activity_manager.h" | |
| 9 #include "athena/extensions/chrome/athena_app_delegate.h" | |
| 10 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 11 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/devtools/devtools_window.h" | 10 #include "chrome/browser/devtools/devtools_window.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 11 #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" | 12 #include "chrome/common/extensions/features/feature_channel.h" |
| 16 #include "extensions/browser/app_window/app_window.h" | 13 #include "extensions/browser/app_window/app_window.h" |
| 17 #include "extensions/common/extension.h" | |
| 18 | 14 |
| 19 namespace athena { | 15 namespace athena { |
| 20 namespace { | |
| 21 | 16 |
| 22 // A short term hack to get WebView from ChromeNativeAppWindowViews. | 17 AthenaChromeAppsClient::AthenaChromeAppsClient() { |
| 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 } | 18 } |
| 41 | 19 |
| 42 AthenaAppsClient::~AthenaAppsClient() { | 20 AthenaChromeAppsClient::~AthenaChromeAppsClient() { |
| 43 } | 21 } |
| 44 | 22 |
| 45 std::vector<content::BrowserContext*> | 23 std::vector<content::BrowserContext*> |
| 46 AthenaAppsClient::GetLoadedBrowserContexts() { | 24 AthenaChromeAppsClient::GetLoadedBrowserContexts() { |
| 47 std::vector<Profile*> profiles = | 25 std::vector<Profile*> profiles = |
| 48 g_browser_process->profile_manager()->GetLoadedProfiles(); | 26 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 49 return std::vector<content::BrowserContext*>(profiles.begin(), | 27 return std::vector<content::BrowserContext*>(profiles.begin(), |
| 50 profiles.end()); | 28 profiles.end()); |
| 51 } | 29 } |
| 52 | 30 |
| 53 extensions::AppWindow* AthenaAppsClient::CreateAppWindow( | 31 extensions::AppWindow* AthenaChromeAppsClient::CreateAppWindow( |
| 54 content::BrowserContext* context, | 32 content::BrowserContext* context, |
| 55 const extensions::Extension* extension) { | 33 const extensions::Extension* extension) { |
| 56 return new extensions::AppWindow(context, new AthenaAppDelegate, extension); | 34 return new extensions::AppWindow( |
| 35 context, new AthenaChromeAppDelegate, extension); |
| 57 } | 36 } |
| 58 | 37 |
| 59 extensions::NativeAppWindow* AthenaAppsClient::CreateNativeAppWindow( | 38 void AthenaChromeAppsClient::OpenDevToolsWindow( |
| 60 extensions::AppWindow* app_window, | 39 content::WebContents* web_contents, |
| 61 const extensions::AppWindow::CreateParams& params) { | 40 const base::Closure& callback) { |
| 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. | 41 // TODO(oshima): Figure out what to do. |
| 81 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( | 42 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( |
| 82 web_contents, DevToolsToggleAction::ShowConsole()); | 43 web_contents, DevToolsToggleAction::ShowConsole()); |
| 83 devtools_window->SetLoadCompletedCallback(callback); | 44 devtools_window->SetLoadCompletedCallback(callback); |
| 84 } | 45 } |
| 85 | 46 |
| 86 bool AthenaAppsClient::IsCurrentChannelOlderThanDev() { | 47 bool AthenaChromeAppsClient::IsCurrentChannelOlderThanDev() { |
| 87 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; | 48 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; |
| 88 } | 49 } |
| 89 | 50 |
| 90 } // namespace athena | 51 } // namespace athena |
| OLD | NEW |