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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

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 | « base/property_bag_unittest.cc ('k') | chrome/browser/ui/cocoa/web_dialog_window_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index 8921e008073805c872b043c15294a4536e58858c..b38c503ef9947af8f8660c72ad7c1f0e5d62899e 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -6,7 +6,6 @@
#include <Carbon/Carbon.h> // kVK_Return
-#include "base/property_bag.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
@@ -85,8 +84,10 @@ NSColor* SecurityErrorSchemeColor() {
return ColorWithRGBBytes(0xa2, 0x00, 0x00);
}
+const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState";
+
// Store's the model and view state across tab switches.
-struct OmniboxViewMacState {
+struct OmniboxViewMacState : public base::SupportsUserData::Data {
OmniboxViewMacState(const OmniboxEditModel::State model_state,
const bool has_focus,
const NSRange& selection)
@@ -94,29 +95,21 @@ struct OmniboxViewMacState {
has_focus(has_focus),
selection(selection) {
}
+ virtual ~OmniboxViewMacState() {}
const OmniboxEditModel::State model_state;
const bool has_focus;
const NSRange selection;
};
-// Returns a lazily initialized property bag accessor for saving our
-// state in a WebContents. When constructed |accessor| generates a
-// globally-unique id used to index into the per-tab PropertyBag used
-// to store the state data.
-base::PropertyAccessor<OmniboxViewMacState>* GetStateAccessor() {
- CR_DEFINE_STATIC_LOCAL(
- base::PropertyAccessor<OmniboxViewMacState>, accessor, ());
- return &accessor;
-}
-
// Accessors for storing and getting the state from the tab.
void StoreStateToTab(WebContents* tab,
- const OmniboxViewMacState& state) {
- GetStateAccessor()->SetProperty(tab->GetPropertyBag(), state);
+ OmniboxViewMacState* state) {
+ tab->SetUserData(kOmniboxViewMacStateKey, state);
}
const OmniboxViewMacState* GetStateFromTab(const WebContents* tab) {
- return GetStateAccessor()->GetProperty(tab->GetPropertyBag());
+ return static_cast<OmniboxViewMacState*>(
+ tab->GetUserData(&kOmniboxViewMacStateKey));
}
// Helper to make converting url_parse ranges to NSRange easier to
@@ -187,7 +180,8 @@ void OmniboxViewMac::SaveStateToTab(WebContents* tab) {
range = NSMakeRange(0, GetTextLength());
}
- OmniboxViewMacState state(model()->GetStateForTabSwitch(), hasFocus, range);
+ OmniboxViewMacState* state =
+ new OmniboxViewMacState(model()->GetStateForTabSwitch(), hasFocus, range);
StoreStateToTab(tab, state);
}
« no previous file with comments | « base/property_bag_unittest.cc ('k') | chrome/browser/ui/cocoa/web_dialog_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698