Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
13453d73
E
engine
项目概览
liujiuri
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
13453d73
编写于
8月 14, 2015
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #628 from chinmaygarde/master
Keyboard service implementation for iOS
上级
23ca0191
4a6bd4a7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
202 addition
and
5 deletion
+202
-5
sky/services/keyboard/BUILD.gn
sky/services/keyboard/BUILD.gn
+21
-0
sky/services/keyboard/ios/keyboard_service_impl.h
sky/services/keyboard/ios/keyboard_service_impl.h
+52
-0
sky/services/keyboard/ios/keyboard_service_impl.mm
sky/services/keyboard/ios/keyboard_service_impl.mm
+117
-0
sky/shell/BUILD.gn
sky/shell/BUILD.gn
+1
-0
sky/shell/mac/platform_service_provider_mac.cc
sky/shell/mac/platform_service_provider_mac.cc
+11
-5
未找到文件。
sky/services/keyboard/BUILD.gn
0 → 100644
浏览文件 @
13453d73
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if (is_ios) {
source_set("keyboard") {
sources = [
"ios/keyboard_service_impl.h",
"ios/keyboard_service_impl.mm",
]
deps = [
"//base:base",
"//mojo/common",
"//mojo/public/cpp/application",
"//mojo/services/keyboard/public/interfaces",
]
}
} else {
group("keyboard") {
}
}
sky/services/keyboard/ios/keyboard_service_impl.h
0 → 100644
浏览文件 @
13453d73
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SERVICES_KEYBOARD_IOS_KEYBOARD_SERVICE_IMPL_H_
#define SKY_SERVICES_KEYBOARD_IOS_KEYBOARD_SERVICE_IMPL_H_
#include "base/macros.h"
#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h"
#if __OBJC__
@
class
KeyboardClient
;
#else // __OBJC__
class
KeyboardClient
;
#endif // __OBJC__
namespace
sky
{
namespace
services
{
namespace
keyboard
{
class
KeyboardServiceImpl
:
public
::
keyboard
::
KeyboardService
{
public:
explicit
KeyboardServiceImpl
(
mojo
::
InterfaceRequest
<::
keyboard
::
KeyboardService
>
request
);
virtual
~
KeyboardServiceImpl
()
override
;
virtual
void
Show
(
::
keyboard
::
KeyboardClientPtr
client
,
::
keyboard
::
KeyboardType
type
)
override
;
virtual
void
ShowByRequest
()
override
;
virtual
void
Hide
()
override
;
private:
mojo
::
StrongBinding
<::
keyboard
::
KeyboardService
>
binding_
;
KeyboardClient
*
client_
;
DISALLOW_COPY_AND_ASSIGN
(
KeyboardServiceImpl
);
};
class
KeyboardServiceFactory
:
public
mojo
::
InterfaceFactory
<::
keyboard
::
KeyboardService
>
{
public:
void
Create
(
mojo
::
ApplicationConnection
*
connection
,
mojo
::
InterfaceRequest
<::
keyboard
::
KeyboardService
>
request
)
override
;
};
}
// namespace keyboard
}
// namespace services
}
// namespace sky
#endif /* defined(SKY_SERVICES_KEYBOARD_IOS_KEYBOARD_SERVICE_IMPL_H__) *
sky/services/keyboard/ios/keyboard_service_impl.mm
0 → 100644
浏览文件 @
13453d73
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/services/keyboard/ios/keyboard_service_impl.h"
#include <UIKit/UIKit.h>
static
inline
UIKeyboardType
ToUIKeyboardType
(
::
keyboard
::
KeyboardType
type
)
{
switch
(
type
)
{
case
::
keyboard
::
KEYBOARD_TYPE_TEXT
:
return
UIKeyboardTypeDefault
;
case
::
keyboard
::
KEYBOARD_TYPE_NUMBER
:
return
UIKeyboardTypeDecimalPad
;
case
::
keyboard
::
KEYBOARD_TYPE_PHONE
:
return
UIKeyboardTypePhonePad
;
default:
break
;
}
return
UIKeyboardTypeDefault
;
}
@interface
KeyboardClient
:
UIView
<
UIKeyInput
>
-
(
void
)
show
:(
::
keyboard
::
KeyboardClientPtr
)
client
;
-
(
void
)
hide
;
@end
@implementation
KeyboardClient
{
::
keyboard
::
KeyboardClientPtr
_client
;
}
@synthesize
keyboardType
=
_keyboardType
;
-
(
UITextAutocorrectionType
)
autocorrectionType
{
return
UITextAutocorrectionTypeNo
;
}
-
(
void
)
show
:(
::
keyboard
::
KeyboardClientPtr
)
client
{
_client
=
client
.
Pass
();
NSAssert
([
UIApplication
sharedApplication
].
keyWindow
!=
nullptr
,
@"The application must have a key window since the keyboard client "
@"must be part of the responder chain to function"
);
[[
UIApplication
sharedApplication
].
keyWindow
addSubview
:
self
];
[
self
becomeFirstResponder
];
}
-
(
void
)
hide
{
[
self
resignFirstResponder
];
[
self
removeFromSuperview
];
_client
=
nullptr
;
}
#pragma mark - UIResponder Overrides
-
(
BOOL
)
canBecomeFirstResponder
{
return
YES
;
}
#pragma mark - UIKey Input Overrides
-
(
BOOL
)
hasText
{
return
YES
;
}
-
(
void
)
insertText
:(
NSString
*
)
text
{
if
(
_client
==
nullptr
)
{
return
;
}
_client
->
CommitText
(
text
.
UTF8String
,
text
.
length
);
}
-
(
void
)
deleteBackward
{
if
(
_client
==
nullptr
)
{
return
;
}
_client
->
DeleteSurroundingText
(
1
,
0
);
}
@end
namespace
sky
{
namespace
services
{
namespace
keyboard
{
KeyboardServiceImpl
::
KeyboardServiceImpl
(
mojo
::
InterfaceRequest
<::
keyboard
::
KeyboardService
>
request
)
:
binding_
(
this
,
request
.
Pass
()),
client_
([[
KeyboardClient
alloc
]
init
])
{}
KeyboardServiceImpl
::~
KeyboardServiceImpl
()
{
[
client_
release
];
}
void
KeyboardServiceImpl
::
Show
(
::
keyboard
::
KeyboardClientPtr
client
,
::
keyboard
::
KeyboardType
type
)
{
client_
.
keyboardType
=
ToUIKeyboardType
(
type
);
[
client_
show
:
client
.
Pass
()];
}
void
KeyboardServiceImpl
::
ShowByRequest
()
{}
void
KeyboardServiceImpl
::
Hide
()
{
[
client_
hide
];
}
void
KeyboardServiceFactory
::
Create
(
mojo
::
ApplicationConnection
*
connection
,
mojo
::
InterfaceRequest
<::
keyboard
::
KeyboardService
>
request
)
{
new
KeyboardServiceImpl
(
request
.
Pass
());
}
}
// namespace keyboard
}
// namespace services
}
// namespace sky
sky/shell/BUILD.gn
浏览文件 @
13453d73
...
...
@@ -199,6 +199,7 @@ if (is_android) {
deps = common_deps + [
":common",
"//sky/services/ns_net",
"//sky/services/keyboard",
]
}
...
...
sky/shell/mac/platform_service_provider_mac.cc
浏览文件 @
13453d73
...
...
@@ -10,6 +10,7 @@
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "sky/engine/wtf/Assertions.h"
#include "sky/services/ns_net/network_service_impl.h"
#include "sky/services/keyboard/ios/keyboard_service_impl.h"
#include "sky/shell/service_provider.h"
#if !TARGET_OS_IPHONE
#include "sky/shell/testing/test_runner.h"
...
...
@@ -21,18 +22,22 @@ namespace shell {
class
PlatformServiceProvider
:
public
mojo
::
ServiceProvider
{
public:
PlatformServiceProvider
(
mojo
::
InterfaceRequest
<
mojo
::
ServiceProvider
>
request
)
:
binding_
(
this
,
request
.
Pass
())
{}
:
binding_
(
this
,
request
.
Pass
())
{}
void
ConnectToService
(
const
mojo
::
String
&
service_name
,
mojo
::
ScopedMessagePipeHandle
client_handle
)
override
{
if
(
service_name
==
mojo
::
NetworkService
::
Name_
)
{
network_
.
Create
(
nullptr
,
mojo
::
MakeRequest
<
mojo
::
NetworkService
>
(
client_handle
.
Pass
()));
network_
.
Create
(
nullptr
,
mojo
::
MakeRequest
<
mojo
::
NetworkService
>
(
client_handle
.
Pass
()));
}
if
(
service_name
==
::
keyboard
::
KeyboardService
::
Name_
)
{
keyboard_
.
Create
(
nullptr
,
mojo
::
MakeRequest
<::
keyboard
::
KeyboardService
>
(
client_handle
.
Pass
()));
}
#if !TARGET_OS_IPHONE
if
(
service_name
==
TestHarness
::
Name_
)
{
TestRunner
::
Shared
().
Create
(
nullptr
,
mojo
::
MakeRequest
<
TestHarness
>
(
client_handle
.
Pass
()));
TestRunner
::
Shared
().
Create
(
nullptr
,
mojo
::
MakeRequest
<
TestHarness
>
(
client_handle
.
Pass
()));
}
#endif
}
...
...
@@ -40,6 +45,7 @@ class PlatformServiceProvider : public mojo::ServiceProvider {
private:
mojo
::
StrongBinding
<
mojo
::
ServiceProvider
>
binding_
;
mojo
::
NetworkServiceFactory
network_
;
sky
::
services
::
keyboard
::
KeyboardServiceFactory
keyboard_
;
};
static
void
CreatePlatformServiceProvider
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录