OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" |
| 6 |
| 7 #include "chrome/browser/extensions/extension_prefs.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/extensions/application_launch.h" |
| 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/browser/web_contents_view.h" |
| 16 #include "ui/base/window_open_disposition.h" |
| 17 #include "ui/keyboard/keyboard_controller.h" |
| 18 |
| 19 namespace { |
| 20 const char kKeyboardExtensionId[] = "mppnpdlheglhdfmldimlhpnegondlapf"; |
| 21 const char kKeyboardUrl[] = |
| 22 "chrome-extension://mppnpdlheglhdfmldimlhpnegondlapf/index.html"; |
| 23 } // namespace |
| 24 |
| 25 AshKeyboardControllerProxy::AshKeyboardControllerProxy() {} |
| 26 |
| 27 AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {} |
| 28 |
| 29 aura::Window* AshKeyboardControllerProxy::GetKeyboardWindow() { |
| 30 if (!keyboard_) { |
| 31 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 32 |
| 33 ExtensionService* service = |
| 34 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 35 if (!service) |
| 36 return NULL; |
| 37 |
| 38 const extensions::Extension* extension = |
| 39 service->GetExtensionById(kKeyboardExtensionId, false); |
| 40 if (!extension) |
| 41 return NULL; |
| 42 |
| 43 // TODO(bryeung): this isn't the right way to launch the application. |
| 44 chrome::AppLaunchParams params( |
| 45 profile, |
| 46 extension, |
| 47 extension_misc::LAUNCH_WINDOW, |
| 48 NEW_FOREGROUND_TAB); |
| 49 params.override_url = GURL(kKeyboardUrl); |
| 50 keyboard_.reset(chrome::OpenApplication(params)); |
| 51 } |
| 52 |
| 53 return keyboard_->GetView()->GetNativeView(); |
| 54 } |
OLD | NEW |