| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 ~IntentPickerBubbleView() override; | 63 ~IntentPickerBubbleView() override; |
| 64 static void ShowBubble(content::NavigationHandle* handle, | 64 static void ShowBubble(content::NavigationHandle* handle, |
| 65 const std::vector<NameAndIcon>& app_info, | 65 const std::vector<NameAndIcon>& app_info, |
| 66 const ThrottleCallback& throttle_cb); | 66 const ThrottleCallback& throttle_cb); |
| 67 static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView( | 67 static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView( |
| 68 const std::vector<NameAndIcon>& app_info, | 68 const std::vector<NameAndIcon>& app_info, |
| 69 const ThrottleCallback& throttle_cb, | 69 const ThrottleCallback& throttle_cb, |
| 70 content::WebContents* web_contents); | 70 content::WebContents* web_contents); |
| 71 | 71 |
| 72 // views::DialogDelegate overrides: |
| 73 bool Accept() override; |
| 74 bool Cancel() override; |
| 75 bool Close() override; |
| 76 int GetDefaultDialogButton() const override; |
| 77 |
| 72 protected: | 78 protected: |
| 73 // views::BubbleDialogDelegateView overrides: | 79 // views::BubbleDialogDelegateView overrides: |
| 74 void Init() override; | 80 void Init() override; |
| 75 | 81 |
| 82 // views::DialogDelegate overrides: |
| 83 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
| 84 |
| 85 // views::WidgetDelegate overrides: |
| 86 base::string16 GetWindowTitle() const override; |
| 87 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 88 |
| 76 private: | 89 private: |
| 77 friend class IntentPickerBubbleViewTest; | 90 friend class IntentPickerBubbleViewTest; |
| 78 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NullIcons); | 91 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NullIcons); |
| 79 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NonNullIcons); | 92 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NonNullIcons); |
| 80 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, LabelsPtrVectorSize); | 93 FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, LabelsPtrVectorSize); |
| 81 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info, | 94 IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info, |
| 82 ThrottleCallback throttle_cb, | 95 ThrottleCallback throttle_cb, |
| 83 content::WebContents* web_contents); | 96 content::WebContents* web_contents); |
| 84 | 97 |
| 85 // views::BubbleDialogDelegateView overrides: | 98 // views::BubbleDialogDelegateView overrides: |
| 86 void OnWidgetDestroying(views::Widget* widget) override; | 99 void OnWidgetDestroying(views::Widget* widget) override; |
| 87 int GetDialogButtons() const override; | |
| 88 | 100 |
| 89 // views::ButtonListener overrides: | 101 // views::ButtonListener overrides: |
| 90 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 102 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 91 | 103 |
| 92 // views::View overrides: | 104 // views::View overrides: |
| 93 gfx::Size GetPreferredSize() const override; | 105 gfx::Size GetPreferredSize() const override; |
| 94 | 106 |
| 95 // content::WebContentsObserver overrides: | 107 // content::WebContentsObserver overrides: |
| 96 void WebContentsDestroyed() override; | 108 void WebContentsDestroyed() override; |
| 97 | 109 |
| 98 // Retrieves the LabelButton* contained at position |index| from the internal | 110 // Retrieves the IntentPickerMenuButton* contained at position |index| from |
| 99 // ScrollView. | 111 // the internal ScrollView. |
| 100 views::LabelButton* GetLabelButtonAt(size_t index); | 112 views::LabelButton* GetLabelButtonAt(size_t index); |
| 101 void SetLabelButtonBackgroundColor(size_t index, SkColor color); | 113 void SetLabelButtonBackgroundColor(size_t index, SkColor color); |
| 102 | 114 gfx::ImageSkia GetAppImageForTesting(size_t index); |
| 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 | 115 |
| 107 // Callback used to respond to ArcNavigationThrottle. | 116 // Callback used to respond to ArcNavigationThrottle. |
| 108 ThrottleCallback throttle_cb_; | 117 ThrottleCallback throttle_cb_; |
| 109 | 118 |
| 110 // Keeps a invalid value unless the user explicitly makes a decision. | 119 // Keeps a invalid value unless the user explicitly makes a decision. |
| 111 size_t selected_app_tag_; | 120 size_t selected_app_tag_; |
| 112 | 121 |
| 113 views::LabelButton* always_button_; | |
| 114 views::LabelButton* just_once_button_; | |
| 115 views::ScrollView* scroll_view_; | 122 views::ScrollView* scroll_view_; |
| 116 | 123 |
| 117 std::vector<NameAndIcon> app_info_; | 124 std::vector<NameAndIcon> app_info_; |
| 118 | 125 |
| 119 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView); | 126 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView); |
| 120 }; | 127 }; |
| 121 | 128 |
| 122 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ | 129 #endif // CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_ |
| OLD | NEW |