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

Unified Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 10831407: Kill PropertyBag, switch WebContents to SupportsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/web_dialog_window_controller.mm ('k') | chrome/browser/ui/gtk/web_dialog_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
index 71d6ec75ce7d80be94ca894d3e327f6c77ad2142..c0a32569594b00b0b74f38405b6bc2f46f5f633b 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
@@ -10,7 +10,6 @@
#include <algorithm>
#include "base/logging.h"
-#include "base/property_bag.h"
#include "base/string_util.h"
#include "base/utf_string_conversion_utils.h"
#include "base/utf_string_conversions.h"
@@ -89,25 +88,20 @@ struct ViewState {
OmniboxViewGtk::CharRange selection_range;
};
-struct AutocompleteEditState {
+const char kAutocompleteEditStateKey[] = "AutocompleteEditState";
+
+struct AutocompleteEditState : public base::SupportsUserData::Data {
AutocompleteEditState(const OmniboxEditModel::State& model_state,
const ViewState& view_state)
: model_state(model_state),
view_state(view_state) {
}
+ virtual ~AutocompleteEditState() {}
const OmniboxEditModel::State model_state;
const ViewState view_state;
};
-// Returns a lazily initialized property bag accessor for saving our state in a
-// WebContents.
-base::PropertyAccessor<AutocompleteEditState>* GetStateAccessor() {
- CR_DEFINE_STATIC_LOCAL(
- base::PropertyAccessor<AutocompleteEditState>, state, ());
- return &state;
-}
-
// Set up style properties to override the default GtkTextView; if a theme has
// overridden some of these properties, an inner-line will be displayed inside
// the fake GtkTextEntry.
@@ -427,9 +421,9 @@ void OmniboxViewGtk::SaveStateToTab(WebContents* tab) {
SavePrimarySelection(selected_text_);
// NOTE: GetStateForTabSwitch may affect GetSelection, so order is important.
OmniboxEditModel::State model_state = model()->GetStateForTabSwitch();
- GetStateAccessor()->SetProperty(
- tab->GetPropertyBag(),
- AutocompleteEditState(model_state, ViewState(GetSelection())));
+ tab->SetUserData(
+ kAutocompleteEditStateKey,
+ new AutocompleteEditState(model_state, ViewState(GetSelection())));
}
void OmniboxViewGtk::Update(const WebContents* contents) {
@@ -445,8 +439,8 @@ void OmniboxViewGtk::Update(const WebContents* contents) {
if (contents) {
selected_text_.clear();
RevertAll();
- const AutocompleteEditState* state =
- GetStateAccessor()->GetProperty(contents->GetPropertyBag());
+ const AutocompleteEditState* state = static_cast<AutocompleteEditState*>(
+ contents->GetUserData(&kAutocompleteEditStateKey));
if (state) {
model()->RestoreState(state->model_state);
« no previous file with comments | « chrome/browser/ui/cocoa/web_dialog_window_controller.mm ('k') | chrome/browser/ui/gtk/web_dialog_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698