OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/browser_instant_controller.h" | 5 #include "chrome/browser/ui/browser_instant_controller.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/prefs/pref_registry_syncable.h" | 9 #include "chrome/browser/prefs/pref_registry_syncable.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ReplaceWebContentsAt( | 164 ReplaceWebContentsAt( |
165 browser_->tab_strip_model()->active_index(), | 165 browser_->tab_strip_model()->active_index(), |
166 preview.Pass()); | 166 preview.Pass()); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 void BrowserInstantController::ReplaceWebContentsAt( | 170 void BrowserInstantController::ReplaceWebContentsAt( |
171 int index, | 171 int index, |
172 scoped_ptr<content::WebContents> new_contents) { | 172 scoped_ptr<content::WebContents> new_contents) { |
173 DCHECK_NE(TabStripModel::kNoTab, index); | 173 DCHECK_NE(TabStripModel::kNoTab, index); |
174 content::WebContents* old_contents = | 174 scoped_ptr<content::WebContents> old_contents(browser_->tab_strip_model()-> |
175 browser_->tab_strip_model()->GetWebContentsAt(index); | 175 ReplaceWebContentsAt(index, new_contents.release())); |
176 // TabStripModel takes ownership of |new_contents|. | 176 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents.Pass(), |
177 browser_->tab_strip_model()->ReplaceWebContentsAt( | 177 index); |
178 index, new_contents.release()); | |
179 // TODO(samarth): use scoped_ptr instead of comments to document ownership | |
180 // transfer. | |
181 // InstantUnloadHandler takes ownership of |old_contents|. | |
182 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents, index); | |
183 } | 178 } |
184 | 179 |
185 void BrowserInstantController::SetInstantSuggestion( | 180 void BrowserInstantController::SetInstantSuggestion( |
186 const InstantSuggestion& suggestion) { | 181 const InstantSuggestion& suggestion) { |
187 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); | 182 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); |
188 } | 183 } |
189 | 184 |
190 gfx::Rect BrowserInstantController::GetInstantBounds() { | 185 gfx::Rect BrowserInstantController::GetInstantBounds() { |
191 return browser_->window()->GetInstantBounds(); | 186 return browser_->window()->GetInstantBounds(); |
192 } | 187 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // part of the image overlay should draw, 'cos the origin is top-left. | 359 // part of the image overlay should draw, 'cos the origin is top-left. |
365 if (!browser_->search_model()->mode().is_ntp() || | 360 if (!browser_->search_model()->mode().is_ntp() || |
366 theme_info_.theme_id.empty() || | 361 theme_info_.theme_id.empty() || |
367 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { | 362 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { |
368 return; | 363 return; |
369 } | 364 } |
370 instant_.ThemeAreaHeightChanged(theme_area_height_); | 365 instant_.ThemeAreaHeightChanged(theme_area_height_); |
371 } | 366 } |
372 | 367 |
373 } // namespace chrome | 368 } // namespace chrome |
OLD | NEW |