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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 113275: Address Mike's last complaint about Issue 114017. (Closed)
Patch Set: Created 11 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" 8 #include "chrome/browser/autocomplete/autocomplete_edit.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
11 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Store's the model and view state across tab switches. 15 // Store's the model and view state across tab switches.
16 struct AutocompleteEditViewMacState { 16 struct AutocompleteEditViewMacState {
17 AutocompleteEditViewMacState(const AutocompleteEditModel::State model_state, 17 AutocompleteEditViewMacState(const AutocompleteEditModel::State model_state,
18 const bool has_focus, const NSRange& selection) 18 const bool has_focus, const NSRange& selection)
19 : model_state(model_state), 19 : model_state(model_state),
20 has_focus(has_focus), 20 has_focus(has_focus),
21 selection(selection) { 21 selection(selection) {
22 } 22 }
23 23
24 const AutocompleteEditModel::State model_state; 24 const AutocompleteEditModel::State model_state;
25 const bool has_focus; 25 const bool has_focus;
26 const NSRange selection; 26 const NSRange selection;
27 }; 27 };
28 28
29 // Returns a lazily initialized property bag accessor for saving our 29 // Returns a lazily initialized property bag accessor for saving our
30 // state in a TabContents. 30 // state in a TabContents. When constructed |accessor| generates a
31 // globally-unique id used to index into the per-tab PropertyBag used
32 // to store the state data.
31 PropertyAccessor<AutocompleteEditViewMacState>* GetStateAccessor() { 33 PropertyAccessor<AutocompleteEditViewMacState>* GetStateAccessor() {
32 static PropertyAccessor<AutocompleteEditViewMacState> state; 34 static PropertyAccessor<AutocompleteEditViewMacState> accessor;
33 return &state; 35 return &accessor;
34 } 36 }
35 37
36 // Accessors for storing and getting the state from the tab. 38 // Accessors for storing and getting the state from the tab.
37 void StoreStateToTab(TabContents* tab, 39 void StoreStateToTab(TabContents* tab,
38 const AutocompleteEditViewMacState& state) { 40 const AutocompleteEditViewMacState& state) {
39 GetStateAccessor()->SetProperty(tab->property_bag(), state); 41 GetStateAccessor()->SetProperty(tab->property_bag(), state);
40 } 42 }
41 const AutocompleteEditViewMacState* GetStateFromTab(const TabContents* tab) { 43 const AutocompleteEditViewMacState* GetStateFromTab(const TabContents* tab) {
42 return GetStateAccessor()->GetProperty(tab->property_bag()); 44 return GetStateAccessor()->GetProperty(tab->property_bag());
43 } 45 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 450 }
449 451
450 - (void)controlTextDidEndEditing:(NSNotification*)aNotification { 452 - (void)controlTextDidEndEditing:(NSNotification*)aNotification {
451 edit_view_->OnKillFocus(); 453 edit_view_->OnKillFocus();
452 454
453 // TODO(shess): Figure out where the selection belongs. On GTK, 455 // TODO(shess): Figure out where the selection belongs. On GTK,
454 // it's set to the start of the text. 456 // it's set to the start of the text.
455 } 457 }
456 458
457 @end 459 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698