| 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 } // namespace content | 22 } // namespace content |
| 23 | 23 |
| 24 namespace arc { | 24 namespace arc { |
| 25 | 25 |
| 26 // Restricts the amount of apps displayed to the user without the need of a | |
| 27 // ScrollView. | |
| 28 constexpr size_t kMaxAppResults = 3; | |
| 29 | |
| 30 // A class that allow us to retrieve ARC app's information and handle URL | 26 // A class that allow us to retrieve ARC app's information and handle URL |
| 31 // traffic initiated on Chrome browser, either on Chrome or an ARC's app. | 27 // traffic initiated on Chrome browser, either on Chrome or an ARC's app. |
| 32 class ArcNavigationThrottle : public content::NavigationThrottle { | 28 class ArcNavigationThrottle : public content::NavigationThrottle { |
| 33 public: | 29 public: |
| 34 // These enums are used to define the buckets for an enumerated UMA histogram | 30 // These enums are used to define the buckets for an enumerated UMA histogram |
| 35 // and need to be synced with histograms.xml. This enum class should also be | 31 // and need to be synced with histograms.xml. This enum class should also be |
| 36 // treated as append-only. | 32 // treated as append-only. |
| 37 enum class CloseReason : int { | 33 enum class CloseReason : int { |
| 38 ERROR = 0, | 34 ERROR = 0, |
| 39 DIALOG_DEACTIVATED = 1, | 35 DIALOG_DEACTIVATED = 1, |
| 40 ALWAYS_PRESSED = 2, | 36 ALWAYS_PRESSED = 2, |
| 41 JUST_ONCE_PRESSED = 3, | 37 JUST_ONCE_PRESSED = 3, |
| 42 PREFERRED_ACTIVITY_FOUND = 4, | 38 PREFERRED_ACTIVITY_FOUND = 4, |
| 43 SIZE, | 39 SIZE, |
| 44 }; | 40 }; |
| 45 | 41 |
| 42 // Restricts the amount of apps displayed to the user without the need of a |
| 43 // ScrollView. |
| 44 enum { kMaxAppResults = 3 }; |
| 45 |
| 46 using NameAndIcon = std::pair<std::string, gfx::Image>; | 46 using NameAndIcon = std::pair<std::string, gfx::Image>; |
| 47 using ShowDisambigDialogCallback = | 47 using ShowDisambigDialogCallback = |
| 48 base::Callback<void(content::NavigationHandle* handle, | 48 base::Callback<void(content::NavigationHandle* handle, |
| 49 const std::vector<NameAndIcon>& app_info, | 49 const std::vector<NameAndIcon>& app_info, |
| 50 const base::Callback<void(size_t, CloseReason)>& cb)>; | 50 const base::Callback<void(size_t, CloseReason)>& cb)>; |
| 51 ArcNavigationThrottle( | 51 ArcNavigationThrottle( |
| 52 content::NavigationHandle* navigation_handle, | 52 content::NavigationHandle* navigation_handle, |
| 53 const ShowDisambigDialogCallback& show_disambig_dialog_cb); | 53 const ShowDisambigDialogCallback& show_disambig_dialog_cb); |
| 54 ~ArcNavigationThrottle() override; | 54 ~ArcNavigationThrottle() override; |
| 55 | 55 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 ShowDisambigDialogCallback show_disambig_dialog_callback_; | 75 ShowDisambigDialogCallback show_disambig_dialog_callback_; |
| 76 | 76 |
| 77 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; | 77 base::WeakPtrFactory<ArcNavigationThrottle> weak_ptr_factory_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); | 79 DISALLOW_COPY_AND_ASSIGN(ArcNavigationThrottle); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace arc | 82 } // namespace arc |
| 83 | 83 |
| 84 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_NAVIGATION_THROTTLE_H_ |
| OLD | NEW |