| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PERMISSION_BUBBLE_CHOOSER_BUBBLE_UI_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PERMISSION_BUBBLE_CHOOSER_BUBBLE_UI_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PERMISSION_BUBBLE_CHOOSER_BUBBLE_UI_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PERMISSION_BUBBLE_CHOOSER_BUBBLE_UI_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/bubble/bubble_ui.h" | 11 #include "components/bubble/bubble_ui.h" |
| 12 #include "ui/gfx/geometry/point.h" |
| 12 #include "ui/views/bubble/bubble_border.h" | 13 #include "ui/views/bubble/bubble_border.h" |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 16 class BubbleDialogDelegateView; |
| 15 class View; | 17 class View; |
| 16 } | 18 } |
| 17 | 19 |
| 18 class Browser; | 20 class Browser; |
| 19 class ChooserController; | 21 class ChooserController; |
| 20 class ChooserBubbleUiViewDelegate; | 22 class ChooserBubbleUiViewDelegate; |
| 21 | 23 |
| 22 // ChooserBubbleUiView implements a chooser-based permission model, | 24 // ChooserBubbleUi implements a chooser-based permission model, |
| 23 // it uses table view to show a list of items (such as usb devices, etc.) | 25 // it uses table view to show a list of items (such as usb devices, etc.) |
| 24 // for user to grant permission. It can be used by the WebUSB or WebBluetooth | 26 // for user to grant permission. It can be used by the WebUSB or WebBluetooth |
| 25 // APIs. It is owned by the BubbleController, which is owned by the | 27 // APIs. It is owned by the BubbleController, which is owned by the |
| 26 // BubbleManager. | 28 // BubbleManager. |
| 27 class ChooserBubbleUiView : public BubbleUi { | 29 class ChooserBubbleUi : public BubbleUi { |
| 28 public: | 30 public: |
| 29 ChooserBubbleUiView(Browser* browser, | 31 ChooserBubbleUi(Browser* browser, |
| 30 std::unique_ptr<ChooserController> chooser_controller); | 32 std::unique_ptr<ChooserController> chooser_controller); |
| 31 ~ChooserBubbleUiView() override; | 33 ~ChooserBubbleUi() override; |
| 32 | 34 |
| 33 // BubbleUi: | 35 // BubbleUi: |
| 34 void Show(BubbleReference bubble_reference) override; | 36 void Show(BubbleReference bubble_reference) override; |
| 35 void Close() override; | 37 void Close() override; |
| 36 void UpdateAnchorPosition() override; | 38 void UpdateAnchorPosition() override; |
| 37 | 39 |
| 38 private: | 40 private: |
| 41 // These functions have separate implementations for Views-based and |
| 42 // Cocoa-based browsers, to allow this bubble to be used in either. |
| 43 void CreateAndShow(views::BubbleDialogDelegateView* delegate); |
| 39 views::View* GetAnchorView(); | 44 views::View* GetAnchorView(); |
| 45 gfx::Point GetAnchorPoint(); |
| 40 views::BubbleBorder::Arrow GetAnchorArrow(); | 46 views::BubbleBorder::Arrow GetAnchorArrow(); |
| 41 | 47 |
| 42 Browser* browser_; // Weak. | 48 Browser* browser_; // Weak. |
| 43 // Weak. Owned by its parent view. | 49 // Weak. Owned by its parent view. |
| 44 ChooserBubbleUiViewDelegate* chooser_bubble_ui_view_delegate_; | 50 ChooserBubbleUiViewDelegate* chooser_bubble_ui_view_delegate_; |
| 45 | 51 |
| 46 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleUiView); | 52 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleUi); |
| 47 }; | 53 }; |
| 48 | 54 |
| 49 #endif // CHROME_BROWSER_UI_VIEWS_PERMISSION_BUBBLE_CHOOSER_BUBBLE_UI_VIEW_H_ | 55 #endif // CHROME_BROWSER_UI_VIEWS_PERMISSION_BUBBLE_CHOOSER_BUBBLE_UI_H_ |
| OLD | NEW |