0

Remove ChromeToolbarModel

SecurityStateModel has now been componentized, which means that ToolbarModel
can refer to it. This change renders ChromeToolbarModel unnecessary.

BUG=515071

Review URL: https://codereview.chromium.org/1578193002

Cr-Commit-Position: refs/heads/master@{#369134}
This commit is contained in:
blundell
2016-01-13 02:56:30 -08:00
committed by Commit bot
parent 99482cad95
commit c1f77e7955
16 changed files with 27 additions and 67 deletions

@ -50,7 +50,6 @@
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
@ -441,15 +440,13 @@ void LocationBarViewMac::Layout() {
}
const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint();
ChromeToolbarModel* chrome_toolbar_model =
static_cast<ChromeToolbarModel*>(GetToolbarModel());
if (!keyword.empty() && !is_keyword_hint) {
// Switch from location icon to keyword mode.
location_icon_decoration_->SetVisible(false);
selected_keyword_decoration_->SetVisible(true);
selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword);
selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
} else if (chrome_toolbar_model->GetSecurityLevel(false) ==
} else if (GetToolbarModel()->GetSecurityLevel(false) ==
security_state::SecurityStateModel::EV_SECURE) {
// Switch from location icon to show the EV bubble instead.
location_icon_decoration_->SetVisible(false);

@ -19,13 +19,14 @@
#include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
#include "chrome/browser/ui/omnibox/chrome_omnibox_client.h"
#include "chrome/browser/ui/omnibox/clipboard_utils.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
#include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/omnibox_edit_controller.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/omnibox_popup_model.h"
#include "components/security_state/security_state_model.h"
#include "components/toolbar/toolbar_model.h"
#include "content/public/browser/web_contents.h"
#include "extensions/common/constants.h"
#import "third_party/mozilla/NSPasteboard+Utils.h"
@ -539,13 +540,11 @@ void OmniboxViewMac::ApplyTextAttributes(
}
}
ChromeToolbarModel* chrome_toolbar_model =
static_cast<ChromeToolbarModel*>(controller()->GetToolbarModel());
// TODO(shess): GTK has this as a member var, figure out why.
// [Could it be to not change if no change? If so, I'm guessing
// AppKit may already handle that.]
const security_state::SecurityStateModel::SecurityLevel security_level =
chrome_toolbar_model->GetSecurityLevel(false);
controller()->GetToolbarModel()->GetSecurityLevel(false);
// Emphasize the scheme for security UI display purposes (if necessary).
if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&

@ -1,9 +0,0 @@
// Copyright 2015 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/chrome_toolbar_model.h"
ChromeToolbarModel::ChromeToolbarModel() {}
ChromeToolbarModel::~ChromeToolbarModel() {}

@ -1,34 +0,0 @@
// Copyright 2015 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.
#ifndef CHROME_BROWSER_UI_TOOLBAR_CHROME_TOOLBAR_MODEL_H_
#define CHROME_BROWSER_UI_TOOLBAR_CHROME_TOOLBAR_MODEL_H_
#include "base/macros.h"
#include "components/security_state/security_state_model.h"
#include "components/toolbar/toolbar_model.h"
// This class is a //chrome-specific extension of the ToolbarModel interface.
// TODO(blundell): Now that SecurityStateModel::SecurityLevel is componentized,
// GetSecurityLevel() can be folded into ToolbarModel and this class can go
// away. crbug.com/515071
class ChromeToolbarModel : public ToolbarModel {
public:
~ChromeToolbarModel() override;
// Returns the security level that the toolbar should display. If
// |ignore_editing| is true, the result reflects the underlying state of the
// page without regard to any user edits that may be in progress in the
// omnibox.
virtual security_state::SecurityStateModel::SecurityLevel GetSecurityLevel(
bool ignore_editing) const = 0;
protected:
ChromeToolbarModel();
private:
DISALLOW_COPY_AND_ASSIGN(ChromeToolbarModel);
};
#endif // CHROME_BROWSER_UI_TOOLBAR_CHROME_TOOLBAR_MODEL_H_

@ -8,8 +8,7 @@
#include "ui/gfx/vector_icons_public.h"
TestToolbarModel::TestToolbarModel()
: ChromeToolbarModel(),
perform_search_term_replacement_(false),
: perform_search_term_replacement_(false),
security_level_(security_state::SecurityStateModel::NONE),
#if defined(TOOLKIT_VIEWS)
icon_(gfx::VectorIconId::LOCATION_BAR_HTTP),

@ -10,7 +10,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
#include "components/toolbar/toolbar_model.h"
namespace gfx {
enum class VectorIconId;
@ -19,7 +19,7 @@ enum class VectorIconId;
// A ToolbarModel that is backed by instance variables, which are initialized
// with some basic values that can be changed with the provided setters. This
// should be used only for testing.
class TestToolbarModel : public ChromeToolbarModel {
class TestToolbarModel : public ToolbarModel {
public:
TestToolbarModel();
~TestToolbarModel() override;

@ -12,7 +12,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
#include "components/toolbar/toolbar_model.h"
#include "url/gurl.h"
class Profile;
@ -30,7 +30,7 @@ class X509Certificate;
// This class is the model used by the toolbar, location bar and autocomplete
// edit. It populates its states from the current navigation entry retrieved
// from the navigation controller returned by GetNavigationController().
class ToolbarModelImpl : public ChromeToolbarModel {
class ToolbarModelImpl : public ToolbarModel {
public:
explicit ToolbarModelImpl(ToolbarModelDelegate* delegate);
~ToolbarModelImpl() override;

@ -58,6 +58,7 @@
#include "components/omnibox/browser/omnibox_popup_view.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/toolbar/toolbar_model.h"
#include "components/translate/core/browser/language_state.h"
#include "components/ui/zoom/zoom_controller.h"
#include "components/ui/zoom/zoom_event_manager.h"
@ -1040,9 +1041,7 @@ bool LocationBarView::ShouldShowKeywordBubble() const {
}
bool LocationBarView::ShouldShowEVBubble() const {
const ChromeToolbarModel* chrome_toolbar_model =
static_cast<const ChromeToolbarModel*>(GetToolbarModel());
return (chrome_toolbar_model->GetSecurityLevel(false) ==
return (GetToolbarModel()->GetSecurityLevel(false) ==
security_state::SecurityStateModel::EV_SECURE);
}

@ -16,7 +16,6 @@
#include "chrome/browser/extensions/extension_context_menu_model.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
#include "chrome/browser/ui/views/dropdown_bar_host.h"
#include "chrome/browser/ui/views/dropdown_bar_host_delegate.h"
#include "chrome/browser/ui/views/extensions/extension_popup.h"

@ -31,6 +31,7 @@
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/omnibox_popup_model.h"
#include "components/search/search.h"
#include "components/toolbar/toolbar_model.h"
#include "content/public/browser/web_contents.h"
#include "extensions/common/constants.h"
#include "net/base/escape.h"
@ -436,9 +437,7 @@ void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value) {
}
void OmniboxViewViews::UpdateSecurityLevel() {
ChromeToolbarModel* chrome_toolbar_model =
static_cast<ChromeToolbarModel*>(controller()->GetToolbarModel());
security_level_ = chrome_toolbar_model->GetSecurityLevel(false);
security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false);
}
void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text,

@ -15,8 +15,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "components/security_state/security_state_model.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/range/range.h"
#include "ui/views/controls/textfield/textfield.h"

@ -2795,8 +2795,6 @@
'browser/ui/webui/local_discovery/local_discovery_ui_handler.h',
],
'chrome_browser_ui_toolbar_model_sources': [
'browser/ui/toolbar/chrome_toolbar_model.cc',
'browser/ui/toolbar/chrome_toolbar_model.h',
'browser/ui/toolbar/toolbar_model_delegate.h',
'browser/ui/toolbar/toolbar_model_impl.cc',
'browser/ui/toolbar/toolbar_model_impl.h',

@ -11,6 +11,7 @@
'dependencies': [
'../base/base.gyp:base',
'../url/url.gyp:url_lib',
'security_state',
],
'include_dirs': [
'..',

@ -10,6 +10,7 @@ source_set("toolbar") {
deps = [
"//base",
"//components/security_state",
"//url",
]
}

3
components/toolbar/DEPS Normal file

@ -0,0 +1,3 @@
include_rules = [
"+components/security_state",
]

@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/security_state/security_state_model.h"
#include "url/gurl.h"
namespace gfx {
@ -60,6 +61,13 @@ class ToolbarModel {
// in progress in the omnibox.
virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0;
// Returns the security level that the toolbar should display. If
// |ignore_editing| is true, the result reflects the underlying state of the
// page without regard to any user edits that may be in progress in the
// omnibox.
virtual security_state::SecurityStateModel::SecurityLevel GetSecurityLevel(
bool ignore_editing) const = 0;
// Returns true if a call to GetText() would return something other than the
// URL because of search term replacement.
bool WouldReplaceURL() const;