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

Side by Side Diff: chrome/browser/ui/views/intent_picker_bubble_view.h

Issue 2134293002: Adding a ScrollView for IntentPickerBubbleView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a DCHECK to make code easier to follow. Created 4 years, 5 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
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_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "chrome/browser/chromeos/arc/arc_navigation_throttle.h" 13 #include "chrome/browser/chromeos/arc/arc_navigation_throttle.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
16 #include "ui/views/bubble/bubble_dialog_delegate.h" 16 #include "ui/views/bubble/bubble_dialog_delegate.h"
17 #include "ui/views/controls/button/button.h" 17 #include "ui/views/controls/button/button.h"
18 18
19 namespace content { 19 namespace content {
20 class NavigationHandle; 20 class NavigationHandle;
21 class WebContents;
21 } // namespace content 22 } // namespace content
22 23
23 namespace views { 24 namespace views {
24 class EventMonitor;
25 class Label; 25 class Label;
26 class LabelButton; 26 class LabelButton;
27 class View; 27 class View;
28 class Widget; 28 class Widget;
29 } // namespace views 29 } // namespace views
30 30
31 namespace ui { 31 namespace ui {
32 class Event; 32 class Event;
33 } // namespace ui 33 } // namespace ui
34 34
(...skipping 18 matching lines...) Expand all
53 public: 53 public:
54 using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon; 54 using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon;
55 // This callback informs the index of the app selected by the user, along with 55 // This callback informs the index of the app selected by the user, along with
56 // the reason why the Bubble was closed. The size_t param must have a value in 56 // the reason why the Bubble was closed. The size_t param must have a value in
57 // the range [0, app_info.size()-1], except when the CloseReason is ERROR or 57 // the range [0, app_info.size()-1], except when the CloseReason is ERROR or
58 // DIALOG_DEACTIVATED, for these cases we return a dummy value 58 // DIALOG_DEACTIVATED, for these cases we return a dummy value
59 // |kAppTagNoneSelected| which won't be used at all and has no significance. 59 // |kAppTagNoneSelected| which won't be used at all and has no significance.
60 using ThrottleCallback = 60 using ThrottleCallback =
61 base::Callback<void(size_t, arc::ArcNavigationThrottle::CloseReason)>; 61 base::Callback<void(size_t, arc::ArcNavigationThrottle::CloseReason)>;
62 62
63 ~IntentPickerBubbleView() override;
63 static void ShowBubble(content::NavigationHandle* handle, 64 static void ShowBubble(content::NavigationHandle* handle,
64 const std::vector<NameAndIcon>& app_info, 65 const std::vector<NameAndIcon>& app_info,
65 const ThrottleCallback& throttle_cb); 66 const ThrottleCallback& throttle_cb);
67 static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView(
68 const std::vector<NameAndIcon>& app_info,
69 const ThrottleCallback& throttle_cb,
70 content::WebContents* web_contents);
66 71
67 protected: 72 protected:
68 // views::BubbleDialogDelegateView overrides: 73 // views::BubbleDialogDelegateView overrides:
69 void Init() override; 74 void Init() override;
70 75
71 private: 76 private:
77 friend class IntentPickerBubbleViewTest;
78 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NullIcons);
79 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NonNullIcons);
80 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, LabelsPtrVectorSize);
72 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info, 81 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info,
73 ThrottleCallback throttle_cb, 82 ThrottleCallback throttle_cb,
74 content::WebContents* web_contents); 83 content::WebContents* web_contents);
75 ~IntentPickerBubbleView() override;
76 84
77 // views::BubbleDialogDelegateView overrides: 85 // views::BubbleDialogDelegateView overrides:
78 void OnWidgetDestroying(views::Widget* widget) override; 86 void OnWidgetDestroying(views::Widget* widget) override;
79 int GetDialogButtons() const override; 87 int GetDialogButtons() const override;
80 88
81 // views::ButtonListener overrides: 89 // views::ButtonListener overrides:
82 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 90 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
83 91
84 // views::View overrides: 92 // views::View overrides:
85 gfx::Size GetPreferredSize() const override; 93 gfx::Size GetPreferredSize() const override;
86 94
87 // content::WebContentsObserver overrides: 95 // content::WebContentsObserver overrides:
88 void WebContentsDestroyed() override; 96 void WebContentsDestroyed() override;
89 97
98 // Retrieves the LabelButton* contained at position |index| from the internal
99 // ScrollView.
100 views::LabelButton* GetLabelButtonAt(size_t index);
101 void SetLabelButtonBackgroundColor(size_t index, SkColor color);
102
90 // Flag set to true iff the callback was Run at some previous step, used to 103 // Flag set to true iff the callback was Run at some previous step, used to
91 // ensure we only use the callback once. 104 // ensure we only use the callback once.
92 bool was_callback_run_; 105 bool was_callback_run_;
93 106
94 // Callback used to respond to ArcNavigationThrottle. 107 // Callback used to respond to ArcNavigationThrottle.
95 ThrottleCallback throttle_cb_; 108 ThrottleCallback throttle_cb_;
96 109
97 // Keeps a invalid value unless the user explicitly makes a decision. 110 // Keeps a invalid value unless the user explicitly makes a decision.
98 size_t selected_app_tag_; 111 size_t selected_app_tag_;
99 112
100 views::LabelButton* always_button_; 113 views::LabelButton* always_button_;
101 views::LabelButton* just_once_button_; 114 views::LabelButton* just_once_button_;
115 views::ScrollView* scroll_view_;
102 116
103 std::vector<NameAndIcon> app_info_; 117 std::vector<NameAndIcon> app_info_;
104 118
105 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView); 119 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView);
106 }; 120 };
107 121
108 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ 122 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_navigation_throttle.h ('k') | chrome/browser/ui/views/intent_picker_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698