| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROME_VIEWS_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "ui/accessibility/ax_enums.h" | 13 #include "ui/accessibility/ax_enums.h" |
| 14 #include "ui/views/views_delegate.h" | 14 #include "ui/views/views_delegate.h" |
| 15 | 15 |
| 16 class ScopedKeepAlive; | 16 class ScopedKeepAlive; |
| 17 | 17 |
| 18 class ChromeViewsDelegate : public views::ViewsDelegate { | 18 class ChromeViewsDelegate : public views::ViewsDelegate { |
| 19 public: | 19 public: |
| 20 ChromeViewsDelegate(); | 20 ChromeViewsDelegate(); |
| 21 ~ChromeViewsDelegate() override; | 21 ~ChromeViewsDelegate() override; |
| 22 | 22 |
| 23 static ChromeViewsDelegate* GetInstance(); | |
| 24 | |
| 25 // views::ViewsDelegate: | 23 // views::ViewsDelegate: |
| 26 void SaveWindowPlacement(const views::Widget* window, | 24 void SaveWindowPlacement(const views::Widget* window, |
| 27 const std::string& window_name, | 25 const std::string& window_name, |
| 28 const gfx::Rect& bounds, | 26 const gfx::Rect& bounds, |
| 29 ui::WindowShowState show_state) override; | 27 ui::WindowShowState show_state) override; |
| 30 bool GetSavedWindowPlacement(const views::Widget* widget, | 28 bool GetSavedWindowPlacement(const views::Widget* widget, |
| 31 const std::string& window_name, | 29 const std::string& window_name, |
| 32 gfx::Rect* bounds, | 30 gfx::Rect* bounds, |
| 33 ui::WindowShowState* show_state) const override; | 31 ui::WindowShowState* show_state) const override; |
| 34 void NotifyAccessibilityEvent(views::View* view, | 32 void NotifyAccessibilityEvent(views::View* view, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 53 void AddRef() override; | 51 void AddRef() override; |
| 54 void ReleaseRef() override; | 52 void ReleaseRef() override; |
| 55 void OnBeforeWidgetInit( | 53 void OnBeforeWidgetInit( |
| 56 views::Widget::InitParams* params, | 54 views::Widget::InitParams* params, |
| 57 views::internal::NativeWidgetDelegate* delegate) override; | 55 views::internal::NativeWidgetDelegate* delegate) override; |
| 58 ui::ContextFactory* GetContextFactory() override; | 56 ui::ContextFactory* GetContextFactory() override; |
| 59 ui::ContextFactoryPrivate* GetContextFactoryPrivate() override; | 57 ui::ContextFactoryPrivate* GetContextFactoryPrivate() override; |
| 60 std::string GetApplicationName() override; | 58 std::string GetApplicationName() override; |
| 61 scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner() override; | 59 scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner() override; |
| 62 | 60 |
| 63 gfx::Insets GetInsetsMetric(views::InsetsMetric metric) const override; | |
| 64 int GetDistanceMetric(views::DistanceMetric metric) const override; | |
| 65 const views::TypographyProvider& GetTypographyProvider() const override; | |
| 66 | |
| 67 static int GetDefaultDistanceMetric(views::DistanceMetric metric); | |
| 68 | |
| 69 private: | 61 private: |
| 70 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 71 typedef std::map<HMONITOR, int> AppbarAutohideEdgeMap; | 63 typedef std::map<HMONITOR, int> AppbarAutohideEdgeMap; |
| 72 | 64 |
| 73 // Callback on main thread with the edges. |returned_edges| is the value that | 65 // Callback on main thread with the edges. |returned_edges| is the value that |
| 74 // was returned from the call to GetAutohideEdges() that initiated the lookup. | 66 // was returned from the call to GetAutohideEdges() that initiated the lookup. |
| 75 void OnGotAppbarAutohideEdges(const base::Closure& callback, | 67 void OnGotAppbarAutohideEdges(const base::Closure& callback, |
| 76 HMONITOR monitor, | 68 HMONITOR monitor, |
| 77 int returned_edges, | 69 int returned_edges, |
| 78 int edges); | 70 int edges); |
| 79 #endif | 71 #endif |
| 80 | 72 |
| 81 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
| 82 // Called from GetSavedWindowPlacement() on ChromeOS to adjust the bounds. | 74 // Called from GetSavedWindowPlacement() on ChromeOS to adjust the bounds. |
| 83 void AdjustSavedWindowPlacementChromeOS(const views::Widget* widget, | 75 void AdjustSavedWindowPlacementChromeOS(const views::Widget* widget, |
| 84 gfx::Rect* bounds) const; | 76 gfx::Rect* bounds) const; |
| 85 #endif | 77 #endif |
| 86 | 78 |
| 87 int InternalGetDefaultDistanceMetric(views::DistanceMetric metric) const; | |
| 88 | |
| 89 // Function to retrieve default opacity value mainly based on platform | 79 // Function to retrieve default opacity value mainly based on platform |
| 90 // and desktop context. | 80 // and desktop context. |
| 91 views::Widget::InitParams::WindowOpacity GetOpacityForInitParams( | 81 views::Widget::InitParams::WindowOpacity GetOpacityForInitParams( |
| 92 const views::Widget::InitParams& params); | 82 const views::Widget::InitParams& params); |
| 93 | 83 |
| 94 views::NativeWidget* CreateNativeWidget( | 84 views::NativeWidget* CreateNativeWidget( |
| 95 views::Widget::InitParams* params, | 85 views::Widget::InitParams* params, |
| 96 views::internal::NativeWidgetDelegate* delegate); | 86 views::internal::NativeWidgetDelegate* delegate); |
| 97 | 87 |
| 98 // |ChromeViewsDelegate| exposes a |RefCounted|-like interface, but //chrome | 88 // |ChromeViewsDelegate| exposes a |RefCounted|-like interface, but //chrome |
| 99 // uses |ScopedKeepAlive|s to manage lifetime. We manage an internal counter | 89 // uses |ScopedKeepAlive|s to manage lifetime. We manage an internal counter |
| 100 // to do that translation. | 90 // to do that translation. |
| 101 unsigned int ref_count_ = 0u; | 91 unsigned int ref_count_ = 0u; |
| 102 | 92 |
| 103 std::unique_ptr<ScopedKeepAlive> keep_alive_; | 93 std::unique_ptr<ScopedKeepAlive> keep_alive_; |
| 104 | 94 |
| 105 #if defined(OS_WIN) | 95 #if defined(OS_WIN) |
| 106 AppbarAutohideEdgeMap appbar_autohide_edge_map_; | 96 AppbarAutohideEdgeMap appbar_autohide_edge_map_; |
| 107 // If true we're in the process of notifying a callback from | 97 // If true we're in the process of notifying a callback from |
| 108 // GetAutohideEdges().start a new query. | 98 // GetAutohideEdges().start a new query. |
| 109 bool in_autohide_edges_callback_; | 99 bool in_autohide_edges_callback_ = false; |
| 110 | 100 |
| 111 base::WeakPtrFactory<ChromeViewsDelegate> weak_factory_; | 101 base::WeakPtrFactory<ChromeViewsDelegate> weak_factory_{this}; |
| 112 #endif | 102 #endif |
| 113 | 103 |
| 114 DISALLOW_COPY_AND_ASSIGN(ChromeViewsDelegate); | 104 DISALLOW_COPY_AND_ASSIGN(ChromeViewsDelegate); |
| 115 }; | 105 }; |
| 116 | 106 |
| 117 #endif // CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ | 107 #endif // CHROME_BROWSER_UI_VIEWS_CHROME_VIEWS_DELEGATE_H_ |
| OLD | NEW |