diff options
author | oshima <oshima@chromium.org> | 2014-09-22 09:34:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-22 16:34:40 +0000 |
commit | 685ccea874df9b5f47665aac007bbc876d344938 (patch) | |
tree | 9e83cb57931913d1616931a692ff6e7f4e917c1f /athena/content | |
parent | 4fab8a0b3d7e2ae3db541795783b41911ad8c711 (diff) | |
download | chromium_src-685ccea874df9b5f47665aac007bbc876d344938.zip chromium_src-685ccea874df9b5f47665aac007bbc876d344938.tar.gz chromium_src-685ccea874df9b5f47665aac007bbc876d344938.tar.bz2 |
As both now uses AppWindow
BUG=None
TBR=yoz@chromium.org
Review URL: https://codereview.chromium.org/587953002
Cr-Commit-Position: refs/heads/master@{#295986}
Diffstat (limited to 'athena/content')
-rw-r--r-- | athena/content/DEPS | 1 | ||||
-rw-r--r-- | athena/content/app_activity.cc | 44 | ||||
-rw-r--r-- | athena/content/app_activity.h | 15 | ||||
-rw-r--r-- | athena/content/app_activity_unittest.cc | 3 | ||||
-rw-r--r-- | athena/content/chrome/DEPS | 1 | ||||
-rw-r--r-- | athena/content/chrome/content_activity_factory.cc | 56 | ||||
-rw-r--r-- | athena/content/content_activity_factory.cc | 7 | ||||
-rw-r--r-- | athena/content/shell/DEPS | 3 | ||||
-rw-r--r-- | athena/content/shell/content_activity_factory.cc | 17 | ||||
-rw-r--r-- | athena/content/shell/shell_app_activity.cc | 36 | ||||
-rw-r--r-- | athena/content/shell/shell_app_activity.h | 37 |
11 files changed, 47 insertions, 173 deletions
diff --git a/athena/content/DEPS b/athena/content/DEPS index 98e54cf..feac790 100644 --- a/athena/content/DEPS +++ b/athena/content/DEPS @@ -11,6 +11,7 @@ include_rules = [ "+components/renderer_context_menu", "+components/web_modal", "+content/public", + "+extensions/browser/app_window/app_window.h", "+net/url_request", "+ui/aura", "+ui/compositor", diff --git a/athena/content/app_activity.cc b/athena/content/app_activity.cc index 6ce1fc2..da5f929 100644 --- a/athena/content/app_activity.cc +++ b/athena/content/app_activity.cc @@ -11,6 +11,7 @@ #include "athena/wm/public/window_list_provider.h" #include "athena/wm/public/window_manager.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/app_window/app_window.h" #include "ui/aura/window.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/widget/widget.h" @@ -18,11 +19,14 @@ namespace athena { // TODO(mukai): specifies the same accelerators of WebActivity. -AppActivity::AppActivity(const std::string& app_id) - : app_id_(app_id), - web_view_(NULL), +AppActivity::AppActivity(extensions::AppWindow* app_window, + views::WebView* web_view) + : app_id_(app_window->extension_id()), + web_view_(web_view), current_state_(ACTIVITY_UNLOADED), app_activity_registry_(NULL) { + DCHECK_EQ(app_window->web_contents(), web_view->GetWebContents()); + Observe(app_window->web_contents()); } scoped_ptr<ContentProxy> AppActivity::GetContentProxy(aura::Window* window) { @@ -125,20 +129,21 @@ bool AppActivity::UsesFrame() const { return false; } -views::View* AppActivity::GetContentsView() { - if (!web_view_) { - web_view_ = GetWebView(); - // Make sure the content gets properly shown. - if (current_state_ == ACTIVITY_VISIBLE) { - HideContentProxy(); - } else if (current_state_ == ACTIVITY_INVISIBLE) { - ShowContentProxy(); - } else { - // If not previously specified, we change the state now to invisible.. - SetCurrentState(ACTIVITY_INVISIBLE); - } - RegisterActivity(); +views::Widget* AppActivity::CreateWidget() { + // Make sure the content gets properly shown. + if (current_state_ == ACTIVITY_VISIBLE) { + HideContentProxy(); + } else if (current_state_ == ACTIVITY_INVISIBLE) { + ShowContentProxy(); + } else { + // If not previously specified, we change the state now to invisible.. + SetCurrentState(ACTIVITY_INVISIBLE); } + RegisterActivity(); + return web_view_->GetWidget(); +} + +views::View* AppActivity::GetContentsView() { return web_view_; } @@ -164,6 +169,13 @@ void AppActivity::ResetContentsView() { } } +AppActivity::AppActivity(const std::string& app_id) + : app_id_(app_id), + web_view_(NULL), + current_state_(ACTIVITY_UNLOADED), + app_activity_registry_(NULL) { +} + AppActivity::~AppActivity() { // If this activity is registered, we unregister it now. if (app_activity_registry_) diff --git a/athena/content/app_activity.h b/athena/content/app_activity.h index 905e956..1b6e29c 100644 --- a/athena/content/app_activity.h +++ b/athena/content/app_activity.h @@ -12,6 +12,10 @@ #include "content/public/browser/web_contents_observer.h" #include "ui/gfx/image/image_skia.h" +namespace extensions { +class AppWindow; +} + namespace views { class WebView; } @@ -22,11 +26,12 @@ class AppActivityRegistry; class ContentProxy; // The activity object for a hosted V2 application. +// TODO(oshima): Move this to athena/extensions class AppActivity : public Activity, public ActivityViewModel, public content::WebContentsObserver { public: - explicit AppActivity(const std::string& app_id); + AppActivity(extensions::AppWindow* app_window, views::WebView* web_view); // Gets the content proxy so that the AppProxy can take it over. scoped_ptr<ContentProxy> GetContentProxy(aura::Window* window); @@ -45,23 +50,25 @@ class AppActivity : public Activity, virtual base::string16 GetTitle() const OVERRIDE; virtual gfx::ImageSkia GetIcon() const OVERRIDE; virtual bool UsesFrame() const OVERRIDE; + virtual views::Widget* CreateWidget() OVERRIDE; virtual views::View* GetContentsView() OVERRIDE; virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; virtual void PrepareContentsForOverview() OVERRIDE; virtual void ResetContentsView() OVERRIDE; protected: + // Constructor for test. + explicit AppActivity(const std::string& app_id); + virtual ~AppActivity(); + private: // content::WebContentsObserver: virtual void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) OVERRIDE; virtual void DidUpdateFaviconURL( const std::vector<content::FaviconURL>& candidates) OVERRIDE; - virtual views::WebView* GetWebView() = 0; - - private: // Register this activity with its application. void RegisterActivity(); diff --git a/athena/content/app_activity_unittest.cc b/athena/content/app_activity_unittest.cc index f4c77e6..0de0e1a 100644 --- a/athena/content/app_activity_unittest.cc +++ b/athena/content/app_activity_unittest.cc @@ -69,9 +69,6 @@ class TestAppActivity : public AppActivity { return view_->GetWidget()->GetNativeWindow(); } - // AppActivity: - virtual views::WebView* GetWebView() OVERRIDE { return NULL; } - // ActivityViewModel: virtual void Init() OVERRIDE {} virtual SkColor GetRepresentativeColor() const OVERRIDE { return 0; } diff --git a/athena/content/chrome/DEPS b/athena/content/chrome/DEPS index 1f04aa2..72382ec 100644 --- a/athena/content/chrome/DEPS +++ b/athena/content/chrome/DEPS @@ -1,4 +1,3 @@ include_rules = [ "+chrome/browser", - "+extensions/browser/app_window/app_window.h", ] diff --git a/athena/content/chrome/content_activity_factory.cc b/athena/content/chrome/content_activity_factory.cc deleted file mode 100644 index f3c9592..0000000 --- a/athena/content/chrome/content_activity_factory.cc +++ /dev/null @@ -1,56 +0,0 @@ -// 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/content_activity_factory.h" - -#include "athena/content/app_activity.h" -#include "extensions/browser/app_window/app_window.h" -#include "ui/views/controls/webview/webview.h" - -// TODO(oshima): Consolidate this and app shell implementation once -// crbug.com/403726 is fixed. -namespace athena { -namespace { - -class ChromeAppActivity : public AppActivity { - public: - ChromeAppActivity(extensions::AppWindow* app_window, views::WebView* web_view) - : AppActivity(app_window->extension_id()), - app_window_(app_window), - web_view_(web_view) { - DCHECK_EQ(app_window->web_contents(), web_view->GetWebContents()); - Observe(app_window_->web_contents()); - } - - private: - virtual ~ChromeAppActivity() {} - - // ActivityViewModel overrides: - virtual views::Widget* CreateWidget() OVERRIDE { - // This is necessary to register apps. - // TODO(oshima): This will become unnecessary once the - // shell_app_window is removed. - GetContentsView(); - return web_view_->GetWidget(); - } - - // AppActivity: - virtual views::WebView* GetWebView() OVERRIDE { return web_view_; } - - // Not owned. - extensions::AppWindow* app_window_; - views::WebView* web_view_; - - DISALLOW_COPY_AND_ASSIGN(ChromeAppActivity); -}; - -} // namespace - -Activity* ContentActivityFactory::CreateAppActivity( - extensions::AppWindow* app_window, - views::WebView* web_view) { - return new ChromeAppActivity(app_window, web_view); -} - -} // namespace athena diff --git a/athena/content/content_activity_factory.cc b/athena/content/content_activity_factory.cc index aaa4e20..ef00f1c 100644 --- a/athena/content/content_activity_factory.cc +++ b/athena/content/content_activity_factory.cc @@ -4,6 +4,7 @@ #include "athena/content/content_activity_factory.h" +#include "athena/content/app_activity.h" #include "athena/content/web_activity.h" #include "base/logging.h" @@ -21,6 +22,12 @@ Activity* ContentActivityFactory::CreateWebActivity( return new WebActivity(browser_context, title, url); } +Activity* ContentActivityFactory::CreateAppActivity( + extensions::AppWindow* app_window, + views::WebView* web_view) { + return new AppActivity(app_window, web_view); +} + ActivityFactory* CreateContentActivityFactory() { return new ContentActivityFactory(); } diff --git a/athena/content/shell/DEPS b/athena/content/shell/DEPS deleted file mode 100644 index 3e1cb59..0000000 --- a/athena/content/shell/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+extensions/browser/app_window", -] diff --git a/athena/content/shell/content_activity_factory.cc b/athena/content/shell/content_activity_factory.cc deleted file mode 100644 index 76ee114..0000000 --- a/athena/content/shell/content_activity_factory.cc +++ /dev/null @@ -1,17 +0,0 @@ -// 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/content_activity_factory.h" - -#include "athena/content/shell/shell_app_activity.h" - -namespace athena { - -Activity* ContentActivityFactory::CreateAppActivity( - extensions::AppWindow* app_window, - views::WebView* web_view) { - return new ShellAppActivity(app_window); -} - -} // namespace athena diff --git a/athena/content/shell/shell_app_activity.cc b/athena/content/shell/shell_app_activity.cc deleted file mode 100644 index cb008e0..0000000 --- a/athena/content/shell/shell_app_activity.cc +++ /dev/null @@ -1,36 +0,0 @@ -// 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/shell/shell_app_activity.h" - -#include "content/public/browser/web_contents.h" -#include "extensions/browser/app_window/app_window.h" -#include "extensions/browser/app_window/native_app_window.h" -#include "ui/views/controls/webview/webview.h" - -namespace athena { - -ShellAppActivity::ShellAppActivity(extensions::AppWindow* app_window) - : AppActivity(app_window->extension_id()), app_window_(app_window) { - DCHECK(app_window_); -} - -ShellAppActivity::~ShellAppActivity() { - app_window_->GetBaseWindow()->Close(); // Deletes |app_window_|. -} - -views::Widget* ShellAppActivity::CreateWidget() { - return NULL; // Use default widget. -} - -views::WebView* ShellAppActivity::GetWebView() { - content::WebContents* web_contents = app_window_->web_contents(); - views::WebView* web_view = - new views::WebView(web_contents->GetBrowserContext()); - web_view->SetWebContents(web_contents); - Observe(web_contents); - return web_view; -} - -} // namespace athena diff --git a/athena/content/shell/shell_app_activity.h b/athena/content/shell/shell_app_activity.h deleted file mode 100644 index a6b7dec..0000000 --- a/athena/content/shell/shell_app_activity.h +++ /dev/null @@ -1,37 +0,0 @@ -// 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_SHELL_SHELL_APP_ACTIVITY_H_ -#define ATHENA_CONTENT_SHELL_SHELL_APP_ACTIVITY_H_ - -#include "athena/content/app_activity.h" - -#include "base/memory/scoped_ptr.h" - -namespace extensions { -class AppWindow; -} - -namespace athena { - -class ShellAppActivity : public AppActivity { - public: - explicit ShellAppActivity(extensions::AppWindow* app_window); - virtual ~ShellAppActivity(); - - private: - // ActivityViewModel: - virtual views::Widget* CreateWidget() OVERRIDE; - - // AppActivity: - virtual views::WebView* GetWebView() OVERRIDE; - - extensions::AppWindow* app_window_; - - DISALLOW_COPY_AND_ASSIGN(ShellAppActivity); -}; - -} // namespace athena - -#endif // ATHENA_CONTENT_SHELL_SHELL_APP_ACTIVITY_H_ |