OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 25 matching lines...) Expand all Loading... |
36 enum class CloseReason : int { | 36 enum class CloseReason : int { |
37 ERROR = 0, | 37 ERROR = 0, |
38 DIALOG_DEACTIVATED = 1, | 38 DIALOG_DEACTIVATED = 1, |
39 ALWAYS_PRESSED = 2, | 39 ALWAYS_PRESSED = 2, |
40 JUST_ONCE_PRESSED = 3, | 40 JUST_ONCE_PRESSED = 3, |
41 PREFERRED_ACTIVITY_FOUND = 4, | 41 PREFERRED_ACTIVITY_FOUND = 4, |
42 SIZE, | 42 SIZE, |
43 INVALID = SIZE, | 43 INVALID = SIZE, |
44 }; | 44 }; |
45 | 45 |
| 46 enum class Platform : int { |
| 47 ARC = 0, |
| 48 CHROME = 1, |
| 49 SIZE, |
| 50 }; |
| 51 |
46 // Restricts the amount of apps displayed to the user without the need of a | 52 // Restricts the amount of apps displayed to the user without the need of a |
47 // ScrollView. | 53 // ScrollView. |
48 enum { kMaxAppResults = 3 }; | 54 enum { kMaxAppResults = 3 }; |
49 | 55 |
50 struct AppInfo { | 56 struct AppInfo { |
51 AppInfo(gfx::Image img, std::string package, std::string activity) | 57 AppInfo(gfx::Image img, std::string package, std::string activity) |
52 : icon(img), package_name(package), activity_name(activity) {} | 58 : icon(img), package_name(package), activity_name(activity) {} |
53 gfx::Image icon; | 59 gfx::Image icon; |
54 std::string package_name; | 60 std::string package_name; |
55 std::string activity_name; | 61 std::string activity_name; |
(...skipping 16 matching lines...) Expand all Loading... |
72 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 78 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
73 const std::string& selected_app_package); | 79 const std::string& selected_app_package); |
74 | 80 |
75 static bool IsAppAvailableForTesting( | 81 static bool IsAppAvailableForTesting( |
76 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); | 82 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); |
77 static size_t FindPreferredAppForTesting( | 83 static size_t FindPreferredAppForTesting( |
78 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); | 84 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); |
79 static bool IsSwapElementsNeededForTesting( | 85 static bool IsSwapElementsNeededForTesting( |
80 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 86 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
81 std::pair<size_t, size_t>* out_indices); | 87 std::pair<size_t, size_t>* out_indices); |
| 88 static Platform GetSelectedPlatform(const std::string& selected_app_package, |
| 89 CloseReason close_reason); |
82 | 90 |
83 private: | 91 private: |
84 // content::Navigation implementation: | 92 // content::Navigation implementation: |
85 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; | 93 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; |
86 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; | 94 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; |
87 | 95 |
88 NavigationThrottle::ThrottleCheckResult HandleRequest(); | 96 NavigationThrottle::ThrottleCheckResult HandleRequest(); |
89 void OnAppCandidatesReceived( | 97 void OnAppCandidatesReceived( |
90 mojo::Array<mojom::IntentHandlerInfoPtr> handlers); | 98 mojo::Array<mojom::IntentHandlerInfoPtr> handlers); |
91 void OnAppIconsReceived( | 99 void OnAppIconsReceived( |
(...skipping 19 matching lines...) Expand all Loading... |
111 | 119 |
112 // This has to be the last member of the class. | 120 // This has to be the last member of the class. |
113 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; | 121 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; |
114 | 122 |
115 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); | 123 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); |
116 }; | 124 }; |
117 | 125 |
118 } // namespace arc | 126 } // namespace arc |
119 | 127 |
120 #endif // CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ | 128 #endif // CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ |
OLD | NEW |