Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: athena/main/athena_main.cc

Issue 480353006: Separate athena's startup process from AppShell's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "athena/activity/public/activity_factory.h"
6 #include "athena/activity/public/activity_manager.h"
5 #include "athena/content/public/web_contents_view_delegate_creator.h" 7 #include "athena/content/public/web_contents_view_delegate_creator.h"
6 #include "athena/main/athena_app_window_controller.h" 8 #include "athena/env/public/athena_env.h"
7 #include "athena/main/athena_launcher.h" 9 #include "athena/main/athena_launcher.h"
8 #include "athena/screen/public/screen_manager.h" 10 #include "athena/screen/public/screen_manager.h"
9 #include "athena/screen/public/screen_manager_delegate.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "content/public/app/content_main.h" 14 #include "content/public/app/content_main.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "extensions/shell/app/shell_main_delegate.h" 16 #include "extensions/shell/app/shell_main_delegate.h"
17 #include "extensions/shell/browser/desktop_controller.h"
18 #include "extensions/shell/browser/shell_app_window.h"
16 #include "extensions/shell/browser/shell_browser_main_delegate.h" 19 #include "extensions/shell/browser/shell_browser_main_delegate.h"
17 #include "extensions/shell/browser/shell_content_browser_client.h" 20 #include "extensions/shell/browser/shell_content_browser_client.h"
18 #include "extensions/shell/browser/shell_desktop_controller.h"
19 #include "extensions/shell/browser/shell_extension_system.h" 21 #include "extensions/shell/browser/shell_extension_system.h"
20 #include "extensions/shell/common/switches.h" 22 #include "extensions/shell/common/switches.h"
21 #include "ui/aura/window_tree_host.h" 23 #include "ui/aura/window_tree_host.h"
22 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/wm/core/visibility_controller.h" 25 #include "ui/wm/core/visibility_controller.h"
24 26
25 namespace { 27 namespace {
26 28
27 // We want to load the sample calculator app by default, for a while. Expecting 29 // We want to load the sample calculator app by default, for a while. Expecting
28 // to run athena_main at src/ 30 // to run athena_main at src/
29 const char kDefaultAppPath[] = 31 const char kDefaultAppPath[] =
30 "chrome/common/extensions/docs/examples/apps/calculator/app"; 32 "chrome/common/extensions/docs/examples/apps/calculator/app";
31 33
32 } // namespace athena 34 } // namespace athena
33 35
34 class AthenaDesktopController : public extensions::ShellDesktopController { 36 class AthenaDesktopController : public extensions::DesktopController {
35 public: 37 public:
36 AthenaDesktopController() {} 38 AthenaDesktopController() {}
37 virtual ~AthenaDesktopController() {} 39 virtual ~AthenaDesktopController() {}
38 40
39 private: 41 private:
40 // extensions::ShellDesktopController: 42 // extensions::ShellDesktopController:
Jun Mukai 2014/08/23 01:11:12 // extensions::DesktopController:
oshima 2014/08/23 01:19:36 Done.
41 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { 43 virtual aura::WindowTreeHost* GetHost() OVERRIDE {
42 return athena::ScreenManager::CreateFocusRules(); 44 return athena::AthenaEnv::Get()->GetHost();
43 } 45 }
44 46
47 // Creates the window that hosts the app.
Jun Mukai 2014/08/23 01:11:12 I don't think you need to comment overriding metho
oshima 2014/08/23 01:19:36 Done.
48 virtual void CreateRootWindow() OVERRIDE {}
49
50 // Creates a new app window and adds it to the desktop. The desktop maintains
51 // ownership of the window.
52 virtual extensions::ShellAppWindow* CreateAppWindow(
53 content::BrowserContext* context) OVERRIDE {
54 extensions::ShellAppWindow* app_window = new extensions::ShellAppWindow();
55 app_window->Init(context, gfx::Size(100, 100));
56 athena::ActivityManager::Get()->AddActivity(
57 athena::ActivityFactory::Get()->CreateAppActivity(app_window));
58 return app_window;
59 }
60
61 // Closes and destroys the app windows.
62 virtual void CloseAppWindows() OVERRIDE {}
63
45 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); 64 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController);
46 }; 65 };
47 66
48 class AthenaScreenManagerDelegate : public athena::ScreenManagerDelegate {
49 public:
50 explicit AthenaScreenManagerDelegate(
51 extensions::ShellDesktopController* controller)
52 : controller_(controller) {
53 }
54
55 virtual ~AthenaScreenManagerDelegate() {
56 }
57
58 private:
59 // athena::ScreenManagerDelegate:
60 virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE {
61 controller_->SetDisplayWorkAreaInsets(insets);
62 }
63
64 // Not owned.
65 extensions::ShellDesktopController* controller_;
66
67 DISALLOW_COPY_AND_ASSIGN(AthenaScreenManagerDelegate);
68 };
69
70 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { 67 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
71 public: 68 public:
72 AthenaBrowserMainDelegate() {} 69 AthenaBrowserMainDelegate() {}
73 virtual ~AthenaBrowserMainDelegate() {} 70 virtual ~AthenaBrowserMainDelegate() {}
74 71
75 // extensions::ShellBrowserMainDelegate: 72 // extensions::ShellBrowserMainDelegate:
76 virtual void Start(content::BrowserContext* context) OVERRIDE { 73 virtual void Start(content::BrowserContext* context) OVERRIDE {
77 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 74 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
78 75
79 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( 76 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe(
80 command_line->HasSwitch(extensions::switches::kAppShellAppPath) 77 command_line->HasSwitch(extensions::switches::kAppShellAppPath)
81 ? command_line->GetSwitchValueNative( 78 ? command_line->GetSwitchValueNative(
82 extensions::switches::kAppShellAppPath) 79 extensions::switches::kAppShellAppPath)
83 : kDefaultAppPath); 80 : kDefaultAppPath);
84 81
85 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); 82 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
86 if (base::DirectoryExists(app_absolute_dir)) { 83 if (base::DirectoryExists(app_absolute_dir)) {
87 extensions::ShellExtensionSystem* extension_system = 84 extensions::ShellExtensionSystem* extension_system =
88 static_cast<extensions::ShellExtensionSystem*>( 85 static_cast<extensions::ShellExtensionSystem*>(
89 extensions::ExtensionSystem::Get(context)); 86 extensions::ExtensionSystem::Get(context));
90 extension_system->LoadApp(app_absolute_dir); 87 extension_system->LoadApp(app_absolute_dir);
91 } 88 }
92 89
93 extensions::ShellDesktopController* desktop_controller = 90 // TODO(oshima|mukai):
Jun Mukai 2014/08/23 01:11:12 What is the content of the TODO?
94 extensions::ShellDesktopController::instance(); 91 athena::StartAthenaEnv(content::BrowserThread::GetMessageLoopProxyForThread(
95 screen_manager_delegate_.reset( 92 content::BrowserThread::FILE));
96 new AthenaScreenManagerDelegate(desktop_controller));
97 athena::StartAthenaEnv(desktop_controller->host()->window(),
98 screen_manager_delegate_.get(),
99 content::BrowserThread::GetMessageLoopProxyForThread(
100 content::BrowserThread::FILE));
101 athena::StartAthenaSessionWithContext(context); 93 athena::StartAthenaSessionWithContext(context);
102 } 94 }
103 95
104 virtual void Shutdown() OVERRIDE { 96 virtual void Shutdown() OVERRIDE {
105 athena::ShutdownAthena(); 97 athena::ShutdownAthena();
106 } 98 }
107 99
108 virtual extensions::ShellDesktopController* CreateDesktopController() 100 virtual extensions::DesktopController* CreateDesktopController() OVERRIDE {
109 OVERRIDE { 101 return new AthenaDesktopController();
110 // TODO(mukai): create Athena's own ShellDesktopController subclass so that
111 // it can initialize its own window manager logic.
112 extensions::ShellDesktopController* desktop = new AthenaDesktopController();
113 desktop->SetAppWindowController(new athena::AthenaAppWindowController());
114 return desktop;
115 } 102 }
116 103
117 private: 104 private:
118 scoped_ptr<AthenaScreenManagerDelegate> screen_manager_delegate_;
119
120 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); 105 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
121 }; 106 };
122 107
123 class AthenaContentBrowserClient 108 class AthenaContentBrowserClient
124 : public extensions::ShellContentBrowserClient { 109 : public extensions::ShellContentBrowserClient {
125 public: 110 public:
126 AthenaContentBrowserClient() 111 AthenaContentBrowserClient()
127 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { 112 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) {
128 } 113 }
129 virtual ~AthenaContentBrowserClient() {} 114 virtual ~AthenaContentBrowserClient() {}
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 148
164 int main(int argc, const char** argv) { 149 int main(int argc, const char** argv) {
165 AthenaMainDelegate delegate; 150 AthenaMainDelegate delegate;
166 content::ContentMainParams params(&delegate); 151 content::ContentMainParams params(&delegate);
167 152
168 params.argc = argc; 153 params.argc = argc;
169 params.argv = argv; 154 params.argv = argv;
170 155
171 return content::ContentMain(params); 156 return content::ContentMain(params);
172 } 157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698