Chromium Code Reviews| 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_apps_client.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/chrome/athena_app_delegate.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/devtools/devtools_window.h" | 12 #include "chrome/browser/devtools/devtools_window.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" | 14 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" |
| 15 #include "chrome/common/extensions/features/feature_channel.h" | 15 #include "chrome/common/extensions/features/feature_channel.h" |
| 16 #include "extensions/browser/app_window/app_window.h" | 16 #include "extensions/browser/app_window/app_window.h" |
| 17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
| 18 | 18 |
| 19 namespace athena { | 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 { | |
|
Jun Mukai
2014/09/10 23:53:14
For the follow-ups of outlined comment:
Noticed th
oshima
2014/09/11 00:20:56
ActivityFrame view is in athena/activity, and requ
| |
| 25 public: | |
| 26 AthenaNativeAppWindowViews() {} | |
| 27 virtual ~AthenaNativeAppWindowViews() {} | |
| 28 | |
| 29 views::WebView* GetWebView() { | |
|
Jun Mukai
2014/09/10 23:58:11
Do you need to expose this?
You may want to pass a
oshima
2014/09/11 00:20:56
I tried that first, but it added extra dependency
| |
| 30 return web_view(); | |
| 31 } | |
| 32 | |
| 33 private: | |
| 34 DISALLOW_COPY_AND_ASSIGN(AthenaNativeAppWindowViews); | |
| 35 }; | |
| 36 | |
| 37 } // namespace | |
| 20 | 38 |
| 21 AthenaAppsClient::AthenaAppsClient() { | 39 AthenaAppsClient::AthenaAppsClient() { |
| 22 } | 40 } |
| 23 | 41 |
| 24 AthenaAppsClient::~AthenaAppsClient() { | 42 AthenaAppsClient::~AthenaAppsClient() { |
| 25 } | 43 } |
| 26 | 44 |
| 27 std::vector<content::BrowserContext*> | 45 std::vector<content::BrowserContext*> |
| 28 AthenaAppsClient::GetLoadedBrowserContexts() { | 46 AthenaAppsClient::GetLoadedBrowserContexts() { |
| 29 std::vector<Profile*> profiles = | 47 std::vector<Profile*> profiles = |
| 30 g_browser_process->profile_manager()->GetLoadedProfiles(); | 48 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 31 return std::vector<content::BrowserContext*>(profiles.begin(), | 49 return std::vector<content::BrowserContext*>(profiles.begin(), |
| 32 profiles.end()); | 50 profiles.end()); |
| 33 } | 51 } |
| 34 | 52 |
| 35 extensions::AppWindow* AthenaAppsClient::CreateAppWindow( | 53 extensions::AppWindow* AthenaAppsClient::CreateAppWindow( |
| 36 content::BrowserContext* context, | 54 content::BrowserContext* context, |
| 37 const extensions::Extension* extension) { | 55 const extensions::Extension* extension) { |
| 38 return new extensions::AppWindow(context, new AthenaAppDelegate, extension); | 56 return new extensions::AppWindow(context, new AthenaAppDelegate, extension); |
| 39 } | 57 } |
| 40 | 58 |
| 41 extensions::NativeAppWindow* AthenaAppsClient::CreateNativeAppWindow( | 59 extensions::NativeAppWindow* AthenaAppsClient::CreateNativeAppWindow( |
| 42 extensions::AppWindow* app_window, | 60 extensions::AppWindow* app_window, |
| 43 const extensions::AppWindow::CreateParams& params) { | 61 const extensions::AppWindow::CreateParams& params) { |
| 44 // TODO(oshima): Implement athena's native appwindow. | 62 AthenaNativeAppWindowViews* native_window = new AthenaNativeAppWindowViews; |
| 45 ChromeNativeAppWindowViews* window = new ChromeNativeAppWindowViews; | 63 native_window->Init(app_window, params); |
| 46 window->Init(app_window, params); | 64 Activity* app_activity = ActivityFactory::Get()->CreateAppActivity( |
| 47 athena::ActivityManager::Get()->AddActivity( | 65 app_window, native_window->GetWebView()); |
| 48 athena::ActivityFactory::Get()->CreateAppActivity(app_window)); | 66 ActivityManager::Get()->AddActivity(app_activity); |
| 49 return window; | 67 return native_window; |
| 50 } | 68 } |
| 51 | 69 |
| 52 void AthenaAppsClient::IncrementKeepAliveCount() { | 70 void AthenaAppsClient::IncrementKeepAliveCount() { |
| 53 // No need to keep track of KeepAlive count on ChromeOS. | 71 // No need to keep track of KeepAlive count on ChromeOS. |
| 54 } | 72 } |
| 55 | 73 |
| 56 void AthenaAppsClient::DecrementKeepAliveCount() { | 74 void AthenaAppsClient::DecrementKeepAliveCount() { |
| 57 // No need to keep track of KeepAlive count on ChromeOS. | 75 // No need to keep track of KeepAlive count on ChromeOS. |
| 58 } | 76 } |
| 59 | 77 |
| 60 void AthenaAppsClient::OpenDevToolsWindow(content::WebContents* web_contents, | 78 void AthenaAppsClient::OpenDevToolsWindow(content::WebContents* web_contents, |
| 61 const base::Closure& callback) { | 79 const base::Closure& callback) { |
| 62 // TODO(oshima): Figure out what to do. | 80 // TODO(oshima): Figure out what to do. |
| 63 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( | 81 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( |
| 64 web_contents, DevToolsToggleAction::ShowConsole()); | 82 web_contents, DevToolsToggleAction::ShowConsole()); |
| 65 devtools_window->SetLoadCompletedCallback(callback); | 83 devtools_window->SetLoadCompletedCallback(callback); |
| 66 } | 84 } |
| 67 | 85 |
| 68 bool AthenaAppsClient::IsCurrentChannelOlderThanDev() { | 86 bool AthenaAppsClient::IsCurrentChannelOlderThanDev() { |
| 69 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; | 87 return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; |
| 70 } | 88 } |
| 71 | 89 |
| 72 } // namespace athena | 90 } // namespace athena |
| OLD | NEW |