Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h

Issue 2770223003: [ios] Switches ToolbarModelDelegateIOS to use WebStateList. (Closed)
Patch Set: Fix compile. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Sets the |web_state_list_| with provided values. |web_state_list| must
27 void SetTabModel(TabModel* tab_model); 28 // outlive this ToolbarModelDelegateIOS object.
29 void SetWebStateList(WebStateList* web_state_list);
28 30
29 // Returns the current tab. 31 // Returns the active WebState.
30 Tab* GetCurrentTab() const; 32 web::WebState* GetActiveWebState() const;
31 33
32 private: 34 private:
33 // Helper method to extract the NavigationItem from which the states are 35 // Helper method to extract the NavigationItem from which the states are
34 // retrieved. If this returns null (which can happens during initialization), 36 // retrieved. If this returns null (which can happens during initialization),
35 // default values are used. 37 // default values are used.
36 web::NavigationItem* GetNavigationItem() const; 38 web::NavigationItem* GetNavigationItem() const;
37 39
38 // ToolbarModelDelegate implementation: 40 // ToolbarModelDelegate implementation:
39 base::string16 FormattedStringWithEquivalentMeaning( 41 base::string16 FormattedStringWithEquivalentMeaning(
40 const GURL& url, 42 const GURL& url,
41 const base::string16& formatted_url) const override; 43 const base::string16& formatted_url) const override;
42 bool GetURL(GURL* url) const override; 44 bool GetURL(GURL* url) const override;
43 bool ShouldDisplayURL() const override; 45 bool ShouldDisplayURL() const override;
44 SecurityLevel GetSecurityLevel() const override; 46 SecurityLevel GetSecurityLevel() const override;
45 scoped_refptr<net::X509Certificate> GetCertificate() const override; 47 scoped_refptr<net::X509Certificate> GetCertificate() const override;
46 bool FailsMalwareCheck() const override; 48 bool FailsMalwareCheck() const override;
47 const gfx::VectorIcon* GetVectorIconOverride() const override; 49 const gfx::VectorIcon* GetVectorIconOverride() const override;
48 50
49 base::scoped_nsobject<TabModel> tab_model_; 51 WebStateList* web_state_list_; // weak
50 52
51 DISALLOW_COPY_AND_ASSIGN(ToolbarModelDelegateIOS); 53 DISALLOW_COPY_AND_ASSIGN(ToolbarModelDelegateIOS);
52 }; 54 };
53 55
54 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_ 56 #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_DELEGATE_IOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698