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

Unified Diff: chrome/browser/ui/views/intent_picker_bubble_view.h

Issue 2436543003: reland: Reusing Ok/Cancel buttons for intent picker (Closed)
Patch Set: Modifying the way I create a dummy event for the testing. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser_dialogs.h ('k') | chrome/browser/ui/views/intent_picker_bubble_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/intent_picker_bubble_view.h
diff --git a/chrome/browser/ui/views/intent_picker_bubble_view.h b/chrome/browser/ui/views/intent_picker_bubble_view.h
index e811528ccc8e59d82d0f8423022908a6e546e19e..019deb9f2302e9b43a620067c5a0406d45657fc5 100644
--- a/chrome/browser/ui/views/intent_picker_bubble_view.h
+++ b/chrome/browser/ui/views/intent_picker_bubble_view.h
@@ -6,11 +6,13 @@
#define CHROME_BROWSER_UI_VIEWS_INTENT_PICKER_BUBBLE_VIEW_H_
#include <memory>
+#include <string>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/arc/arc_navigation_throttle.h"
+#include "chrome/browser/ui/browser_dialogs.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/image/image.h"
#include "ui/views/bubble/bubble_dialog_delegate.h"
@@ -31,6 +33,8 @@ namespace ui {
class Event;
} // namespace ui
+class IntentPickerLabelButton;
+
// A bubble that displays a list of aplications (icons and names), after the
// list we show a pair of buttons which allow the user to remember the selection
// or not. This class comunicates the user's selection with a callback used by
@@ -43,47 +47,49 @@ class Event;
// | ... |
// | Icon(N) Name(N) |
// | |
-// | [JUST ONCE] [ALWAYS] |
+// | [Just once] [Always] |
// +--------------------------------+
class IntentPickerBubbleView : public views::BubbleDialogDelegateView,
public views::ButtonListener,
public content::WebContentsObserver {
public:
- using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon;
- // This callback informs the index of the app selected by the user, along with
- // the reason why the Bubble was closed. The size_t param must have a value in
- // the range [0, app_info.size()-1], except when the CloseReason is ERROR or
- // DIALOG_DEACTIVATED, for these cases we return a dummy value
- // |kAppTagNoneSelected| which won't be used at all and has no significance.
- using ThrottleCallback =
- base::Callback<void(size_t, arc::ArcNavigationThrottle::CloseReason)>;
+ using AppInfo = arc::ArcNavigationThrottle::AppInfo;
~IntentPickerBubbleView() override;
static void ShowBubble(content::WebContents* web_contents,
- const std::vector<NameAndIcon>& app_info,
- const ThrottleCallback& throttle_cb);
+ const std::vector<AppInfo>& app_info,
+ const IntentPickerResponse& intent_picker_cb);
static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView(
- const std::vector<NameAndIcon>& app_info,
- const ThrottleCallback& throttle_cb,
+ const std::vector<AppInfo>& app_info,
+ const IntentPickerResponse& intent_picker_cb,
content::WebContents* web_contents);
+ // views::BubbleDialogDelegateView overrides:
+ bool Accept() override;
+ bool Cancel() override;
+ bool Close() override;
+
protected:
// views::BubbleDialogDelegateView overrides:
void Init() override;
+ base::string16 GetWindowTitle() const override;
+ base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
private:
friend class IntentPickerBubbleViewTest;
FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NullIcons);
FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, NonNullIcons);
FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, LabelsPtrVectorSize);
- IntentPickerBubbleView(const std::vector<NameAndIcon>& app_info,
- ThrottleCallback throttle_cb,
+ FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, VerifyStartingInkDrop);
+ FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, InkDropStateTransition);
+ FRIEND_TEST_ALL_PREFIXES(IntentPickerBubbleViewTest, PressButtonTwice);
+ IntentPickerBubbleView(const std::vector<AppInfo>& app_info,
+ IntentPickerResponse intent_picker_cb,
content::WebContents* web_contents);
// views::BubbleDialogDelegateView overrides:
void OnWidgetDestroying(views::Widget* widget) override;
- int GetDialogButtons() const override;
// views::ButtonListener overrides:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
@@ -94,26 +100,25 @@ class IntentPickerBubbleView : public views::BubbleDialogDelegateView,
// content::WebContentsObserver overrides:
void WebContentsDestroyed() override;
- // Retrieves the LabelButton* contained at position |index| from the internal
- // ScrollView.
- views::LabelButton* GetLabelButtonAt(size_t index);
- void SetLabelButtonBackgroundColor(size_t index, SkColor color);
+ // Retrieves the IntentPickerLabelButton* contained at position |index| from
+ // the internal ScrollView.
+ IntentPickerLabelButton* GetIntentPickerLabelButtonAt(size_t index);
+ void RunCallback(std::string package,
+ arc::ArcNavigationThrottle::CloseReason close_reason);
- // Flag set to true iff the callback was Run at some previous step, used to
- // ensure we only use the callback once.
- bool was_callback_run_;
+ gfx::ImageSkia GetAppImageForTesting(size_t index);
+ views::InkDropState GetInkDropStateForTesting(size_t);
+ void PressButtonForTesting(size_t index, const ui::Event& event);
// Callback used to respond to ArcNavigationThrottle.
- ThrottleCallback throttle_cb_;
+ IntentPickerResponse intent_picker_cb_;
- // Keeps a invalid value unless the user explicitly makes a decision.
- size_t selected_app_tag_;
+ // Pre-select the first app on the list.
+ size_t selected_app_tag_ = 0;
- views::LabelButton* always_button_;
- views::LabelButton* just_once_button_;
views::ScrollView* scroll_view_;
- std::vector<NameAndIcon> app_info_;
+ std::vector<AppInfo> app_info_;
DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleView);
};
« no previous file with comments | « chrome/browser/ui/browser_dialogs.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