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

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

Issue 356263003: Move HomeCard to avoid virtual keyboard when it's shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 5 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/DEPS ('k') | no next file » | 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 "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/common/switches.h" 9 #include "apps/shell/common/switches.h"
10 #include "apps/shell/renderer/shell_renderer_main_delegate.h" 10 #include "apps/shell/renderer/shell_renderer_main_delegate.h"
11 #include "athena/content/public/content_activity_factory.h" 11 #include "athena/content/public/content_activity_factory.h"
12 #include "athena/content/public/content_app_model_builder.h" 12 #include "athena/content/public/content_app_model_builder.h"
13 #include "athena/home/public/home_card.h" 13 #include "athena/home/public/home_card.h"
14 #include "athena/main/athena_app_window_controller.h" 14 #include "athena/main/athena_app_window_controller.h"
15 #include "athena/main/athena_launcher.h" 15 #include "athena/main/athena_launcher.h"
16 #include "athena/main/debug/debug_window.h" 16 #include "athena/main/debug/debug_window.h"
17 #include "athena/main/placeholder.h" 17 #include "athena/main/placeholder.h"
18 #include "athena/main/url_search_provider.h" 18 #include "athena/main/url_search_provider.h"
19 #include "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" 19 #include "athena/virtual_keyboard/public/virtual_keyboard_bindings.h"
20 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h" 20 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/file_util.h" 22 #include "base/file_util.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "content/public/app/content_main.h" 24 #include "content/public/app/content_main.h"
25 #include "ui/aura/window_tree_host.h" 25 #include "ui/aura/window_tree_host.h"
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/keyboard/keyboard_controller.h"
28 #include "ui/keyboard/keyboard_controller_observer.h"
27 #include "ui/wm/core/visibility_controller.h" 29 #include "ui/wm/core/visibility_controller.h"
28 30
29 namespace { 31 namespace {
30 32
31 // We want to load the sample calculator app by default, for a while. Expecting 33 // We want to load the sample calculator app by default, for a while. Expecting
32 // to run athena_main at src/ 34 // to run athena_main at src/
33 const char kDefaultAppPath[] = 35 const char kDefaultAppPath[] =
34 "chrome/common/extensions/docs/examples/apps/calculator/app"; 36 "chrome/common/extensions/docs/examples/apps/calculator/app";
35 } // namespace 37 } // namespace
36 38
39 // This class observes the change of the virtual keyboard and distribute the
40 // change to appropriate modules of athena.
41 // TODO(oshima): move the VK bounds logic to screen manager.
42 class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver {
43 public:
44 VirtualKeyboardObserver() {
45 keyboard::KeyboardController::GetInstance()->AddObserver(this);
46 }
47
48 virtual ~VirtualKeyboardObserver() {
49 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
50 }
51
52 private:
53 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE {
54 athena::HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds);
55 }
56
57 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver);
58 };
59
37 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { 60 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
38 public: 61 public:
39 AthenaBrowserMainDelegate() {} 62 AthenaBrowserMainDelegate() {}
40 virtual ~AthenaBrowserMainDelegate() {} 63 virtual ~AthenaBrowserMainDelegate() {}
41 64
42 // apps::ShellBrowserMainDelegate: 65 // apps::ShellBrowserMainDelegate:
43 virtual void Start(content::BrowserContext* context) OVERRIDE { 66 virtual void Start(content::BrowserContext* context) OVERRIDE {
44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 67 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
45 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( 68 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe(
46 command_line->HasSwitch(apps::switches::kAppShellAppPath) ? 69 command_line->HasSwitch(apps::switches::kAppShellAppPath) ?
47 command_line->GetSwitchValueNative(apps::switches::kAppShellAppPath) : 70 command_line->GetSwitchValueNative(apps::switches::kAppShellAppPath) :
48 kDefaultAppPath); 71 kDefaultAppPath);
49 72
50 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); 73 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
51 if (base::DirectoryExists(app_absolute_dir)) { 74 if (base::DirectoryExists(app_absolute_dir)) {
52 extensions::ShellExtensionSystem* extension_system = 75 extensions::ShellExtensionSystem* extension_system =
53 static_cast<extensions::ShellExtensionSystem*>( 76 static_cast<extensions::ShellExtensionSystem*>(
54 extensions::ExtensionSystem::Get(context)); 77 extensions::ExtensionSystem::Get(context));
55 extension_system->LoadApp(app_absolute_dir); 78 extension_system->LoadApp(app_absolute_dir);
56 } 79 }
57 80
58 athena::StartAthena( 81 athena::StartAthena(
59 apps::ShellDesktopController::instance()->host()->window(), 82 apps::ShellDesktopController::instance()->host()->window(),
60 new athena::ContentActivityFactory(), 83 new athena::ContentActivityFactory(),
61 new athena::ContentAppModelBuilder(context)); 84 new athena::ContentAppModelBuilder(context));
62 athena::HomeCard::Get()->RegisterSearchProvider( 85 athena::HomeCard::Get()->RegisterSearchProvider(
63 new athena::UrlSearchProvider(context)); 86 new athena::UrlSearchProvider(context));
64 athena::VirtualKeyboardManager::Create(context); 87 athena::VirtualKeyboardManager::Create(context);
88 keyboard_observer_.reset(new VirtualKeyboardObserver());
65 89
66 CreateTestPages(context); 90 CreateTestPages(context);
67 CreateDebugWindow(); 91 CreateDebugWindow();
68 } 92 }
69 93
70 virtual void Shutdown() OVERRIDE { athena::ShutdownAthena(); } 94 virtual void Shutdown() OVERRIDE {
95 keyboard_observer_.reset();
96 athena::ShutdownAthena();
97 }
71 98
72 virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE { 99 virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE {
73 // TODO(mukai): create Athena's own ShellDesktopController subclass so that 100 // TODO(mukai): create Athena's own ShellDesktopController subclass so that
74 // it can initialize its own window manager logic. 101 // it can initialize its own window manager logic.
75 apps::ShellDesktopController* desktop = new apps::ShellDesktopController(); 102 apps::ShellDesktopController* desktop = new apps::ShellDesktopController();
76 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); 103 desktop->SetAppWindowController(new athena::AthenaAppWindowController());
77 return desktop; 104 return desktop;
78 } 105 }
79 106
80 private: 107 private:
108 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_;
109
81 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); 110 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
82 }; 111 };
83 112
84 class AthenaRendererMainDelegate : public apps::ShellRendererMainDelegate { 113 class AthenaRendererMainDelegate : public apps::ShellRendererMainDelegate {
85 public: 114 public:
86 AthenaRendererMainDelegate() {} 115 AthenaRendererMainDelegate() {}
87 virtual ~AthenaRendererMainDelegate() {} 116 virtual ~AthenaRendererMainDelegate() {}
88 117
89 private: 118 private:
90 // apps::ShellRendererMainDelegate: 119 // apps::ShellRendererMainDelegate:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 157
129 int main(int argc, const char** argv) { 158 int main(int argc, const char** argv) {
130 AthenaMainDelegate delegate; 159 AthenaMainDelegate delegate;
131 content::ContentMainParams params(&delegate); 160 content::ContentMainParams params(&delegate);
132 161
133 params.argc = argc; 162 params.argc = argc;
134 params.argv = argv; 163 params.argv = argv;
135 164
136 return content::ContentMain(params); 165 return content::ContentMain(params);
137 } 166 }
OLDNEW
« no previous file with comments | « athena/main/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698