| 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_LOCATION_BAR_LOCATION_BAR_BUBBLE_DELEGATE_VIEW_H
_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_BUBBLE_DELEGATE_VIEW_H
_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_BUBBLE_DELEGATE_VIEW_H
_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_BUBBLE_DELEGATE_VIEW_H
_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "content/public/browser/notification_observer.h" | 9 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| 11 #include "ui/views/bubble/bubble_delegate.h" | 11 #include "ui/views/bubble/bubble_delegate.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class NotificationDetails; | 14 class NotificationDetails; |
| 15 class NotificationSource; | 15 class NotificationSource; |
| 16 class WebContents; | 16 class WebContents; |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 // Base class for bubbles that are shown from location bar icons. The bubble | 19 // Base class for bubbles that are shown from location bar icons. The bubble |
| 20 // will automatically close when the browser transitions in or out of fullscreen | 20 // will automatically close when the browser transitions in or out of fullscreen |
| 21 // mode. | 21 // mode. |
| 22 class LocationBarBubbleDelegateView : public views::BubbleDelegateView, | 22 class LocationBarBubbleDelegateView : public views::BubbleDelegateView, |
| 23 public content::NotificationObserver { | 23 public content::NotificationObserver { |
| 24 public: | 24 public: |
| 25 enum DisplayReason { |
| 26 // The bubble appears as a direct result of a user action (clicking on the |
| 27 // location bar icon). |
| 28 USER_GESTURE, |
| 29 |
| 30 // The bubble appears spontaneously over the course of the user's |
| 31 // interaction with Chrome (e.g. due to some change in the feature's |
| 32 // status). |
| 33 AUTOMATIC, |
| 34 }; |
| 35 |
| 25 LocationBarBubbleDelegateView(views::View* anchor_view, | 36 LocationBarBubbleDelegateView(views::View* anchor_view, |
| 26 content::WebContents* web_contents); | 37 content::WebContents* web_contents); |
| 27 ~LocationBarBubbleDelegateView() override; | 38 ~LocationBarBubbleDelegateView() override; |
| 28 | 39 |
| 40 // Displays the bubble with appearance and behavior tailored for |reason|. |
| 41 void ShowForReason(DisplayReason reason); |
| 42 |
| 29 // content::NotificationObserver: | 43 // content::NotificationObserver: |
| 30 void Observe(int type, | 44 void Observe(int type, |
| 31 const content::NotificationSource& source, | 45 const content::NotificationSource& source, |
| 32 const content::NotificationDetails& details) override; | 46 const content::NotificationDetails& details) override; |
| 33 | 47 |
| 34 protected: | 48 protected: |
| 35 // Closes the bubble. | 49 // Closes the bubble. |
| 36 virtual void Close(); | 50 virtual void Close(); |
| 37 | 51 |
| 38 // If the bubble is not anchored to a view, places the bubble in the top right | 52 // If the bubble is not anchored to a view, places the bubble in the top right |
| 39 // (left in RTL) of the |screen_bounds| that contain web contents's browser | 53 // (left in RTL) of the |screen_bounds| that contain web contents's browser |
| 40 // window. Because the positioning is based on the size of the bubble, this | 54 // window. Because the positioning is based on the size of the bubble, this |
| 41 // must be called after the bubble is created. | 55 // must be called after the bubble is created. |
| 42 void AdjustForFullscreen(const gfx::Rect& screen_bounds); | 56 void AdjustForFullscreen(const gfx::Rect& screen_bounds); |
| 43 | 57 |
| 44 private: | 58 private: |
| 45 // Used to register for fullscreen change notifications. | 59 // Used to register for fullscreen change notifications. |
| 46 content::NotificationRegistrar registrar_; | 60 content::NotificationRegistrar registrar_; |
| 47 | 61 |
| 48 DISALLOW_COPY_AND_ASSIGN(LocationBarBubbleDelegateView); | 62 DISALLOW_COPY_AND_ASSIGN(LocationBarBubbleDelegateView); |
| 49 }; | 63 }; |
| 50 | 64 |
| 51 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_BUBBLE_DELEGATE_VIE
W_H_ | 65 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_BUBBLE_DELEGATE_VIE
W_H_ |
| OLD | NEW |