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

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

Issue 2433733002: Revert "Reusing Ok/Cancel buttons for intent picker" (Closed)
Patch Set: Created 4 years, 2 months 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_ARC_NAVIGATION_THROTTLE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_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 29 matching lines...) Expand all
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 // Restricts the amount of apps displayed to the user without the need of a 46 // Restricts the amount of apps displayed to the user without the need of a
47 // ScrollView. 47 // ScrollView.
48 enum { kMaxAppResults = 3 }; 48 enum { kMaxAppResults = 3 };
49 49
50 struct AppInfo { 50 using NameAndIcon = std::pair<std::string, gfx::Image>;
51 explicit AppInfo(gfx::Image img, std::string package, std::string activity) 51 using ShowIntentPickerCallback =
52 : icon(img), package_name(package), activity_name(activity) {} 52 base::Callback<void(content::WebContents* web_contents,
53 gfx::Image icon; 53 const std::vector<NameAndIcon>& app_info,
54 std::string package_name; 54 const base::Callback<void(size_t, CloseReason)>& cb)>;
55 std::string activity_name;
56 };
57
58 using ShowIntentPickerCallback = base::Callback<void(
59 content::WebContents* web_contents,
60 const std::vector<AppInfo>& app_info,
61 const base::Callback<void(std::string, CloseReason)>& cb)>;
62 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, 55 ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
63 const ShowIntentPickerCallback& show_intent_picker_cb); 56 const ShowIntentPickerCallback& show_intent_picker_cb);
64 ~ArcNavigationThrottle() override; 57 ~ArcNavigationThrottle() override;
65 58
66 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url, 59 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url,
67 const GURL& current_url); 60 const GURL& current_url);
68 61
69 private: 62 private:
70 // content::Navigation implementation: 63 // content::Navigation implementation:
71 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; 64 NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
72 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; 65 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
73 66
74 NavigationThrottle::ThrottleCheckResult HandleRequest(); 67 NavigationThrottle::ThrottleCheckResult HandleRequest();
75 void OnAppCandidatesReceived( 68 void OnAppCandidatesReceived(
76 mojo::Array<mojom::IntentHandlerInfoPtr> handlers); 69 mojo::Array<mojom::IntentHandlerInfoPtr> handlers);
77 void OnAppIconsReceived( 70 void OnAppIconsReceived(
78 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, 71 mojo::Array<mojom::IntentHandlerInfoPtr> handlers,
79 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons); 72 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons);
80 void OnIntentPickerClosed(mojo::Array<mojom::IntentHandlerInfoPtr> handlers, 73 void OnIntentPickerClosed(mojo::Array<mojom::IntentHandlerInfoPtr> handlers,
81 std::string selected_app_package, 74 size_t selected_app_index,
82 CloseReason close_reason); 75 CloseReason close_reason);
83 // A callback object that allow us to display an IntentPicker when Run() is 76 // A callback object that allow us to display an IntentPicker when Run() is
84 // executed, it also allow us to report the user's selection back to 77 // executed, it also allow us to report the user's selection back to
85 // OnIntentPickerClosed(). 78 // OnIntentPickerClosed().
86 ShowIntentPickerCallback show_intent_picker_callback_; 79 ShowIntentPickerCallback show_intent_picker_callback_;
87 80
88 // A cache of the action the user took the last time this navigation throttle 81 // A cache of the action the user took the last time this navigation throttle
89 // popped up the intent picker dialog. If the dialog has never been popped up 82 // popped up the intent picker dialog. If the dialog has never been popped up
90 // before, this will have a value of CloseReason::INVALID. Used to avoid 83 // before, this will have a value of CloseReason::INVALID. Used to avoid
91 // popping up the dialog multiple times on chains of multiple redirects. 84 // popping up the dialog multiple times on chains of multiple redirects.
92 CloseReason previous_user_action_; 85 CloseReason previous_user_action_;
93 86
94 // This has to be the last member of the class. 87 // This has to be the last member of the class.
95 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; 88 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_;
96 89
97 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); 90 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle);
98 }; 91 };
99 92
100 } // namespace arc 93 } // namespace arc
101 94
102 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_ 95 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc ('k') | chrome/browser/chromeos/arc/arc_navigation_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698