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

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

Issue 2476783002: Adding a destination platform histogram for UMA. (Closed)
Patch Set: Removing histograms include 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>
(...skipping 25 matching lines...) Expand all
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 // As for CloseReason, these define the buckets for an UMA histogram, so this
47 // must be treated in an append-only fashion. This helps especify where a
48 // navigation will continue.
49 enum class Platform : int {
50 ARC = 0,
51 CHROME = 1,
52 SIZE,
53 };
54
46 // Restricts the amount of apps displayed to the user without the need of a 55 // Restricts the amount of apps displayed to the user without the need of a
47 // ScrollView. 56 // ScrollView.
48 enum { kMaxAppResults = 3 }; 57 enum { kMaxAppResults = 3 };
49 58
50 struct AppInfo { 59 struct AppInfo {
51 AppInfo(gfx::Image img, std::string package, std::string activity) 60 AppInfo(gfx::Image img, std::string package, std::string activity)
52 : icon(img), package_name(package), activity_name(activity) {} 61 : icon(img), package_name(package), activity_name(activity) {}
53 gfx::Image icon; 62 gfx::Image icon;
54 std::string package_name; 63 std::string package_name;
55 std::string activity_name; 64 std::string activity_name;
56 }; 65 };
57 66
58 using ShowIntentPickerCallback = base::Callback<void( 67 using ShowIntentPickerCallback = base::Callback<void(
59 content::WebContents* web_contents, 68 content::WebContents* web_contents,
60 const std::vector<AppInfo>& app_info, 69 const std::vector<AppInfo>& app_info,
61 const base::Callback<void(const std::string&, CloseReason)>& cb)>; 70 const base::Callback<void(const std::string&, CloseReason)>& cb)>;
62 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, 71 ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
63 const ShowIntentPickerCallback& show_intent_picker_cb); 72 const ShowIntentPickerCallback& show_intent_picker_cb);
64 ~ArcNavigationThrottle() override; 73 ~ArcNavigationThrottle() override;
65 74
66 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url, 75 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url,
67 const GURL& current_url); 76 const GURL& current_url);
68 77
69 // Finds |selected_app_package| from the |handlers| array and returns the 78 // Finds |selected_app_package| from the |handlers| array and returns the
70 // index. If the app is not found, returns |handlers.size()|. 79 // index. If the app is not found, returns |handlers.size()|.
71 static size_t GetAppIndex( 80 static size_t GetAppIndex(
72 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, 81 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers,
73 const std::string& selected_app_package); 82 const std::string& selected_app_package);
83 // Determines the destination of the current navigation. We know that if the
84 // |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
86 // exception of the |selected_app_package| being Chrome.
87 static Platform GetDestinationPlatform(
88 const std::string& selected_app_package,
89 CloseReason close_reason);
90 // Records intent picker usage statistics as well as whether navigations are
91 // continued or redirected to Chrome or ARC respectively, via UMA histograms.
92 static void RecordUma(CloseReason close_reason, Platform platform);
74 93
75 static bool IsAppAvailableForTesting( 94 static bool IsAppAvailableForTesting(
76 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); 95 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers);
77 static size_t FindPreferredAppForTesting( 96 static size_t FindPreferredAppForTesting(
78 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers); 97 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers);
79 static bool IsSwapElementsNeededForTesting( 98 static bool IsSwapElementsNeededForTesting(
80 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, 99 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers,
81 std::pair<size_t, size_t>* out_indices); 100 std::pair<size_t, size_t>* out_indices);
82 101
83 private: 102 private:
(...skipping 27 matching lines...) Expand all
111 130
112 // This has to be the last member of the class. 131 // This has to be the last member of the class.
113 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; 132 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_;
114 133
115 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); 134 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle);
116 }; 135 };
117 136
118 } // namespace arc 137 } // namespace arc
119 138
120 #endif // CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_ 139 #endif // CHROME_BROWSER_CHROMEOS_ARC_INTENT_HELPER_ARC_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698