summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-31 04:27:24 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-31 04:27:24 +0000
commit5a1e6026ab247c6f4d4a850a20a35b34cd7d3715 (patch)
tree709e415a31bc73850c1af7056de737f11916f65c /athena
parentedffa7a2736436b8b2810d28f3e6e553a50f7e56 (diff)
downloadchromium_src-5a1e6026ab247c6f4d4a850a20a35b34cd7d3715.zip
chromium_src-5a1e6026ab247c6f4d4a850a20a35b34cd7d3715.tar.gz
chromium_src-5a1e6026ab247c6f4d4a850a20a35b34cd7d3715.tar.bz2
athena: Add the concept of Activity and related managers.
An Activity can be a WebActivity, a SampleActivity etc. Each Activity has an ActivityViewModel. The ActivityViewModel describes the UI for the Activity. The ActivityManager is there to manage the list of activities. It is the source of all the activities that various other activity-managers would use. The ActivityViewManager is notified of activity updates from the ActivityManager, and it creates the appropriate UI elements (views::Widget, etc.) to show the UI for the activity to the user. BUG=376357 R=oshima@chromium.org, skuhne@chromium.org TBR=ben@chromium.org Review URL: https://codereview.chromium.org/302683002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena')
-rw-r--r--athena/activity/DEPS5
-rw-r--r--athena/activity/activity_manager_impl.cc86
-rw-r--r--athena/activity/activity_view_manager_impl.cc166
-rw-r--r--athena/activity/public/DEPS4
-rw-r--r--athena/activity/public/activity.h26
-rw-r--r--athena/activity/public/activity_manager.h33
-rw-r--r--athena/activity/public/activity_view_manager.h33
-rw-r--r--athena/activity/public/activity_view_model.h36
-rw-r--r--athena/athena.gyp6
-rw-r--r--athena/main/DEPS5
-rw-r--r--athena/main/athena_launcher.cc3
-rw-r--r--athena/main/athena_main.cc2
-rw-r--r--athena/main/athena_main.gyp6
-rw-r--r--athena/main/athena_shell.cc19
-rw-r--r--athena/main/placeholder_content.cc25
-rw-r--r--athena/main/placeholder_content.h15
-rw-r--r--athena/main/sample_activity.cc37
-rw-r--r--athena/main/sample_activity.h35
-rw-r--r--athena/main/web_activity.cc44
-rw-r--r--athena/main/web_activity.h42
20 files changed, 628 insertions, 0 deletions
diff --git a/athena/activity/DEPS b/athena/activity/DEPS
new file mode 100644
index 0000000..aafc6d4
--- /dev/null
+++ b/athena/activity/DEPS
@@ -0,0 +1,5 @@
+include_rules = [
+ "+athena/screen",
+ "+ui/aura",
+ "+ui/views",
+]
diff --git a/athena/activity/activity_manager_impl.cc b/athena/activity/activity_manager_impl.cc
new file mode 100644
index 0000000..e20930e
--- /dev/null
+++ b/athena/activity/activity_manager_impl.cc
@@ -0,0 +1,86 @@
+// 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/activity/public/activity_manager.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "athena/activity/public/activity_view_manager.h"
+#include "base/logging.h"
+
+namespace athena {
+
+namespace {
+
+ActivityManager* instance = NULL;
+
+class ActivityManagerImpl : public ActivityManager {
+ public:
+ ActivityManagerImpl() {
+ CHECK(!instance);
+ instance = this;
+ }
+ virtual ~ActivityManagerImpl() {
+ CHECK_EQ(this, instance);
+ instance = NULL;
+ }
+
+ // ActivityManager:
+ virtual void AddActivity(Activity* activity) OVERRIDE {
+ CHECK(activities_.end() == std::find(activities_.begin(),
+ activities_.end(),
+ activity));
+ activities_.push_back(activity);
+ ActivityViewManager* manager = ActivityViewManager::Get();
+ manager->AddActivity(activity);
+ }
+
+ virtual void RemoveActivity(Activity* activity) OVERRIDE {
+ std::vector<Activity*>::iterator find = std::find(activities_.begin(),
+ activities_.end(),
+ activity);
+ if (find != activities_.end()) {
+ activities_.erase(find);
+
+ ActivityViewManager* manager = ActivityViewManager::Get();
+ manager->AddActivity(activity);
+ }
+ }
+
+ virtual void UpdateActivity(Activity* activity) OVERRIDE {
+ ActivityViewManager* manager = ActivityViewManager::Get();
+ manager->UpdateActivity(activity);
+ }
+
+ private:
+ std::vector<Activity*> activities_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActivityManagerImpl);
+};
+
+} // namespace
+
+// static
+ActivityManager* ActivityManager::Create() {
+ new ActivityManagerImpl();
+ CHECK(instance);
+
+ ActivityViewManager::Create();
+
+ return instance;
+}
+
+ActivityManager* ActivityManager::Get() {
+ return instance;
+}
+
+void ActivityManager::Shutdown() {
+ ActivityViewManager::Shutdown();
+
+ CHECK(instance);
+ delete instance;
+}
+
+} // namespace athena
diff --git a/athena/activity/activity_view_manager_impl.cc b/athena/activity/activity_view_manager_impl.cc
new file mode 100644
index 0000000..eaf0792
--- /dev/null
+++ b/athena/activity/activity_view_manager_impl.cc
@@ -0,0 +1,166 @@
+// 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/activity/public/activity_view_manager.h"
+
+#include <algorithm>
+#include <map>
+
+#include "athena/activity/public/activity.h"
+#include "athena/activity/public/activity_view_model.h"
+#include "athena/screen/public/screen_manager.h"
+#include "base/strings/utf_string_conversions.h"
+#include "ui/aura/window.h"
+#include "ui/views/background.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/controls/native/native_view_host.h"
+#include "ui/views/layout/layout_manager.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
+
+namespace athena {
+namespace {
+
+class ActivityWidget : public views::LayoutManager {
+ public:
+ explicit ActivityWidget(Activity* activity)
+ : activity_(activity),
+ container_(NULL),
+ title_(NULL),
+ host_(NULL),
+ widget_(NULL) {
+ container_ = new views::View;
+
+ title_ = new views::Label();
+ title_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
+ const gfx::FontList& font_list = title_->font_list();
+ title_->SetFontList(font_list.Derive(1, gfx::Font::BOLD));
+ title_->SetEnabledColor(SK_ColorBLACK);
+ title_->SetShadowColors(SK_ColorWHITE, SK_ColorWHITE);
+ title_->set_shadow_blur(.5);
+ container_->AddChildView(title_);
+ container_->SetLayoutManager(this);
+
+ host_ = new views::NativeViewHost();
+ container_->AddChildView(host_);
+
+ widget_ = new views::Widget;
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.context = ScreenManager::Get()->GetContext();
+ params.delegate = NULL;
+ params.activatable = views::Widget::InitParams::ACTIVATABLE_YES;
+ widget_->Init(params);
+ widget_->SetContentsView(container_);
+
+ host_->Attach(activity_->GetActivityViewModel()->GetNativeWindow());
+ }
+
+ virtual ~ActivityWidget() {}
+
+ void Show() {
+ Update();
+ widget_->Show();
+ }
+
+ void Update() {
+ title_->SetText(
+ base::UTF8ToUTF16(activity_->GetActivityViewModel()->GetTitle()));
+ title_->set_background(views::Background::CreateSolidBackground(
+ activity_->GetActivityViewModel()->GetRepresentativeColor()));
+ }
+
+ private:
+ // views::LayoutManager:
+ virtual void Layout(views::View* host) OVERRIDE {
+ CHECK_EQ(container_, host);
+ const gfx::Rect& host_bounds = host->bounds();
+ const int kTitleHeight = 25;
+ title_->SetBounds(0, 0, host_bounds.width(), kTitleHeight);
+ host_->SetBounds(0,
+ kTitleHeight,
+ host_bounds.width(),
+ host_bounds.height() - kTitleHeight);
+ }
+
+ virtual gfx::Size GetPreferredSize(const views::View* host) const OVERRIDE {
+ CHECK_EQ(container_, host);
+ gfx::Size size;
+ gfx::Size label_size = title_->GetPreferredSize();
+ gfx::Size host_size = host_->GetPreferredSize();
+
+ size.set_width(std::max(label_size.width(), host_size.width()));
+ size.set_height(label_size.height() + host_size.height());
+ return size;
+ }
+
+ Activity* activity_;
+ views::View* container_;
+ views::Label* title_;
+ views::NativeViewHost* host_;
+ views::Widget* widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActivityWidget);
+};
+
+ActivityViewManager* instance = NULL;
+
+class ActivityViewManagerImpl : public ActivityViewManager {
+ public:
+ ActivityViewManagerImpl() {
+ CHECK(!instance);
+ instance = this;
+ }
+ virtual ~ActivityViewManagerImpl() {
+ CHECK_EQ(this, instance);
+ instance = NULL;
+ }
+
+ // ActivityViewManager:
+ virtual void AddActivity(Activity* activity) OVERRIDE {
+ CHECK(activity_widgets_.end() == activity_widgets_.find(activity));
+ ActivityWidget* container = new ActivityWidget(activity);
+ activity_widgets_[activity] = container;
+ container->Show();
+ }
+
+ virtual void RemoveActivity(Activity* activity) OVERRIDE {
+ std::map<Activity*, ActivityWidget*>::iterator find =
+ activity_widgets_.find(activity);
+ if (find != activity_widgets_.end())
+ activity_widgets_.erase(activity);
+ }
+
+ virtual void UpdateActivity(Activity* activity) OVERRIDE {
+ std::map<Activity*, ActivityWidget*>::iterator find =
+ activity_widgets_.find(activity);
+ if (find != activity_widgets_.end())
+ find->second->Update();
+ }
+
+ private:
+ std::map<Activity*, ActivityWidget*> activity_widgets_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActivityViewManagerImpl);
+};
+
+} // namespace
+
+// static
+ActivityViewManager* ActivityViewManager::Create() {
+ new ActivityViewManagerImpl();
+ CHECK(instance);
+ return instance;
+}
+
+ActivityViewManager* ActivityViewManager::Get() {
+ return instance;
+}
+
+void ActivityViewManager::Shutdown() {
+ CHECK(instance);
+ delete instance;
+}
+
+} // namespace athena
diff --git a/athena/activity/public/DEPS b/athena/activity/public/DEPS
new file mode 100644
index 0000000..4777041
--- /dev/null
+++ b/athena/activity/public/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "-athena/task",
+ "+athena/athena_export.h",
+]
diff --git a/athena/activity/public/activity.h b/athena/activity/public/activity.h
new file mode 100644
index 0000000..00bb2f6
--- /dev/null
+++ b/athena/activity/public/activity.h
@@ -0,0 +1,26 @@
+// 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_ACTIVITY_PUBLIC_ACTIVITY_H_
+#define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_
+
+#include <string>
+
+#include "athena/athena_export.h"
+
+namespace athena {
+
+class ActivityViewModel;
+
+class ATHENA_EXPORT Activity {
+ public:
+ virtual ~Activity() {}
+
+ // The Activity retains ownership of the returned view-model.
+ virtual ActivityViewModel* GetActivityViewModel() = 0;
+};
+
+} // namespace athena
+
+#endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_
diff --git a/athena/activity/public/activity_manager.h b/athena/activity/public/activity_manager.h
new file mode 100644
index 0000000..ed53b79
--- /dev/null
+++ b/athena/activity/public/activity_manager.h
@@ -0,0 +1,33 @@
+// 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_ACTIVITY_PUBLIC_ACTIVITY_MANAGER_H_
+#define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_MANAGER_H_
+
+#include "athena/athena_export.h"
+
+namespace athena {
+
+class Activity;
+
+// Manages a set of activities.
+class ATHENA_EXPORT ActivityManager {
+ public:
+ static ActivityManager* Create();
+ static ActivityManager* Get();
+ static void Shutdown();
+
+ virtual ~ActivityManager() {}
+
+ // Adds/Removes a task.
+ virtual void AddActivity(Activity* task) = 0;
+ virtual void RemoveActivity(Activity* task) = 0;
+
+ // Updates the UI when the task color/title changes.
+ virtual void UpdateActivity(Activity* task) = 0;
+};
+
+} // namespace athena
+
+#endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_MANAGER_H_
diff --git a/athena/activity/public/activity_view_manager.h b/athena/activity/public/activity_view_manager.h
new file mode 100644
index 0000000..6ca8b31
--- /dev/null
+++ b/athena/activity/public/activity_view_manager.h
@@ -0,0 +1,33 @@
+// 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_ACTIVITY_PUBLIC_ACTIVITY_VIEW_MANAGER_H_
+#define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_VIEW_MANAGER_H_
+
+#include "athena/athena_export.h"
+
+namespace athena {
+
+class Activity;
+
+// Manages the views for the activities.
+class ATHENA_EXPORT ActivityViewManager {
+ public:
+ static ActivityViewManager* Create();
+ static ActivityViewManager* Get();
+ static void Shutdown();
+
+ virtual ~ActivityViewManager() {}
+
+ // Adds/Removes a task.
+ virtual void AddActivity(Activity* task) = 0;
+ virtual void RemoveActivity(Activity* task) = 0;
+
+ // Updates the UI when the task color/title changes.
+ virtual void UpdateActivity(Activity* task) = 0;
+};
+
+} // namespace athena
+
+#endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_VIEW_MANAGER_H_
diff --git a/athena/activity/public/activity_view_model.h b/athena/activity/public/activity_view_model.h
new file mode 100644
index 0000000..8384bba
--- /dev/null
+++ b/athena/activity/public/activity_view_model.h
@@ -0,0 +1,36 @@
+// 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_ACTIVITY_PUBLIC_ACTIVITY_VIEW_MODEL_H_
+#define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_VIEW_MODEL_H_
+
+#include <string>
+
+#include "athena/athena_export.h"
+
+typedef unsigned int SkColor;
+
+namespace aura {
+class Window;
+}
+
+namespace athena {
+
+class ATHENA_EXPORT ActivityViewModel {
+ public:
+ virtual ~ActivityViewModel() {}
+
+ // Returns a color most representative of this activity.
+ virtual SkColor GetRepresentativeColor() = 0;
+
+ // Returns a title for the activity.
+ virtual std::string GetTitle() = 0;
+
+ // Returns the native window containing the activity.
+ virtual aura::Window* GetNativeWindow() = 0;
+};
+
+} // namespace athena
+
+#endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_VIEW_MODEL_H_
diff --git a/athena/athena.gyp b/athena/athena.gyp
index fef87f5..f418dcc 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -30,6 +30,12 @@
'screen/background_controller.h',
'screen/public/screen_manager.h',
'screen/screen_manager_impl.cc',
+ 'activity/public/activity.h',
+ 'activity/public/activity_manager.h',
+ 'activity/public/activity_view_manager.h',
+ 'activity/public/activity_view_model.h',
+ 'activity/activity_manager_impl.cc',
+ 'activity/activity_view_manager_impl.cc',
'wm/public/window_manager.h',
'wm/window_manager_impl.cc',
],
diff --git a/athena/main/DEPS b/athena/main/DEPS
index 2d53fb1..f83276f 100644
--- a/athena/main/DEPS
+++ b/athena/main/DEPS
@@ -1,8 +1,12 @@
include_rules = [
+ "+athena/activity/public",
"+athena/home/public",
"+athena/screen/public",
+ "+athena/task/public",
"+athena/wm/public",
+ "+content/public",
"+ui/aura",
+ "+ui/base",
"+ui/compositor",
"+ui/gl",
"+ui/wm/core",
@@ -16,6 +20,7 @@ specific_include_rules = {
],
"athena_shell\.cc": [
"+athena/test",
+ "+third_party/skia/include/core",
],
# TODO(oshima): Remove this.
"placeholder\.*": [
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index b061ff0..6cdf031 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -4,6 +4,7 @@
#include "athena/main/athena_launcher.h"
+#include "athena/activity/public/activity_manager.h"
#include "athena/home/public/home_card.h"
#include "athena/main/placeholder.h"
#include "athena/screen/public/screen_manager.h"
@@ -40,11 +41,13 @@ void StartAthena(aura::Window* root_window) {
athena::ScreenManager::Create(root_window);
athena::WindowManager::Create();
athena::HomeCard::Create();
+ athena::ActivityManager::Create();
SetupBackgroundImage();
}
void ShutdownAthena() {
+ athena::ActivityManager::Shutdown();
athena::HomeCard::Shutdown();
athena::WindowManager::Shutdown();
athena::ScreenManager::Shutdown();
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index 6ee8ee4..692f80d 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -7,6 +7,7 @@
#include "apps/shell/browser/shell_desktop_controller.h"
#include "athena/main/athena_launcher.h"
#include "athena/main/placeholder.h"
+#include "athena/main/placeholder_content.h"
#include "content/public/app/content_main.h"
#include "ui/aura/window_tree_host.h"
#include "ui/wm/core/visibility_controller.h"
@@ -22,6 +23,7 @@ class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
->GetWindowTreeHost()
->window());
CreateTestWindows();
+ CreateTestPages(context);
}
virtual void Shutdown() OVERRIDE { athena::ShutdownAthena(); }
diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp
index c21fa111..2341e3e 100644
--- a/athena/main/athena_main.gyp
+++ b/athena/main/athena_main.gyp
@@ -26,6 +26,10 @@
'athena_main.cc',
'placeholder.cc',
'placeholder.h',
+ 'placeholder_content.cc',
+ 'placeholder_content.h',
+ 'web_activity.cc',
+ 'web_activity.h',
],
},
{
@@ -44,6 +48,8 @@
],
'sources': [
'athena_shell.cc',
+ 'sample_activity.cc',
+ 'sample_activity.h',
],
}
], # targets
diff --git a/athena/main/athena_shell.cc b/athena/main/athena_shell.cc
index 3a1ef1d..48fbc9e 100644
--- a/athena/main/athena_shell.cc
+++ b/athena/main/athena_shell.cc
@@ -2,13 +2,19 @@
// 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_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"
#include "base/i18n/icu_util.h"
#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"
#include "ui/compositor/test/context_factories_for_test.h"
#include "ui/gl/gl_surface.h"
@@ -21,6 +27,14 @@ class UIShell {
ui::InitializeContextFactoryForTests(enable_pixel_output);
athena_helper_.SetUp(factory);
athena_helper_.host()->Show();
+
+ InitSampleActivities();
+ }
+
+ void InitSampleActivities() {
+ athena::Activity* task = new SampleActivity(
+ SK_ColorRED, SK_ColorGREEN, std::string("Activity 1"));
+ athena::ActivityManager::Get()->AddActivity(task);
}
private:
@@ -33,10 +47,15 @@ int main(int argc, const char **argv) {
setlocale(LC_ALL, "");
base::AtExitManager exit_manager;
+ ui::RegisterPathProvider();
base::CommandLine::Init(argc, argv);
base::i18n::InitializeICU();
gfx::GLSurface::InitializeOneOffForTests();
+ base::FilePath ui_test_pak_path;
+ DCHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+
base::MessageLoopForUI message_loop;
UIShell shell(&message_loop);
base::RunLoop run_loop;
diff --git a/athena/main/placeholder_content.cc b/athena/main/placeholder_content.cc
new file mode 100644
index 0000000..90464b2
--- /dev/null
+++ b/athena/main/placeholder_content.cc
@@ -0,0 +1,25 @@
+// 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/main/placeholder_content.h"
+
+#include "athena/activity/public/activity_manager.h"
+#include "athena/main/web_activity.h"
+#include "content/public/browser/web_contents.h"
+
+void CreateTestPages(content::BrowserContext* browser_context) {
+ const char* kTestURLs[] = {
+ "http://cyan.bikeshed.com", "https://www.google.com",
+ };
+ for (size_t i = 0; i < arraysize(kTestURLs); ++i) {
+ content::WebContents::CreateParams params(browser_context);
+ content::WebContents* contents = content::WebContents::Create(params);
+ contents->GetController().LoadURL(GURL(kTestURLs[i]),
+ content::Referrer(),
+ content::PAGE_TRANSITION_TYPED,
+ std::string());
+ athena::ActivityManager::Get()->AddActivity(new WebActivity(contents));
+ contents->Focus();
+ }
+}
diff --git a/athena/main/placeholder_content.h b/athena/main/placeholder_content.h
new file mode 100644
index 0000000..404a4e7
--- /dev/null
+++ b/athena/main/placeholder_content.h
@@ -0,0 +1,15 @@
+// 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_MAIN_PLACEHOLDER_CONTENT_H_
+#define ATHENA_MAIN_PLACEHOLDER_CONTENT_H_
+
+namespace content {
+class BrowserContext;
+}
+
+// Creates WebContents with a pre-defined set of windows.
+void CreateTestPages(content::BrowserContext* browser_context);
+
+#endif // ATHENA_MAIN_PLACEHOLDER_CONTENT_H_
diff --git a/athena/main/sample_activity.cc b/athena/main/sample_activity.cc
new file mode 100644
index 0000000..8ad23e7
--- /dev/null
+++ b/athena/main/sample_activity.cc
@@ -0,0 +1,37 @@
+// 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/main/sample_activity.h"
+
+#include "ui/aura/window.h"
+
+SampleActivity::SampleActivity(SkColor color,
+ SkColor content_color,
+ const std::string& title)
+ : color_(color), content_color_(content_color), title_(title) {
+}
+
+SampleActivity::~SampleActivity() {
+}
+
+athena::ActivityViewModel* SampleActivity::GetActivityViewModel() {
+ return this;
+}
+
+SkColor SampleActivity::GetRepresentativeColor() {
+ return color_;
+}
+
+std::string SampleActivity::GetTitle() {
+ return title_;
+}
+
+aura::Window* SampleActivity::GetNativeWindow() {
+ if (!window_) {
+ window_.reset(new aura::Window(NULL));
+ window_->Init(aura::WINDOW_LAYER_SOLID_COLOR);
+ window_->layer()->SetColor(content_color_);
+ }
+ return window_.get();
+}
diff --git a/athena/main/sample_activity.h b/athena/main/sample_activity.h
new file mode 100644
index 0000000..bbd8b58
--- /dev/null
+++ b/athena/main/sample_activity.h
@@ -0,0 +1,35 @@
+// 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_MAIN_SAMPLE_ACTIVITY_H_
+#define ATHENA_MAIN_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 {
+ public:
+ SampleActivity(SkColor color, SkColor content, const std::string& title);
+ virtual ~SampleActivity();
+
+ private:
+ // athena::Activity:
+ virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE;
+
+ // athena::ActivityViewModel:
+ virtual SkColor GetRepresentativeColor() OVERRIDE;
+ virtual std::string GetTitle() OVERRIDE;
+ virtual aura::Window* GetNativeWindow() OVERRIDE;
+
+ SkColor color_;
+ SkColor content_color_;
+ std::string title_;
+ scoped_ptr<aura::Window> window_;
+
+ DISALLOW_COPY_AND_ASSIGN(SampleActivity);
+};
+
+#endif // ATHENA_MAIN_SAMPLE_ACTIVITY_H_
diff --git a/athena/main/web_activity.cc b/athena/main/web_activity.cc
new file mode 100644
index 0000000..196e7e7
--- /dev/null
+++ b/athena/main/web_activity.cc
@@ -0,0 +1,44 @@
+// 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/main/web_activity.h"
+
+#include "athena/activity/public/activity_manager.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/web_contents.h"
+
+WebActivity::WebActivity(content::WebContents* contents)
+ : content::WebContentsObserver(contents) {
+}
+
+WebActivity::~WebActivity() {
+ athena::ActivityManager::Get()->RemoveActivity(this);
+}
+
+athena::ActivityViewModel* WebActivity::GetActivityViewModel() {
+ return this;
+}
+
+SkColor WebActivity::GetRepresentativeColor() {
+ // TODO(sad): Compute the color from the favicon.
+ return SK_ColorGRAY;
+}
+
+std::string WebActivity::GetTitle() {
+ return base::UTF16ToUTF8(web_contents()->GetTitle());
+}
+
+aura::Window* WebActivity::GetNativeWindow() {
+ return web_contents()->GetNativeView();
+}
+
+void WebActivity::TitleWasSet(content::NavigationEntry* entry,
+ bool explicit_set) {
+ athena::ActivityManager::Get()->UpdateActivity(this);
+}
+
+void WebActivity::DidUpdateFaviconURL(
+ const std::vector<content::FaviconURL>& candidates) {
+ athena::ActivityManager::Get()->UpdateActivity(this);
+}
diff --git a/athena/main/web_activity.h b/athena/main/web_activity.h
new file mode 100644
index 0000000..7d1867e
--- /dev/null
+++ b/athena/main/web_activity.h
@@ -0,0 +1,42 @@
+// 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_MAIN_WEB_ACTIVITY_H_
+#define ATHENA_MAIN_WEB_ACTIVITY_H_
+
+#include "athena/activity/public/activity.h"
+#include "athena/activity/public/activity_view_model.h"
+#include "content/public/browser/web_contents_observer.h"
+
+namespace content {
+class WebContents;
+}
+
+class WebActivity : public athena::Activity,
+ public athena::ActivityViewModel,
+ public content::WebContentsObserver {
+ public:
+ explicit WebActivity(content::WebContents* contents);
+ virtual ~WebActivity();
+
+ protected:
+ // athena::Activity:
+ virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE;
+
+ // athena::ActivityViewModel:
+ virtual SkColor GetRepresentativeColor() OVERRIDE;
+ virtual std::string GetTitle() OVERRIDE;
+ virtual aura::Window* GetNativeWindow() OVERRIDE;
+
+ // content::WebContentsObserver:
+ virtual void TitleWasSet(content::NavigationEntry* entry,
+ bool explicit_set) OVERRIDE;
+ virtual void DidUpdateFaviconURL(
+ const std::vector<content::FaviconURL>& candidates) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebActivity);
+};
+
+#endif // ATHENA_MAIN_WEB_ACTIVITY_H_