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

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

Issue 2443313002: Add more tests to arc_navigation_throttle.cc (Closed)
Patch Set: address comments 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_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>
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"
18 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
19 20
20 class GURL; 21 class GURL;
21 22
22 namespace content { 23 namespace content {
23 class NavigationHandle; 24 class NavigationHandle;
24 class WebContents; 25 class WebContents;
25 } // namespace content 26 } // namespace content
26 27
27 namespace arc { 28 namespace arc {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 content::WebContents* web_contents, 60 content::WebContents* web_contents,
60 const std::vector<AppInfo>& app_info, 61 const std::vector<AppInfo>& app_info,
61 const base::Callback<void(std::string, CloseReason)>& cb)>; 62 const base::Callback<void(std::string, CloseReason)>& cb)>;
62 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, 63 ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
63 const ShowIntentPickerCallback& show_intent_picker_cb); 64 const ShowIntentPickerCallback& show_intent_picker_cb);
64 ~ArcNavigationThrottle() override; 65 ~ArcNavigationThrottle() override;
65 66
66 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url, 67 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url,
67 const GURL& current_url); 68 const GURL& current_url);
68 69
70 // Finds |selected_app_package| from the |handlers| array and returns the
71 // index. If the app is not found, returns |handlers.size()|.
72 static size_t GetAppIndex(
73 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers,
74 const std::string& selected_app_package);
75
76 static bool IsAppAvailableForTesting(
77 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers);
78 static size_t FindPreferredAppForTesting(
79 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers);
80 static bool IsSwapElementsNeededForTesting(
81 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers,
82 std::pair<size_t, size_t>* out_indices);
83
69 private: 84 private:
70 // content::Navigation implementation: 85 // content::Navigation implementation:
71 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; 86 NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
72 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; 87 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
73 88
74 NavigationThrottle::ThrottleCheckResult HandleRequest(); 89 NavigationThrottle::ThrottleCheckResult HandleRequest();
75 void OnAppCandidatesReceived( 90 void OnAppCandidatesReceived(
76 mojo::Array<mojom::IntentHandlerInfoPtr> handlers); 91 mojo::Array<mojom::IntentHandlerInfoPtr> handlers);
77 void OnAppIconsReceived( 92 void OnAppIconsReceived(
78 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, 93 mojo::Array<mojom::IntentHandlerInfoPtr> handlers,
(...skipping 14 matching lines...) Expand all
93 108
94 // This has to be the last member of the class. 109 // This has to be the last member of the class.
95 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; 110 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_;
96 111
97 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); 112 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle);
98 }; 113 };
99 114
100 } // namespace arc 115 } // namespace arc
101 116
102 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_ 117 #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