From 9ef47615d1a9898017890afad2eaacef81358cd2 Mon Sep 17 00:00:00 2001 From: Ellie Kwon Date: Sun, 12 Nov 2017 17:56:13 +0900 Subject: [PATCH 1/4] Add application manager frame --- client/absolute.ts | 2 ++ client/application/application_manager.ts | 25 +++++++++++++++++++++++ client/main.ts | 1 + 3 files changed, 28 insertions(+) create mode 100644 client/application/application_manager.ts diff --git a/client/absolute.ts b/client/absolute.ts index 422d9437..02ac81c3 100644 --- a/client/absolute.ts +++ b/client/absolute.ts @@ -16,10 +16,12 @@ import PushManager from './push/push_manager'; import Notification from './notification/notification_manager'; +import AppManager from './application/application_manager'; import IndexedDB from './indexeddb/indexeddb'; export default class absolute { static push: PushManager = new PushManager(); static notification: Notification = new Notification(); + static app: AppManager = new AppManager(); static indexeddb: IndexedDB = new IndexedDB(); } diff --git a/client/application/application_manager.ts b/client/application/application_manager.ts new file mode 100644 index 00000000..e30d1dfa --- /dev/null +++ b/client/application/application_manager.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2017 The Absolute Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare var navigator: any; + +export default class ApplicationManager { + + async isCromeBrowser(): Promise { + + return false; + } +} \ No newline at end of file diff --git a/client/main.ts b/client/main.ts index 73fe0c73..d3786817 100644 --- a/client/main.ts +++ b/client/main.ts @@ -19,6 +19,7 @@ import absolute from './absolute'; async function main() { console.log(await absolute.push.register('key')); console.log(await absolute.push.unregister()); + console.log(await absolute.appManager.isCromeBrowser()); } main(); From 4f3f99bb6d44c540eda797d83ff5ab68d73ad0ab Mon Sep 17 00:00:00 2001 From: Ellie Kwon Date: Sun, 12 Nov 2017 18:06:02 +0900 Subject: [PATCH 2/4] Change static AppManager name 'app' to 'appManager' --- client/absolute.ts | 2 +- .../application/application_manager.test.ts | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 client/application/application_manager.test.ts diff --git a/client/absolute.ts b/client/absolute.ts index 02ac81c3..72ae80c7 100644 --- a/client/absolute.ts +++ b/client/absolute.ts @@ -22,6 +22,6 @@ import IndexedDB from './indexeddb/indexeddb'; export default class absolute { static push: PushManager = new PushManager(); static notification: Notification = new Notification(); - static app: AppManager = new AppManager(); + static appManager: AppManager = new AppManager(); static indexeddb: IndexedDB = new IndexedDB(); } diff --git a/client/application/application_manager.test.ts b/client/application/application_manager.test.ts new file mode 100644 index 00000000..cc6e3f10 --- /dev/null +++ b/client/application/application_manager.test.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2017 The Absolute Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {} from 'jest'; +import absolute from '../absolute'; + +test('absolute.appManager.isCromeBrowser()', async() => { + expect(await absolute.appManager.isCromeBrowser()).toBe(false); +}); \ No newline at end of file From 6402121496daa06d44020c70164e56ede858a715 Mon Sep 17 00:00:00 2001 From: Ellie Kwon Date: Sun, 12 Nov 2017 18:37:13 +0900 Subject: [PATCH 3/4] Chrome browser check as userAgent --- client/application/application_manager.test.ts | 2 +- client/application/application_manager.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/application/application_manager.test.ts b/client/application/application_manager.test.ts index cc6e3f10..af1d5190 100644 --- a/client/application/application_manager.test.ts +++ b/client/application/application_manager.test.ts @@ -18,5 +18,5 @@ import {} from 'jest'; import absolute from '../absolute'; test('absolute.appManager.isCromeBrowser()', async() => { - expect(await absolute.appManager.isCromeBrowser()).toBe(false); + expect(await absolute.appManager.isCromeBrowser()).toBe(true); }); \ No newline at end of file diff --git a/client/application/application_manager.ts b/client/application/application_manager.ts index e30d1dfa..6f0a944c 100644 --- a/client/application/application_manager.ts +++ b/client/application/application_manager.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -declare var navigator: any; - export default class ApplicationManager { async isCromeBrowser(): Promise { - - return false; + var agent = navigator.userAgent.toLowerCase(); + if(agent.indexOf('chrome') != -1){ + return true; + } else { + return false; + } } } \ No newline at end of file From 6894583b0830a5e2a5fd40e679e8296acf7a97f9 Mon Sep 17 00:00:00 2001 From: Ellie Kwon Date: Sun, 12 Nov 2017 18:53:41 +0900 Subject: [PATCH 4/4] Change test value for 'isCromeBrowser' --- client/application/application_manager.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/application/application_manager.test.ts b/client/application/application_manager.test.ts index af1d5190..cc6e3f10 100644 --- a/client/application/application_manager.test.ts +++ b/client/application/application_manager.test.ts @@ -18,5 +18,5 @@ import {} from 'jest'; import absolute from '../absolute'; test('absolute.appManager.isCromeBrowser()', async() => { - expect(await absolute.appManager.isCromeBrowser()).toBe(true); + expect(await absolute.appManager.isCromeBrowser()).toBe(false); }); \ No newline at end of file