Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: athena/main/athena_main.cc

Issue 485183002: introduced athena_main_lib (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gyp cleanup Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « athena/main/athena_launcher.cc ('k') | athena/main/athena_main.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/content/public/content_activity_factory.h"
6 #include "athena/content/public/content_app_model_builder.h"
7 #include "athena/content/public/web_contents_view_delegate_creator.h" 5 #include "athena/content/public/web_contents_view_delegate_creator.h"
8 #include "athena/home/public/home_card.h"
9 #include "athena/main/athena_app_window_controller.h" 6 #include "athena/main/athena_app_window_controller.h"
10 #include "athena/main/athena_launcher.h" 7 #include "athena/main/athena_launcher.h"
11 #include "athena/main/debug/debug_window.h"
12 #include "athena/main/placeholder.h"
13 #include "athena/main/url_search_provider.h"
14 #include "athena/screen/public/screen_manager.h" 8 #include "athena/screen/public/screen_manager.h"
15 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
16 #include "base/command_line.h" 9 #include "base/command_line.h"
17 #include "base/file_util.h" 10 #include "base/file_util.h"
18 #include "base/path_service.h" 11 #include "base/path_service.h"
19 #include "content/public/app/content_main.h" 12 #include "content/public/app/content_main.h"
20 #include "extensions/shell/app/shell_main_delegate.h" 13 #include "extensions/shell/app/shell_main_delegate.h"
21 #include "extensions/shell/browser/shell_browser_main_delegate.h" 14 #include "extensions/shell/browser/shell_browser_main_delegate.h"
22 #include "extensions/shell/browser/shell_content_browser_client.h" 15 #include "extensions/shell/browser/shell_content_browser_client.h"
23 #include "extensions/shell/browser/shell_desktop_controller.h" 16 #include "extensions/shell/browser/shell_desktop_controller.h"
24 #include "extensions/shell/browser/shell_extension_system.h" 17 #include "extensions/shell/browser/shell_extension_system.h"
25 #include "extensions/shell/common/switches.h" 18 #include "extensions/shell/common/switches.h"
26 #include "extensions/shell/renderer/shell_renderer_main_delegate.h" 19 #include "extensions/shell/renderer/shell_renderer_main_delegate.h"
27 #include "ui/app_list/app_list_switches.h"
28 #include "ui/aura/window_tree_host.h" 20 #include "ui/aura/window_tree_host.h"
29 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/keyboard/keyboard_controller.h"
31 #include "ui/keyboard/keyboard_controller_observer.h"
32 #include "ui/native_theme/native_theme_switches.h"
33 #include "ui/wm/core/visibility_controller.h" 22 #include "ui/wm/core/visibility_controller.h"
34 23
35 namespace { 24 namespace {
36 25
37 // We want to load the sample calculator app by default, for a while. Expecting 26 // We want to load the sample calculator app by default, for a while. Expecting
38 // to run athena_main at src/ 27 // to run athena_main at src/
39 const char kDefaultAppPath[] = 28 const char kDefaultAppPath[] =
40 "chrome/common/extensions/docs/examples/apps/calculator/app"; 29 "chrome/common/extensions/docs/examples/apps/calculator/app";
41 } // namespace
42 30
43 // This class observes the change of the virtual keyboard and distribute the 31 } // namespace athena
44 // change to appropriate modules of athena.
45 // TODO(oshima): move the VK bounds logic to screen manager.
46 class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver {
47 public:
48 VirtualKeyboardObserver() {
49 keyboard::KeyboardController::GetInstance()->AddObserver(this);
50 }
51
52 virtual ~VirtualKeyboardObserver() {
53 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
54 }
55
56 private:
57 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE {
58 athena::HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds);
59 }
60
61 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver);
62 };
63 32
64 class AthenaDesktopController : public extensions::ShellDesktopController { 33 class AthenaDesktopController : public extensions::ShellDesktopController {
65 public: 34 public:
66 AthenaDesktopController() {} 35 AthenaDesktopController() {}
67 virtual ~AthenaDesktopController() {} 36 virtual ~AthenaDesktopController() {}
68 37
69 private: 38 private:
70 // extensions::ShellDesktopController: 39 // extensions::ShellDesktopController:
71 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { 40 virtual wm::FocusRules* CreateFocusRules() OVERRIDE {
72 return athena::ScreenManager::CreateFocusRules(); 41 return athena::ScreenManager::CreateFocusRules();
73 } 42 }
74 43
75 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); 44 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController);
76 }; 45 };
77 46
78 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { 47 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
79 public: 48 public:
80 AthenaBrowserMainDelegate() {} 49 AthenaBrowserMainDelegate() {}
81 virtual ~AthenaBrowserMainDelegate() {} 50 virtual ~AthenaBrowserMainDelegate() {}
82 51
83 // extensions::ShellBrowserMainDelegate: 52 // extensions::ShellBrowserMainDelegate:
84 virtual void Start(content::BrowserContext* context) OVERRIDE { 53 virtual void Start(content::BrowserContext* context) OVERRIDE {
85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 54 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
86 55
87 // Force showing in the experimental app-list view.
88 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList);
89 command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
90
91 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( 56 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe(
92 command_line->HasSwitch(extensions::switches::kAppShellAppPath) 57 command_line->HasSwitch(extensions::switches::kAppShellAppPath)
93 ? command_line->GetSwitchValueNative( 58 ? command_line->GetSwitchValueNative(
94 extensions::switches::kAppShellAppPath) 59 extensions::switches::kAppShellAppPath)
95 : kDefaultAppPath); 60 : kDefaultAppPath);
96 61
97 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); 62 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
98 if (base::DirectoryExists(app_absolute_dir)) { 63 if (base::DirectoryExists(app_absolute_dir)) {
99 extensions::ShellExtensionSystem* extension_system = 64 extensions::ShellExtensionSystem* extension_system =
100 static_cast<extensions::ShellExtensionSystem*>( 65 static_cast<extensions::ShellExtensionSystem*>(
101 extensions::ExtensionSystem::Get(context)); 66 extensions::ExtensionSystem::Get(context));
102 extension_system->LoadApp(app_absolute_dir); 67 extension_system->LoadApp(app_absolute_dir);
103 } 68 }
104 69
105 athena::StartAthena( 70 athena::StartAthenaEnv(
106 extensions::ShellDesktopController::instance()->host()->window(), 71 extensions::ShellDesktopController::instance()->host()->window());
107 new athena::ContentActivityFactory(), 72 athena::StartAthenaSessionWithContext(context);
108 new athena::ContentAppModelBuilder(context));
109 athena::HomeCard::Get()->RegisterSearchProvider(
110 new athena::UrlSearchProvider(context));
111 athena::VirtualKeyboardManager::Create(context);
112 keyboard_observer_.reset(new VirtualKeyboardObserver());
113
114 CreateTestPages(context);
115 CreateDebugWindow();
116 } 73 }
117 74
118 virtual void Shutdown() OVERRIDE { 75 virtual void Shutdown() OVERRIDE {
119 keyboard_observer_.reset();
120 athena::ShutdownAthena(); 76 athena::ShutdownAthena();
121 } 77 }
122 78
123 virtual extensions::ShellDesktopController* CreateDesktopController() 79 virtual extensions::ShellDesktopController* CreateDesktopController()
124 OVERRIDE { 80 OVERRIDE {
125 // TODO(mukai): create Athena's own ShellDesktopController subclass so that 81 // TODO(mukai): create Athena's own ShellDesktopController subclass so that
126 // it can initialize its own window manager logic. 82 // it can initialize its own window manager logic.
127 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); 83 extensions::ShellDesktopController* desktop = new AthenaDesktopController();
128 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); 84 desktop->SetAppWindowController(new athena::AthenaAppWindowController());
129 return desktop; 85 return desktop;
130 } 86 }
131 87
132 private: 88 private:
133 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_;
134
135 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); 89 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
136 }; 90 };
137 91
138 class AthenaContentBrowserClient 92 class AthenaContentBrowserClient
139 : public extensions::ShellContentBrowserClient { 93 : public extensions::ShellContentBrowserClient {
140 public: 94 public:
141 AthenaContentBrowserClient() 95 AthenaContentBrowserClient()
142 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { 96 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) {
143 } 97 }
144 virtual ~AthenaContentBrowserClient() {} 98 virtual ~AthenaContentBrowserClient() {}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 154
201 int main(int argc, const char** argv) { 155 int main(int argc, const char** argv) {
202 AthenaMainDelegate delegate; 156 AthenaMainDelegate delegate;
203 content::ContentMainParams params(&delegate); 157 content::ContentMainParams params(&delegate);
204 158
205 params.argc = argc; 159 params.argc = argc;
206 params.argv = argv; 160 params.argv = argv;
207 161
208 return content::ContentMain(params); 162 return content::ContentMain(params);
209 } 163 }
OLDNEW
« no previous file with comments | « athena/main/athena_launcher.cc ('k') | athena/main/athena_main.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698