OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/instant/instant_overlay.h" | 5 #include "chrome/browser/instant/instant_overlay.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/supports_user_data.h" | 8 #include "base/supports_user_data.h" |
9 #include "chrome/browser/ui/search/search.h" | 9 #include "chrome/browser/ui/search/search.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 contents()->RemoveUserData(&kUserDataKey); | 64 contents()->RemoveUserData(&kUserDataKey); |
65 SetContents(NULL); | 65 SetContents(NULL); |
66 return loader_.ReleaseContents(); | 66 return loader_.ReleaseContents(); |
67 } | 67 } |
68 | 68 |
69 void InstantOverlay::DidNavigate( | 69 void InstantOverlay::DidNavigate( |
70 const history::HistoryAddPageArgs& add_page_args) { | 70 const history::HistoryAddPageArgs& add_page_args) { |
71 last_navigation_ = add_page_args; | 71 last_navigation_ = add_page_args; |
72 } | 72 } |
73 | 73 |
74 bool InstantOverlay::IsUsingLocalPreview() const { | 74 bool InstantOverlay::IsUsingLocalOverlay() const { |
75 return instant_url_ == chrome::search::kLocalOmniboxPopupURL; | 75 return instant_url_ == chrome::search::kLocalOmniboxPopupURL; |
76 } | 76 } |
77 | 77 |
78 void InstantOverlay::Update(const string16& text, | 78 void InstantOverlay::Update(const string16& text, |
79 size_t selection_start, | 79 size_t selection_start, |
80 size_t selection_end, | 80 size_t selection_end, |
81 bool verbatim) { | 81 bool verbatim) { |
82 last_navigation_ = history::HistoryAddPageArgs(); | 82 last_navigation_ = history::HistoryAddPageArgs(); |
83 InstantPage::Update(text, selection_start, selection_end, verbatim); | 83 InstantPage::Update(text, selection_start, selection_end, verbatim); |
84 } | 84 } |
(...skipping 23 matching lines...) Expand all Loading... |
108 } | 108 } |
109 | 109 |
110 void InstantOverlay::OnSwappedContents() { | 110 void InstantOverlay::OnSwappedContents() { |
111 contents()->RemoveUserData(&kUserDataKey); | 111 contents()->RemoveUserData(&kUserDataKey); |
112 SetContents(loader_.contents()); | 112 SetContents(loader_.contents()); |
113 contents()->SetUserData(&kUserDataKey, new InstantOverlayUserData(this)); | 113 contents()->SetUserData(&kUserDataKey, new InstantOverlayUserData(this)); |
114 instant_controller()->SwappedOverlayContents(); | 114 instant_controller()->SwappedOverlayContents(); |
115 } | 115 } |
116 | 116 |
117 void InstantOverlay::OnFocus() { | 117 void InstantOverlay::OnFocus() { |
118 // The preview is getting focus. Equivalent to it being clicked. | 118 // The overlay is getting focus. Equivalent to it being clicked. |
119 base::AutoReset<bool> reset(&is_pointer_down_from_activate_, true); | 119 base::AutoReset<bool> reset(&is_pointer_down_from_activate_, true); |
120 instant_controller()->FocusedOverlayContents(); | 120 instant_controller()->FocusedOverlayContents(); |
121 } | 121 } |
122 | 122 |
123 void InstantOverlay::OnMouseDown() { | 123 void InstantOverlay::OnMouseDown() { |
124 is_pointer_down_from_activate_ = true; | 124 is_pointer_down_from_activate_ = true; |
125 } | 125 } |
126 | 126 |
127 void InstantOverlay::OnMouseUp() { | 127 void InstantOverlay::OnMouseUp() { |
128 if (is_pointer_down_from_activate_) { | 128 if (is_pointer_down_from_activate_) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 DCHECK_NE(&loader_, overlay->GetDelegate()); | 162 DCHECK_NE(&loader_, overlay->GetDelegate()); |
163 return overlay->GetDelegate()->OpenURLFromTab(source, params); | 163 return overlay->GetDelegate()->OpenURLFromTab(source, params); |
164 } | 164 } |
165 return NULL; | 165 return NULL; |
166 } | 166 } |
167 | 167 |
168 void InstantOverlay::HandleStalePage() { | 168 void InstantOverlay::HandleStalePage() { |
169 is_stale_ = true; | 169 is_stale_ = true; |
170 instant_controller()->ReloadOverlayIfStale(); | 170 instant_controller()->ReloadOverlayIfStale(); |
171 } | 171 } |
OLD | NEW |