Commit fbda35b8 authored by mukai@chromium.org's avatar mukai@chromium.org

Introduces ActivityFactory for SampleActivity.

BUG=None
R=oshima@chromium.org
TBR=reed@google.com
TEST=athena_shell

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275393 0039d316-1c4b-4281-b951-d872f2087c98
parent 21f6da37
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
'../ui/compositor/compositor.gyp:compositor_test_support', '../ui/compositor/compositor.gyp:compositor_test_support',
'../ui/views/views.gyp:views', '../ui/views/views.gyp:views',
'../ui/wm/wm.gyp:wm', '../ui/wm/wm.gyp:wm',
'../url/url.gyp:url_lib',
'athena_lib', 'athena_lib',
], ],
'sources': [ 'sources': [
...@@ -87,6 +88,10 @@ ...@@ -87,6 +88,10 @@
'test/athena_test_base.h', 'test/athena_test_base.h',
'test/athena_test_helper.cc', 'test/athena_test_helper.cc',
'test/athena_test_helper.h', 'test/athena_test_helper.h',
'test/sample_activity.cc',
'test/sample_activity.h',
'test/sample_activity_factory.cc',
'test/sample_activity_factory.h',
], ],
}, },
{ {
......
...@@ -22,7 +22,6 @@ specific_include_rules = { ...@@ -22,7 +22,6 @@ specific_include_rules = {
], ],
"athena_shell\.cc": [ "athena_shell\.cc": [
"+athena/test", "+athena/test",
"+third_party/skia/include/core",
], ],
# TODO(oshima): Remove this. # TODO(oshima): Remove this.
"placeholder\.*": [ "placeholder\.*": [
......
...@@ -35,7 +35,8 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::RootWindowState, ...@@ -35,7 +35,8 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::RootWindowState,
kRootWindowStateKey, kRootWindowStateKey,
NULL); NULL);
void StartAthena(aura::Window* root_window) { void StartAthena(aura::Window* root_window,
athena::ActivityFactory* activity_factory) {
#if defined(USE_X11) #if defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine(); ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif #endif
...@@ -50,10 +51,12 @@ void StartAthena(aura::Window* root_window) { ...@@ -50,10 +51,12 @@ void StartAthena(aura::Window* root_window) {
athena::WindowManager::Create(); athena::WindowManager::Create();
athena::HomeCard::Create(); athena::HomeCard::Create();
athena::ActivityManager::Create(); athena::ActivityManager::Create();
athena::ActivityFactory::RegisterActivityFactory(activity_factory);
SetupBackgroundImage(); SetupBackgroundImage();
} }
void ShutdownAthena() { void ShutdownAthena() {
athena::ActivityFactory::Shutdown();
athena::ActivityManager::Shutdown(); athena::ActivityManager::Shutdown();
athena::HomeCard::Shutdown(); athena::HomeCard::Shutdown();
athena::WindowManager::Shutdown(); athena::WindowManager::Shutdown();
......
...@@ -10,9 +10,11 @@ class Window; ...@@ -10,9 +10,11 @@ class Window;
} }
namespace athena { namespace athena {
class ActivityFactory;
// Starts/shuts down the athena shell environment. // Starts/shuts down the athena shell environment.
void StartAthena(aura::Window* root_window); void StartAthena(aura::Window* root_window,
ActivityFactory* activity_factory);
void ShutdownAthena(); void ShutdownAthena();
} // namespace athena } // namespace athena
......
...@@ -21,19 +21,13 @@ class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { ...@@ -21,19 +21,13 @@ class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
// apps::ShellBrowserMainDelegate: // apps::ShellBrowserMainDelegate:
virtual void Start(content::BrowserContext* context) OVERRIDE { virtual void Start(content::BrowserContext* context) OVERRIDE {
athena::StartAthena( athena::StartAthena(
apps::ShellDesktopController::instance()->host()->window()); apps::ShellDesktopController::instance()->host()->window(),
athena::ActivityFactory::RegisterActivityFactory(
new athena::ContentActivityFactory()); new athena::ContentActivityFactory());
CreateTestWindows(); CreateTestWindows();
CreateTestPages(context); CreateTestPages(context);
} }
virtual void Shutdown() OVERRIDE { virtual void Shutdown() OVERRIDE { athena::ShutdownAthena(); }
// TODO(mukai):cleanup the start/shutdown processes and the dependency to
// ContentActivityFactory.
athena::ActivityFactory::Shutdown();
athena::ShutdownAthena();
}
virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE { virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE {
// TODO(mukai): create Athena's own ShellDesktopController subclass so that // TODO(mukai): create Athena's own ShellDesktopController subclass so that
......
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
], ],
'sources': [ 'sources': [
'athena_shell.cc', 'athena_shell.cc',
'sample_activity.cc',
'sample_activity.h',
], ],
} }
], # targets ], # targets
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h" #include "athena/activity/public/activity_manager.h"
#include "athena/main/sample_activity.h"
#include "athena/test/athena_test_helper.h" #include "athena/test/athena_test_helper.h"
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
...@@ -32,9 +31,9 @@ class UIShell { ...@@ -32,9 +31,9 @@ class UIShell {
} }
void InitSampleActivities() { void InitSampleActivities() {
athena::Activity* task = new SampleActivity( athena::ActivityManager::Get()->AddActivity(
SK_ColorRED, SK_ColorGREEN, std::string("Activity 1")); athena::ActivityFactory::Get()->CreateWebActivity(
athena::ActivityManager::Get()->AddActivity(task); NULL, GURL("http://www.google.com/")));
} }
private: private:
......
include_rules = [ include_rules = [
"+athena/activity",
"+athena/main", "+athena/main",
"+third_party/skia/include",
"+ui/aura", "+ui/aura",
"+ui/base", "+ui/base",
"+ui/compositor", "+ui/compositor",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "athena/test/athena_test_helper.h" #include "athena/test/athena_test_helper.h"
#include "athena/main/athena_launcher.h" #include "athena/main/athena_launcher.h"
#include "athena/test/sample_activity_factory.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
...@@ -77,7 +78,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -77,7 +78,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
// Ensure width != height so tests won't confuse them. // Ensure width != height so tests won't confuse them.
host()->SetBounds(gfx::Rect(800, 600)); host()->SetBounds(gfx::Rect(800, 600));
athena::StartAthena(root_window()); athena::StartAthena(root_window(), new SampleActivityFactory());
} }
void AthenaTestHelper::TearDown() { void AthenaTestHelper::TearDown() {
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/main/sample_activity.h" #include "athena/test/sample_activity.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
namespace athena {
namespace test {
SampleActivity::SampleActivity(SkColor color, SampleActivity::SampleActivity(SkColor color,
SkColor content_color, SkColor content_color,
const std::string& title) const std::string& title)
...@@ -35,3 +38,6 @@ aura::Window* SampleActivity::GetNativeWindow() { ...@@ -35,3 +38,6 @@ aura::Window* SampleActivity::GetNativeWindow() {
} }
return window_.get(); return window_.get();
} }
} // namespace test
} // namespace athena
...@@ -2,15 +2,18 @@ ...@@ -2,15 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATHENA_MAIN_SAMPLE_ACTIVITY_H_ #ifndef ATHENA_TEST_SAMPLE_ACTIVITY_H_
#define ATHENA_MAIN_SAMPLE_ACTIVITY_H_ #define ATHENA_TEST_SAMPLE_ACTIVITY_H_
#include "athena/activity/public/activity.h" #include "athena/activity/public/activity.h"
#include "athena/activity/public/activity_view_model.h" #include "athena/activity/public/activity_view_model.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
class SampleActivity : public athena::Activity, namespace athena {
public athena::ActivityViewModel { namespace test {
class SampleActivity : public Activity,
public ActivityViewModel {
public: public:
SampleActivity(SkColor color, SkColor content, const std::string& title); SampleActivity(SkColor color, SkColor content, const std::string& title);
virtual ~SampleActivity(); virtual ~SampleActivity();
...@@ -32,4 +35,7 @@ class SampleActivity : public athena::Activity, ...@@ -32,4 +35,7 @@ class SampleActivity : public athena::Activity,
DISALLOW_COPY_AND_ASSIGN(SampleActivity); DISALLOW_COPY_AND_ASSIGN(SampleActivity);
}; };
#endif // ATHENA_MAIN_SAMPLE_ACTIVITY_H_ } // namespace test
} // namespace athena
#endif // ATHENA_TEST_SAMPLE_ACTIVITY_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/test/sample_activity_factory.h"
#include <string>
#include "athena/test/sample_activity.h"
#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
namespace athena {
namespace test {
namespace {
const SkColor kDefaultColor = SK_ColorRED;
const SkColor kDefaultContentColor = SK_ColorGREEN;
}
SampleActivityFactory::SampleActivityFactory() {}
SampleActivityFactory::~SampleActivityFactory() {}
Activity* SampleActivityFactory::CreateWebActivity(
content::BrowserContext* browser_context,
const GURL& url) {
return new SampleActivity(
kDefaultColor, kDefaultContentColor, url.spec());
}
} // namespace test
} // 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_TEST_SAMPLE_ACTIVITY_FACTORY_H_
#define ATHENA_TEST_SAMPLE_ACTIVITY_FACTORY_H_
#include "athena/activity/public/activity_factory.h"
#include "base/macros.h"
namespace athena {
namespace test {
class SampleActivityFactory : public ActivityFactory {
public:
SampleActivityFactory();
virtual ~SampleActivityFactory();
// Overridden from ActivityFactory:
virtual Activity* CreateWebActivity(content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(SampleActivityFactory);
};
} // namespace test
} // namespace athena
#endif // ATHENA_TEST_SAMPLE_ACTIVITY_FACTORY_H_
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