Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h

Issue 2498223002: arc: enable use_new_wrapper_types for intent_helper.mojom (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "components/arc/intent_helper/activity_icon_loader.h" 16 #include "components/arc/intent_helper/activity_icon_loader.h"
17 #include "content/public/browser/navigation_throttle.h" 17 #include "content/public/browser/navigation_throttle.h"
18 #include "mojo/public/cpp/bindings/array.h"
19 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
20 #include "url/gurl.h" 19 #include "url/gurl.h"
21 20
22 namespace content { 21 namespace content {
23 class NavigationHandle; 22 class NavigationHandle;
24 class WebContents; 23 class WebContents;
25 } // namespace content 24 } // namespace content
26 25
27 namespace arc { 26 namespace arc {
28 27
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, 70 ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
72 const ShowIntentPickerCallback& show_intent_picker_cb); 71 const ShowIntentPickerCallback& show_intent_picker_cb);
73 ~ArcNavigationThrottle() override; 72 ~ArcNavigationThrottle() override;
74 73
75 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url, 74 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url,
76 const GURL& current_url); 75 const GURL& current_url);
77 76
78 // Finds |selected_app_package| from the |handlers| array and returns the 77 // Finds |selected_app_package| from the |handlers| array and returns the
79 // index. If the app is not found, returns |handlers.size()|. 78 // index. If the app is not found, returns |handlers.size()|.
80 static size_t GetAppIndex( 79 static size_t GetAppIndex(
81 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, 80 const std::vector<mojom::IntentHandlerInfoPtr>& handlers,
82 const std::string& selected_app_package); 81 const std::string& selected_app_package);
83 // Determines the destination of the current navigation. We know that if the 82 // Determines the destination of the current navigation. We know that if the
84 // |close_reason| is either ERROR or DIALOG_DEACTIVATED the navigation MUST 83 // |close_reason| is either ERROR or DIALOG_DEACTIVATED the navigation MUST
85 // stay in Chrome, otherwise we can assume the navigation goes to ARC with the 84 // stay in Chrome, otherwise we can assume the navigation goes to ARC with the
86 // exception of the |selected_app_package| being Chrome. 85 // exception of the |selected_app_package| being Chrome.
87 static Platform GetDestinationPlatform( 86 static Platform GetDestinationPlatform(
88 const std::string& selected_app_package, 87 const std::string& selected_app_package,
89 CloseReason close_reason); 88 CloseReason close_reason);
90 // Records intent picker usage statistics as well as whether navigations are 89 // Records intent picker usage statistics as well as whether navigations are
91 // continued or redirected to Chrome or ARC respectively, via UMA histograms. 90 // continued or redirected to Chrome or ARC respectively, via UMA histograms.
92 static void RecordUma(CloseReason close_reason, Platform platform); 91 static void RecordUma(CloseReason close_reason, Platform platform);
93 92
94 // Swaps Chrome app with any app in row |kMaxAppResults-1| iff its index is 93 // Swaps Chrome app with any app in row |kMaxAppResults-1| iff its index is
95 // bigger, thus ensuring the user can always see Chrome without scrolling. 94 // bigger, thus ensuring the user can always see Chrome without scrolling.
96 // When swap is needed, fills |out_indices| and returns true. If |handlers| 95 // When swap is needed, fills |out_indices| and returns true. If |handlers|
97 // do not have Chrome, returns false. 96 // do not have Chrome, returns false.
98 static bool IsSwapElementsNeeded( 97 static bool IsSwapElementsNeeded(
99 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, 98 const std::vector<mojom::IntentHandlerInfoPtr>& handlers,
100 std::pair<size_t, size_t>* out_indices); 99 std::pair<size_t, size_t>* out_indices);
101 100
102 static bool IsAppAvailableForTesting( 101 static bool IsAppAvailableForTesting(
103 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); 102 const std::vector<mojom::IntentHandlerInfoPtr>& handlers);
104 static size_t FindPreferredAppForTesting( 103 static size_t FindPreferredAppForTesting(
105 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); 104 const std::vector<mojom::IntentHandlerInfoPtr>& handlers);
106 105
107 private: 106 private:
108 // content::Navigation implementation: 107 // content::Navigation implementation:
109 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; 108 NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
110 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; 109 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
111 110
112 NavigationThrottle::ThrottleCheckResult HandleRequest(); 111 NavigationThrottle::ThrottleCheckResult HandleRequest();
113 void OnAppCandidatesReceived( 112 void OnAppCandidatesReceived(
114 mojo::Array<mojom::IntentHandlerInfoPtr> handlers); 113 std::vector<mojom::IntentHandlerInfoPtr> handlers);
115 void OnAppIconsReceived( 114 void OnAppIconsReceived(
116 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, 115 std::vector<mojom::IntentHandlerInfoPtr> handlers,
117 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons); 116 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons);
118 void OnIntentPickerClosed(mojo::Array<mojom::IntentHandlerInfoPtr> handlers, 117 void OnIntentPickerClosed(std::vector<mojom::IntentHandlerInfoPtr> handlers,
119 const std::string& selected_app_package, 118 const std::string& selected_app_package,
120 CloseReason close_reason); 119 CloseReason close_reason);
121 GURL GetStartingGURL() const; 120 GURL GetStartingGURL() const;
122 // A callback object that allow us to display an IntentPicker when Run() is 121 // A callback object that allow us to display an IntentPicker when Run() is
123 // executed, it also allow us to report the user's selection back to 122 // executed, it also allow us to report the user's selection back to
124 // OnIntentPickerClosed(). 123 // OnIntentPickerClosed().
125 ShowIntentPickerCallback show_intent_picker_callback_; 124 ShowIntentPickerCallback show_intent_picker_callback_;
126 125
127 // A cache of the action the user took the last time this navigation throttle 126 // A cache of the action the user took the last time this navigation throttle
128 // popped up the intent picker dialog. If the dialog has never been popped up 127 // popped up the intent picker dialog. If the dialog has never been popped up
129 // before, this will have a value of CloseReason::INVALID. Used to avoid 128 // before, this will have a value of CloseReason::INVALID. Used to avoid
130 // popping up the dialog multiple times on chains of multiple redirects. 129 // popping up the dialog multiple times on chains of multiple redirects.
131 CloseReason previous_user_action_; 130 CloseReason previous_user_action_;
132 131
133 // Keeps a referrence to the starting GURL. 132 // Keeps a referrence to the starting GURL.
134 GURL starting_gurl_; 133 GURL starting_gurl_;
135 134
136 // This has to be the last member of the class. 135 // This has to be the last member of the class.
137 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; 136 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_;
138 137
139 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); 138 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle);
140 }; 139 };
141 140
142 } // namespace arc 141 } // namespace arc
143 142
144 #endif // CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ 143 #endif // CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698