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

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

Issue 2359893002: Open |current_url| in Chrome when |previous_url| is empty (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_navigation_throttle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
19 19
20 class GURL;
21
20 namespace content { 22 namespace content {
21 class NavigationHandle; 23 class NavigationHandle;
22 } // namespace content 24 } // namespace content
23 25
24 namespace arc { 26 namespace arc {
25 27
26 // A class that allow us to retrieve ARC app's information and handle URL 28 // A class that allow us to retrieve ARC app's information and handle URL
27 // traffic initiated on Chrome browser, either on Chrome or an ARC's app. 29 // traffic initiated on Chrome browser, either on Chrome or an ARC's app.
28 class ArcNavigationThrottle : public content::NavigationThrottle { 30 class ArcNavigationThrottle : public content::NavigationThrottle {
29 public: 31 public:
(...skipping 16 matching lines...) Expand all
46 48
47 using NameAndIcon = std::pair<std::string, gfx::Image>; 49 using NameAndIcon = std::pair<std::string, gfx::Image>;
48 using ShowIntentPickerCallback = 50 using ShowIntentPickerCallback =
49 base::Callback<void(content::NavigationHandle* handle, 51 base::Callback<void(content::NavigationHandle* handle,
50 const std::vector<NameAndIcon>& app_info, 52 const std::vector<NameAndIcon>& app_info,
51 const base::Callback<void(size_t, CloseReason)>& cb)>; 53 const base::Callback<void(size_t, CloseReason)>& cb)>;
52 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, 54 ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
53 const ShowIntentPickerCallback& show_intent_picker_cb); 55 const ShowIntentPickerCallback& show_intent_picker_cb);
54 ~ArcNavigationThrottle() override; 56 ~ArcNavigationThrottle() override;
55 57
58 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url,
59 const GURL& current_url);
60
56 private: 61 private:
57 // content::Navigation implementation: 62 // content::Navigation implementation:
58 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; 63 NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
59 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; 64 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
60 65
61 NavigationThrottle::ThrottleCheckResult HandleRequest(); 66 NavigationThrottle::ThrottleCheckResult HandleRequest();
62 void OnAppCandidatesReceived(mojo::Array<mojom::UrlHandlerInfoPtr> handlers); 67 void OnAppCandidatesReceived(mojo::Array<mojom::UrlHandlerInfoPtr> handlers);
63 void OnAppIconsReceived( 68 void OnAppIconsReceived(
64 mojo::Array<mojom::UrlHandlerInfoPtr> handlers, 69 mojo::Array<mojom::UrlHandlerInfoPtr> handlers,
65 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons); 70 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons);
66 void OnIntentPickerClosed(mojo::Array<mojom::UrlHandlerInfoPtr> handlers, 71 void OnIntentPickerClosed(mojo::Array<mojom::UrlHandlerInfoPtr> handlers,
67 size_t selected_app_index, 72 size_t selected_app_index,
68 CloseReason close_reason); 73 CloseReason close_reason);
69 // Compares the host name of the referrer and target URL to decide whether
70 // the navigation needs to be overriden.
71 bool ShouldOverrideUrlLoading(content::NavigationHandle* navigation_handle);
72
73 // A callback object that allow us to display an IntentPicker when Run() is 74 // A callback object that allow us to display an IntentPicker when Run() is
74 // executed, it also allow us to report the user's selection back to 75 // executed, it also allow us to report the user's selection back to
75 // OnIntentPickerClosed(). 76 // OnIntentPickerClosed().
76 ShowIntentPickerCallback show_intent_picker_callback_; 77 ShowIntentPickerCallback show_intent_picker_callback_;
77 78
78 // A cache of the action the user took the last time this navigation throttle 79 // A cache of the action the user took the last time this navigation throttle
79 // popped up the intent picker dialog. If the dialog has never been popped up 80 // popped up the intent picker dialog. If the dialog has never been popped up
80 // before, this will have a value of CloseReason::INVALID. Used to avoid 81 // before, this will have a value of CloseReason::INVALID. Used to avoid
81 // popping up the dialog multiple times on chains of multiple redirects. 82 // popping up the dialog multiple times on chains of multiple redirects.
82 CloseReason previous_user_action_; 83 CloseReason previous_user_action_;
83 84
84 // This has to be the last member of the class. 85 // This has to be the last member of the class.
85 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; 86 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_;
86 87
87 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); 88 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle);
88 }; 89 };
89 90
90 } // namespace arc 91 } // namespace arc
91 92
92 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_ 93 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_navigation_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698