summaryrefslogtreecommitdiffstats
path: root/athena/content
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 20:07:13 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 20:07:13 +0000
commit33fda21dab63ec8ad43c65332c6a4beeace51395 (patch)
treeac4a77705f9a5696c6e4cfce7146b6cb97cf934f /athena/content
parent210b95666a12f3eb7224cec489d775a13229e882 (diff)
downloadchromium_src-33fda21dab63ec8ad43c65332c6a4beeace51395.zip
chromium_src-33fda21dab63ec8ad43c65332c6a4beeace51395.tar.gz
chromium_src-33fda21dab63ec8ad43c65332c6a4beeace51395.tar.bz2
Introduces AppActivity and handler of chrome.shell API.
Now, clicking the app item just emits onLaunched event, and the app will create an app window on the event handler. The API handler creates a ShellAppWindow for app_shell, but it should create an activity on athena. BUG=380421 R=jamescook@chromium.org, oshima@chromium.org TEST=manually Review URL: https://codereview.chromium.org/335003003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena/content')
-rw-r--r--athena/content/app_activity.cc60
-rw-r--r--athena/content/app_activity.h54
-rw-r--r--athena/content/content_activity_factory.cc21
-rw-r--r--athena/content/content_app_model_builder.cc31
-rw-r--r--athena/content/public/content_activity_factory.h4
-rw-r--r--athena/content/web_activity.h2
6 files changed, 138 insertions, 34 deletions
diff --git a/athena/content/app_activity.cc b/athena/content/app_activity.cc
new file mode 100644
index 0000000..e25d9f3
--- /dev/null
+++ b/athena/content/app_activity.cc
@@ -0,0 +1,60 @@
+// 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/content/app_activity.h"
+
+#include "apps/shell/browser/shell_app_window.h"
+#include "athena/activity/public/activity_manager.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/views/controls/webview/webview.h"
+
+namespace athena {
+
+// TODO(mukai): specifies the same accelerators of WebActivity.
+AppActivity::AppActivity(apps::ShellAppWindow* app_window)
+ : app_window_(app_window), web_view_(NULL) {
+ DCHECK(app_window_);
+}
+
+AppActivity::~AppActivity() {
+}
+
+ActivityViewModel* AppActivity::GetActivityViewModel() {
+ return this;
+}
+
+void AppActivity::Init() {
+}
+
+SkColor AppActivity::GetRepresentativeColor() {
+ // TODO(sad): Compute the color from the favicon.
+ return SK_ColorGRAY;
+}
+
+base::string16 AppActivity::GetTitle() {
+ return web_view_->GetWebContents()->GetTitle();
+}
+
+views::View* AppActivity::GetContentsView() {
+ if (!web_view_) {
+ content::WebContents* web_contents =
+ app_window_->GetAssociatedWebContents();
+ web_view_ = new views::WebView(web_contents->GetBrowserContext());
+ web_view_->SetWebContents(web_contents);
+ Observe(web_contents);
+ }
+ return web_view_;
+}
+
+void AppActivity::TitleWasSet(content::NavigationEntry* entry,
+ bool explicit_set) {
+ ActivityManager::Get()->UpdateActivity(this);
+}
+
+void AppActivity::DidUpdateFaviconURL(
+ const std::vector<content::FaviconURL>& candidates) {
+ ActivityManager::Get()->UpdateActivity(this);
+}
+
+} // namespace athena
diff --git a/athena/content/app_activity.h b/athena/content/app_activity.h
new file mode 100644
index 0000000..6c5a742
--- /dev/null
+++ b/athena/content/app_activity.h
@@ -0,0 +1,54 @@
+// 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_ACTIVITY_H_
+#define ATHENA_CONTENT_PUBLIC_APP_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 apps {
+class ShellAppWindow;
+}
+
+namespace views {
+class WebView;
+}
+
+namespace athena {
+
+class AppActivity : public Activity,
+ public ActivityViewModel,
+ public content::WebContentsObserver {
+ public:
+ explicit AppActivity(apps::ShellAppWindow* app_window);
+ virtual ~AppActivity();
+
+ protected:
+ // Activity:
+ virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE;
+
+ // ActivityViewModel:
+ virtual void Init() OVERRIDE;
+ virtual SkColor GetRepresentativeColor() OVERRIDE;
+ virtual base::string16 GetTitle() OVERRIDE;
+ virtual views::View* GetContentsView() OVERRIDE;
+
+ // content::WebContentsObserver:
+ virtual void TitleWasSet(content::NavigationEntry* entry,
+ bool explicit_set) OVERRIDE;
+ virtual void DidUpdateFaviconURL(
+ const std::vector<content::FaviconURL>& candidates) OVERRIDE;
+
+ private:
+ scoped_ptr<apps::ShellAppWindow> app_window_;
+ views::WebView* web_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppActivity);
+};
+
+} // namespace athena
+
+#endif // ATHENA_CONTENT_APP_ACTIVITY_H_
diff --git a/athena/content/content_activity_factory.cc b/athena/content/content_activity_factory.cc
index 4f74909..3a08641 100644
--- a/athena/content/content_activity_factory.cc
+++ b/athena/content/content_activity_factory.cc
@@ -4,6 +4,7 @@
#include "athena/content/public/content_activity_factory.h"
+#include "athena/content/app_activity.h"
#include "athena/content/web_activity.h"
#include "base/logging.h"
@@ -21,24 +22,8 @@ Activity* ContentActivityFactory::CreateWebActivity(
}
Activity* ContentActivityFactory::CreateAppActivity(
- content::BrowserContext* browser_context,
- const std::string& app_id) {
- // TODO(mukai): port the extension system and launch the app actually.
- GURL url;
- if (app_id == "mail")
- url = GURL("https://mail.google.com/");
- else if (app_id == "calendar")
- url = GURL("https://calendar.google.com/");
- else if (app_id == "video")
- url = GURL("http://youtube.com/");
- else if (app_id == "music")
- url = GURL("https://play.google.com/music");
- else if (app_id == "contact")
- url = GURL("https://www.google.com/contacts");
- else
- LOG(FATAL) << "Unknown app id: " << app_id;
- DCHECK(!url.is_empty());
- return CreateWebActivity(browser_context, url);
+ apps::ShellAppWindow* app_window) {
+ return new AppActivity(app_window);
}
} // namespace athena
diff --git a/athena/content/content_app_model_builder.cc b/athena/content/content_app_model_builder.cc
index 7fcad45..f91b1c1 100644
--- a/athena/content/content_app_model_builder.cc
+++ b/athena/content/content_app_model_builder.cc
@@ -37,10 +37,11 @@ gfx::ImageSkia CreateFlatColorImage(SkColor color) {
class DummyItem : public app_list::AppListItem {
public:
DummyItem(const std::string& id,
+ const GURL& url,
SkColor color,
content::BrowserContext* browser_context)
: app_list::AppListItem(id),
- id_(id),
+ url_(url),
browser_context_(browser_context) {
SetIcon(CreateFlatColorImage(color), false /* has_shadow */);
@@ -51,11 +52,10 @@ class DummyItem : public app_list::AppListItem {
// Overridden from app_list::AppListItem:
virtual void Activate(int event_flags) OVERRIDE {
ActivityManager::Get()->AddActivity(
- ActivityFactory::Get()->CreateAppActivity(
- browser_context_, id_));
+ ActivityFactory::Get()->CreateWebActivity(browser_context_, url_));
}
- std::string id_;
+ GURL url_;
content::BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(DummyItem);
@@ -98,16 +98,19 @@ ContentAppModelBuilder::~ContentAppModelBuilder() {
}
void ContentAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
- model->AddItem(scoped_ptr<app_list::AppListItem>(
- new DummyItem("mail", SK_ColorRED, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(
- new DummyItem("calendar", SK_ColorBLUE, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(
- new DummyItem("video", SK_ColorGREEN, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(
- new DummyItem("music", SK_ColorYELLOW, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(
- new DummyItem("contact", SK_ColorCYAN, browser_context_)));
+ model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
+ "mail", GURL("http://gmail.com/"), SK_ColorRED, browser_context_)));
+ model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
+ "calendar", GURL("https://calendar.google.com/"),
+ SK_ColorBLUE, browser_context_)));
+ model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
+ "video", GURL("http://youtube.com/"), SK_ColorGREEN, browser_context_)));
+ model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
+ "music", GURL("http://play.google.com/music"),
+ SK_ColorYELLOW, browser_context_)));
+ model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
+ "contact", GURL("https://www.google.com/contacts"),
+ SK_ColorCYAN, browser_context_)));
ShellExtensionSystem* extension_system =
GetShellExtensionSystem(browser_context_);
diff --git a/athena/content/public/content_activity_factory.h b/athena/content/public/content_activity_factory.h
index 70e5ec4..2698123 100644
--- a/athena/content/public/content_activity_factory.h
+++ b/athena/content/public/content_activity_factory.h
@@ -19,8 +19,8 @@ class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory {
// Overridden from ActivityFactory:
virtual Activity* CreateWebActivity(content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
- virtual Activity* CreateAppActivity(content::BrowserContext* browser_context,
- const std::string& app_id) OVERRIDE;
+ virtual Activity* CreateAppActivity(
+ apps::ShellAppWindow* app_window) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ContentActivityFactory);
diff --git a/athena/content/web_activity.h b/athena/content/web_activity.h
index af012d9..840cceef 100644
--- a/athena/content/web_activity.h
+++ b/athena/content/web_activity.h
@@ -11,6 +11,7 @@
namespace content {
class BrowserContext;
+class WebContents;
}
namespace views {
@@ -44,6 +45,7 @@ class WebActivity : public Activity,
private:
content::BrowserContext* browser_context_;
+ content::WebContents* web_contents_;
const GURL url_;
views::WebView* web_view_;