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

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

Issue 2441563002: arc: Create intermediate directories in c/b/c/arc (Closed)
Patch Set: Moved the boot notification to notification/ 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_
7
8 #include <memory>
9 #include <string>
10 #include <utility>
11 #include <vector>
12
13 #include "base/callback.h"
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "components/arc/intent_helper/activity_icon_loader.h"
17 #include "content/public/browser/navigation_throttle.h"
18 #include "ui/gfx/image/image.h"
19
20 class GURL;
21
22 namespace content {
23 class NavigationHandle;
24 class WebContents;
25 } // namespace content
26
27 namespace arc {
28
29 // A class that allow us to retrieve ARC app's information and handle URL
30 // traffic initiated on Chrome browser, either on Chrome or an ARC's app.
31 class ArcNavigationThrottle : public content::NavigationThrottle {
32 public:
33 // These enums are used to define the buckets for an enumerated UMA histogram
34 // and need to be synced with histograms.xml. This enum class should also be
35 // treated as append-only.
36 enum class CloseReason : int {
37 ERROR = 0,
38 DIALOG_DEACTIVATED = 1,
39 ALWAYS_PRESSED = 2,
40 JUST_ONCE_PRESSED = 3,
41 PREFERRED_ACTIVITY_FOUND = 4,
42 SIZE,
43 INVALID = SIZE,
44 };
45
46 // Restricts the amount of apps displayed to the user without the need of a
47 // ScrollView.
48 enum { kMaxAppResults = 3 };
49
50 using NameAndIcon = std::pair<std::string, gfx::Image>;
51 using ShowIntentPickerCallback =
52 base::Callback<void(content::WebContents* web_contents,
53 const std::vector<NameAndIcon>& app_info,
54 const base::Callback<void(size_t, CloseReason)>& cb)>;
55 ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
56 const ShowIntentPickerCallback& show_intent_picker_cb);
57 ~ArcNavigationThrottle() override;
58
59 static bool ShouldOverrideUrlLoadingForTesting(const GURL& previous_url,
60 const GURL& current_url);
61
62 private:
63 // content::Navigation implementation:
64 NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
65 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
66
67 NavigationThrottle::ThrottleCheckResult HandleRequest();
68 void OnAppCandidatesReceived(
69 mojo::Array<mojom::IntentHandlerInfoPtr> handlers);
70 void OnAppIconsReceived(
71 mojo::Array<mojom::IntentHandlerInfoPtr> handlers,
72 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons);
73 void OnIntentPickerClosed(mojo::Array<mojom::IntentHandlerInfoPtr> handlers,
74 size_t selected_app_index,
75 CloseReason close_reason);
76 // A callback object that allow us to display an IntentPicker when Run() is
77 // executed, it also allow us to report the user's selection back to
78 // OnIntentPickerClosed().
79 ShowIntentPickerCallback show_intent_picker_callback_;
80
81 // A cache of the action the user took the last time this navigation throttle
82 // popped up the intent picker dialog. If the dialog has never been popped up
83 // before, this will have a value of CloseReason::INVALID. Used to avoid
84 // popping up the dialog multiple times on chains of multiple redirects.
85 CloseReason previous_user_action_;
86
87 // This has to be the last member of the class.
88 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_;
89
90 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle);
91 };
92
93 } // namespace arc
94
95 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698