summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
Diffstat (limited to 'athena')
-rw-r--r--athena/activity/public/activity_factory.h4
-rw-r--r--athena/athena.gyp4
-rw-r--r--athena/content/app_activity.cc17
-rw-r--r--athena/content/app_activity.h7
-rw-r--r--athena/content/app_activity_registry.cc8
-rw-r--r--athena/content/app_activity_unittest.cc107
-rw-r--r--athena/content/app_registry_impl.cc21
-rw-r--r--athena/content/content_activity_factory.h4
-rw-r--r--athena/content/public/app_content_control_delegate.h40
-rw-r--r--athena/content/public/app_registry.h9
-rw-r--r--athena/content/shell/content_activity_factory.cc5
-rw-r--r--athena/content/shell/shell_app_activity.cc8
-rw-r--r--athena/content/shell/shell_app_activity.h3
-rw-r--r--athena/extensions/public/extensions_delegate.h10
-rw-r--r--athena/extensions/shell/extensions_delegate_impl.cc5
-rw-r--r--athena/extensions/test/test_extensions_delegate.cc3
-rw-r--r--athena/main/athena_main.cc3
-rw-r--r--athena/test/sample_activity_factory.cc3
-rw-r--r--athena/test/sample_activity_factory.h7
19 files changed, 98 insertions, 170 deletions
diff --git a/athena/activity/public/activity_factory.h b/athena/activity/public/activity_factory.h
index d9ec79a..557f3b1 100644
--- a/athena/activity/public/activity_factory.h
+++ b/athena/activity/public/activity_factory.h
@@ -44,8 +44,8 @@ class ATHENA_EXPORT ActivityFactory {
// The returned activity should own |app_window|.
// TODO(oshima): Consolidate these two methods to create AppActivity
// once crbug.com/403726 is finished.
- virtual Activity* CreateAppActivity(
- extensions::ShellAppWindow* app_window) = 0;
+ virtual Activity* CreateAppActivity(extensions::ShellAppWindow* app_window,
+ const std::string& id) = 0;
// Create an activity of an app with |app_window| for chrome environment.
virtual Activity* CreateAppActivity(apps::AppWindow* app_window) = 0;
diff --git a/athena/athena.gyp b/athena/athena.gyp
index fb0ccc1..7185932 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -129,8 +129,6 @@
'content/app_registry_impl.cc',
'content/content_activity_factory.cc',
'content/content_app_model_builder.cc',
- 'content/delegate/app_content_control_delegate_impl.cc',
- 'content/public/app_content_control_delegate.h',
'content/public/app_registry.h',
'content/content_activity_factory.h',
'content/public/content_activity_factory_creator.h',
@@ -181,7 +179,6 @@
'resources/athena_resources.gyp:athena_resources',
],
'sources': [
- 'content/public/app_content_control_delegate.h',
'extensions/test/test_extensions_delegate.cc',
'test/athena_test_base.cc',
'test/athena_test_base.h',
@@ -191,7 +188,6 @@
'test/sample_activity.h',
'test/sample_activity_factory.cc',
'test/sample_activity_factory.h',
- 'test/test_app_content_control_delegate_impl.cc',
'test/test_app_model_builder.cc',
'test/test_app_model_builder.h',
'wm/test/window_manager_impl_test_api.cc',
diff --git a/athena/content/app_activity.cc b/athena/content/app_activity.cc
index 7dcad7e..48f9b6c 100644
--- a/athena/content/app_activity.cc
+++ b/athena/content/app_activity.cc
@@ -6,7 +6,6 @@
#include "athena/activity/public/activity_manager.h"
#include "athena/content/app_activity_registry.h"
-#include "athena/content/public/app_content_control_delegate.h"
#include "athena/content/public/app_registry.h"
#include "content/public/browser/web_contents.h"
#include "ui/views/controls/webview/webview.h"
@@ -15,8 +14,9 @@
namespace athena {
// TODO(mukai): specifies the same accelerators of WebActivity.
-AppActivity::AppActivity()
- : web_view_(NULL),
+AppActivity::AppActivity(const std::string& app_id)
+ : app_id_(app_id),
+ web_view_(NULL),
current_state_(ACTIVITY_UNLOADED),
app_activity_registry_(NULL) {
}
@@ -120,6 +120,7 @@ views::View* AppActivity::GetContentsView() {
SetCurrentState(ACTIVITY_INVISIBLE);
Observe(web_contents);
overview_mode_image_ = gfx::ImageSkia();
+ RegisterActivity();
}
return web_view_;
}
@@ -142,13 +143,6 @@ void AppActivity::DidUpdateFaviconURL(
ActivityManager::Get()->UpdateActivity(this);
}
-void AppActivity::DidStartNavigationToPendingEntry(
- const GURL& url,
- content::NavigationController::ReloadType reload_type) {
- if (!app_activity_registry_)
- RegisterActivity();
-}
-
// Register an |activity| with an application.
// Note: This should only get called once for an |app_window| of the
// |activity|.
@@ -157,8 +151,7 @@ void AppActivity::RegisterActivity() {
AppRegistry* app_registry = AppRegistry::Get();
// Get the application's registry.
app_activity_registry_ = app_registry->GetAppActivityRegistry(
- app_registry->GetDelegate()->GetApplicationID(web_contents),
- web_contents->GetBrowserContext());
+ app_id_, web_contents->GetBrowserContext());
DCHECK(app_activity_registry_);
// Register the activity.
app_activity_registry_->RegisterAppActivity(this);
diff --git a/athena/content/app_activity.h b/athena/content/app_activity.h
index 9984baf..9bacf45 100644
--- a/athena/content/app_activity.h
+++ b/athena/content/app_activity.h
@@ -27,7 +27,7 @@ class AppActivity : public Activity,
public ActivityViewModel,
public content::WebContentsObserver {
public:
- AppActivity();
+ explicit AppActivity(const std::string& app_id);
virtual ~AppActivity();
// Activity:
@@ -53,9 +53,6 @@ class AppActivity : public Activity,
bool explicit_set) OVERRIDE;
virtual void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) OVERRIDE;
- virtual void DidStartNavigationToPendingEntry(
- const GURL& url,
- content::NavigationController::ReloadType reload_type) OVERRIDE;
protected:
virtual content::WebContents* GetWebContents() = 0;
@@ -64,6 +61,8 @@ class AppActivity : public Activity,
// Register this activity with its application.
void RegisterActivity();
+ const std::string app_id_;
+
views::WebView* web_view_;
// The current state for this activity.
diff --git a/athena/content/app_activity_registry.cc b/athena/content/app_activity_registry.cc
index dc7bce9..6b3f0af 100644
--- a/athena/content/app_activity_registry.cc
+++ b/athena/content/app_activity_registry.cc
@@ -7,8 +7,8 @@
#include "athena/activity/public/activity_manager.h"
#include "athena/content/app_activity.h"
#include "athena/content/app_activity_proxy.h"
-#include "athena/content/public/app_content_control_delegate.h"
#include "athena/content/public/app_registry.h"
+#include "athena/extensions/public/extensions_delegate.h"
#include "ui/aura/window.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -91,8 +91,7 @@ void AppActivityRegistry::Unload() {
MoveBeforeMruApplicationWindow(unloaded_activity_proxy_->GetWindow());
// Unload the application. This operation will be asynchronous.
- if (!AppRegistry::Get()->GetDelegate()->UnloadApplication(app_id_,
- browser_context_)) {
+ if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) {
while(!activity_list_.empty())
delete activity_list_.back();
}
@@ -110,8 +109,7 @@ void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) {
void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) {
DCHECK_EQ(unloaded_activity_proxy_, proxy);
// Restart the application.
- AppRegistry::Get()->GetDelegate()->RestartApplication(app_id_,
- browser_context_);
+ ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_);
// Remove the activity from the Activity manager.
ActivityManager::Get()->RemoveActivity(unloaded_activity_proxy_);
delete unloaded_activity_proxy_; // Will call ProxyDestroyed.
diff --git a/athena/content/app_activity_unittest.cc b/athena/content/app_activity_unittest.cc
index c62b374..44efd34 100644
--- a/athena/content/app_activity_unittest.cc
+++ b/athena/content/app_activity_unittest.cc
@@ -6,9 +6,10 @@
#include "athena/activity/public/activity_manager.h"
#include "athena/content/app_activity.h"
#include "athena/content/app_activity_registry.h"
-#include "athena/content/public/app_content_control_delegate.h"
#include "athena/content/public/app_registry.h"
+#include "athena/extensions/public/extensions_delegate.h"
#include "athena/test/athena_test_base.h"
+#include "extensions/common/extension_set.h"
#include "ui/aura/window.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -29,11 +30,10 @@ const char kDummyApp2[] = "bbbbbbb";
// A dummy test app activity which works without content / ShellAppWindow.
class TestAppActivity : public AppActivity {
public:
- explicit TestAppActivity(const std::string& app_id) :
- AppActivity(),
- app_id_(app_id),
- view_(new views::View()),
- current_state_(ACTIVITY_VISIBLE) {
+ explicit TestAppActivity(const std::string& app_id)
+ : AppActivity(app_id),
+ view_(new views::View()),
+ current_state_(ACTIVITY_VISIBLE) {
app_activity_registry_ =
AppRegistry::Get()->GetAppActivityRegistry(app_id, NULL);
app_activity_registry_->RegisterAppActivity(this);
@@ -67,9 +67,7 @@ class TestAppActivity : public AppActivity {
}
// AppActivity:
- virtual content::WebContents* GetWebContents() OVERRIDE {
- return NULL;
- }
+ virtual content::WebContents* GetWebContents() OVERRIDE { return NULL; }
// ActivityViewModel:
virtual void Init() OVERRIDE {}
@@ -83,9 +81,6 @@ class TestAppActivity : public AppActivity {
// If known the registry which holds all activities for the associated app.
AppActivityRegistry* app_activity_registry_;
- // The application ID.
- const std::string& app_id_;
-
// The title of the activity.
base::string16 title_;
@@ -99,45 +94,40 @@ class TestAppActivity : public AppActivity {
};
// An AppContentDelegateClass which we can query for call stats.
-class TestAppContentControlDelegate : public AppContentControlDelegate {
+class TestExtensionsDelegate : public ExtensionsDelegate {
public:
- TestAppContentControlDelegate() : unload_called_(0),
- restart_called_(0) {}
- virtual ~TestAppContentControlDelegate() {}
-
- int unload_called() { return unload_called_; }
- int restart_called() { return restart_called_; }
- void SetExtensionID(const std::string& extension_id) {
- extension_id_to_return_ = extension_id;
- }
+ TestExtensionsDelegate() : unload_called_(0), restart_called_(0) {}
+ virtual ~TestExtensionsDelegate() {}
+
+ int unload_called() const { return unload_called_; }
+ int restart_called() const { return restart_called_; }
+ // ExtensionsDelegate:
+ virtual content::BrowserContext* GetBrowserContext() const OVERRIDE {
+ return NULL;
+ }
+ virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE {
+ return extension_set_;
+ }
// Unload an application. Returns true when unloaded.
- virtual bool UnloadApplication(
- const std::string& app_id,
- content::BrowserContext* browser_context) OVERRIDE {
+ virtual bool UnloadApp(const std::string& app_id) OVERRIDE {
unload_called_++;
// Since we did not close anything we let the framework clean up.
return false;
}
// Restarts an application. Returns true when the restart was initiated.
- virtual bool RestartApplication(
- const std::string& app_id,
- content::BrowserContext* browser_context) OVERRIDE {
+ virtual bool LaunchApp(const std::string& app_id) OVERRIDE {
restart_called_++;
return true;
}
- // Returns the application ID (or an empty string) for a given web content.
- virtual std::string GetApplicationID(
- content::WebContents* web_contents) OVERRIDE {
- return extension_id_to_return_;
- }
private:
int unload_called_;
int restart_called_;
- std::string extension_id_to_return_;
- DISALLOW_COPY_AND_ASSIGN(TestAppContentControlDelegate);
+ extensions::ExtensionSet extension_set_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestExtensionsDelegate);
};
} // namespace
@@ -145,15 +135,16 @@ class TestAppContentControlDelegate : public AppContentControlDelegate {
// Our testing base.
class AppActivityTest : public AthenaTestBase {
public:
- AppActivityTest() : test_app_content_control_delegate_(NULL) {}
+ AppActivityTest() : test_extensions_delegate_(NULL) {}
virtual ~AppActivityTest() {}
// AthenaTestBase:
virtual void SetUp() OVERRIDE {
AthenaTestBase::SetUp();
// Create and install our TestAppContentDelegate with instrumentation.
- test_app_content_control_delegate_ = new TestAppContentControlDelegate();
- AppRegistry::Get()->SetDelegate(test_app_content_control_delegate_);
+ ExtensionsDelegate::Shutdown();
+ // The instance will be deleted by ExtensionsDelegate::Shutdown().
+ test_extensions_delegate_ = new TestExtensionsDelegate();
}
// A function to create an Activity.
@@ -181,12 +172,12 @@ class AppActivityTest : public AthenaTestBase {
}
protected:
- TestAppContentControlDelegate* test_app_content_control_delegate() {
- return test_app_content_control_delegate_;
+ TestExtensionsDelegate* test_extensions_delegate() {
+ return test_extensions_delegate_;
}
private:
- TestAppContentControlDelegate* test_app_content_control_delegate_;
+ TestExtensionsDelegate* test_extensions_delegate_;
DISALLOW_COPY_AND_ASSIGN(AppActivityTest);
};
@@ -203,8 +194,8 @@ TEST_F(AppActivityTest, OneAppActivity) {
CloseActivity(app_activity);
}
EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
- EXPECT_EQ(0, test_app_content_control_delegate()->unload_called());
- EXPECT_EQ(0, test_app_content_control_delegate()->restart_called());
+ EXPECT_EQ(0, test_extensions_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->restart_called());
}
// Test running of two applications.
@@ -222,8 +213,8 @@ TEST_F(AppActivityTest, TwoAppsWithOneActivityEach) {
CloseActivity(app_activity2);
}
EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
- EXPECT_EQ(0, test_app_content_control_delegate()->unload_called());
- EXPECT_EQ(0, test_app_content_control_delegate()->restart_called());
+ EXPECT_EQ(0, test_extensions_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->restart_called());
}
// Create and destroy two activities for the same application.
@@ -255,8 +246,8 @@ TEST_F(AppActivityTest, TwoAppActivities) {
CloseActivity(app_activity1);
}
EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
- EXPECT_EQ(0, test_app_content_control_delegate()->unload_called());
- EXPECT_EQ(0, test_app_content_control_delegate()->restart_called());
+ EXPECT_EQ(0, test_extensions_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->restart_called());
}
// Test unload and the creation of the proxy, then "closing the activity".
@@ -273,13 +264,13 @@ TEST_F(AppActivityTest, TestUnloadFollowedByClose) {
// Calling Unload now should not do anything since at least one activity in
// the registry is still visible.
app_activity_registry->Unload();
- EXPECT_EQ(0, test_app_content_control_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->unload_called());
// After setting our activity to unloaded however the application should get
// unloaded as requested.
app_activity->SetCurrentState(Activity::ACTIVITY_UNLOADED);
app_activity_registry->Unload();
- EXPECT_EQ(1, test_app_content_control_delegate()->unload_called());
+ EXPECT_EQ(1, test_extensions_delegate()->unload_called());
// Check that our created application is gone, and instead a proxy got
// created.
@@ -297,8 +288,8 @@ TEST_F(AppActivityTest, TestUnloadFollowedByClose) {
CloseActivity(activity_proxy);
EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
- EXPECT_EQ(1, test_app_content_control_delegate()->unload_called());
- EXPECT_EQ(0, test_app_content_control_delegate()->restart_called());
+ EXPECT_EQ(1, test_extensions_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->restart_called());
}
// Test that when unloading an app while multiple apps / activities are present,
@@ -357,13 +348,13 @@ TEST_F(AppActivityTest, TestMultipleActivityUnloadLock) {
// After setting all activities to UNLOADED the application should unload.
app_activity1->SetCurrentState(Activity::ACTIVITY_UNLOADED);
app_activity1->app_activity_registry()->Unload();
- EXPECT_EQ(0, test_app_content_control_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->unload_called());
app_activity2->SetCurrentState(Activity::ACTIVITY_UNLOADED);
app_activity2->app_activity_registry()->Unload();
- EXPECT_EQ(0, test_app_content_control_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->unload_called());
app_activity3->SetCurrentState(Activity::ACTIVITY_UNLOADED);
app_activity3->app_activity_registry()->Unload();
- EXPECT_EQ(1, test_app_content_control_delegate()->unload_called());
+ EXPECT_EQ(1, test_extensions_delegate()->unload_called());
// Now there should only be the proxy activity left.
ASSERT_EQ(1, AppRegistry::Get()->NumberOfApplications());
@@ -382,8 +373,8 @@ TEST_F(AppActivityTest, TestMultipleActivityUnloadLock) {
CloseActivity(activity_proxy);
EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
- EXPECT_EQ(1, test_app_content_control_delegate()->unload_called());
- EXPECT_EQ(0, test_app_content_control_delegate()->restart_called());
+ EXPECT_EQ(1, test_extensions_delegate()->unload_called());
+ EXPECT_EQ(0, test_extensions_delegate()->restart_called());
}
// Test that activating the proxy will reload the application.
@@ -397,14 +388,14 @@ TEST_F(AppActivityTest, TestUnloadWithReload) {
// Unload the activity.
app_activity->SetCurrentState(Activity::ACTIVITY_UNLOADED);
app_activity_registry->Unload();
- EXPECT_EQ(1, test_app_content_control_delegate()->unload_called());
+ EXPECT_EQ(1, test_extensions_delegate()->unload_called());
// Try to activate the activity again. This will force the application to
// reload.
Activity* activity_proxy =
app_activity_registry->unloaded_activity_proxy_for_test();
activity_proxy->SetCurrentState(Activity::ACTIVITY_VISIBLE);
- EXPECT_EQ(1, test_app_content_control_delegate()->restart_called());
+ EXPECT_EQ(1, test_extensions_delegate()->restart_called());
// However - the restart in this test framework does not really restart and
// all objects should be gone now.
diff --git a/athena/content/app_registry_impl.cc b/athena/content/app_registry_impl.cc
index a140f11..69510c7 100644
--- a/athena/content/app_registry_impl.cc
+++ b/athena/content/app_registry_impl.cc
@@ -5,7 +5,6 @@
#include "athena/content/public/app_registry.h"
#include "athena/content/app_activity_registry.h"
-#include "athena/content/public/app_content_control_delegate.h"
#include "base/logging.h"
namespace athena {
@@ -16,8 +15,6 @@ class AppRegistryImpl : public AppRegistry {
virtual ~AppRegistryImpl();
// AppRegistry:
- virtual void SetDelegate(AppContentControlDelegate* delegate) OVERRIDE;
- virtual AppContentControlDelegate* GetDelegate() OVERRIDE;
virtual AppActivityRegistry* GetAppActivityRegistry(
const std::string& app_id,
content::BrowserContext* browser_context) OVERRIDE;
@@ -27,9 +24,7 @@ class AppRegistryImpl : public AppRegistry {
virtual void RemoveAppActivityRegistry(
AppActivityRegistry* registry) OVERRIDE;
- std::vector<AppActivityRegistry*> app_list_;
-
- scoped_ptr<AppContentControlDelegate> delegate_;
+ std::vector<AppActivityRegistry*> app_list_;
DISALLOW_COPY_AND_ASSIGN(AppRegistryImpl);
};
@@ -40,22 +35,12 @@ AppRegistryImpl* instance = NULL;
} // namespace
-AppRegistryImpl::AppRegistryImpl() :
- delegate_(AppContentControlDelegate::CreateAppContentControlDelegate()) {}
-
+AppRegistryImpl::AppRegistryImpl() {
+}
AppRegistryImpl::~AppRegistryImpl() {
DCHECK(app_list_.empty());
}
-void AppRegistryImpl::SetDelegate(AppContentControlDelegate* delegate) {
- DCHECK(delegate);
- delegate_.reset(delegate);
-}
-
-AppContentControlDelegate* AppRegistryImpl::GetDelegate() {
- return delegate_.get();
-}
-
AppActivityRegistry* AppRegistryImpl::GetAppActivityRegistry(
const std::string& app_id,
content::BrowserContext* browser_context) {
diff --git a/athena/content/content_activity_factory.h b/athena/content/content_activity_factory.h
index 18c66b7..bf3031c 100644
--- a/athena/content/content_activity_factory.h
+++ b/athena/content/content_activity_factory.h
@@ -18,8 +18,8 @@ class ContentActivityFactory : public ActivityFactory {
// Overridden from ActivityFactory:
virtual Activity* CreateWebActivity(content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
- virtual Activity* CreateAppActivity(
- extensions::ShellAppWindow* app_window) OVERRIDE;
+ virtual Activity* CreateAppActivity(extensions::ShellAppWindow* app_window,
+ const std::string& app_id) OVERRIDE;
virtual Activity* CreateAppActivity(apps::AppWindow* app_window) OVERRIDE;
private:
diff --git a/athena/content/public/app_content_control_delegate.h b/athena/content/public/app_content_control_delegate.h
deleted file mode 100644
index ad3e553..0000000
--- a/athena/content/public/app_content_control_delegate.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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_CONTENT_PUBLIC_APP_CONTENT_CONTROL_DLEGATE_H_
-#define ATHENA_CONTENT_PUBLIC_APP_CONTENT_CONTROL_DLEGATE_H_
-
-#include <string>
-
-#include "base/macros.h"
-
-namespace content {
-class BrowserContext;
-class WebContents;
-}
-
-namespace athena {
-
-// The application content delegate which can be overwritten for unit tests to
-// eliminate dependencies to the content / browser system.
-class AppContentControlDelegate {
- public:
- static AppContentControlDelegate* CreateAppContentControlDelegate();
-
- AppContentControlDelegate() {}
- virtual ~AppContentControlDelegate() {}
-
- // Unload an application. Returns true when unloaded.
- virtual bool UnloadApplication(const std::string& app_id,
- content::BrowserContext* browser_context) = 0;
- // Restarts an application. Returns true when the restart was initiated.
- virtual bool RestartApplication(const std::string& app_id,
- content::BrowserContext* browser_context) = 0;
- // Returns the application ID (or an empty string) for a given web content.
- virtual std::string GetApplicationID(content::WebContents* web_contents) = 0;
-};
-
-} // namespace athena
-
-#endif // ATHENA_CONTENT_PUBLIC_APP_CONTENT_CONTROL_DLEGATE_H_
diff --git a/athena/content/public/app_registry.h b/athena/content/public/app_registry.h
index c296f2e..095beba 100644
--- a/athena/content/public/app_registry.h
+++ b/athena/content/public/app_registry.h
@@ -19,7 +19,6 @@ class BrowserContext;
namespace athena {
class AppActivityRegistry;
-class AppContentControlDelegate;
class AppRegistryImpl;
// This class holds for each application, held by a user, a list of activities.
@@ -37,14 +36,6 @@ class ATHENA_EXPORT AppRegistry {
// Shuts down the registry (all applications should be shut down by then).
static void ShutDown();
- // Overrides the used AppContentDelegate. This function will own it
- // afterwards. A value of NULL is invalid.
- virtual void SetDelegate(AppContentControlDelegate* delegate) = 0;
-
- // Retrieves the application content delegate. The ownership remains with this
- // class.
- virtual AppContentControlDelegate* GetDelegate() = 0;
-
// Returns an |AppActivityRegistry| for a given activity |app_id| and
// |browser_context|.
virtual AppActivityRegistry* GetAppActivityRegistry(
diff --git a/athena/content/shell/content_activity_factory.cc b/athena/content/shell/content_activity_factory.cc
index c150f32..538ca26 100644
--- a/athena/content/shell/content_activity_factory.cc
+++ b/athena/content/shell/content_activity_factory.cc
@@ -9,8 +9,9 @@
namespace athena {
Activity* ContentActivityFactory::CreateAppActivity(
- extensions::ShellAppWindow* app_window) {
- return new ShellAppActivity(app_window);
+ extensions::ShellAppWindow* app_window,
+ const std::string& app_id) {
+ return new ShellAppActivity(app_window, app_id);
}
Activity* ContentActivityFactory::CreateAppActivity(
diff --git a/athena/content/shell/shell_app_activity.cc b/athena/content/shell/shell_app_activity.cc
index 77824f2..7e414e7 100644
--- a/athena/content/shell/shell_app_activity.cc
+++ b/athena/content/shell/shell_app_activity.cc
@@ -8,11 +8,13 @@
namespace athena {
-ShellAppActivity::ShellAppActivity(extensions::ShellAppWindow* app_window)
- : shell_app_window_(app_window) {
+ShellAppActivity::ShellAppActivity(extensions::ShellAppWindow* app_window,
+ const std::string& app_id)
+ : AppActivity(app_id), shell_app_window_(app_window) {
}
-ShellAppActivity::~ShellAppActivity() {}
+ShellAppActivity::~ShellAppActivity() {
+}
content::WebContents* ShellAppActivity::GetWebContents() {
return shell_app_window_->GetAssociatedWebContents();
diff --git a/athena/content/shell/shell_app_activity.h b/athena/content/shell/shell_app_activity.h
index baea929..f91c555 100644
--- a/athena/content/shell/shell_app_activity.h
+++ b/athena/content/shell/shell_app_activity.h
@@ -17,7 +17,8 @@ namespace athena {
class ShellAppActivity : public AppActivity {
public:
- explicit ShellAppActivity(extensions::ShellAppWindow* app_window);
+ ShellAppActivity(extensions::ShellAppWindow* app_window,
+ const std::string& app_id);
virtual ~ShellAppActivity();
private:
diff --git a/athena/extensions/public/extensions_delegate.h b/athena/extensions/public/extensions_delegate.h
index 5fc1b29..394ea82 100644
--- a/athena/extensions/public/extensions_delegate.h
+++ b/athena/extensions/public/extensions_delegate.h
@@ -11,6 +11,7 @@
namespace content {
class BrowserContext;
+class WebContents;
}
namespace extensions {
@@ -43,8 +44,13 @@ class ATHENA_EXPORT ExtensionsDelegate {
// Returns the set of extensions that are currently installed.
virtual const extensions::ExtensionSet& GetInstalledExtensions() = 0;
- // Launch an application specified by |app_id|.
- virtual void LaunchApp(const std::string& app_id) = 0;
+ // Starts an application. Returns true if the application was
+ // successfully started.
+ virtual bool LaunchApp(const std::string& app_id) = 0;
+
+ // Unload an application. Returns true if the application was
+ // successfully unloaded.
+ virtual bool UnloadApp(const std::string& app_id) = 0;
};
} // namespace athena
diff --git a/athena/extensions/shell/extensions_delegate_impl.cc b/athena/extensions/shell/extensions_delegate_impl.cc
index da3566c..1316177 100644
--- a/athena/extensions/shell/extensions_delegate_impl.cc
+++ b/athena/extensions/shell/extensions_delegate_impl.cc
@@ -30,10 +30,13 @@ class ShellExtensionsDelegate : public ExtensionsDelegate {
shell_extensions_.Insert(extension_system_->extension());
return shell_extensions_;
}
- virtual void LaunchApp(const std::string& app_id) OVERRIDE {
+ virtual bool LaunchApp(const std::string& app_id) OVERRIDE {
extension_system_->LaunchApp();
+ return true;
}
+ virtual bool UnloadApp(const std::string& app_id) OVERRIDE { return false; }
+
content::BrowserContext* context_;
extensions::ShellExtensionSystem* extension_system_;
extensions::ExtensionSet shell_extensions_;
diff --git a/athena/extensions/test/test_extensions_delegate.cc b/athena/extensions/test/test_extensions_delegate.cc
index cac6a00..d22bf29 100644
--- a/athena/extensions/test/test_extensions_delegate.cc
+++ b/athena/extensions/test/test_extensions_delegate.cc
@@ -23,7 +23,8 @@ class TestExtensionsDelegate : public ExtensionsDelegate {
virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE {
return shell_extensions_;
}
- virtual void LaunchApp(const std::string& app_id) OVERRIDE {}
+ virtual bool LaunchApp(const std::string& app_id) OVERRIDE { return true; }
+ virtual bool UnloadApp(const std::string& app_id) OVERRIDE { return false; }
extensions::ExtensionSet shell_extensions_;
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index b3d825e..f003ba5 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -53,7 +53,8 @@ class AthenaDesktopController : public extensions::DesktopController {
extensions::ShellAppWindow* app_window = new extensions::ShellAppWindow();
app_window->Init(context, extension, gfx::Size(100, 100));
athena::ActivityManager::Get()->AddActivity(
- athena::ActivityFactory::Get()->CreateAppActivity(app_window));
+ athena::ActivityFactory::Get()->CreateAppActivity(app_window,
+ extension->id()));
return app_window;
}
diff --git a/athena/test/sample_activity_factory.cc b/athena/test/sample_activity_factory.cc
index 71ffef5..b043e17 100644
--- a/athena/test/sample_activity_factory.cc
+++ b/athena/test/sample_activity_factory.cc
@@ -35,7 +35,8 @@ Activity* SampleActivityFactory::CreateWebActivity(
}
Activity* SampleActivityFactory::CreateAppActivity(
- extensions::ShellAppWindow* app_window) {
+ extensions::ShellAppWindow* app_window,
+ const std::string& app_id) {
// SampleActivityFactory can't own the |app_window|, so it must be NULL.
DCHECK(app_window == NULL);
return new SampleActivity(
diff --git a/athena/test/sample_activity_factory.h b/athena/test/sample_activity_factory.h
index 46d4b94..5dd9e1a 100644
--- a/athena/test/sample_activity_factory.h
+++ b/athena/test/sample_activity_factory.h
@@ -19,10 +19,9 @@ class SampleActivityFactory : public ActivityFactory {
// Overridden from ActivityFactory:
virtual Activity* CreateWebActivity(content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
- virtual Activity* CreateAppActivity(
- extensions::ShellAppWindow* app_window) OVERRIDE;
- virtual Activity* CreateAppActivity(
- apps::AppWindow* app_window) OVERRIDE;
+ virtual Activity* CreateAppActivity(extensions::ShellAppWindow* app_window,
+ const std::string& app_id) OVERRIDE;
+ virtual Activity* CreateAppActivity(apps::AppWindow* app_window) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(SampleActivityFactory);