| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ | 6 #define IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ |
| 7 | 7 |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/toolbar/toolbar_model_delegate.h" | 10 #include "components/toolbar/toolbar_model_delegate.h" |
| 11 | 11 |
| 12 @class Tab; | 12 class WebStateList; |
| 13 @class TabModel; | |
| 14 | 13 |
| 15 namespace web { | 14 namespace web { |
| 16 class NavigationItem; | 15 class NavigationItem; |
| 16 class WebState; |
| 17 } | 17 } |
| 18 | 18 |
| 19 // Implementation of ToolbarModelDelegate which uses an instance of | 19 // Implementation of ToolbarModelDelegate which uses an instance of |
| 20 // TabModel in order to fulfil its duties. | 20 // TabModel in order to fulfil its duties. |
| 21 class ToolbarModelDelegateIOS : public ToolbarModelDelegate { | 21 class ToolbarModelDelegateIOS : public ToolbarModelDelegate { |
| 22 public: | 22 public: |
| 23 explicit ToolbarModelDelegateIOS(TabModel* tab_model); | 23 // |web_state_list| must outlive this ToolbarModelDelegateIOS object. |
| 24 explicit ToolbarModelDelegateIOS(WebStateList* web_state_list); |
| 24 ~ToolbarModelDelegateIOS() override; | 25 ~ToolbarModelDelegateIOS() override; |
| 25 | 26 |
| 26 // Sets the |tab_model_| with provided values. | 27 // Returns the active WebState. |
| 27 void SetTabModel(TabModel* tab_model); | 28 web::WebState* GetActiveWebState() const; |
| 28 | |
| 29 // Returns the current tab. | |
| 30 Tab* GetCurrentTab() const; | |
| 31 | 29 |
| 32 private: | 30 private: |
| 33 // Helper method to extract the NavigationItem from which the states are | 31 // Helper method to extract the NavigationItem from which the states are |
| 34 // retrieved. If this returns null (which can happens during initialization), | 32 // retrieved. If this returns null (which can happens during initialization), |
| 35 // default values are used. | 33 // default values are used. |
| 36 web::NavigationItem* GetNavigationItem() const; | 34 web::NavigationItem* GetNavigationItem() const; |
| 37 | 35 |
| 38 // ToolbarModelDelegate implementation: | 36 // ToolbarModelDelegate implementation: |
| 39 base::string16 FormattedStringWithEquivalentMeaning( | 37 base::string16 FormattedStringWithEquivalentMeaning( |
| 40 const GURL& url, | 38 const GURL& url, |
| 41 const base::string16& formatted_url) const override; | 39 const base::string16& formatted_url) const override; |
| 42 bool GetURL(GURL* url) const override; | 40 bool GetURL(GURL* url) const override; |
| 43 bool ShouldDisplayURL() const override; | 41 bool ShouldDisplayURL() const override; |
| 44 SecurityLevel GetSecurityLevel() const override; | 42 SecurityLevel GetSecurityLevel() const override; |
| 45 scoped_refptr<net::X509Certificate> GetCertificate() const override; | 43 scoped_refptr<net::X509Certificate> GetCertificate() const override; |
| 46 bool FailsMalwareCheck() const override; | 44 bool FailsMalwareCheck() const override; |
| 47 const gfx::VectorIcon* GetVectorIconOverride() const override; | 45 const gfx::VectorIcon* GetVectorIconOverride() const override; |
| 48 | 46 |
| 49 base::scoped_nsobject<TabModel> tab_model_; | 47 WebStateList* web_state_list_; // weak |
| 50 | 48 |
| 51 DISALLOW_COPY_AND_ASSIGN(ToolbarModelDelegateIOS); | 49 DISALLOW_COPY_AND_ASSIGN(ToolbarModelDelegateIOS); |
| 52 }; | 50 }; |
| 53 | 51 |
| 54 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ | 52 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ |
| OLD | NEW |