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/activity/public/activity_factory.h" | 5 #include "athena/activity/public/activity_factory.h" |
6 #include "athena/activity/public/activity_manager.h" | 6 #include "athena/activity/public/activity_manager.h" |
7 #include "athena/content/public/web_contents_view_delegate_creator.h" | 7 #include "athena/content/public/web_contents_view_delegate_creator.h" |
8 #include "athena/env/public/athena_env.h" | 8 #include "athena/env/public/athena_env.h" |
9 #include "athena/extensions/public/extensions_delegate.h" | 9 #include "athena/extensions/public/extensions_delegate.h" |
10 #include "athena/main/athena_content_client.h" | 10 #include "athena/main/athena_content_client.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 class AthenaDesktopController : public extensions::DesktopController { | 46 class AthenaDesktopController : public extensions::DesktopController { |
47 public: | 47 public: |
48 AthenaDesktopController() {} | 48 AthenaDesktopController() {} |
49 virtual ~AthenaDesktopController() {} | 49 virtual ~AthenaDesktopController() {} |
50 | 50 |
51 private: | 51 private: |
52 // extensions::DesktopController: | 52 // extensions::DesktopController: |
53 virtual aura::WindowTreeHost* GetHost() OVERRIDE { | 53 virtual aura::WindowTreeHost* GetHost() override { |
54 return athena::AthenaEnv::Get()->GetHost(); | 54 return athena::AthenaEnv::Get()->GetHost(); |
55 } | 55 } |
56 | 56 |
57 // Creates a new app window and adds it to the desktop. The desktop maintains | 57 // Creates a new app window and adds it to the desktop. The desktop maintains |
58 // ownership of the window. | 58 // ownership of the window. |
59 // TODO(jamescook|oshima): Is this function needed? | 59 // TODO(jamescook|oshima): Is this function needed? |
60 virtual extensions::AppWindow* CreateAppWindow( | 60 virtual extensions::AppWindow* CreateAppWindow( |
61 content::BrowserContext* context, | 61 content::BrowserContext* context, |
62 const extensions::Extension* extension) OVERRIDE { | 62 const extensions::Extension* extension) override { |
63 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
64 return NULL; | 64 return NULL; |
65 } | 65 } |
66 | 66 |
67 // Adds the window to the desktop. | 67 // Adds the window to the desktop. |
68 virtual void AddAppWindow(aura::Window* window) OVERRIDE { | 68 virtual void AddAppWindow(aura::Window* window) override { |
69 NOTIMPLEMENTED(); | 69 NOTIMPLEMENTED(); |
70 } | 70 } |
71 | 71 |
72 // Closes and destroys the app windows. | 72 // Closes and destroys the app windows. |
73 virtual void CloseAppWindows() OVERRIDE {} | 73 virtual void CloseAppWindows() override {} |
74 | 74 |
75 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); | 75 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); |
76 }; | 76 }; |
77 | 77 |
78 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { | 78 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { |
79 public: | 79 public: |
80 AthenaBrowserMainDelegate() {} | 80 AthenaBrowserMainDelegate() {} |
81 virtual ~AthenaBrowserMainDelegate() {} | 81 virtual ~AthenaBrowserMainDelegate() {} |
82 | 82 |
83 // extensions::ShellBrowserMainDelegate: | 83 // extensions::ShellBrowserMainDelegate: |
84 virtual void Start(content::BrowserContext* context) OVERRIDE { | 84 virtual void Start(content::BrowserContext* context) override { |
85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
86 | 86 |
87 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( | 87 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
88 command_line->HasSwitch(extensions::switches::kAppShellAppPath) | 88 command_line->HasSwitch(extensions::switches::kAppShellAppPath) |
89 ? command_line->GetSwitchValueNative( | 89 ? command_line->GetSwitchValueNative( |
90 extensions::switches::kAppShellAppPath) | 90 extensions::switches::kAppShellAppPath) |
91 : kDefaultAppPath); | 91 : kDefaultAppPath); |
92 | 92 |
93 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 93 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
94 if (base::DirectoryExists(app_absolute_dir)) { | 94 if (base::DirectoryExists(app_absolute_dir)) { |
95 extensions::ShellExtensionSystem* extension_system = | 95 extensions::ShellExtensionSystem* extension_system = |
96 static_cast<extensions::ShellExtensionSystem*>( | 96 static_cast<extensions::ShellExtensionSystem*>( |
97 extensions::ExtensionSystem::Get(context)); | 97 extensions::ExtensionSystem::Get(context)); |
98 extension_system->LoadApp(app_absolute_dir); | 98 extension_system->LoadApp(app_absolute_dir); |
99 } | 99 } |
100 | 100 |
101 athena::StartAthenaEnv(content::BrowserThread::GetBlockingPool()-> | 101 athena::StartAthenaEnv(content::BrowserThread::GetBlockingPool()-> |
102 GetTaskRunnerWithShutdownBehavior( | 102 GetTaskRunnerWithShutdownBehavior( |
103 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 103 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
104 athena::CreateVirtualKeyboardWithContext(context); | 104 athena::CreateVirtualKeyboardWithContext(context); |
105 athena::StartAthenaSessionWithContext(context); | 105 athena::StartAthenaSessionWithContext(context); |
106 } | 106 } |
107 | 107 |
108 virtual void Shutdown() OVERRIDE { | 108 virtual void Shutdown() override { |
109 athena::AthenaEnv::Get()->OnTerminating(); | 109 athena::AthenaEnv::Get()->OnTerminating(); |
110 athena::ShutdownAthena(); | 110 athena::ShutdownAthena(); |
111 } | 111 } |
112 | 112 |
113 virtual extensions::DesktopController* CreateDesktopController() OVERRIDE { | 113 virtual extensions::DesktopController* CreateDesktopController() override { |
114 return new AthenaDesktopController(); | 114 return new AthenaDesktopController(); |
115 } | 115 } |
116 | 116 |
117 private: | 117 private: |
118 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); | 118 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); |
119 }; | 119 }; |
120 | 120 |
121 class AthenaContentBrowserClient | 121 class AthenaContentBrowserClient |
122 : public extensions::ShellContentBrowserClient { | 122 : public extensions::ShellContentBrowserClient { |
123 public: | 123 public: |
124 AthenaContentBrowserClient() | 124 AthenaContentBrowserClient() |
125 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { | 125 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { |
126 } | 126 } |
127 virtual ~AthenaContentBrowserClient() {} | 127 virtual ~AthenaContentBrowserClient() {} |
128 | 128 |
129 // content::ContentBrowserClient: | 129 // content::ContentBrowserClient: |
130 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate( | 130 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate( |
131 content::WebContents* web_contents) OVERRIDE { | 131 content::WebContents* web_contents) override { |
132 return athena::CreateWebContentsViewDelegate(web_contents); | 132 return athena::CreateWebContentsViewDelegate(web_contents); |
133 } | 133 } |
134 | 134 |
135 private: | 135 private: |
136 DISALLOW_COPY_AND_ASSIGN(AthenaContentBrowserClient); | 136 DISALLOW_COPY_AND_ASSIGN(AthenaContentBrowserClient); |
137 }; | 137 }; |
138 | 138 |
139 class AthenaContentRendererClient | 139 class AthenaContentRendererClient |
140 : public extensions::ShellContentRendererClient { | 140 : public extensions::ShellContentRendererClient { |
141 public: | 141 public: |
142 AthenaContentRendererClient() {} | 142 AthenaContentRendererClient() {} |
143 virtual ~AthenaContentRendererClient() {} | 143 virtual ~AthenaContentRendererClient() {} |
144 | 144 |
145 // content::ContentRendererClient: | 145 // content::ContentRendererClient: |
146 virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE { | 146 virtual void RenderFrameCreated(content::RenderFrame* render_frame) override { |
147 new athena::AthenaRendererPDFHelper(render_frame); | 147 new athena::AthenaRendererPDFHelper(render_frame); |
148 extensions::ShellContentRendererClient::RenderFrameCreated(render_frame); | 148 extensions::ShellContentRendererClient::RenderFrameCreated(render_frame); |
149 } | 149 } |
150 | 150 |
151 virtual const void* CreatePPAPIInterface( | 151 virtual const void* CreatePPAPIInterface( |
152 const std::string& interface_name) OVERRIDE { | 152 const std::string& interface_name) override { |
153 if (interface_name == PPB_PDF_INTERFACE) | 153 if (interface_name == PPB_PDF_INTERFACE) |
154 return pdf::PPB_PDF_Impl::GetInterface(); | 154 return pdf::PPB_PDF_Impl::GetInterface(); |
155 return extensions::ShellContentRendererClient::CreatePPAPIInterface( | 155 return extensions::ShellContentRendererClient::CreatePPAPIInterface( |
156 interface_name); | 156 interface_name); |
157 } | 157 } |
158 }; | 158 }; |
159 | 159 |
160 class AthenaMainDelegate : public extensions::ShellMainDelegate { | 160 class AthenaMainDelegate : public extensions::ShellMainDelegate { |
161 public: | 161 public: |
162 AthenaMainDelegate() {} | 162 AthenaMainDelegate() {} |
163 virtual ~AthenaMainDelegate() {} | 163 virtual ~AthenaMainDelegate() {} |
164 | 164 |
165 private: | 165 private: |
166 // extensions::ShellMainDelegate: | 166 // extensions::ShellMainDelegate: |
167 virtual content::ContentClient* CreateContentClient() OVERRIDE { | 167 virtual content::ContentClient* CreateContentClient() override { |
168 return new athena::AthenaContentClient(); | 168 return new athena::AthenaContentClient(); |
169 } | 169 } |
170 virtual content::ContentBrowserClient* CreateShellContentBrowserClient() | 170 virtual content::ContentBrowserClient* CreateShellContentBrowserClient() |
171 OVERRIDE { | 171 override { |
172 return new AthenaContentBrowserClient(); | 172 return new AthenaContentBrowserClient(); |
173 } | 173 } |
174 | 174 |
175 virtual content::ContentRendererClient* CreateShellContentRendererClient() | 175 virtual content::ContentRendererClient* CreateShellContentRendererClient() |
176 OVERRIDE { | 176 override { |
177 return new AthenaContentRendererClient(); | 177 return new AthenaContentRendererClient(); |
178 } | 178 } |
179 | 179 |
180 virtual void InitializeResourceBundle() OVERRIDE { | 180 virtual void InitializeResourceBundle() override { |
181 base::FilePath pak_dir; | 181 base::FilePath pak_dir; |
182 PathService::Get(base::DIR_MODULE, &pak_dir); | 182 PathService::Get(base::DIR_MODULE, &pak_dir); |
183 base::FilePath pak_file = | 183 base::FilePath pak_file = |
184 pak_dir.Append(FILE_PATH_LITERAL("athena_resources.pak")); | 184 pak_dir.Append(FILE_PATH_LITERAL("athena_resources.pak")); |
185 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 185 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
186 } | 186 } |
187 | 187 |
188 DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate); |
189 }; | 189 }; |
190 | 190 |
191 int main(int argc, const char** argv) { | 191 int main(int argc, const char** argv) { |
192 AthenaMainDelegate delegate; | 192 AthenaMainDelegate delegate; |
193 content::ContentMainParams params(&delegate); | 193 content::ContentMainParams params(&delegate); |
194 | 194 |
195 params.argc = argc; | 195 params.argc = argc; |
196 params.argv = argv; | 196 params.argv = argv; |
197 | 197 |
198 return content::ContentMain(params); | 198 return content::ContentMain(params); |
199 } | 199 } |
OLD | NEW |