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

Unified Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/toolbar_model_impl.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
similarity index 83%
copy from chrome/browser/ui/toolbar/toolbar_model.cc
copy to chrome/browser/ui/toolbar/toolbar_model_impl.cc
index 46efad6cc1a35e7633f910d2b278430a162795ef..fea5c1e8694df2d542d43fb8b421d15e7c51d253 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/toolbar/toolbar_model.h"
+#include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_input.h"
@@ -35,16 +35,17 @@ using content::NavigationEntry;
using content::SSLStatus;
using content::WebContents;
-ToolbarModel::ToolbarModel(ToolbarModelDelegate* delegate)
+ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate)
: delegate_(delegate),
input_in_progress_(false) {
}
-ToolbarModel::~ToolbarModel() {
+ToolbarModelImpl::~ToolbarModelImpl() {
}
-// ToolbarModel Implementation.
-string16 ToolbarModel::GetText(bool display_search_urls_as_search_terms) const {
+// ToolbarModelImpl Implementation.
+string16 ToolbarModelImpl::GetText(
+ bool display_search_urls_as_search_terms) const {
GURL url(GetURL());
if (display_search_urls_as_search_terms) {
@@ -67,7 +68,7 @@ string16 ToolbarModel::GetText(bool display_search_urls_as_search_terms) const {
net::UnescapeRule::NORMAL, NULL, NULL, NULL));
}
-GURL ToolbarModel::GetURL() const {
+GURL ToolbarModelImpl::GetURL() const {
const NavigationController* navigation_controller = GetNavigationController();
if (navigation_controller) {
const NavigationEntry* entry = navigation_controller->GetVisibleEntry();
@@ -78,11 +79,11 @@ GURL ToolbarModel::GetURL() const {
return GURL(chrome::kAboutBlankURL);
}
-bool ToolbarModel::WouldReplaceSearchURLWithSearchTerms() const {
+bool ToolbarModelImpl::WouldReplaceSearchURLWithSearchTerms() const {
return !TryToExtractSearchTermsFromURL(GetURL()).empty();
}
-bool ToolbarModel::ShouldDisplayURL() const {
+bool ToolbarModelImpl::ShouldDisplayURL() const {
// Note: The order here is important.
// - The WebUI test must come before the extension scheme test because there
// can be WebUIs that have extension schemes (e.g. the bookmark manager). In
@@ -114,7 +115,7 @@ bool ToolbarModel::ShouldDisplayURL() const {
return true;
}
-ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const {
+ToolbarModelImpl::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const {
if (input_in_progress_) // When editing, assume no security style.
return NONE;
@@ -153,7 +154,7 @@ ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const {
}
}
-int ToolbarModel::GetIcon() const {
+int ToolbarModelImpl::GetIcon() const {
static int icon_ids[NUM_SECURITY_LEVELS] = {
IDR_LOCATION_BAR_HTTP,
IDR_OMNIBOX_HTTPS_VALID,
@@ -165,32 +166,25 @@ int ToolbarModel::GetIcon() const {
return icon_ids[GetSecurityLevel()];
}
-string16 ToolbarModel::GetEVCertName() const {
+string16 ToolbarModelImpl::GetEVCertName() const {
DCHECK_EQ(GetSecurityLevel(), EV_SECURE);
scoped_refptr<net::X509Certificate> cert;
// Note: Navigation controller and active entry are guaranteed non-NULL or
// the security level would be NONE.
content::CertStore::GetInstance()->RetrieveCert(
GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert);
- return GetEVCertName(*cert);
+ return ToolbarModel::GetEVCertName(*cert);
}
-// static
-string16 ToolbarModel::GetEVCertName(const net::X509Certificate& cert) {
- // EV are required to have an organization name and country.
- if (cert.subject().organization_names.empty() ||
- cert.subject().country_name.empty()) {
- NOTREACHED();
- return string16();
- }
+void ToolbarModelImpl::SetInputInProgress(bool value) {
+ input_in_progress_ = value;
+}
- return l10n_util::GetStringFUTF16(
- IDS_SECURE_CONNECTION_EV,
- UTF8ToUTF16(cert.subject().organization_names[0]),
- UTF8ToUTF16(cert.subject().country_name));
+bool ToolbarModelImpl::GetInputInProgress() const {
+ return input_in_progress_;
}
-NavigationController* ToolbarModel::GetNavigationController() const {
+NavigationController* ToolbarModelImpl::GetNavigationController() const {
// This |current_tab| can be NULL during the initialization of the
// toolbar during window creation (i.e. before any tabs have been added
// to the window).
@@ -198,7 +192,8 @@ NavigationController* ToolbarModel::GetNavigationController() const {
return current_tab ? &current_tab->GetController() : NULL;
}
-string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const {
+string16 ToolbarModelImpl::TryToExtractSearchTermsFromURL(
+ const GURL& url) const {
Profile* profile = GetProfile();
// Ensure instant extended API is enabled.
@@ -217,7 +212,7 @@ string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const {
return result;
}
-Profile* ToolbarModel::GetProfile() const {
+Profile* ToolbarModelImpl::GetProfile() const {
NavigationController* navigation_controller = GetNavigationController();
return navigation_controller ?
Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) :

Powered by Google App Engine
This is Rietveld 408576698