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