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) : |
| 43 kDefaultAppPath); |
| 44 |
| 45 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
| 46 if (base::DirectoryExists(app_absolute_dir)) { |
38 extensions::ShellExtensionSystem* extension_system = | 47 extensions::ShellExtensionSystem* extension_system = |
39 static_cast<extensions::ShellExtensionSystem*>( | 48 static_cast<extensions::ShellExtensionSystem*>( |
40 extensions::ExtensionSystem::Get(context)); | 49 extensions::ExtensionSystem::Get(context)); |
41 extension_system->LoadApp(app_absolute_dir); | 50 extension_system->LoadApp(app_absolute_dir); |
42 } | 51 } |
43 | 52 |
44 athena::StartAthena( | 53 athena::StartAthena( |
45 apps::ShellDesktopController::instance()->host()->window(), | 54 apps::ShellDesktopController::instance()->host()->window(), |
46 new athena::ContentActivityFactory(), | 55 new athena::ContentActivityFactory(), |
47 new athena::ContentAppModelBuilder(context)); | 56 new athena::ContentAppModelBuilder(context)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 110 |
102 int main(int argc, const char** argv) { | 111 int main(int argc, const char** argv) { |
103 AthenaMainDelegate delegate; | 112 AthenaMainDelegate delegate; |
104 content::ContentMainParams params(&delegate); | 113 content::ContentMainParams params(&delegate); |
105 | 114 |
106 params.argc = argc; | 115 params.argc = argc; |
107 params.argv = argv; | 116 params.argv = argv; |
108 | 117 |
109 return content::ContentMain(params); | 118 return content::ContentMain(params); |
110 } | 119 } |
OLD | NEW |