Commit 03102bd6 authored by oshima's avatar oshima Committed by Commit bot

* Use componentized NativeAppWindowViews

* Factor out code that can be used for both chrome/app_shell version from athena/extensions/chrome
* Create AppsClient/AppsDelegate for app_shell version.
* Removed CreateAppsClient as it's no longer necessary.

AthenaNativeAppWindow needs more work in order to work properly on athena. I'll address them in separate bug/CLs.

BUG=410448,410448
TBR=ben@chromium.org

Note: This CL depends on https://codereview.chromium.org/576863003/

Review URL: https://codereview.chromium.org/563083003

Cr-Commit-Position: refs/heads/master@{#295583}
parent c584fb92
......@@ -126,6 +126,7 @@
'dependencies': [
'athena_lib',
'../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'../components/components.gyp:native_app_window',
'../components/components.gyp:renderer_context_menu',
'../components/components.gyp:web_modal',
'../extensions/extensions.gyp:extensions_browser',
......@@ -159,6 +160,12 @@
'content/web_activity.cc',
'content/web_activity.h',
'content/web_contents_view_delegate_factory_impl.cc',
'extensions/athena_app_delegate_base.cc',
'extensions/athena_app_delegate_base.h',
'extensions/athena_apps_client_base.cc',
'extensions/athena_apps_client_base.h',
'extensions/athena_native_app_window_views.cc',
'extensions/athena_native_app_window_views.h',
'extensions/extension_app_model_builder.cc',
'extensions/extensions_delegate.cc',
'extensions/public/extension_app_model_builder.h',
......@@ -176,10 +183,10 @@
'sources': [
'content/chrome/content_activity_factory.cc',
'content/chrome/dialogs.cc',
'extensions/chrome/athena_app_delegate.cc',
'extensions/chrome/athena_app_delegate.h',
'extensions/chrome/athena_apps_client.cc',
'extensions/chrome/athena_apps_client.h',
'extensions/chrome/athena_chrome_app_delegate.cc',
'extensions/chrome/athena_chrome_app_delegate.h',
'extensions/chrome/athena_chrome_apps_client.cc',
'extensions/chrome/athena_chrome_apps_client.h',
'extensions/chrome/extensions_delegate_impl.cc',
],
},
......@@ -196,6 +203,11 @@
'content/shell/shell_app_activity.cc',
'content/shell/shell_app_activity.h',
'extensions/shell/extensions_delegate_impl.cc',
'extensions/shell/athena_shell_app_delegate.cc',
'extensions/shell/athena_shell_app_delegate.h',
'extensions/shell/athena_shell_apps_client.cc',
'extensions/shell/athena_shell_apps_client.h',
'extensions/shell/athena_apps_client_delegate.h',
],
},
{
......
include_rules = [
"+athena/env/public",
"+athena/activity/public",
"+athena/home/public",
"+components/native_app_window",
"+content/public/browser",
"+extensions/browser",
"+extensions/common",
"+extensions/grit",
"+ui/app_list",
"+ui/aura",
"+ui/base/resource",
"+ui/gfx",
]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/athena_app_delegate_base.h"
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
#include "athena/env/public/athena_env.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "extensions/common/constants.h"
#include "extensions/grit/extensions_browser_resources.h"
#include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/rect.h"
namespace athena {
namespace {
content::WebContents* OpenURLInActivity(content::BrowserContext* context,
const content::OpenURLParams& params) {
// Force all links to open in a new activity.
Activity* activity = ActivityFactory::Get()->CreateWebActivity(
context, base::string16(), params.url);
ActivityManager::Get()->AddActivity(activity);
// TODO(oshima): Get the web cotnents from activity.
return NULL;
}
} // namespace
// This is a extra step to open a new Activity when a link is simply clicked
// on an app activity (which usually replaces the content).
class AthenaAppDelegateBase::NewActivityContentsDelegate
: public content::WebContentsDelegate {
public:
NewActivityContentsDelegate() {}
virtual ~NewActivityContentsDelegate() {}
// content::WebContentsDelegate:
virtual content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE {
if (!source)
return NULL;
return OpenURLInActivity(source->GetBrowserContext(), params);
}
private:
DISALLOW_COPY_AND_ASSIGN(NewActivityContentsDelegate);
};
AthenaAppDelegateBase::AthenaAppDelegateBase()
: new_window_contents_delegate_(new NewActivityContentsDelegate) {
}
AthenaAppDelegateBase::~AthenaAppDelegateBase() {
if (!terminating_callback_.is_null())
AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_);
}
void AthenaAppDelegateBase::ResizeWebContents(
content::WebContents* web_contents,
const gfx::Size& size) {
aura::Window* window = web_contents->GetNativeView();
window->SetBounds(gfx::Rect(window->bounds().origin(), size));
}
content::WebContents* AthenaAppDelegateBase::OpenURLFromTab(
content::BrowserContext* context,
content::WebContents* source,
const content::OpenURLParams& params) {
return OpenURLInActivity(context, params);
}
void AthenaAppDelegateBase::AddNewContents(content::BrowserContext* context,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) {
new_contents->SetDelegate(new_window_contents_delegate_.get());
}
int AthenaAppDelegateBase::PreferredIconSize() {
// TODO(oshima): Find out what to use.
return extension_misc::EXTENSION_ICON_SMALL;
}
gfx::ImageSkia AthenaAppDelegateBase::GetAppDefaultIcon() {
return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_APP_DEFAULT_ICON);
}
bool AthenaAppDelegateBase::IsWebContentsVisible(
content::WebContents* web_contents) {
return web_contents->GetNativeView()->IsVisible();
}
void AthenaAppDelegateBase::SetTerminatingCallback(
const base::Closure& callback) {
if (!terminating_callback_.is_null())
AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_);
terminating_callback_ = callback;
if (!terminating_callback_.is_null())
AthenaEnv::Get()->AddTerminatingCallback(terminating_callback_);
}
} // namespace athena
......@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_CHROME_ATHENA_APP_DELEGATE_H_
#define ATHENA_EXTENSIONS_CHROME_ATHENA_APP_DELEGATE_H_
#ifndef ATHENA_EXTENSIONS_ATHENA_APP_DELEGATE_BASE_H_
#define ATHENA_EXTENSIONS_ATHENA_APP_DELEGATE_BASE_H_
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "extensions/browser/app_window/app_delegate.h"
#include "ui/base/window_open_disposition.h"
namespace athena {
class AthenaAppDelegate : public extensions::AppDelegate {
class AthenaAppDelegateBase : public extensions::AppDelegate {
public:
AthenaAppDelegate();
virtual ~AthenaAppDelegate();
AthenaAppDelegateBase();
virtual ~AthenaAppDelegateBase();
private:
class NewWindowContentsDelegate;
class NewActivityContentsDelegate;
// extensions::AppDelegate:
virtual void InitWebContents(content::WebContents* web_contents) OVERRIDE;
virtual void ResizeWebContents(content::WebContents* web_contents,
const gfx::Size& size) OVERRIDE;
virtual content::WebContents* OpenURLFromTab(
......@@ -34,36 +32,18 @@ class AthenaAppDelegate : public extensions::AppDelegate {
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) OVERRIDE;
virtual content::ColorChooser* ShowColorChooser(
content::WebContents* web_contents,
SkColor initial_color) OVERRIDE;
virtual void RunFileChooser(
content::WebContents* tab,
const content::FileChooserParams& params) OVERRIDE;
virtual void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
const extensions::Extension* extension) OVERRIDE;
virtual bool CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const extensions::Extension* extension) OVERRIDE;
virtual int PreferredIconSize() OVERRIDE;
virtual gfx::ImageSkia GetAppDefaultIcon() OVERRIDE;
virtual void SetWebContentsBlocked(content::WebContents* web_contents,
bool blocked) OVERRIDE;
virtual bool IsWebContentsVisible(
content::WebContents* web_contents) OVERRIDE;
virtual void SetTerminatingCallback(const base::Closure& callback) OVERRIDE;
scoped_ptr<NewWindowContentsDelegate> new_window_contents_delegate_;
scoped_ptr<NewActivityContentsDelegate> new_window_contents_delegate_;
base::Closure terminating_callback_;
DISALLOW_COPY_AND_ASSIGN(AthenaAppDelegate);
DISALLOW_COPY_AND_ASSIGN(AthenaAppDelegateBase);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_CHROME_ATHENA_APP_DELEGATE_H_
#endif // ATHENA_EXTENSIONS_ATHENA_APP_DELEGATE_BASE_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/athena_apps_client_base.h"
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
#include "athena/extensions/athena_native_app_window_views.h"
#include "extensions/common/extension.h"
namespace athena {
AthenaAppsClientBase::AthenaAppsClientBase() {
}
AthenaAppsClientBase::~AthenaAppsClientBase() {
}
extensions::NativeAppWindow* AthenaAppsClientBase::CreateNativeAppWindow(
extensions::AppWindow* app_window,
const extensions::AppWindow::CreateParams& params) {
AthenaNativeAppWindowViews* native_window = new AthenaNativeAppWindowViews;
native_window->Init(app_window, params);
Activity* app_activity = ActivityFactory::Get()->CreateAppActivity(
app_window, native_window->GetWebView());
ActivityManager::Get()->AddActivity(app_activity);
return native_window;
}
void AthenaAppsClientBase::IncrementKeepAliveCount() {
// No need to keep track of KeepAlive count on ChromeOS.
}
void AthenaAppsClientBase::DecrementKeepAliveCount() {
// No need to keep track of KeepAlive count on ChromeOS.
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_ATHENA_APPS_CLIENT_BASE_H_
#define ATHENA_EXTENSIONS_ATHENA_APPS_CLIENT_BASE_H_
#include "extensions/browser/app_window/apps_client.h"
#include "base/macros.h"
namespace athena {
// Athena's base impl of AppsClient.
class AthenaAppsClientBase : public extensions::AppsClient {
public:
AthenaAppsClientBase();
virtual ~AthenaAppsClientBase();
private:
// extensions::AppsClient
virtual extensions::NativeAppWindow* CreateNativeAppWindow(
extensions::AppWindow* window,
const extensions::AppWindow::CreateParams& params) OVERRIDE;
virtual void IncrementKeepAliveCount() OVERRIDE;
virtual void DecrementKeepAliveCount() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AthenaAppsClientBase);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_ATHENA_APPS_CLIENT_BASE_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/athena_native_app_window_views.h"
namespace athena {
views::WebView* AthenaNativeAppWindowViews::GetWebView() {
return web_view();
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_ATHENA_NATIVE_APP_WINDOW_VIEWS_H_
#define ATHENA_EXTENSIONS_ATHENA_NATIVE_APP_WINDOW_VIEWS_H_
#include "components/native_app_window/native_app_window_views.h"
namespace athena {
class AthenaNativeAppWindowViews
: public native_app_window::NativeAppWindowViews {
public:
AthenaNativeAppWindowViews() {}
virtual ~AthenaNativeAppWindowViews() {}
views::WebView* GetWebView();
private:
DISALLOW_COPY_AND_ASSIGN(AthenaNativeAppWindowViews);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_ATHENA_NATIVE_APP_WINDOW_VIEWS_H_
include_rules = [
"+athena/env/public",
"+chrome/browser",
"+chrome/common/extensions",
"+content/public/browser",
"+net/base",
"+ui/base",
]
......@@ -2,36 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/chrome/athena_app_delegate.h"
#include "athena/extensions/chrome/athena_chrome_app_delegate.h"
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
#include "athena/env/public/athena_env.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/web_contents_sizer.h"
#include "chrome/common/extensions/chrome_extension_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "extensions/common/constants.h"
#include "extensions/grit/extensions_browser_resources.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_FULL_PRINTING)
......@@ -43,53 +25,15 @@
#endif // defined(ENABLE_PRINTING)
namespace athena {
namespace {
content::WebContents* OpenURLInActivity(
content::BrowserContext* context,
const content::OpenURLParams& params) {
// Force all links to open in a new activity.
Activity* activity = ActivityFactory::Get()->CreateWebActivity(
context, base::string16(), params.url);
ActivityManager::Get()->AddActivity(activity);
// TODO(oshima): Get the web cotnents from activity.
return NULL;
AthenaChromeAppDelegate::AthenaChromeAppDelegate() {
}
} // namespace
// This is a extra step to open a new Activity when a link is simply clicked
// on an app activity (which usually replaces the content).
class AthenaAppDelegate::NewWindowContentsDelegate
: public content::WebContentsDelegate {
public:
NewWindowContentsDelegate() {}
virtual ~NewWindowContentsDelegate() {}
// content::WebContentsDelegate:
virtual content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE {
if (!source)
return NULL;
return OpenURLInActivity(source->GetBrowserContext(), params);
}
private:
DISALLOW_COPY_AND_ASSIGN(NewWindowContentsDelegate);
};
AthenaAppDelegate::AthenaAppDelegate()
: new_window_contents_delegate_(new NewWindowContentsDelegate()) {
AthenaChromeAppDelegate::~AthenaChromeAppDelegate() {
}
AthenaAppDelegate::~AthenaAppDelegate() {
if (!terminating_callback_.is_null())
AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_);
}
void AthenaAppDelegate::InitWebContents(content::WebContents* web_contents) {
void AthenaChromeAppDelegate::InitWebContents(
content::WebContents* web_contents) {
FaviconTabHelper::CreateForWebContents(web_contents);
#if defined(ENABLE_PRINTING)
......@@ -104,40 +48,19 @@ void AthenaAppDelegate::InitWebContents(content::WebContents* web_contents) {
web_contents);
}
void AthenaAppDelegate::ResizeWebContents(content::WebContents* web_contents,
const gfx::Size& size) {
::ResizeWebContents(web_contents, size);
}
content::WebContents* AthenaAppDelegate::OpenURLFromTab(
content::BrowserContext* context,
content::WebContents* source,
const content::OpenURLParams& params) {
return OpenURLInActivity(context, params);
}
void AthenaAppDelegate::AddNewContents(content::BrowserContext* context,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) {
new_contents->SetDelegate(new_window_contents_delegate_.get());
}
content::ColorChooser* AthenaAppDelegate::ShowColorChooser(
content::ColorChooser* AthenaChromeAppDelegate::ShowColorChooser(
content::WebContents* web_contents,
SkColor initial_color) {
return chrome::ShowColorChooser(web_contents, initial_color);
}
void AthenaAppDelegate::RunFileChooser(
void AthenaChromeAppDelegate::RunFileChooser(
content::WebContents* tab,
const content::FileChooserParams& params) {
FileSelectHelper::RunFileChooser(tab, params);
}
void AthenaAppDelegate::RequestMediaAccessPermission(
void AthenaChromeAppDelegate::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
......@@ -146,7 +69,7 @@ void AthenaAppDelegate::RequestMediaAccessPermission(
web_contents, request, callback, extension);
}
bool AthenaAppDelegate::CheckMediaAccessPermission(
bool AthenaChromeAppDelegate::CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
......@@ -156,17 +79,7 @@ bool AthenaAppDelegate::CheckMediaAccessPermission(
web_contents, security_origin, type, extension);
}
int AthenaAppDelegate::PreferredIconSize() {
// TODO(oshima): Find out what to use.
return extension_misc::EXTENSION_ICON_SMALL;
}
gfx::ImageSkia AthenaAppDelegate::GetAppDefaultIcon() {
return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_APP_DEFAULT_ICON);
}
void AthenaAppDelegate::SetWebContentsBlocked(
void AthenaChromeAppDelegate::SetWebContentsBlocked(
content::WebContents* web_contents,
bool blocked) {
// RenderViewHost may be NULL during shutdown.
......@@ -177,17 +90,4 @@ void AthenaAppDelegate::SetWebContentsBlocked(
}
}
bool AthenaAppDelegate::IsWebContentsVisible(
content::WebContents* web_contents) {
return platform_util::IsVisible(web_contents->GetNativeView());
}
void AthenaAppDelegate::SetTerminatingCallback(const base::Closure& callback) {
if (!terminating_callback_.is_null())
AthenaEnv::Get()->RemoveTerminatingCallback(terminating_callback_);
terminating_callback_ = callback;
if (!terminating_callback_.is_null())
AthenaEnv::Get()->AddTerminatingCallback(terminating_callback_);
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_CHROME_ATHENA_CHROME_APP_DELEGATE_H_
#define ATHENA_EXTENSIONS_CHROME_ATHENA_CHROME_APP_DELEGATE_H_
#include "athena/extensions/athena_app_delegate_base.h"
namespace athena {
class AthenaChromeAppDelegate : public AthenaAppDelegateBase {
public:
AthenaChromeAppDelegate();
virtual ~AthenaChromeAppDelegate();
private:
// extensions::AppDelegate:
virtual void InitWebContents(content::WebContents* web_contents) OVERRIDE;
virtual content::ColorChooser* ShowColorChooser(
content::WebContents* web_contents,
SkColor initial_color) OVERRIDE;
virtual void RunFileChooser(
content::WebContents* tab,
const content::FileChooserParams& params) OVERRIDE;
virtual void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
const extensions::Extension* extension) OVERRIDE;
virtual bool CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const extensions::Extension* extension) OVERRIDE;
virtual void SetWebContentsBlocked(content::WebContents* web_contents,
bool blocked) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AthenaChromeAppDelegate);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_CHROME_ATHENA_CHROME_APP_DELEGATE_H_
......@@ -2,88 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/chrome/athena_apps_client.h"
#include "athena/extensions/chrome/athena_chrome_apps_client.h"
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
#include "athena/extensions/chrome/athena_app_delegate.h"
#include "athena/extensions/chrome/athena_chrome_app_delegate.h"
#include "base/memory/singleton.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/common/extension.h"
namespace athena {
namespace {
// A short term hack to get WebView from ChromeNativeAppWindowViews.
// TODO(oshima): Implement athena's NativeAppWindow.
class AthenaNativeAppWindowViews : public ChromeNativeAppWindowViews {
public:
AthenaNativeAppWindowViews() {}
virtual ~AthenaNativeAppWindowViews() {}
views::WebView* GetWebView() {
return web_view();
}
private:
DISALLOW_COPY_AND_ASSIGN(AthenaNativeAppWindowViews);
};
} // namespace
AthenaAppsClient::AthenaAppsClient() {
AthenaChromeAppsClient::AthenaChromeAppsClient() {
}
AthenaAppsClient::~AthenaAppsClient() {
AthenaChromeAppsClient::~AthenaChromeAppsClient() {
}
std::vector<content::BrowserContext*>
AthenaAppsClient::GetLoadedBrowserContexts() {
AthenaChromeAppsClient::GetLoadedBrowserContexts() {
std::vector<Profile*> profiles =
g_browser_process->profile_manager()->GetLoadedProfiles();
return std::vector<content::BrowserContext*>(profiles.begin(),
profiles.end());
}
extensions::AppWindow* AthenaAppsClient::CreateAppWindow(
extensions::AppWindow* AthenaChromeAppsClient::CreateAppWindow(
content::BrowserContext* context,
const extensions::Extension* extension) {
return new extensions::AppWindow(context, new AthenaAppDelegate, extension);
}
extensions::NativeAppWindow* AthenaAppsClient::CreateNativeAppWindow(
extensions::AppWindow* app_window,
const extensions::AppWindow::CreateParams& params) {
AthenaNativeAppWindowViews* native_window = new AthenaNativeAppWindowViews;
native_window->Init(app_window, params);
Activity* app_activity = ActivityFactory::Get()->CreateAppActivity(
app_window, native_window->GetWebView());
ActivityManager::Get()->AddActivity(app_activity);
return native_window;
}
void AthenaAppsClient::IncrementKeepAliveCount() {
// No need to keep track of KeepAlive count on ChromeOS.
}
void AthenaAppsClient::DecrementKeepAliveCount() {
// No need to keep track of KeepAlive count on ChromeOS.
return new extensions::AppWindow(
context, new AthenaChromeAppDelegate, extension);
}
void AthenaAppsClient::OpenDevToolsWindow(content::WebContents* web_contents,
const base::Closure& callback) {
void AthenaChromeAppsClient::OpenDevToolsWindow(
content::WebContents* web_contents,
const base::Closure& callback) {
// TODO(oshima): Figure out what to do.
DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(
web_contents, DevToolsToggleAction::ShowConsole());
devtools_window->SetLoadCompletedCallback(callback);
}
bool AthenaAppsClient::IsCurrentChannelOlderThanDev() {
bool AthenaChromeAppsClient::IsCurrentChannelOlderThanDev() {
return extensions::GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV;
}
......
......@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_CHROME_ATHENA_APPS_CLIENT_H_
#define ATHENA_EXTENSIONS_CHROME_ATHENA_APPS_CLIENT_H_
#ifndef ATHENA_EXTENSIONS_CHROME_ATHENA_CHROME_APPS_CLIENT_H_
#define ATHENA_EXTENSIONS_CHROME_ATHENA_CHROME_APPS_CLIENT_H_
#include "extensions/browser/app_window/apps_client.h"
#include "athena/extensions/athena_apps_client_base.h"
#include "base/macros.h"
namespace athena {
// The implementation of AppsClient for Athena.
class AthenaAppsClient : public extensions::AppsClient {
class AthenaChromeAppsClient : public AthenaAppsClientBase {
public:
AthenaAppsClient();
virtual ~AthenaAppsClient();
AthenaChromeAppsClient();
virtual ~AthenaChromeAppsClient();
private:
// extensions::AppsClient
......@@ -23,18 +23,13 @@ class AthenaAppsClient : public extensions::AppsClient {
virtual extensions::AppWindow* CreateAppWindow(
content::BrowserContext* context,
const extensions::Extension* extension) OVERRIDE;
virtual extensions::NativeAppWindow* CreateNativeAppWindow(
extensions::AppWindow* window,
const extensions::AppWindow::CreateParams& params) OVERRIDE;
virtual void IncrementKeepAliveCount() OVERRIDE;
virtual void DecrementKeepAliveCount() OVERRIDE;
virtual void OpenDevToolsWindow(content::WebContents* web_contents,
const base::Closure& callback) OVERRIDE;
virtual bool IsCurrentChannelOlderThanDev() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AthenaAppsClient);
DISALLOW_COPY_AND_ASSIGN(AthenaChromeAppsClient);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_CHROME_ATHENA_APPS_CLIENT_H_
#endif // ATHENA_EXTENSIONS_CHROME_ATHENA_CHROME_APPS_CLIENT_H_
......@@ -6,7 +6,7 @@
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
#include "athena/extensions/chrome/athena_apps_client.h"
#include "athena/extensions/chrome/athena_chrome_apps_client.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_service.h"
......@@ -32,7 +32,7 @@ class ChromeExtensionsDelegate : public ExtensionsDelegate {
extensions::AppsClient::Set(&apps_client_);
}
virtual ~ChromeExtensionsDelegate() {}
virtual ~ChromeExtensionsDelegate() { extensions::AppsClient::Set(NULL); }
private:
// ExtensionsDelegate:
......@@ -106,7 +106,7 @@ class ChromeExtensionsDelegate : public ExtensionsDelegate {
// Installed extensions.
extensions::ExtensionSet extensions_;
AthenaAppsClient apps_client_;
AthenaChromeAppsClient apps_client_;
DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate);
};
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/shell/athena_shell_app_delegate.h"
#include "content/public/browser/web_contents.h"
#include "extensions/shell/browser/media_capture_util.h"
namespace athena {
AthenaShellAppDelegate::AthenaShellAppDelegate() {
}
AthenaShellAppDelegate::~AthenaShellAppDelegate() {
}
void AthenaShellAppDelegate::InitWebContents(
content::WebContents* web_contents) {
// TODO(oshima): Enable Favicon, Printing, e c. See
// athena_chrome_app_delegate.cc.
NOTIMPLEMENTED();
}
content::ColorChooser* AthenaShellAppDelegate::ShowColorChooser(
content::WebContents* web_contents,
SkColor initial_color) {
NOTIMPLEMENTED();
return NULL;
}
void AthenaShellAppDelegate::RunFileChooser(
content::WebContents* tab,
const content::FileChooserParams& params) {
NOTIMPLEMENTED();
}
void AthenaShellAppDelegate::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
const extensions::Extension* extension) {
extensions::media_capture_util::GrantMediaStreamRequest(
web_contents, request, callback, extension);
}
bool AthenaShellAppDelegate::CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const extensions::Extension* extension) {
extensions::media_capture_util::VerifyMediaAccessPermission(type, extension);
return true;
}
void AthenaShellAppDelegate::SetWebContentsBlocked(
content::WebContents* web_contents,
bool blocked) {
NOTIMPLEMENTED();
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_SHELL_ATHENA_APP_DELEGATE_H_
#define ATHENA_EXTENSIONS_SHELL_ATHENA_APP_DELEGATE_H_
#include "athena/extensions/athena_app_delegate_base.h"
namespace athena {
class AthenaShellAppDelegate : public AthenaAppDelegateBase {
public:
AthenaShellAppDelegate();
virtual ~AthenaShellAppDelegate();
private:
// extensions::AppDelegate:
virtual void InitWebContents(content::WebContents* web_contents) OVERRIDE;
virtual content::ColorChooser* ShowColorChooser(
content::WebContents* web_contents,
SkColor initial_color) OVERRIDE;
virtual void RunFileChooser(
content::WebContents* tab,
const content::FileChooserParams& params) OVERRIDE;
virtual void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
const extensions::Extension* extension) OVERRIDE;
virtual bool CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const extensions::Extension* extension) OVERRIDE;
virtual void SetWebContentsBlocked(content::WebContents* web_contents,
bool blocked) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AthenaShellAppDelegate);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_SHELL_ATHENA_APP_DELEGATE_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/shell/athena_shell_apps_client.h"
#include "athena/extensions/shell/athena_shell_app_delegate.h"
#include "extensions/browser/app_window/app_window.h"
namespace athena {
AthenaShellAppsClient::AthenaShellAppsClient(content::BrowserContext* context)
: context_(context) {
DCHECK(context_);
}
AthenaShellAppsClient::~AthenaShellAppsClient() {
}
std::vector<content::BrowserContext*>
AthenaShellAppsClient::GetLoadedBrowserContexts() {
std::vector<content::BrowserContext*> contexts(1, context_);
return contexts;
}
extensions::AppWindow* AthenaShellAppsClient::CreateAppWindow(
content::BrowserContext* context,
const extensions::Extension* extension) {
return new extensions::AppWindow(
context, new AthenaShellAppDelegate, extension);
}
void AthenaShellAppsClient::OpenDevToolsWindow(
content::WebContents* web_contents,
const base::Closure& callback) {
// TODO(oshima): Figure out what to do.
}
bool AthenaShellAppsClient::IsCurrentChannelOlderThanDev() {
return false;
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_SHELL_ATHENA_SHELL_APPS_CLIENT_H_
#define ATHENA_EXTENSIONS_SHELL_ATHENA_SHELL_APPS_CLIENT_H_
#include "athena/extensions/athena_apps_client_base.h"
#include "base/macros.h"
namespace athena {
class AthenaShellAppsClient : public AthenaAppsClientBase {
public:
AthenaShellAppsClient(content::BrowserContext* context);
virtual ~AthenaShellAppsClient();
private:
// extensions::AppsClient
virtual std::vector<content::BrowserContext*> GetLoadedBrowserContexts()
OVERRIDE;
virtual extensions::AppWindow* CreateAppWindow(
content::BrowserContext* context,
const extensions::Extension* extension) OVERRIDE;
virtual void OpenDevToolsWindow(content::WebContents* web_contents,
const base::Closure& callback) OVERRIDE;
virtual bool IsCurrentChannelOlderThanDev() OVERRIDE;
content::BrowserContext* context_;
DISALLOW_COPY_AND_ASSIGN(AthenaShellAppsClient);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_SHELL_ATHENA_SHELL_APPS_CLIENT_H_
......@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "athena/extensions/public/extensions_delegate.h"
#include "athena/extensions/shell/athena_shell_apps_client.h"
#include "base/macros.h"
#include "extensions/common/extension_set.h"
#include "extensions/shell/browser/shell_extension_system.h"
......@@ -15,9 +17,12 @@ class ShellExtensionsDelegate : public ExtensionsDelegate {
explicit ShellExtensionsDelegate(content::BrowserContext* context)
: context_(context),
extension_system_(static_cast<extensions::ShellExtensionSystem*>(
extensions::ExtensionSystem::Get(context))) {}
extensions::ExtensionSystem::Get(context))),
apps_client_(context) {
extensions::AppsClient::Set(&apps_client_);
}
virtual ~ShellExtensionsDelegate() {}
virtual ~ShellExtensionsDelegate() { extensions::AppsClient::Set(NULL); }
private:
// ExtensionsDelegate:
......@@ -41,6 +46,8 @@ class ShellExtensionsDelegate : public ExtensionsDelegate {
extensions::ShellExtensionSystem* extension_system_;
extensions::ExtensionSet shell_extensions_;
AthenaShellAppsClient apps_client_;
DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate);
};
......
......@@ -75,50 +75,6 @@ class AthenaDesktopController : public extensions::DesktopController {
DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController);
};
class AthenaAppsClient : public extensions::AppsClient {
public:
AthenaAppsClient() {}
virtual ~AthenaAppsClient() {}
// extensions::AppsClient:
virtual std::vector<content::BrowserContext*>
GetLoadedBrowserContexts() OVERRIDE {
NOTIMPLEMENTED();
return std::vector<content::BrowserContext*>();
}
virtual extensions::AppWindow* CreateAppWindow(
content::BrowserContext* context,
const extensions::Extension* extension) OVERRIDE {
return new extensions::AppWindow(
context, new extensions::ShellAppDelegate, extension);
}
virtual extensions::NativeAppWindow* CreateNativeAppWindow(
extensions::AppWindow* window,
const extensions::AppWindow::CreateParams& params) OVERRIDE {
athena::ActivityManager::Get()->AddActivity(
athena::ActivityFactory::Get()->CreateAppActivity(window, NULL));
return new extensions::ShellNativeAppWindow(window, params);
}
virtual void IncrementKeepAliveCount() OVERRIDE {}
virtual void DecrementKeepAliveCount() OVERRIDE {}
virtual void OpenDevToolsWindow(content::WebContents* web_contents,
const base::Closure& callback) OVERRIDE {
NOTIMPLEMENTED();
}
virtual bool IsCurrentChannelOlderThanDev() OVERRIDE {
return false;
}
private:
DISALLOW_COPY_AND_ASSIGN(AthenaAppsClient);
};
class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
public:
AthenaBrowserMainDelegate() {}
......@@ -159,10 +115,6 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
return new AthenaDesktopController();
}
virtual extensions::AppsClient* CreateAppsClient() OVERRIDE {
return new AthenaAppsClient();
}
private:
DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
};
......
......@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "extensions/shell/browser/shell_apps_client.h"
#include "extensions/shell/browser/shell_desktop_controller.h"
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/common/switches.h"
......@@ -46,8 +45,4 @@ DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
return new ShellDesktopController();
}
AppsClient* DefaultShellBrowserMainDelegate::CreateAppsClient() {
return new ShellAppsClient();
}
} // namespace extensions
......@@ -22,7 +22,6 @@ class DefaultShellBrowserMainDelegate : public ShellBrowserMainDelegate {
virtual void Start(content::BrowserContext* context) OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual DesktopController* CreateDesktopController() OVERRIDE;
virtual AppsClient* CreateAppsClient() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DefaultShellBrowserMainDelegate);
......
......@@ -11,7 +11,6 @@ class BrowserContext;
namespace extensions {
class AppsClient;
class DesktopController;
class ShellBrowserMainDelegate {
......@@ -30,9 +29,6 @@ class ShellBrowserMainDelegate {
// and window manager. Subclass may return its subclass to customize the
// windo manager.
virtual DesktopController* CreateDesktopController() = 0;
// Creates the AppsClient instance to support app.window extension API.
virtual AppsClient* CreateAppsClient() = 0;
};
} // namespace extensions
......
......@@ -125,9 +125,6 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
device_client_.reset(new ShellDeviceClient);
apps_client_.reset(browser_main_delegate_->CreateAppsClient());
extensions::AppsClient::Set(apps_client_.get());
extensions_client_.reset(new ShellExtensionsClient());
ExtensionsClient::Set(extensions_client_.get());
......
......@@ -11,6 +11,7 @@
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/shell/browser/shell_app_delegate.h"
#include "extensions/shell/browser/shell_apps_client.h"
#include "extensions/shell/common/switches.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/default_capture_client.h"
......@@ -159,7 +160,9 @@ class AppsFocusRules : public wm::BaseFocusRules {
} // namespace
ShellDesktopController::ShellDesktopController()
: app_window_(NULL) {
: apps_client_(new ShellAppsClient), app_window_(NULL) {
extensions::AppsClient::Set(apps_client_.get());
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
AddObserver(this);
......@@ -168,7 +171,6 @@ ShellDesktopController::ShellDesktopController()
display_configurator_->ForceInitialConfigure(0);
display_configurator_->AddObserver(this);
#endif
CreateRootWindow();
}
......@@ -179,6 +181,7 @@ ShellDesktopController::~ShellDesktopController() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
RemoveObserver(this);
#endif
extensions::AppsClient::Set(NULL);
}
aura::WindowTreeHost* ShellDesktopController::GetHost() {
......
......@@ -49,7 +49,7 @@ class UserActivityDetector;
}
namespace extensions {
class AppsClient;
class Extension;
// Handles desktop-related tasks for app_shell.
......@@ -129,6 +129,8 @@ class ShellDesktopController : public DesktopController,
scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
#endif
scoped_ptr<AppsClient> apps_client_;
// The desktop supports a single app window.
AppWindow* app_window_; // NativeAppWindow::Close() deletes this.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment