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 WebStateList; | 12 @class Tab; |
| 13 @class TabModel; |
13 | 14 |
14 namespace web { | 15 namespace web { |
15 class NavigationItem; | 16 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 // |web_state_list| must outlive this ToolbarModelDelegateIOS object. | 23 explicit ToolbarModelDelegateIOS(TabModel* tab_model); |
24 explicit ToolbarModelDelegateIOS(WebStateList* web_state_list); | |
25 ~ToolbarModelDelegateIOS() override; | 24 ~ToolbarModelDelegateIOS() override; |
26 | 25 |
27 // Returns the active WebState. | 26 // Sets the |tab_model_| with provided values. |
28 web::WebState* GetActiveWebState() const; | 27 void SetTabModel(TabModel* tab_model); |
| 28 |
| 29 // Returns the current tab. |
| 30 Tab* GetCurrentTab() const; |
29 | 31 |
30 private: | 32 private: |
31 // Helper method to extract the NavigationItem from which the states are | 33 // Helper method to extract the NavigationItem from which the states are |
32 // retrieved. If this returns null (which can happens during initialization), | 34 // retrieved. If this returns null (which can happens during initialization), |
33 // default values are used. | 35 // default values are used. |
34 web::NavigationItem* GetNavigationItem() const; | 36 web::NavigationItem* GetNavigationItem() const; |
35 | 37 |
36 // ToolbarModelDelegate implementation: | 38 // ToolbarModelDelegate implementation: |
37 base::string16 FormattedStringWithEquivalentMeaning( | 39 base::string16 FormattedStringWithEquivalentMeaning( |
38 const GURL& url, | 40 const GURL& url, |
39 const base::string16& formatted_url) const override; | 41 const base::string16& formatted_url) const override; |
40 bool GetURL(GURL* url) const override; | 42 bool GetURL(GURL* url) const override; |
41 bool ShouldDisplayURL() const override; | 43 bool ShouldDisplayURL() const override; |
42 SecurityLevel GetSecurityLevel() const override; | 44 SecurityLevel GetSecurityLevel() const override; |
43 scoped_refptr<net::X509Certificate> GetCertificate() const override; | 45 scoped_refptr<net::X509Certificate> GetCertificate() const override; |
44 bool FailsMalwareCheck() const override; | 46 bool FailsMalwareCheck() const override; |
45 const gfx::VectorIcon* GetVectorIconOverride() const override; | 47 const gfx::VectorIcon* GetVectorIconOverride() const override; |
46 | 48 |
47 WebStateList* web_state_list_; // weak | 49 base::scoped_nsobject<TabModel> tab_model_; |
48 | 50 |
49 DISALLOW_COPY_AND_ASSIGN(ToolbarModelDelegateIOS); | 51 DISALLOW_COPY_AND_ASSIGN(ToolbarModelDelegateIOS); |
50 }; | 52 }; |
51 | 53 |
52 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ | 54 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ |
OLD | NEW |