Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" | 13 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| 14 #include "ui/gfx/geometry/point.h" | |
| 13 #include "ui/views/bubble/bubble_border.h" | 15 #include "ui/views/bubble/bubble_border.h" |
| 14 | 16 |
| 15 namespace views { | 17 namespace views { |
| 16 class View; | 18 class View; |
| 17 } | 19 } |
| 18 | 20 |
| 19 class Browser; | 21 class Browser; |
| 20 class PermissionsBubbleDialogDelegateView; | 22 class PermissionsBubbleDialogDelegateView; |
| 21 | 23 |
| 22 class PermissionBubbleViewViews : public PermissionBubbleView { | 24 class PermissionBubbleViewViews : public PermissionBubbleView { |
| 23 public: | 25 public: |
| 26 // A PermissionBubbleViewViews owns an AnchorDelegate, which is constructed by | |
| 27 // calling PermissionBubbleViewViews::CreateAnchorDelegate. The AnchorDelegate | |
| 28 // is responsible for determining the anchor view (or point, for platforms | |
| 29 // without an appropriate native view) and the immediate parent NativeView of | |
| 30 // this view. | |
| 31 class AnchorDelegate { | |
|
msw
2016/05/18 18:57:00
I don't really like the added complexity of this A
Elly Fong-Jones
2016/05/18 19:13:11
I think this technique will run into trouble for m
msw
2016/05/18 19:26:21
Ah, and this views bubble is used for the cocoa br
| |
| 32 public: | |
| 33 AnchorDelegate() {} | |
| 34 virtual views::View* GetAnchorView() = 0; | |
| 35 virtual gfx::Point GetAnchorPoint() = 0; | |
| 36 virtual views::BubbleBorder::Arrow GetAnchorArrow() = 0; | |
| 37 }; | |
| 38 | |
| 24 explicit PermissionBubbleViewViews(Browser* browser); | 39 explicit PermissionBubbleViewViews(Browser* browser); |
| 25 ~PermissionBubbleViewViews() override; | 40 ~PermissionBubbleViewViews() override; |
| 26 | 41 |
| 27 // PermissionBubbleView: | 42 // PermissionBubbleView: |
| 28 void SetDelegate(Delegate* delegate) override; | 43 void SetDelegate(Delegate* delegate) override; |
| 29 void Show(const std::vector<PermissionBubbleRequest*>& requests, | 44 void Show(const std::vector<PermissionBubbleRequest*>& requests, |
| 30 const std::vector<bool>& accept_state) override; | 45 const std::vector<bool>& accept_state) override; |
| 31 bool CanAcceptRequestUpdate() override; | 46 bool CanAcceptRequestUpdate() override; |
| 32 void Hide() override; | 47 void Hide() override; |
| 33 bool IsVisible() override; | 48 bool IsVisible() override; |
| 34 void UpdateAnchorPosition() override; | 49 void UpdateAnchorPosition() override; |
| 35 gfx::NativeWindow GetNativeWindow() override; | 50 gfx::NativeWindow GetNativeWindow() override; |
| 36 | 51 |
| 37 void Closing(); | 52 void Closing(); |
| 38 void Toggle(int index, bool value); | 53 void Toggle(int index, bool value); |
| 39 void Accept(); | 54 void Accept(); |
| 40 void Deny(); | 55 void Deny(); |
| 41 | 56 |
| 42 private: | 57 private: |
| 43 views::View* GetAnchorView(); | 58 // This function has separate implementations for Views-based and Cocoa-based |
| 44 views::BubbleBorder::Arrow GetAnchorArrow(); | 59 // browsers. |
| 60 static std::unique_ptr<AnchorDelegate> CreateAnchorDelegate(Browser* browser); | |
| 45 | 61 |
| 46 Browser* browser_; | 62 Browser* browser_; |
| 47 Delegate* delegate_; | 63 Delegate* delegate_; |
| 48 PermissionsBubbleDialogDelegateView* bubble_delegate_; | 64 PermissionsBubbleDialogDelegateView* bubble_delegate_; |
| 65 std::unique_ptr<AnchorDelegate> anchor_delegate_; | |
| 49 | 66 |
| 50 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleViewViews); | 67 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleViewViews); |
| 51 }; | 68 }; |
| 52 | 69 |
| 53 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_ | 70 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_ |
| OLD | NEW |