Chromium Code Reviews| 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 "apps/shell/app/shell_main_delegate.h" | 5 #include "apps/shell/app/shell_main_delegate.h" |
| 6 #include "apps/shell/browser/shell_browser_main_delegate.h" | 6 #include "apps/shell/browser/shell_browser_main_delegate.h" |
| 7 #include "apps/shell/browser/shell_desktop_controller.h" | 7 #include "apps/shell/browser/shell_desktop_controller.h" |
| 8 #include "apps/shell/browser/shell_extension_system.h" | 8 #include "apps/shell/browser/shell_extension_system.h" |
| 9 #include "apps/shell/renderer/shell_renderer_main_delegate.h" | 9 #include "apps/shell/renderer/shell_renderer_main_delegate.h" |
| 10 #include "athena/content/public/content_activity_factory.h" | 10 #include "athena/content/public/content_activity_factory.h" |
| 11 #include "athena/content/public/content_app_model_builder.h" | 11 #include "athena/content/public/content_app_model_builder.h" |
| 12 #include "athena/home/public/home_card.h" | 12 #include "athena/home/public/home_card.h" |
| 13 #include "athena/main/athena_app_window_controller.h" | 13 #include "athena/main/athena_app_window_controller.h" |
| 14 #include "athena/main/athena_launcher.h" | 14 #include "athena/main/athena_launcher.h" |
| 15 #include "athena/main/placeholder.h" | 15 #include "athena/main/placeholder.h" |
| 16 #include "athena/main/url_search_provider.h" | 16 #include "athena/main/url_search_provider.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "content/public/app/content_main.h" | 19 #include "content/public/app/content_main.h" |
| 20 #include "ui/aura/window_tree_host.h" | 20 #include "ui/aura/window_tree_host.h" |
| 21 #include "ui/wm/core/visibility_controller.h" | 21 #include "ui/wm/core/visibility_controller.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 const std::string kAppSwitch = "app"; | 24 const char kAppSwitch[] = "app"; |
| 25 | |
| 26 // We want to load the sample calculator app by default, for a while. Expecting | |
| 27 // to run athena_main at src/ | |
| 28 const char kDefaultAppPath[] = | |
| 29 "chrome/common/extensions/docs/examples/apps/calculator/app"; | |
| 25 } // namespace | 30 } // namespace |
| 26 | 31 |
| 27 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { | 32 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { |
| 28 public: | 33 public: |
| 29 AthenaBrowserMainDelegate() {} | 34 AthenaBrowserMainDelegate() {} |
| 30 virtual ~AthenaBrowserMainDelegate() {} | 35 virtual ~AthenaBrowserMainDelegate() {} |
| 31 | 36 |
| 32 // apps::ShellBrowserMainDelegate: | 37 // apps::ShellBrowserMainDelegate: |
| 33 virtual void Start(content::BrowserContext* context) OVERRIDE { | 38 virtual void Start(content::BrowserContext* context) OVERRIDE { |
| 34 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 39 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 35 if (command_line->HasSwitch(kAppSwitch)) { | 40 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
| 36 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); | 41 command_line->HasSwitch(kAppSwitch) ? |
| 37 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 42 command_line->GetSwitchValueNative(kAppSwitch) : |
| 38 extensions::ShellExtensionSystem* extension_system = | 43 kDefaultAppPath); |
|
oshima
2014/06/19 23:28:27
what if the directory does not exist? Just want to
Jun Mukai
2014/06/19 23:34:18
Oops, didn't notice shell_extension_system has a C
| |
| 39 static_cast<extensions::ShellExtensionSystem*>( | 44 |
| 40 extensions::ExtensionSystem::Get(context)); | 45 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
| 41 extension_system->LoadApp(app_absolute_dir); | 46 extensions::ShellExtensionSystem* extension_system = |
| 42 } | 47 static_cast<extensions::ShellExtensionSystem*>( |
| 48 extensions::ExtensionSystem::Get(context)); | |
| 49 extension_system->LoadApp(app_absolute_dir); | |
| 43 | 50 |
| 44 athena::StartAthena( | 51 athena::StartAthena( |
| 45 apps::ShellDesktopController::instance()->host()->window(), | 52 apps::ShellDesktopController::instance()->host()->window(), |
| 46 new athena::ContentActivityFactory(), | 53 new athena::ContentActivityFactory(), |
| 47 new athena::ContentAppModelBuilder(context)); | 54 new athena::ContentAppModelBuilder(context)); |
| 48 athena::HomeCard::Get()->RegisterSearchProvider( | 55 athena::HomeCard::Get()->RegisterSearchProvider( |
| 49 new athena::UrlSearchProvider(context)); | 56 new athena::UrlSearchProvider(context)); |
| 50 CreateTestPages(context); | 57 CreateTestPages(context); |
| 51 } | 58 } |
| 52 | 59 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 108 |
| 102 int main(int argc, const char** argv) { | 109 int main(int argc, const char** argv) { |
| 103 AthenaMainDelegate delegate; | 110 AthenaMainDelegate delegate; |
| 104 content::ContentMainParams params(&delegate); | 111 content::ContentMainParams params(&delegate); |
| 105 | 112 |
| 106 params.argc = argc; | 113 params.argc = argc; |
| 107 params.argv = argv; | 114 params.argv = argv; |
| 108 | 115 |
| 109 return content::ContentMain(params); | 116 return content::ContentMain(params); |
| 110 } | 117 } |
| OLD | NEW |