| 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_launcher.h" | 11 #include "athena/main/athena_launcher.h" |
| 12 #include "athena/main/athena_renderer_pdf_helper.h" |
| 11 #include "athena/screen/public/screen_manager.h" | 13 #include "athena/screen/public/screen_manager.h" |
| 12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 14 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "components/pdf/renderer/ppb_pdf_impl.h" |
| 15 #include "content/public/app/content_main.h" | 18 #include "content/public/app/content_main.h" |
| 16 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 17 #include "extensions/shell/app/shell_main_delegate.h" | 20 #include "extensions/shell/app/shell_main_delegate.h" |
| 18 #include "extensions/shell/browser/desktop_controller.h" | 21 #include "extensions/shell/browser/desktop_controller.h" |
| 19 #include "extensions/shell/browser/shell_app_window.h" | 22 #include "extensions/shell/browser/shell_app_window.h" |
| 20 #include "extensions/shell/browser/shell_browser_main_delegate.h" | 23 #include "extensions/shell/browser/shell_browser_main_delegate.h" |
| 21 #include "extensions/shell/browser/shell_content_browser_client.h" | 24 #include "extensions/shell/browser/shell_content_browser_client.h" |
| 22 #include "extensions/shell/browser/shell_extension_system.h" | 25 #include "extensions/shell/browser/shell_extension_system.h" |
| 26 #include "extensions/shell/common/shell_content_client.h" |
| 23 #include "extensions/shell/common/switches.h" | 27 #include "extensions/shell/common/switches.h" |
| 28 #include "extensions/shell/renderer/shell_content_renderer_client.h" |
| 29 #include "ppapi/c/private/ppb_pdf.h" |
| 24 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/wm/core/visibility_controller.h" | 32 #include "ui/wm/core/visibility_controller.h" |
| 27 | 33 |
| 28 namespace { | 34 namespace { |
| 29 | 35 |
| 30 // We want to load the sample calculator app by default, for a while. Expecting | 36 // We want to load the sample calculator app by default, for a while. Expecting |
| 31 // to run athena_main at src/ | 37 // to run athena_main at src/ |
| 32 const char kDefaultAppPath[] = | 38 const char kDefaultAppPath[] = |
| 33 "chrome/common/extensions/docs/examples/apps/calculator/app"; | 39 "chrome/common/extensions/docs/examples/apps/calculator/app"; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // content::ContentBrowserClient: | 122 // content::ContentBrowserClient: |
| 117 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate( | 123 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate( |
| 118 content::WebContents* web_contents) OVERRIDE { | 124 content::WebContents* web_contents) OVERRIDE { |
| 119 return athena::CreateWebContentsViewDelegate(web_contents); | 125 return athena::CreateWebContentsViewDelegate(web_contents); |
| 120 } | 126 } |
| 121 | 127 |
| 122 private: | 128 private: |
| 123 DISALLOW_COPY_AND_ASSIGN(AthenaContentBrowserClient); | 129 DISALLOW_COPY_AND_ASSIGN(AthenaContentBrowserClient); |
| 124 }; | 130 }; |
| 125 | 131 |
| 132 class AthenaContentRendererClient |
| 133 : public extensions::ShellContentRendererClient { |
| 134 public: |
| 135 AthenaContentRendererClient() {} |
| 136 virtual ~AthenaContentRendererClient() {} |
| 137 |
| 138 // content::ContentRendererClient: |
| 139 virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE { |
| 140 new athena::AthenaRendererPDFHelper(render_frame); |
| 141 extensions::ShellContentRendererClient::RenderFrameCreated(render_frame); |
| 142 } |
| 143 |
| 144 virtual const void* CreatePPAPIInterface( |
| 145 const std::string& interface_name) OVERRIDE { |
| 146 if (interface_name == PPB_PDF_INTERFACE) |
| 147 return pdf::PPB_PDF_Impl::GetInterface(); |
| 148 return extensions::ShellContentRendererClient::CreatePPAPIInterface( |
| 149 interface_name); |
| 150 } |
| 151 }; |
| 152 |
| 126 class AthenaMainDelegate : public extensions::ShellMainDelegate { | 153 class AthenaMainDelegate : public extensions::ShellMainDelegate { |
| 127 public: | 154 public: |
| 128 AthenaMainDelegate() {} | 155 AthenaMainDelegate() {} |
| 129 virtual ~AthenaMainDelegate() {} | 156 virtual ~AthenaMainDelegate() {} |
| 130 | 157 |
| 131 private: | 158 private: |
| 132 // extensions::ShellMainDelegate: | 159 // extensions::ShellMainDelegate: |
| 160 virtual content::ContentClient* CreateContentClient() OVERRIDE { |
| 161 return new athena::AthenaContentClient(); |
| 162 } |
| 133 virtual content::ContentBrowserClient* CreateShellContentBrowserClient() | 163 virtual content::ContentBrowserClient* CreateShellContentBrowserClient() |
| 134 OVERRIDE { | 164 OVERRIDE { |
| 135 return new AthenaContentBrowserClient(); | 165 return new AthenaContentBrowserClient(); |
| 136 } | 166 } |
| 137 | 167 |
| 168 virtual content::ContentRendererClient* CreateShellContentRendererClient() |
| 169 OVERRIDE { |
| 170 return new AthenaContentRendererClient(); |
| 171 } |
| 172 |
| 138 virtual void InitializeResourceBundle() OVERRIDE { | 173 virtual void InitializeResourceBundle() OVERRIDE { |
| 139 base::FilePath pak_dir; | 174 base::FilePath pak_dir; |
| 140 PathService::Get(base::DIR_MODULE, &pak_dir); | 175 PathService::Get(base::DIR_MODULE, &pak_dir); |
| 141 base::FilePath pak_file = | 176 base::FilePath pak_file = |
| 142 pak_dir.Append(FILE_PATH_LITERAL("athena_resources.pak")); | 177 pak_dir.Append(FILE_PATH_LITERAL("athena_resources.pak")); |
| 143 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 178 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
| 144 } | 179 } |
| 145 | 180 |
| 146 DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate); | 181 DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate); |
| 147 }; | 182 }; |
| 148 | 183 |
| 149 int main(int argc, const char** argv) { | 184 int main(int argc, const char** argv) { |
| 150 AthenaMainDelegate delegate; | 185 AthenaMainDelegate delegate; |
| 151 content::ContentMainParams params(&delegate); | 186 content::ContentMainParams params(&delegate); |
| 152 | 187 |
| 153 params.argc = argc; | 188 params.argc = argc; |
| 154 params.argv = argv; | 189 params.argv = argv; |
| 155 | 190 |
| 156 return content::ContentMain(params); | 191 return content::ContentMain(params); |
| 157 } | 192 } |
| OLD | NEW |