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

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: 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.
oshima 2014/07/08 18:31:29 can you add // TODO(oshima): move the VK bounds l
Jun Mukai 2014/07/08 22:25:40 Done.
41 class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver {
42 public:
43 VirtualKeyboardObserver() {
44 keyboard::KeyboardController::GetInstance()->AddObserver(this);
45 }
46
47 virtual ~VirtualKeyboardObserver() {
48 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
49 }
50
51 private:
52 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE {
53 athena::HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds);
54 }
oshima 2014/07/08 18:31:29 DISALLOW_COPY_AND_ASSIGN
Jun Mukai 2014/07/08 22:25:40 Done.
55 };
56
37 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { 57 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
38 public: 58 public:
39 AthenaBrowserMainDelegate() {} 59 AthenaBrowserMainDelegate() {}
40 virtual ~AthenaBrowserMainDelegate() {} 60 virtual ~AthenaBrowserMainDelegate() {}
41 61
42 // apps::ShellBrowserMainDelegate: 62 // apps::ShellBrowserMainDelegate:
43 virtual void Start(content::BrowserContext* context) OVERRIDE { 63 virtual void Start(content::BrowserContext* context) OVERRIDE {
44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 64 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
45 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( 65 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe(
46 command_line->HasSwitch(apps::switches::kApp) ? 66 command_line->HasSwitch(apps::switches::kApp) ?
47 command_line->GetSwitchValueNative(apps::switches::kApp) : 67 command_line->GetSwitchValueNative(apps::switches::kApp) :
48 kDefaultAppPath); 68 kDefaultAppPath);
49 69
50 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); 70 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
51 if (base::DirectoryExists(app_absolute_dir)) { 71 if (base::DirectoryExists(app_absolute_dir)) {
52 extensions::ShellExtensionSystem* extension_system = 72 extensions::ShellExtensionSystem* extension_system =
53 static_cast<extensions::ShellExtensionSystem*>( 73 static_cast<extensions::ShellExtensionSystem*>(
54 extensions::ExtensionSystem::Get(context)); 74 extensions::ExtensionSystem::Get(context));
55 extension_system->LoadApp(app_absolute_dir); 75 extension_system->LoadApp(app_absolute_dir);
56 } 76 }
57 77
58 athena::StartAthena( 78 athena::StartAthena(
59 apps::ShellDesktopController::instance()->host()->window(), 79 apps::ShellDesktopController::instance()->host()->window(),
60 new athena::ContentActivityFactory(), 80 new athena::ContentActivityFactory(),
61 new athena::ContentAppModelBuilder(context)); 81 new athena::ContentAppModelBuilder(context));
62 athena::HomeCard::Get()->RegisterSearchProvider( 82 athena::HomeCard::Get()->RegisterSearchProvider(
63 new athena::UrlSearchProvider(context)); 83 new athena::UrlSearchProvider(context));
64 athena::VirtualKeyboardManager::Create(context); 84 athena::VirtualKeyboardManager::Create(context);
85 keyboard_observer_.reset(new VirtualKeyboardObserver());
65 86
66 CreateTestPages(context); 87 CreateTestPages(context);
67 CreateDebugWindow(); 88 CreateDebugWindow();
68 } 89 }
69 90
70 virtual void Shutdown() OVERRIDE { athena::ShutdownAthena(); } 91 virtual void Shutdown() OVERRIDE {
92 keyboard_observer_.reset();
93 athena::ShutdownAthena();
94 }
71 95
72 virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE { 96 virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE {
73 // TODO(mukai): create Athena's own ShellDesktopController subclass so that 97 // TODO(mukai): create Athena's own ShellDesktopController subclass so that
74 // it can initialize its own window manager logic. 98 // it can initialize its own window manager logic.
75 apps::ShellDesktopController* desktop = new apps::ShellDesktopController(); 99 apps::ShellDesktopController* desktop = new apps::ShellDesktopController();
76 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); 100 desktop->SetAppWindowController(new athena::AthenaAppWindowController());
77 return desktop; 101 return desktop;
78 } 102 }
79 103
80 private: 104 private:
105 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_;
106
81 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); 107 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
82 }; 108 };
83 109
84 class AthenaRendererMainDelegate : public apps::ShellRendererMainDelegate { 110 class AthenaRendererMainDelegate : public apps::ShellRendererMainDelegate {
85 public: 111 public:
86 AthenaRendererMainDelegate() {} 112 AthenaRendererMainDelegate() {}
87 virtual ~AthenaRendererMainDelegate() {} 113 virtual ~AthenaRendererMainDelegate() {}
88 114
89 private: 115 private:
90 // apps::ShellRendererMainDelegate: 116 // apps::ShellRendererMainDelegate:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 154
129 int main(int argc, const char** argv) { 155 int main(int argc, const char** argv) {
130 AthenaMainDelegate delegate; 156 AthenaMainDelegate delegate;
131 content::ContentMainParams params(&delegate); 157 content::ContentMainParams params(&delegate);
132 158
133 params.argc = argc; 159 params.argc = argc;
134 params.argv = argv; 160 params.argv = argv;
135 161
136 return content::ContentMain(params); 162 return content::ContentMain(params);
137 } 163 }
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