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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model.h

Issue 9479008: Re-factor location bar/toolbar code to get rid of the browser dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_TOOLBAR_TOOLBAR_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 13
14 class Browser; 14 class TabContentsWrapperContainer;
15 15
16 namespace content { 16 namespace content {
17 class NavigationController; 17 class NavigationController;
18 class WebContents;
18 } 19 }
19 20
20 namespace net { 21 namespace net {
21 class X509Certificate; 22 class X509Certificate;
22 } 23 }
23 24
24 // This class is the model used by the toolbar, location bar and autocomplete 25 // This class is the model used by the toolbar, location bar and autocomplete
25 // edit. It populates its states from the current navigation entry retrieved 26 // edit. It populates its states from the current navigation entry retrieved
26 // from the navigation controller returned by GetNavigationController(). 27 // from the navigation controller returned by GetNavigationController().
27 class ToolbarModel { 28 class ToolbarModel {
28 public: 29 public:
29 // TODO(wtc): unify ToolbarModel::SecurityLevel with SecurityStyle. We 30 // TODO(wtc): unify ToolbarModel::SecurityLevel with SecurityStyle. We
30 // don't need two sets of security UI levels. SECURITY_STYLE_AUTHENTICATED 31 // don't need two sets of security UI levels. SECURITY_STYLE_AUTHENTICATED
31 // needs to be refined into three levels: warning, standard, and EV. 32 // needs to be refined into three levels: warning, standard, and EV.
32 enum SecurityLevel { 33 enum SecurityLevel {
33 NONE = 0, // HTTP/no URL/user is editing 34 NONE = 0, // HTTP/no URL/user is editing
34 EV_SECURE, // HTTPS with valid EV cert 35 EV_SECURE, // HTTPS with valid EV cert
35 SECURE, // HTTPS (non-EV) 36 SECURE, // HTTPS (non-EV)
36 SECURITY_WARNING, // HTTPS, but unable to check certificate revocation 37 SECURITY_WARNING, // HTTPS, but unable to check certificate revocation
37 // status or with insecure content on the page 38 // status or with insecure content on the page
38 SECURITY_ERROR, // Attempted HTTPS and failed, page not authenticated 39 SECURITY_ERROR, // Attempted HTTPS and failed, page not authenticated
39 NUM_SECURITY_LEVELS, 40 NUM_SECURITY_LEVELS,
40 }; 41 };
41 42
42 explicit ToolbarModel(Browser* browser); 43 explicit ToolbarModel(TabContentsWrapperContainer* container);
43 ~ToolbarModel(); 44 ~ToolbarModel();
44 45
45 // Returns the text that should be displayed in the location bar. 46 // Returns the text that should be displayed in the location bar.
46 string16 GetText() const; 47 string16 GetText() const;
47 48
48 // Returns the security level that the toolbar should display. 49 // Returns the security level that the toolbar should display.
49 SecurityLevel GetSecurityLevel() const; 50 SecurityLevel GetSecurityLevel() const;
50 51
51 // Returns the resource_id of the icon to show to the left of the address, 52 // Returns the resource_id of the icon to show to the left of the address,
52 // based on the current URL. This doesn't cover specialized icons while the 53 // based on the current URL. This doesn't cover specialized icons while the
(...skipping 15 matching lines...) Expand all
68 69
69 // Returns "<organization_name> [<country>]". 70 // Returns "<organization_name> [<country>]".
70 static string16 GetEVCertName(const net::X509Certificate& cert); 71 static string16 GetEVCertName(const net::X509Certificate& cert);
71 72
72 private: 73 private:
73 // Returns the navigation controller used to retrieve the navigation entry 74 // Returns the navigation controller used to retrieve the navigation entry
74 // from which the states are retrieved. 75 // from which the states are retrieved.
75 // If this returns NULL, default values are used. 76 // If this returns NULL, default values are used.
76 content::NavigationController* GetNavigationController() const; 77 content::NavigationController* GetNavigationController() const;
77 78
78 Browser* browser_; 79 content::WebContents* GetSelectedWebContents() const;
80
81 TabContentsWrapperContainer* container_;
79 82
80 // Whether the text in the location bar is currently being edited. 83 // Whether the text in the location bar is currently being edited.
81 bool input_in_progress_; 84 bool input_in_progress_;
82 85
83 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel); 86 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel);
84 }; 87 };
85 88
86 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 89 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698