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

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: Inner button class for hovering/selected/unselected effects 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 // | ... |
(...skipping 17 matching lines...) Expand all
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);
81 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info, 96 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info,
82 ThrottleCallback throttle_cb, 97 ThrottleCallback throttle_cb,
83 content::WebContents* web_contents); 98 content::WebContents* web_contents);
84 99
85 // views::BubbleDialogDelegateView overrides: 100 // views::BubbleDialogDelegateView overrides:
86 void OnWidgetDestroying(views::Widget* widget) override; 101 void OnWidgetDestroying(views::Widget* widget) override;
87 int GetDialogButtons() const override;
88 102
89 // views::ButtonListener overrides: 103 // views::ButtonListener overrides:
90 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 104 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
91 105
92 // views::View overrides: 106 // views::View overrides:
93 gfx::Size GetPreferredSize() const override; 107 gfx::Size GetPreferredSize() const override;
94 108
95 // content::WebContentsObserver overrides: 109 // content::WebContentsObserver overrides:
96 void WebContentsDestroyed() override; 110 void WebContentsDestroyed() override;
97 111
98 // Retrieves the LabelButton* contained at position |index| from the internal 112 // Retrieves the IntentPickerMenuButton* contained at position |index| from
99 // ScrollView. 113 // the internal ScrollView.
100 views::LabelButton* GetLabelButtonAt(size_t index); 114 IntentPickerMenuButton* GetIntentPickerMenuButtonAt(size_t index);
101 void SetLabelButtonBackgroundColor(size_t index, SkColor color); 115 gfx::ImageSkia GetAppImageForTesting(size_t index);
102
103 // Flag set to true iff the callback was Run at some previous step, used to
104 // ensure we only use the callback once.
105 bool was_callback_run_;
106 116
107 // Callback used to respond to ArcNavigationThrottle. 117 // Callback used to respond to ArcNavigationThrottle.
108 ThrottleCallback throttle_cb_; 118 ThrottleCallback throttle_cb_;
109 119
110 // Keeps a invalid value unless the user explicitly makes a decision. 120 // Keeps a invalid value unless the user explicitly makes a decision.
111 size_t selected_app_tag_; 121 size_t selected_app_tag_;
112 122
113 views::LabelButton* always_button_;
114 views::LabelButton* just_once_button_;
115 views::ScrollView* scroll_view_; 123 views::ScrollView* scroll_view_;
116 124
117 std::vector<NameAndIcon> app_info_; 125 std::vector<NameAndIcon> app_info_;
118 126
119 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView); 127 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView);
120 }; 128 };
121 129
122 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ 130 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698