OLD | NEW |
---|---|
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 namespace content { | 20 namespace content { |
21 class NavigationHandle; | 21 class NavigationHandle; |
22 class WebContents; | |
22 } // namespace content | 23 } // namespace content |
23 | 24 |
24 namespace arc { | 25 namespace arc { |
25 | 26 |
26 // A class that allow us to retrieve ARC app's information and handle URL | 27 // 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. | 28 // traffic initiated on Chrome browser, either on Chrome or an ARC's app. |
28 class ArcNavigationThrottle : public content::NavigationThrottle { | 29 class ArcNavigationThrottle : public content::NavigationThrottle { |
29 public: | 30 public: |
30 // These enums are used to define the buckets for an enumerated UMA histogram | 31 // These enums are used to define the buckets for an enumerated UMA histogram |
31 // and need to be synced with histograms.xml. This enum class should also be | 32 // and need to be synced with histograms.xml. This enum class should also be |
32 // treated as append-only. | 33 // treated as append-only. |
33 enum class CloseReason : int { | 34 enum class CloseReason : int { |
34 ERROR = 0, | 35 ERROR = 0, |
35 DIALOG_DEACTIVATED = 1, | 36 DIALOG_DEACTIVATED = 1, |
36 ALWAYS_PRESSED = 2, | 37 ALWAYS_PRESSED = 2, |
37 JUST_ONCE_PRESSED = 3, | 38 JUST_ONCE_PRESSED = 3, |
38 PREFERRED_ACTIVITY_FOUND = 4, | 39 PREFERRED_ACTIVITY_FOUND = 4, |
39 SIZE, | 40 SIZE, |
40 INVALID = SIZE, | 41 INVALID = SIZE, |
41 }; | 42 }; |
42 | 43 |
43 // Restricts the amount of apps displayed to the user without the need of a | 44 // Restricts the amount of apps displayed to the user without the need of a |
44 // ScrollView. | 45 // ScrollView. |
45 enum { kMaxAppResults = 3 }; | 46 enum { kMaxAppResults = 3 }; |
46 | 47 |
47 using NameAndIcon = std::pair<std::string, gfx::Image>; | 48 using NameAndIcon = std::pair<std::string, gfx::Image>; |
48 using ShowIntentPickerCallback = | 49 using ShowIntentPickerCallback = |
49 base::Callback<void(content::NavigationHandle* handle, | 50 base::Callback<void(content::WebContents* contents, |
djacobo_
2016/09/14 17:16:45
nit: replace contents with web_contents
Yusuke Sato
2016/09/14 18:15:54
Done.
| |
50 const std::vector<NameAndIcon>& app_info, | 51 const std::vector<NameAndIcon>& app_info, |
51 const base::Callback<void(size_t, CloseReason)>& cb)>; | 52 const base::Callback<void(size_t, CloseReason)>& cb)>; |
52 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, | 53 ArcNavigationThrottle(content::NavigationHandle* navigation_handle, |
53 const ShowIntentPickerCallback& show_intent_picker_cb); | 54 const ShowIntentPickerCallback& show_intent_picker_cb); |
54 ~ArcNavigationThrottle() override; | 55 ~ArcNavigationThrottle() override; |
55 | 56 |
56 private: | 57 private: |
57 // content::Navigation implementation: | 58 // content::Navigation implementation: |
58 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; | 59 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; |
59 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; | 60 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; |
(...skipping 23 matching lines...) Expand all Loading... | |
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_ |
OLD | NEW |