OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 // ====== New Architecture ===== | |
6 // = This code is only used in the new iOS Chrome architecture. = | |
7 // ============================================================================ | |
8 | |
9 #import "ios/chrome/app/steps/launch_to_foreground.h" | |
10 | |
11 #include "components/content_settings/core/browser/host_content_settings_map.h" | |
12 #include "ios/chrome/app/application_state.h" | |
13 #include "ios/chrome/browser/application_context.h" | |
14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | |
15 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" | |
16 #include "ios/web/public/web_capabilities.h" | |
17 #include "ios/web/public/web_thread.h" | |
18 | |
19 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
20 #error "This file requires ARC support." | |
21 #endif | |
22 | |
23 // Temporary class to trigger URL-opening events from a shake gesture. | |
24 @interface ShakeCatchingWindow : UIWindow | |
25 @end | |
26 | |
27 @implementation BeginForegrounding | |
28 | |
29 - (BOOL)canRunInState:(ApplicationState*)state { | |
30 return state.phase == APPLICATION_BACKGROUNDED; | |
31 } | |
32 | |
33 - (void)runInState:(ApplicationState*)state { | |
34 GetApplicationContext()->OnAppEnterForeground(); | |
35 } | |
36 | |
37 @end | |
38 | |
39 @implementation PrepareForUI | |
40 | |
41 - (BOOL)canRunInState:(ApplicationState*)state { | |
42 return state.phase == APPLICATION_BACKGROUNDED; | |
43 } | |
44 | |
45 - (void)runInState:(ApplicationState*)state { | |
46 state.window = | |
47 [[ShakeCatchingWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
48 [state.window makeKeyWindow]; | |
49 } | |
50 | |
51 @end | |
52 | |
53 @implementation CompleteForegrounding | |
54 - (BOOL)canRunInState:(ApplicationState*)state { | |
55 return state.window.keyWindow && state.phase == APPLICATION_BACKGROUNDED; | |
56 } | |
57 | |
58 - (void)runInState:(ApplicationState*)state { | |
59 state.phase = APPLICATION_FOREGROUNDED; | |
60 } | |
61 | |
62 @end | |
63 | |
64 @implementation ShakeCatchingWindow | |
65 | |
66 #pragma mark - UIResponder | |
67 | |
68 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent*)event { | |
69 if (motion == UIEventSubtypeMotionShake) { | |
70 UIApplication* app = [UIApplication sharedApplication]; | |
71 [app.delegate application:app | |
72 openURL:[NSURL URLWithString:@"https://www.google.com"] | |
73 options:@{}]; | |
74 } | |
75 [super motionEnded:motion withEvent:event]; | |
76 } | |
77 | |
78 @end | |
OLD | NEW |