Chromium Code Reviews| 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 "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" | 5 #include "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 v8::Handle<v8::Object> chrome = | 99 v8::Handle<v8::Object> chrome = |
| 100 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject(); | 100 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject(); |
| 101 CHECK(!chrome.IsEmpty()); | 101 CHECK(!chrome.IsEmpty()); |
| 102 | 102 |
| 103 gin::Handle<VKBindings> controller = | 103 gin::Handle<VKBindings> controller = |
| 104 gin::CreateHandle(isolate, new VKBindings(render_view)); | 104 gin::CreateHandle(isolate, new VKBindings(render_view)); |
| 105 if (controller.IsEmpty()) | 105 if (controller.IsEmpty()) |
| 106 return; | 106 return; |
| 107 chrome->Set(gin::StringToSymbol(isolate, "virtualKeyboardPrivate"), | 107 chrome->Set(gin::StringToSymbol(isolate, "virtualKeyboardPrivate"), |
| 108 controller.ToV8()); | 108 controller.ToV8()); |
| 109 | |
| 110 const std::string kInputBoxFocusedEvent = | |
| 111 "chrome.virtualKeyboardPrivate.onTextInputBoxFocused = {};" | |
| 112 "chrome.virtualKeyboardPrivate.onTextInputBoxFocused.addListener = " | |
| 113 " function(callback) { " | |
| 114 " window.setTimeout(function() {" | |
| 115 " callback({type: 'text'});" | |
| 116 " }, 100);" | |
| 117 " };"; | |
| 118 render_view->GetMainRenderFrame()->ExecuteJavaScript( | |
| 119 base::UTF8ToUTF16(kInputBoxFocusedEvent)); | |
|
bshe
2014/06/20 21:00:30
Just curios when is this javascript been executed?
sadrul
2014/06/20 22:24:46
This happens when the page navigates to chrome://k
| |
| 109 } | 120 } |
| 110 | 121 |
| 111 private: | 122 private: |
| 112 explicit VKBindings(content::RenderView* render_view) | 123 explicit VKBindings(content::RenderView* render_view) |
| 113 : render_view_(render_view) {} | 124 : render_view_(render_view) {} |
| 114 virtual ~VKBindings() {} | 125 virtual ~VKBindings() {} |
| 115 | 126 |
| 116 // gin::WrappableBase | 127 // gin::WrappableBase |
| 117 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 128 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 118 v8::Isolate* isolate) OVERRIDE { | 129 v8::Isolate* isolate) OVERRIDE { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 }; | 193 }; |
| 183 | 194 |
| 184 } // namespace | 195 } // namespace |
| 185 | 196 |
| 186 VirtualKeyboardBindings* VirtualKeyboardBindings::Create( | 197 VirtualKeyboardBindings* VirtualKeyboardBindings::Create( |
| 187 content::RenderView* render_view) { | 198 content::RenderView* render_view) { |
| 188 return new VirtualKeyboardBindingsImpl(render_view); | 199 return new VirtualKeyboardBindingsImpl(render_view); |
| 189 } | 200 } |
| 190 | 201 |
| 191 } // namespace athena | 202 } // namespace athena |
| OLD | NEW |