Commit 025e4673 authored by oshima's avatar oshima Committed by Commit bot

Move app_shell specific impl from athena_lib to athena_shell_lib

* AppActivity is now base class. There will be one for chrome
* Moved content_activity_factory.h from public to impl as ther eis no need to expose header.
* Added CreateAppActivity that takes apps::Window. Chrome
 impl will use this to create an activity. This simply returns NULL for app_shell version.

BUG=397167
R=mukai@chromium.org
TBR=jamescook@chromium.org
TEST=no functional change. all tests must pass.

Review URL: https://codereview.chromium.org/505273002

Cr-Commit-Position: refs/heads/master@{#292038}
parent 5d0211f2
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include "athena/athena_export.h" #include "athena/athena_export.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace apps {
class AppWindow;
}
namespace content { namespace content {
class BrowserContext; class BrowserContext;
} }
...@@ -36,10 +40,15 @@ class ATHENA_EXPORT ActivityFactory { ...@@ -36,10 +40,15 @@ class ATHENA_EXPORT ActivityFactory {
virtual Activity* CreateWebActivity(content::BrowserContext* browser_context, virtual Activity* CreateWebActivity(content::BrowserContext* browser_context,
const GURL& url) = 0; const GURL& url) = 0;
// Create an activity of an app with |app_window|. The returned activity // Create an activity of an app with |app_window| for app shell environemnt.
// should own |app_window|. // The returned activity should own |app_window|.
// TODO(oshima): Consolidate these two methods to create AppActivity
// once crbug.com/403726 is finished.
virtual Activity* CreateAppActivity( virtual Activity* CreateAppActivity(
extensions::ShellAppWindow* app_window) = 0; extensions::ShellAppWindow* app_window) = 0;
// Create an activity of an app with |app_window| for chrome environment.
virtual Activity* CreateAppActivity(apps::AppWindow* app_window) = 0;
}; };
} // namespace athena } // namespace athena
......
...@@ -111,7 +111,6 @@ ...@@ -111,7 +111,6 @@
'../components/components.gyp:web_modal', '../components/components.gyp:web_modal',
'../extensions/extensions.gyp:extensions_browser', '../extensions/extensions.gyp:extensions_browser',
'../extensions/extensions.gyp:extensions_common', '../extensions/extensions.gyp:extensions_common',
'../extensions/shell/app_shell.gyp:app_shell_lib',
'../content/content.gyp:content_browser', '../content/content.gyp:content_browser',
'../ui/app_list/app_list.gyp:app_list', '../ui/app_list/app_list.gyp:app_list',
'../ui/keyboard/keyboard.gyp:keyboard', '../ui/keyboard/keyboard.gyp:keyboard',
...@@ -133,7 +132,8 @@ ...@@ -133,7 +132,8 @@
'content/delegate/app_content_control_delegate_impl.cc', 'content/delegate/app_content_control_delegate_impl.cc',
'content/public/app_content_control_delegate.h', 'content/public/app_content_control_delegate.h',
'content/public/app_registry.h', 'content/public/app_registry.h',
'content/public/content_activity_factory.h', 'content/content_activity_factory.h',
'content/public/content_activity_factory_creator.h',
'content/public/content_app_model_builder.h', 'content/public/content_app_model_builder.h',
'content/public/web_contents_view_delegate_creator.h', 'content/public/web_contents_view_delegate_creator.h',
'content/render_view_context_menu_impl.cc', 'content/render_view_context_menu_impl.cc',
...@@ -154,6 +154,9 @@ ...@@ -154,6 +154,9 @@
'../extensions/shell/app_shell.gyp:app_shell_lib', '../extensions/shell/app_shell.gyp:app_shell_lib',
], ],
'sources': [ 'sources': [
'content/shell/content_activity_factory.cc',
'content/shell/shell_app_activity.cc',
'content/shell/shell_app_activity.h',
'extensions/shell/extensions_delegate_impl.cc', 'extensions/shell/extensions_delegate_impl.cc',
], ],
}, },
...@@ -201,6 +204,7 @@ ...@@ -201,6 +204,7 @@
'dependencies': [ 'dependencies': [
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'athena_app_shell_lib',
'athena_lib', 'athena_lib',
'athena_test_support', 'athena_test_support',
'main/athena_main.gyp:athena_main_lib', 'main/athena_main.gyp:athena_main_lib',
......
...@@ -17,10 +17,3 @@ include_rules = [ ...@@ -17,10 +17,3 @@ include_rules = [
# strictly enum/POD, header-only types, and some selected common code. # strictly enum/POD, header-only types, and some selected common code.
"+third_party/WebKit/public/web/WebContextMenuData.h", "+third_party/WebKit/public/web/WebContextMenuData.h",
] ]
specific_include_rules = {
# Remove this once app shell uses app_window.h (crbug.com/403726)
"app_activity\.cc": [
"+extensions/shell/browser/shell_app_window.h",
],
}
...@@ -9,16 +9,14 @@ ...@@ -9,16 +9,14 @@
#include "athena/content/public/app_content_control_delegate.h" #include "athena/content/public/app_content_control_delegate.h"
#include "athena/content/public/app_registry.h" #include "athena/content/public/app_registry.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/shell/browser/shell_app_window.h"
#include "ui/views/controls/webview/webview.h" #include "ui/views/controls/webview/webview.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace athena { namespace athena {
// TODO(mukai): specifies the same accelerators of WebActivity. // TODO(mukai): specifies the same accelerators of WebActivity.
AppActivity::AppActivity(extensions::ShellAppWindow* app_window) AppActivity::AppActivity()
: app_window_(app_window), : web_view_(NULL),
web_view_(NULL),
current_state_(ACTIVITY_UNLOADED), current_state_(ACTIVITY_UNLOADED),
app_activity_registry_(NULL) { app_activity_registry_(NULL) {
} }
...@@ -116,8 +114,7 @@ bool AppActivity::UsesFrame() const { ...@@ -116,8 +114,7 @@ bool AppActivity::UsesFrame() const {
views::View* AppActivity::GetContentsView() { views::View* AppActivity::GetContentsView() {
if (!web_view_) { if (!web_view_) {
// TODO(oshima): use apps::NativeAppWindowViews // TODO(oshima): use apps::NativeAppWindowViews
content::WebContents* web_contents = content::WebContents* web_contents = GetWebContents();
app_window_->GetAssociatedWebContents();
web_view_ = new views::WebView(web_contents->GetBrowserContext()); web_view_ = new views::WebView(web_contents->GetBrowserContext());
web_view_->SetWebContents(web_contents); web_view_->SetWebContents(web_contents);
SetCurrentState(ACTIVITY_INVISIBLE); SetCurrentState(ACTIVITY_INVISIBLE);
...@@ -156,7 +153,7 @@ void AppActivity::DidStartNavigationToPendingEntry( ...@@ -156,7 +153,7 @@ void AppActivity::DidStartNavigationToPendingEntry(
// Note: This should only get called once for an |app_window| of the // Note: This should only get called once for an |app_window| of the
// |activity|. // |activity|.
void AppActivity::RegisterActivity() { void AppActivity::RegisterActivity() {
content::WebContents* web_contents = app_window_->GetAssociatedWebContents(); content::WebContents* web_contents = GetWebContents();
AppRegistry* app_registry = AppRegistry::Get(); AppRegistry* app_registry = AppRegistry::Get();
// Get the application's registry. // Get the application's registry.
app_activity_registry_ = app_registry->GetAppActivityRegistry( app_activity_registry_ = app_registry->GetAppActivityRegistry(
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
namespace extensions { namespace contents {
class ShellAppWindow; class WebContents;
} }
namespace views { namespace views {
...@@ -27,7 +27,7 @@ class AppActivity : public Activity, ...@@ -27,7 +27,7 @@ class AppActivity : public Activity,
public ActivityViewModel, public ActivityViewModel,
public content::WebContentsObserver { public content::WebContentsObserver {
public: public:
explicit AppActivity(extensions::ShellAppWindow* app_window); AppActivity();
virtual ~AppActivity(); virtual ~AppActivity();
// Activity: // Activity:
...@@ -57,11 +57,13 @@ class AppActivity : public Activity, ...@@ -57,11 +57,13 @@ class AppActivity : public Activity,
const GURL& url, const GURL& url,
content::NavigationController::ReloadType reload_type) OVERRIDE; content::NavigationController::ReloadType reload_type) OVERRIDE;
protected:
virtual content::WebContents* GetWebContents() = 0;
private: private:
// Register this activity with its application. // Register this activity with its application.
void RegisterActivity(); void RegisterActivity();
scoped_ptr<extensions::ShellAppWindow> app_window_;
views::WebView* web_view_; views::WebView* web_view_;
// The current state for this activity. // The current state for this activity.
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace content { namespace content {
class BrowserContext; class BrowserContext;
} }
...@@ -31,7 +30,7 @@ const char kDummyApp2[] = "bbbbbbb"; ...@@ -31,7 +30,7 @@ const char kDummyApp2[] = "bbbbbbb";
class TestAppActivity : public AppActivity { class TestAppActivity : public AppActivity {
public: public:
explicit TestAppActivity(const std::string& app_id) : explicit TestAppActivity(const std::string& app_id) :
AppActivity(NULL), AppActivity(),
app_id_(app_id), app_id_(app_id),
view_(new views::View()), view_(new views::View()),
current_state_(ACTIVITY_VISIBLE) { current_state_(ACTIVITY_VISIBLE) {
...@@ -67,6 +66,11 @@ class TestAppActivity : public AppActivity { ...@@ -67,6 +66,11 @@ class TestAppActivity : public AppActivity {
return view_->GetWidget()->GetNativeWindow(); return view_->GetWidget()->GetNativeWindow();
} }
// AppActivity:
virtual content::WebContents* GetWebContents() OVERRIDE {
return NULL;
}
// ActivityViewModel: // ActivityViewModel:
virtual void Init() OVERRIDE {} virtual void Init() OVERRIDE {}
virtual SkColor GetRepresentativeColor() const OVERRIDE { return 0; } virtual SkColor GetRepresentativeColor() const OVERRIDE { return 0; }
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/content/public/content_activity_factory.h" #include "athena/content/content_activity_factory.h"
#include "athena/content/app_activity.h"
#include "athena/content/web_activity.h" #include "athena/content/web_activity.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -21,9 +20,8 @@ Activity* ContentActivityFactory::CreateWebActivity( ...@@ -21,9 +20,8 @@ Activity* ContentActivityFactory::CreateWebActivity(
return new WebActivity(browser_context, url); return new WebActivity(browser_context, url);
} }
Activity* ContentActivityFactory::CreateAppActivity( ActivityFactory* CreateContentActivityFactory() {
extensions::ShellAppWindow* app_window) { return new ContentActivityFactory();
return new AppActivity(app_window);
} }
} // namespace athena } // namespace athena
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATHENA_CONTENT_PUBLIC_CONTENT_ACTIVITY_FACTORY_H_ #ifndef ATHENA_CONTENT_CONTENT_ACTIVITY_FACTORY_H_
#define ATHENA_CONTENT_PUBLIC_CONTENT_ACTIVITY_FACTORY_H_ #define ATHENA_CONTENT_CONTENT_ACTIVITY_FACTORY_H_
#include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_factory.h"
#include "athena/athena_export.h"
#include "base/macros.h" #include "base/macros.h"
namespace athena { namespace athena {
class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory { class ContentActivityFactory : public ActivityFactory {
public: public:
ContentActivityFactory(); ContentActivityFactory();
virtual ~ContentActivityFactory(); virtual ~ContentActivityFactory();
...@@ -21,6 +20,7 @@ class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory { ...@@ -21,6 +20,7 @@ class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory {
const GURL& url) OVERRIDE; const GURL& url) OVERRIDE;
virtual Activity* CreateAppActivity( virtual Activity* CreateAppActivity(
extensions::ShellAppWindow* app_window) OVERRIDE; extensions::ShellAppWindow* app_window) OVERRIDE;
virtual Activity* CreateAppActivity(apps::AppWindow* app_window) OVERRIDE;
private: private:
DISALLOW_COPY_AND_ASSIGN(ContentActivityFactory); DISALLOW_COPY_AND_ASSIGN(ContentActivityFactory);
...@@ -28,4 +28,4 @@ class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory { ...@@ -28,4 +28,4 @@ class ATHENA_EXPORT ContentActivityFactory : public ActivityFactory {
} // namespace athena } // namespace athena
#endif // ATHENA_CONTENT_PUBLIC_CONTENT_ACTIVITY_FACTORY_H_ #endif // ATHENA_CONTENT_CONTENT_ACTIVITY_FACTORY_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.
#ifndef ATHENA_CONTENT_CONTENT_ACTIVITY_FACTORY_CREATOR_H_
#define ATHENA_CONTENT_CONTENT_ACTIVITY_FACTORY_CREATOR_H_
namespace athena {
class ActivityFactory;
ActivityFactory* CreateContentActivityFactory();
} // namespace athena
#endif // ATHENA_CONTENT_CONTENT_ACTIVITY_FACTORY_CREATOR_H_
include_rules = [
"+extensions/shell/browser/shell_app_window.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/content/content_activity_factory.h"
#include "athena/content/shell/shell_app_activity.h"
namespace athena {
Activity* ContentActivityFactory::CreateAppActivity(
extensions::ShellAppWindow* app_window) {
return new ShellAppActivity(app_window);
}
Activity* ContentActivityFactory::CreateAppActivity(
apps::AppWindow* app_window) {
return NULL;
}
} // 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.
#include "athena/content/shell/shell_app_activity.h"
#include "extensions/shell/browser/shell_app_window.h"
namespace athena {
ShellAppActivity::ShellAppActivity(extensions::ShellAppWindow* app_window)
: shell_app_window_(app_window) {
}
ShellAppActivity::~ShellAppActivity() {}
content::WebContents* ShellAppActivity::GetWebContents() {
return shell_app_window_->GetAssociatedWebContents();
}
} // 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_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 ShellAppWindow;
}
namespace athena {
class ShellAppActivity : public AppActivity {
public:
explicit ShellAppActivity(extensions::ShellAppWindow* app_window);
virtual ~ShellAppActivity();
private:
// AppActivity:
virtual content::WebContents* GetWebContents() OVERRIDE;
scoped_ptr<extensions::ShellAppWindow> shell_app_window_;
DISALLOW_COPY_AND_ASSIGN(ShellAppActivity);
};
} // namespace athena
#endif // ATHENA_CONTENT_SHELL_SHELL_APP_ACTIVITY_H_
...@@ -7,12 +7,11 @@ ...@@ -7,12 +7,11 @@
#include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h" #include "athena/activity/public/activity_manager.h"
#include "athena/content/public/app_registry.h" #include "athena/content/public/app_registry.h"
#include "athena/content/public/content_activity_factory.h" #include "athena/content/public/content_activity_factory_creator.h"
#include "athena/content/public/content_app_model_builder.h" #include "athena/content/public/content_app_model_builder.h"
#include "athena/env/public/athena_env.h" #include "athena/env/public/athena_env.h"
#include "athena/extensions/public/extensions_delegate.h" #include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/home_card.h" #include "athena/home/public/home_card.h"
#include "athena/home/public/home_card.h"
#include "athena/input/public/input_manager.h" #include "athena/input/public/input_manager.h"
#include "athena/main/debug/debug_window.h" #include "athena/main/debug/debug_window.h"
#include "athena/main/placeholder.h" #include "athena/main/placeholder.h"
...@@ -131,7 +130,7 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) { ...@@ -131,7 +130,7 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) {
} }
void StartAthenaSessionWithContext(content::BrowserContext* context) { void StartAthenaSessionWithContext(content::BrowserContext* context) {
StartAthenaSession(new athena::ContentActivityFactory(), StartAthenaSession(athena::CreateContentActivityFactory(),
new athena::ContentAppModelBuilder(context)); new athena::ContentAppModelBuilder(context));
athena::VirtualKeyboardManager::Create(context); athena::VirtualKeyboardManager::Create(context);
athena::HomeCard::Get()->RegisterSearchProvider( athena::HomeCard::Get()->RegisterSearchProvider(
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "athena/content/public/web_contents_view_delegate_creator.h" #include "athena/content/public/web_contents_view_delegate_creator.h"
#include "athena/env/public/athena_env.h" #include "athena/env/public/athena_env.h"
#include "athena/extensions/public/extensions_delegate.h" #include "athena/extensions/public/extensions_delegate.h"
#include "athena/main/athena_app_window_controller.h"
#include "athena/main/athena_launcher.h" #include "athena/main/athena_launcher.h"
#include "athena/screen/public/screen_manager.h" #include "athena/screen/public/screen_manager.h"
#include "base/command_line.h" #include "base/command_line.h"
......
...@@ -42,5 +42,11 @@ Activity* SampleActivityFactory::CreateAppActivity( ...@@ -42,5 +42,11 @@ Activity* SampleActivityFactory::CreateAppActivity(
kDefaultAppColor, kDefaultAppContentColor, base::UTF8ToUTF16("App")); kDefaultAppColor, kDefaultAppContentColor, base::UTF8ToUTF16("App"));
} }
Activity* SampleActivityFactory::CreateAppActivity(
apps::AppWindow* app_window) {
return new SampleActivity(
kDefaultAppColor, kDefaultAppContentColor, base::UTF8ToUTF16("App"));
}
} // namespace test } // namespace test
} // namespace athena } // namespace athena
...@@ -21,6 +21,8 @@ class SampleActivityFactory : public ActivityFactory { ...@@ -21,6 +21,8 @@ class SampleActivityFactory : public ActivityFactory {
const GURL& url) OVERRIDE; const GURL& url) OVERRIDE;
virtual Activity* CreateAppActivity( virtual Activity* CreateAppActivity(
extensions::ShellAppWindow* app_window) OVERRIDE; extensions::ShellAppWindow* app_window) OVERRIDE;
virtual Activity* CreateAppActivity(
apps::AppWindow* app_window) OVERRIDE;
private: private:
DISALLOW_COPY_AND_ASSIGN(SampleActivityFactory); DISALLOW_COPY_AND_ASSIGN(SampleActivityFactory);
......
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