OLD | NEW |
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/content/public/web_contents_view_delegate_creator.h" | 5 #include "athena/content/public/web_contents_view_delegate_creator.h" |
6 #include "athena/main/athena_app_window_controller.h" | 6 #include "athena/main/athena_app_window_controller.h" |
7 #include "athena/main/athena_launcher.h" | 7 #include "athena/main/athena_launcher.h" |
8 #include "athena/screen/public/screen_manager.h" | 8 #include "athena/screen/public/screen_manager.h" |
| 9 #include "athena/screen/public/screen_manager_delegate.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "content/public/app/content_main.h" | 13 #include "content/public/app/content_main.h" |
13 #include "extensions/shell/app/shell_main_delegate.h" | 14 #include "extensions/shell/app/shell_main_delegate.h" |
14 #include "extensions/shell/browser/shell_browser_main_delegate.h" | 15 #include "extensions/shell/browser/shell_browser_main_delegate.h" |
15 #include "extensions/shell/browser/shell_content_browser_client.h" | 16 #include "extensions/shell/browser/shell_content_browser_client.h" |
16 #include "extensions/shell/browser/shell_desktop_controller.h" | 17 #include "extensions/shell/browser/shell_desktop_controller.h" |
17 #include "extensions/shell/browser/shell_extension_system.h" | 18 #include "extensions/shell/browser/shell_extension_system.h" |
18 #include "extensions/shell/common/switches.h" | 19 #include "extensions/shell/common/switches.h" |
(...skipping 18 matching lines...) Expand all Loading... |
37 | 38 |
38 private: | 39 private: |
39 // extensions::ShellDesktopController: | 40 // extensions::ShellDesktopController: |
40 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { | 41 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { |
41 return athena::ScreenManager::CreateFocusRules(); | 42 return athena::ScreenManager::CreateFocusRules(); |
42 } | 43 } |
43 | 44 |
44 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); | 45 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); |
45 }; | 46 }; |
46 | 47 |
| 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 |
47 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { | 70 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { |
48 public: | 71 public: |
49 AthenaBrowserMainDelegate() {} | 72 AthenaBrowserMainDelegate() {} |
50 virtual ~AthenaBrowserMainDelegate() {} | 73 virtual ~AthenaBrowserMainDelegate() {} |
51 | 74 |
52 // extensions::ShellBrowserMainDelegate: | 75 // extensions::ShellBrowserMainDelegate: |
53 virtual void Start(content::BrowserContext* context) OVERRIDE { | 76 virtual void Start(content::BrowserContext* context) OVERRIDE { |
54 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 77 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
55 | 78 |
56 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( | 79 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
57 command_line->HasSwitch(extensions::switches::kAppShellAppPath) | 80 command_line->HasSwitch(extensions::switches::kAppShellAppPath) |
58 ? command_line->GetSwitchValueNative( | 81 ? command_line->GetSwitchValueNative( |
59 extensions::switches::kAppShellAppPath) | 82 extensions::switches::kAppShellAppPath) |
60 : kDefaultAppPath); | 83 : kDefaultAppPath); |
61 | 84 |
62 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 85 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
63 if (base::DirectoryExists(app_absolute_dir)) { | 86 if (base::DirectoryExists(app_absolute_dir)) { |
64 extensions::ShellExtensionSystem* extension_system = | 87 extensions::ShellExtensionSystem* extension_system = |
65 static_cast<extensions::ShellExtensionSystem*>( | 88 static_cast<extensions::ShellExtensionSystem*>( |
66 extensions::ExtensionSystem::Get(context)); | 89 extensions::ExtensionSystem::Get(context)); |
67 extension_system->LoadApp(app_absolute_dir); | 90 extension_system->LoadApp(app_absolute_dir); |
68 } | 91 } |
69 | 92 |
70 athena::StartAthenaEnv( | 93 extensions::ShellDesktopController* desktop_controller = |
71 extensions::ShellDesktopController::instance()->host()->window()); | 94 extensions::ShellDesktopController::instance(); |
| 95 screen_manager_delegate_.reset( |
| 96 new AthenaScreenManagerDelegate(desktop_controller)); |
| 97 athena::StartAthenaEnv(desktop_controller->host()->window(), |
| 98 screen_manager_delegate_.get()); |
72 athena::StartAthenaSessionWithContext(context); | 99 athena::StartAthenaSessionWithContext(context); |
73 } | 100 } |
74 | 101 |
75 virtual void Shutdown() OVERRIDE { | 102 virtual void Shutdown() OVERRIDE { |
76 athena::ShutdownAthena(); | 103 athena::ShutdownAthena(); |
77 } | 104 } |
78 | 105 |
79 virtual extensions::ShellDesktopController* CreateDesktopController() | 106 virtual extensions::ShellDesktopController* CreateDesktopController() |
80 OVERRIDE { | 107 OVERRIDE { |
81 // TODO(mukai): create Athena's own ShellDesktopController subclass so that | 108 // TODO(mukai): create Athena's own ShellDesktopController subclass so that |
82 // it can initialize its own window manager logic. | 109 // it can initialize its own window manager logic. |
83 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); | 110 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); |
84 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); | 111 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); |
85 return desktop; | 112 return desktop; |
86 } | 113 } |
87 | 114 |
88 private: | 115 private: |
| 116 scoped_ptr<AthenaScreenManagerDelegate> screen_manager_delegate_; |
| 117 |
89 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); | 118 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); |
90 }; | 119 }; |
91 | 120 |
92 class AthenaContentBrowserClient | 121 class AthenaContentBrowserClient |
93 : public extensions::ShellContentBrowserClient { | 122 : public extensions::ShellContentBrowserClient { |
94 public: | 123 public: |
95 AthenaContentBrowserClient() | 124 AthenaContentBrowserClient() |
96 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { | 125 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { |
97 } | 126 } |
98 virtual ~AthenaContentBrowserClient() {} | 127 virtual ~AthenaContentBrowserClient() {} |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 183 |
155 int main(int argc, const char** argv) { | 184 int main(int argc, const char** argv) { |
156 AthenaMainDelegate delegate; | 185 AthenaMainDelegate delegate; |
157 content::ContentMainParams params(&delegate); | 186 content::ContentMainParams params(&delegate); |
158 | 187 |
159 params.argc = argc; | 188 params.argc = argc; |
160 params.argv = argv; | 189 params.argv = argv; |
161 | 190 |
162 return content::ContentMain(params); | 191 return content::ContentMain(params); |
163 } | 192 } |
OLD | NEW |