diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 17:34:57 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 17:34:57 +0000 |
commit | 03e9869d55d7eae4744b8482760903a81b50ff6c (patch) | |
tree | d44b6327c683e0297c13065514c1d85129a6c710 /athena | |
parent | aab4dc592246fa4a5b4a0b7936cff48393291497 (diff) | |
download | chromium_src-03e9869d55d7eae4744b8482760903a81b50ff6c.zip chromium_src-03e9869d55d7eae4744b8482760903a81b50ff6c.tar.gz chromium_src-03e9869d55d7eae4744b8482760903a81b50ff6c.tar.bz2 |
Moves WebActivity to a new directory athena/content.
WebActivity would be used from the home card, so better to be
in another directory accessible from athena/home.
BUG=380421
R=oshima@chromium.org
TBR=jam@chromium.org
TEST=compile succeeds
Review URL: https://codereview.chromium.org/307353007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena')
-rw-r--r-- | athena/activity/activity_factory.cc | 36 | ||||
-rw-r--r-- | athena/activity/public/activity_factory.h | 38 | ||||
-rw-r--r-- | athena/athena.gyp | 31 | ||||
-rw-r--r-- | athena/content/DEPS | 4 | ||||
-rw-r--r-- | athena/content/content_activity_factory.cc | 33 | ||||
-rw-r--r-- | athena/content/public/DEPS | 4 | ||||
-rw-r--r-- | athena/content/public/content_activity_factory.h | 29 | ||||
-rw-r--r-- | athena/content/web_activity.cc (renamed from athena/main/web_activity.cc) | 14 | ||||
-rw-r--r-- | athena/content/web_activity.h (renamed from athena/main/web_activity.h) | 18 | ||||
-rw-r--r-- | athena/main/DEPS | 1 | ||||
-rw-r--r-- | athena/main/athena_launcher.cc | 2 | ||||
-rw-r--r-- | athena/main/athena_main.cc | 10 | ||||
-rw-r--r-- | athena/main/athena_main.gyp | 3 | ||||
-rw-r--r-- | athena/main/placeholder_content.cc | 14 |
14 files changed, 205 insertions, 32 deletions
diff --git a/athena/activity/activity_factory.cc b/athena/activity/activity_factory.cc new file mode 100644 index 0000000..2507281 --- /dev/null +++ b/athena/activity/activity_factory.cc @@ -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. + +#include "athena/activity/public/activity_factory.h" + +#include "base/logging.h" + +namespace athena { + +namespace { + +ActivityFactory* instance = NULL; + +} + +// static +void ActivityFactory::RegisterActivityFactory(ActivityFactory* factory) { + DCHECK(!instance); + instance = factory; +} + +// static +ActivityFactory* ActivityFactory::Get() { + DCHECK(instance); + return instance; +} + +// static +void ActivityFactory::Shutdown() { + DCHECK(instance); + delete instance; + instance = NULL; +} + +} // namespace athena diff --git a/athena/activity/public/activity_factory.h b/athena/activity/public/activity_factory.h new file mode 100644 index 0000000..8cea669 --- /dev/null +++ b/athena/activity/public/activity_factory.h @@ -0,0 +1,38 @@ +// 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_FACTORY_H_ +#define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_FACTORY_H_ + +#include "athena/athena_export.h" +#include "url/gurl.h" + +namespace content { +class BrowserContext; +} + +namespace athena { +class Activity; + +class ATHENA_EXPORT ActivityFactory { + public: + // Registers the singleton factory. + static void RegisterActivityFactory(ActivityFactory* factory); + + // Gets the registered singleton factory. + static ActivityFactory* Get(); + + // Shutdowns the factory. + static void Shutdown(); + + virtual ~ActivityFactory() {} + + // Create an activity of a web page. + virtual Activity* CreateWebActivity(content::BrowserContext* browser_context, + const GURL& url) = 0; +}; + +} // namespace athena + +#endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_FACTORY_H_ diff --git a/athena/athena.gyp b/athena/athena.gyp index 96a72e1..e4f53b7 100644 --- a/athena/athena.gyp +++ b/athena/athena.gyp @@ -21,6 +21,14 @@ ], 'sources': [ # All .cc, .h under athena, except unittests + 'activity/activity_factory.cc', + 'activity/activity_manager_impl.cc', + 'activity/activity_view_manager_impl.cc', + 'activity/public/activity.h', + 'activity/public/activity_factory.h', + 'activity/public/activity_manager.h', + 'activity/public/activity_view_manager.h', + 'activity/public/activity_view_model.h', 'athena_export.h', 'home/home_card_delegate_view.cc', 'home/home_card_delegate_view.h', @@ -30,12 +38,6 @@ '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', 'wm/window_overview_mode.cc', @@ -43,6 +45,23 @@ ], }, { + 'target_name': 'athena_content_lib', + 'type': '<(component)', + 'dependencies': [ + 'athena_lib', + '../content/content.gyp:content_browser', + ], + 'defines': [ + 'ATHENA_IMPLEMENTATION', + ], + 'sources': [ + 'content/public/content_activity_factory.h', + 'content/content_activity_factory.cc', + 'content/web_activity.h', + 'content/web_activity.cc', + ], + }, + { 'target_name': 'athena_test_support', 'type': 'static_library', 'dependencies': [ diff --git a/athena/content/DEPS b/athena/content/DEPS new file mode 100644 index 0000000..0eaa1e2 --- /dev/null +++ b/athena/content/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+athena/activity/public", + "+content/public", +] diff --git a/athena/content/content_activity_factory.cc b/athena/content/content_activity_factory.cc new file mode 100644 index 0000000..ab6ecf7 --- /dev/null +++ b/athena/content/content_activity_factory.cc @@ -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. + +#include "athena/content/public/content_activity_factory.h" + +#include "athena/content/web_activity.h" +#include "content/public/browser/web_contents.h" +#include "url/gurl.h" + +namespace athena { + +ContentActivityFactory::ContentActivityFactory() { +} + +ContentActivityFactory::~ContentActivityFactory() {} + +Activity* ContentActivityFactory::CreateWebActivity( + content::BrowserContext* browser_context, + const GURL& url) { + content::WebContents::CreateParams params(browser_context); + content::WebContents* contents = content::WebContents::Create(params); + contents->GetController().LoadURL(url, + content::Referrer(), + content::PAGE_TRANSITION_TYPED, + std::string()); + WebActivity* activity = new WebActivity(contents); + // TODO(mukai): it might be better to move Focus to another place. + contents->Focus(); + return activity; +} + +} // namespace athena diff --git a/athena/content/public/DEPS b/athena/content/public/DEPS new file mode 100644 index 0000000..27d5887 --- /dev/null +++ b/athena/content/public/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "-athena/content", + "+athena/athena_export.h", +] diff --git a/athena/content/public/content_activity_factory.h b/athena/content/public/content_activity_factory.h new file mode 100644 index 0000000..25d6fe4 --- /dev/null +++ b/athena/content/public/content_activity_factory.h @@ -0,0 +1,29 @@ +// 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_CONTENT_ACTIVITY_FACTORY_H_ +#define ATHENA_CONTENT_PUBLIC_CONTENT_ACTIVITY_FACTORY_H_ + +#include "athena/activity/public/activity_factory.h" +#include "athena/athena_export.h" +#include "base/macros.h" + +namespace athena { + +class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory { + public: + ContentActivityFactory(); + virtual ~ContentActivityFactory(); + + // Overridden from ActivityFactory: + virtual Activity* CreateWebActivity(content::BrowserContext* browser_context, + const GURL& url) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ContentActivityFactory); +}; + +} // namespace athena + +#endif // ATHENA_CONTENT_PUBLIC_CONTENT_ACTIVITY_FACTORY_H_ diff --git a/athena/main/web_activity.cc b/athena/content/web_activity.cc index 196e7e7..9afe404 100644 --- a/athena/main/web_activity.cc +++ b/athena/content/web_activity.cc @@ -2,21 +2,23 @@ // 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/content/web_activity.h" #include "athena/activity/public/activity_manager.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/web_contents.h" +namespace athena { + WebActivity::WebActivity(content::WebContents* contents) : content::WebContentsObserver(contents) { } WebActivity::~WebActivity() { - athena::ActivityManager::Get()->RemoveActivity(this); + ActivityManager::Get()->RemoveActivity(this); } -athena::ActivityViewModel* WebActivity::GetActivityViewModel() { +ActivityViewModel* WebActivity::GetActivityViewModel() { return this; } @@ -35,10 +37,12 @@ aura::Window* WebActivity::GetNativeWindow() { void WebActivity::TitleWasSet(content::NavigationEntry* entry, bool explicit_set) { - athena::ActivityManager::Get()->UpdateActivity(this); + ActivityManager::Get()->UpdateActivity(this); } void WebActivity::DidUpdateFaviconURL( const std::vector<content::FaviconURL>& candidates) { - athena::ActivityManager::Get()->UpdateActivity(this); + ActivityManager::Get()->UpdateActivity(this); } + +} // namespace athena diff --git a/athena/main/web_activity.h b/athena/content/web_activity.h index 7d1867e..5b40019 100644 --- a/athena/main/web_activity.h +++ b/athena/content/web_activity.h @@ -2,8 +2,8 @@ // 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_ +#ifndef ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ +#define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ #include "athena/activity/public/activity.h" #include "athena/activity/public/activity_view_model.h" @@ -13,18 +13,20 @@ namespace content { class WebContents; } -class WebActivity : public athena::Activity, - public athena::ActivityViewModel, +namespace athena { + +class WebActivity : public Activity, + public ActivityViewModel, public content::WebContentsObserver { public: explicit WebActivity(content::WebContents* contents); virtual ~WebActivity(); protected: - // athena::Activity: + // Activity: virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; - // athena::ActivityViewModel: + // ActivityViewModel: virtual SkColor GetRepresentativeColor() OVERRIDE; virtual std::string GetTitle() OVERRIDE; virtual aura::Window* GetNativeWindow() OVERRIDE; @@ -39,4 +41,6 @@ class WebActivity : public athena::Activity, DISALLOW_COPY_AND_ASSIGN(WebActivity); }; -#endif // ATHENA_MAIN_WEB_ACTIVITY_H_ +} // namespace athena + +#endif // ATHENA_CONTENT_WEB_ACTIVITY_H_ diff --git a/athena/main/DEPS b/athena/main/DEPS index 737d051..72f587f 100644 --- a/athena/main/DEPS +++ b/athena/main/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+athena/activity/public", + "+athena/content/public", "+athena/home/public", "+athena/screen/public", "+athena/task/public", diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc index d112346..7e88e78 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_factory.h" #include "athena/activity/public/activity_manager.h" #include "athena/home/public/home_card.h" #include "athena/main/placeholder.h" @@ -49,7 +50,6 @@ void StartAthena(aura::Window* root_window) { athena::WindowManager::Create(); athena::HomeCard::Create(); athena::ActivityManager::Create(); - SetupBackgroundImage(); } diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc index 347e9f8..c2f9742 100644 --- a/athena/main/athena_main.cc +++ b/athena/main/athena_main.cc @@ -5,6 +5,7 @@ #include "apps/shell/app/shell_main_delegate.h" #include "apps/shell/browser/shell_browser_main_delegate.h" #include "apps/shell/browser/shell_desktop_controller.h" +#include "athena/content/public/content_activity_factory.h" #include "athena/main/athena_launcher.h" #include "athena/main/placeholder.h" #include "athena/main/placeholder_content.h" @@ -21,11 +22,18 @@ class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { virtual void Start(content::BrowserContext* context) OVERRIDE { athena::StartAthena( apps::ShellDesktopController::instance()->host()->window()); + athena::ActivityFactory::RegisterActivityFactory( + new athena::ContentActivityFactory()); CreateTestWindows(); CreateTestPages(context); } - virtual void Shutdown() OVERRIDE { athena::ShutdownAthena(); } + virtual void Shutdown() OVERRIDE { + // TODO(mukai):cleanup the start/shutdown processes and the dependency to + // ContentActivityFactory. + athena::ActivityFactory::Shutdown(); + athena::ShutdownAthena(); + } virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE { // TODO(mukai): create Athena's own ShellDesktopController subclass so that diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp index 2341e3e..f66babd 100644 --- a/athena/main/athena_main.gyp +++ b/athena/main/athena_main.gyp @@ -12,6 +12,7 @@ 'type': 'executable', 'dependencies': [ '../athena.gyp:athena_lib', + '../athena.gyp:athena_content_lib', '../../apps/shell/app_shell.gyp:app_shell_lib', '../../skia/skia.gyp:skia', '../../ui/accessibility/accessibility.gyp:ax_gen', @@ -28,8 +29,6 @@ 'placeholder.h', 'placeholder_content.cc', 'placeholder_content.h', - 'web_activity.cc', - 'web_activity.h', ], }, { diff --git a/athena/main/placeholder_content.cc b/athena/main/placeholder_content.cc index 6a0b5f1..c3ff97e 100644 --- a/athena/main/placeholder_content.cc +++ b/athena/main/placeholder_content.cc @@ -4,9 +4,8 @@ #include "athena/main/placeholder_content.h" +#include "athena/activity/public/activity_factory.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[] = { @@ -14,13 +13,8 @@ void CreateTestPages(content::BrowserContext* browser_context) { "http://blue.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(); + athena::ActivityManager::Get()->AddActivity( + athena::ActivityFactory::Get()->CreateWebActivity( + browser_context, GURL(kTestURLs[i]))); } } |