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