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

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

Issue 2229943003: Reusing Ok/Cancel buttons for intent picker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing strings to lowercase. 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
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
(...skipping 14 matching lines...) Expand all
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
35 class IntentPickerMenuButton;
36
35 // A bubble that displays a list of aplications (icons and names), after the 37 // A bubble that displays a list of aplications (icons and names), after the
36 // list we show a pair of buttons which allow the user to remember the selection 38 // list we show a pair of buttons which allow the user to remember the selection
37 // or not. This class comunicates the user's selection with a callback used by 39 // or not. This class comunicates the user's selection with a callback used by
38 // ArcNavigationThrottle. 40 // ArcNavigationThrottle.
39 // +--------------------------------+ 41 // +--------------------------------+
40 // | Open with | 42 // | Open with |
41 // | | 43 // | |
42 // | Icon1 Name1 | 44 // | Icon1 Name1 |
43 // | Icon2 Name2 | 45 // | Icon2 Name2 |
44 // | ... | 46 // | ... |
45 // | Icon(N) Name(N) | 47 // | Icon(N) Name(N) |
46 // | | 48 // | |
47 // | [JUST ONCE] [ALWAYS] | 49 // | [JUST ONCE] [ALWAYS] |
48 // +--------------------------------+ 50 // +--------------------------------+
49 51
50 class IntentPickerBubbleView : public views::BubbleDialogDelegateView, 52 class IntentPickerBubbleView : public views::BubbleDialogDelegateView,
51 public views::ButtonListener, 53 public views::ButtonListener,
52 public content::WebContentsObserver { 54 public content::WebContentsObserver {
53 public: 55 public:
54 using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon; 56 using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon;
55 // This callback informs the index of the app selected by the user, along with 57 // 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 58 // 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 59 // 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 60 // DIALOG_DEACTIVATED, for these cases we return a dummy value
59 // |kAppTagNoneSelected| which won't be used at all and has no significance. 61 // |kAppTagNoneSelected| which won't be used at all and has no significance.
60 using ThrottleCallback = 62 using ThrottleCallback =
Evan Stade 2016/09/14 17:48:00 I thought we were going to change the name of this
djacobo_ 2016/09/14 21:29:35 We agreed on changing the callback name for the in
61 base::Callback<void(size_t, arc::ArcNavigationThrottle::CloseReason)>; 63 base::Callback<void(size_t, arc::ArcNavigationThrottle::CloseReason)>;
Evan Stade 2016/09/14 17:48:00 I'm told we should use int for indexes and not to
djacobo_ 2016/09/14 21:29:35 I am not using size_t just to ensure we have somet
Evan Stade 2016/09/14 21:53:08 okey dokey, size_t it is
djacobo_ 2016/09/16 01:23:08 Given our conversation I am using package_name to
62 64
63 ~IntentPickerBubbleView() override; 65 ~IntentPickerBubbleView() override;
64 static void ShowBubble(content::NavigationHandle* handle, 66 static void ShowBubble(content::NavigationHandle* handle,
65 const std::vector<NameAndIcon>& app_info, 67 const std::vector<NameAndIcon>& app_info,
66 const ThrottleCallback& throttle_cb); 68 const ThrottleCallback& throttle_cb);
67 static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView( 69 static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView(
68 const std::vector<NameAndIcon>& app_info, 70 const std::vector<NameAndIcon>& app_info,
69 const ThrottleCallback& throttle_cb, 71 const ThrottleCallback& throttle_cb,
70 content::WebContents* web_contents); 72 content::WebContents* web_contents);
71 73
74 // views::DialogDelegate overrides:
75 bool Accept() override;
76 bool Cancel() override;
77 bool Close() override;
78 int GetDefaultDialogButton() const override;
79
72 protected: 80 protected:
73 // views::BubbleDialogDelegateView overrides: 81 // views::BubbleDialogDelegateView overrides:
74 void Init() override; 82 void Init() override;
75 83
84 // views::DialogDelegate overrides:
85 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
86
87 // views::WidgetDelegate overrides:
88 base::string16 GetWindowTitle() const override;
89 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
90
76 private: 91 private:
77 friend class IntentPickerBubbleViewTest; 92 friend class IntentPickerBubbleViewTest;
78 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NullIcons); 93 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NullIcons);
79 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NonNullIcons); 94 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NonNullIcons);
80 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, LabelsPtrVectorSize); 95 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, LabelsPtrVectorSize);
96 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, VerifyStartingInkDrop);
97 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, InkDropStateTransition);
98 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, PressButtonTwice);
81 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info, 99 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info,
82 ThrottleCallback throttle_cb, 100 ThrottleCallback throttle_cb,
83 content::WebContents* web_contents); 101 content::WebContents* web_contents);
84 102
85 // views::BubbleDialogDelegateView overrides: 103 // views::BubbleDialogDelegateView overrides:
86 void OnWidgetDestroying(views::Widget* widget) override; 104 void OnWidgetDestroying(views::Widget* widget) override;
87 int GetDialogButtons() const override;
88 105
89 // views::ButtonListener overrides: 106 // views::ButtonListener overrides:
90 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 107 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
91 108
92 // views::View overrides: 109 // views::View overrides:
93 gfx::Size GetPreferredSize() const override; 110 gfx::Size GetPreferredSize() const override;
94 111
95 // content::WebContentsObserver overrides: 112 // content::WebContentsObserver overrides:
96 void WebContentsDestroyed() override; 113 void WebContentsDestroyed() override;
97 114
98 // Retrieves the LabelButton* contained at position |index| from the internal 115 // Retrieves the IntentPickerMenuButton* contained at position |index| from
99 // ScrollView. 116 // the internal ScrollView.
100 views::LabelButton* GetLabelButtonAt(size_t index); 117 IntentPickerMenuButton* GetIntentPickerMenuButtonAt(size_t index);
101 void SetLabelButtonBackgroundColor(size_t index, SkColor color);
102 118
103 // Flag set to true iff the callback was Run at some previous step, used to 119 gfx::ImageSkia GetAppImageForTesting(size_t index);
104 // ensure we only use the callback once. 120 views::InkDropState GetInkDropStateForTesting(size_t);
105 bool was_callback_run_; 121 void PressButtonForTesting(size_t index, const ui::Event& event);
106 122
107 // Callback used to respond to ArcNavigationThrottle. 123 // Callback used to respond to ArcNavigationThrottle.
108 ThrottleCallback throttle_cb_; 124 ThrottleCallback throttle_cb_;
109 125
110 // Keeps a invalid value unless the user explicitly makes a decision. 126 // Keeps a invalid value unless the user explicitly makes a decision.
111 size_t selected_app_tag_; 127 size_t selected_app_tag_;
112 128
113 views::LabelButton* always_button_;
114 views::LabelButton* just_once_button_;
115 views::ScrollView* scroll_view_; 129 views::ScrollView* scroll_view_;
116 130
117 std::vector<NameAndIcon> app_info_; 131 std::vector<NameAndIcon> app_info_;
118 132
119 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView); 133 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView);
120 }; 134 };
121 135
122 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ 136 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698