Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "apps/shell/app/shell_main_delegate.h" | 5 #include "apps/shell/app/shell_main_delegate.h" |
| 6 #include "apps/shell/browser/shell_browser_main_parts.h" | |
| 7 #include "apps/shell/browser/shell_extension_system.h" | |
| 8 #include "apps/shell/common/shell_delegate.h" | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/file_util.h" | |
| 11 #include "base/files/file_path.h" | |
| 6 #include "content/public/app/content_main.h" | 12 #include "content/public/app/content_main.h" |
| 7 | 13 |
| 8 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 9 #include "content/public/app/startup_helper_win.h" | 15 #include "content/public/app/startup_helper_win.h" |
| 10 #include "sandbox/win/src/sandbox_types.h" | 16 #include "sandbox/win/src/sandbox_types.h" |
| 11 #endif | 17 #endif |
| 12 | 18 |
| 19 class AppShellDelegate : public apps::ShellDelegate { | |
|
oshima
2014/05/07 22:08:03
I'm not sure where this code should live. Maybe in
James Cook
2014/05/07 23:42:45
The final code should live in apps/shell/browser,
oshima
2014/05/08 21:12:37
moved to apps/shell/browser/shell_app_starter.
| |
| 20 public: | |
| 21 AppShellDelegate() {} | |
| 22 virtual ~AppShellDelegate() {} | |
| 23 | |
| 24 virtual void Start(content::BrowserContext* browser_context) OVERRIDE { | |
| 25 const std::string kAppSwitch = "app"; | |
| 26 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 27 if (command_line->HasSwitch(kAppSwitch)) { | |
| 28 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); | |
| 29 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | |
| 30 | |
| 31 extensions::ShellExtensionSystem* extension_system = | |
| 32 static_cast<extensions::ShellExtensionSystem*>( | |
| 33 extensions::ExtensionSystem::Get(browser_context)); | |
|
oshima
2014/05/07 22:08:03
Not sure if this is right thing to do either....
James Cook
2014/05/07 23:42:45
The cast is fine. It's just convenient to put Loa
| |
| 34 extension_system->LoadAndLaunchApp(app_absolute_dir); | |
| 35 } else { | |
| 36 LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future"; | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 DISALLOW_COPY_AND_ASSIGN(AppShellDelegate); | |
| 42 }; | |
| 43 | |
| 13 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 14 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { | 45 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { |
| 15 #else | 46 #else |
| 16 int main(int argc, const char** argv) { | 47 int main(int argc, const char** argv) { |
| 17 #endif | 48 #endif |
| 18 apps::ShellMainDelegate delegate; | 49 AppShellDelegate app_shell_delegate; |
| 50 apps::ShellMainDelegate delegate(&app_shell_delegate); | |
| 19 content::ContentMainParams params(&delegate); | 51 content::ContentMainParams params(&delegate); |
| 20 | 52 |
| 21 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 22 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | 54 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
| 23 content::InitializeSandboxInfo(&sandbox_info); | 55 content::InitializeSandboxInfo(&sandbox_info); |
| 24 params.instance = instance; | 56 params.instance = instance; |
| 25 params.sandbox_info = &sandbox_info; | 57 params.sandbox_info = &sandbox_info; |
| 26 #else | 58 #else |
| 27 params.argc = argc; | 59 params.argc = argc; |
| 28 params.argv = argv; | 60 params.argv = argv; |
| 29 #endif | 61 #endif |
| 30 | 62 |
| 31 return content::ContentMain(params); | 63 return content::ContentMain(params); |
| 32 } | 64 } |
| OLD | NEW |