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

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

Issue 11040055: Adds a FakeToolbarModel for use in testing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: renamed methods and fixed usage Created 8 years, 2 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 (c) 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 CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
11 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "chrome/browser/ui/toolbar/toolbar_model.h"
12 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
13 15
14 class Profile; 16 class Profile;
15 class ToolbarModelDelegate; 17 class ToolbarModelDelegate;
16 18
17 namespace content { 19 namespace content {
18 class NavigationController; 20 class NavigationController;
19 } 21 }
20 22
21 namespace net { 23 namespace net {
22 class X509Certificate; 24 class X509Certificate;
23 } 25 }
24 26
25 // This class is the model used by the toolbar, location bar and autocomplete 27 // This class is the model used by the toolbar, location bar and autocomplete
26 // edit. It populates its states from the current navigation entry retrieved 28 // edit. It populates its states from the current navigation entry retrieved
27 // from the navigation controller returned by GetNavigationController(). 29 // from the navigation controller returned by GetNavigationController().
28 class ToolbarModel { 30 class ToolbarModelImpl : public ToolbarModel {
29 public: 31 public:
30 // TODO(wtc): unify ToolbarModel::SecurityLevel with SecurityStyle. We 32 explicit ToolbarModelImpl(ToolbarModelDelegate* delegate);
31 // don't need two sets of security UI levels. SECURITY_STYLE_AUTHENTICATED 33 virtual ~ToolbarModelImpl();
32 // needs to be refined into three levels: warning, standard, and EV.
33 enum SecurityLevel {
34 NONE = 0, // HTTP/no URL/user is editing
35 EV_SECURE, // HTTPS with valid EV cert
36 SECURE, // HTTPS (non-EV)
37 SECURITY_WARNING, // HTTPS, but unable to check certificate revocation
38 // status or with insecure content on the page
39 SECURITY_ERROR, // Attempted HTTPS and failed, page not authenticated
40 NUM_SECURITY_LEVELS,
41 };
42
43 explicit ToolbarModel(ToolbarModelDelegate* delegate);
44 ~ToolbarModel();
45 34
46 // Returns the text for the current page's URL. This will have been formatted 35 // Returns the text for the current page's URL. This will have been formatted
sky 2012/10/10 21:17:36 Don't duplicate all the comments here. Just remove
lliabraa 2012/10/11 18:14:59 Done.
47 // for display to the user: 36 // for display to the user:
48 // - Some characters may be unescaped. 37 // - Some characters may be unescaped.
49 // - The scheme and/or trailing slash may be dropped. 38 // - The scheme and/or trailing slash may be dropped.
50 // - if |display_search_urls_as_search_terms| is true, the query will be 39 // - if |display_search_urls_as_search_terms| is true, the query will be
51 // extracted from search URLs for the user's default search engine and those 40 // extracted from search URLs for the user's default search engine and those
52 // will be displayed in place of the URL. 41 // will be displayed in place of the URL.
53 string16 GetText(bool display_search_urls_as_search_terms) const; 42 virtual string16 GetText(
43 bool display_search_urls_as_search_terms) const OVERRIDE;
54 44
55 // Returns the URL of the current navigation entry. 45 // Returns the URL of the current navigation entry.
56 GURL GetURL() const; 46 virtual GURL GetURL() const OVERRIDE;
57 47
58 // Returns true if a call to GetText(true) would successfully replace the URL 48 // Returns true if a call to GetText(true) would successfully replace the URL
59 // with search terms. 49 // with search terms.
60 bool WouldReplaceSearchURLWithSearchTerms() const; 50 virtual bool WouldReplaceSearchURLWithSearchTerms() const OVERRIDE;
61 51
62 // Returns the security level that the toolbar should display. 52 // Returns the security level that the toolbar should display.
63 SecurityLevel GetSecurityLevel() const; 53 virtual SecurityLevel GetSecurityLevel() const OVERRIDE;
64 54
65 // Returns the resource_id of the icon to show to the left of the address, 55 // Returns the resource_id of the icon to show to the left of the address,
66 // based on the current URL. This doesn't cover specialized icons while the 56 // based on the current URL. This doesn't cover specialized icons while the
67 // user is editing; see OmniboxView::GetIcon(). 57 // user is editing; see OmniboxView::GetIcon().
68 int GetIcon() const; 58 virtual int GetIcon() const OVERRIDE;
69 59
70 // Returns the name of the EV cert holder. Only call this when the security 60 // Returns the name of the EV cert holder. Only call this when the security
71 // level is EV_SECURE. 61 // level is EV_SECURE.
72 string16 GetEVCertName() const; 62 virtual string16 GetEVCertName() const OVERRIDE;
73 63
74 // Returns whether the URL for the current navigation entry should be 64 // Returns whether the URL for the current navigation entry should be
75 // in the location bar. 65 // in the location bar.
76 bool ShouldDisplayURL() const; 66 virtual bool ShouldDisplayURL() const OVERRIDE;
77 67
78 // Getter/setter of whether the text in location bar is currently being 68 // Getter/setter of whether the text in location bar is currently being
79 // edited. 69 // edited.
80 void set_input_in_progress(bool value) { input_in_progress_ = value; } 70 virtual void SetInputInProgress(bool value) OVERRIDE;
81 bool input_in_progress() const { return input_in_progress_; } 71 virtual bool GetInputInProgress() const OVERRIDE;
82
83 // Returns "<organization_name> [<country>]".
84 static string16 GetEVCertName(const net::X509Certificate& cert);
85 72
86 private: 73 private:
87 // Returns the navigation controller used to retrieve the navigation entry 74 // Returns the navigation controller used to retrieve the navigation entry
88 // from which the states are retrieved. 75 // from which the states are retrieved.
89 // If this returns NULL, default values are used. 76 // If this returns NULL, default values are used.
90 content::NavigationController* GetNavigationController() const; 77 content::NavigationController* GetNavigationController() const;
91 78
92 // Attempt to extract search terms from |url|. Called by GetText if 79 // Attempt to extract search terms from |url|. Called by GetText if
93 // |display_search_urls_as_search_terms| is true and by 80 // |display_search_urls_as_search_terms| is true and by
94 // WouldReplaceSearchURLWithSearchTerms. 81 // WouldReplaceSearchURLWithSearchTerms.
95 string16 TryToExtractSearchTermsFromURL(const GURL& url) const; 82 string16 TryToExtractSearchTermsFromURL(const GURL& url) const;
96 83
97 // Helper method to extract the profile from the navigation controller. 84 // Helper method to extract the profile from the navigation controller.
98 Profile* GetProfile() const; 85 Profile* GetProfile() const;
99 86
100 ToolbarModelDelegate* delegate_; 87 ToolbarModelDelegate* delegate_;
101 88
102 // Whether the text in the location bar is currently being edited. 89 // Whether the text in the location bar is currently being edited.
103 bool input_in_progress_; 90 bool input_in_progress_;
104 91
105 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel); 92 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModelImpl);
106 }; 93 };
107 94
108 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 95 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698