Chromium Code Reviews| 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 content::WebContents* old_contents = |
|
Jered
2013/02/13 23:25:48
I think this should be a scoped_ptr and the call s
sreeram
2013/02/13 23:41:27
Done. Added a comment for clarity too.
sreeram
2013/02/13 23:53:11
Patchset #3 does this correctly now, without any c
| |
| 175 browser_->tab_strip_model()->GetWebContentsAt(index); | 175 browser_->tab_strip_model()->GetWebContentsAt(index); |
| 176 // TabStripModel takes ownership of |new_contents|. | 176 browser_->tab_strip_model()->ReplaceWebContentsAt(index, |
| 177 browser_->tab_strip_model()->ReplaceWebContentsAt( | 177 new_contents.release()); |
| 178 index, new_contents.release()); | 178 instant_unload_handler_.RunUnloadListenersOrDestroy( |
| 179 // TODO(samarth): use scoped_ptr instead of comments to document ownership | 179 scoped_ptr<content::WebContents>(old_contents), index); |
| 180 // transfer. | |
| 181 // InstantUnloadHandler takes ownership of |old_contents|. | |
| 182 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents, index); | |
| 183 } | 180 } |
| 184 | 181 |
| 185 void BrowserInstantController::SetInstantSuggestion( | 182 void BrowserInstantController::SetInstantSuggestion( |
| 186 const InstantSuggestion& suggestion) { | 183 const InstantSuggestion& suggestion) { |
| 187 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); | 184 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); |
| 188 } | 185 } |
| 189 | 186 |
| 190 gfx::Rect BrowserInstantController::GetInstantBounds() { | 187 gfx::Rect BrowserInstantController::GetInstantBounds() { |
| 191 return browser_->window()->GetInstantBounds(); | 188 return browser_->window()->GetInstantBounds(); |
| 192 } | 189 } |
| (...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. | 361 // part of the image overlay should draw, 'cos the origin is top-left. |
| 365 if (!browser_->search_model()->mode().is_ntp() || | 362 if (!browser_->search_model()->mode().is_ntp() || |
| 366 theme_info_.theme_id.empty() || | 363 theme_info_.theme_id.empty() || |
| 367 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { | 364 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { |
| 368 return; | 365 return; |
| 369 } | 366 } |
| 370 instant_.ThemeAreaHeightChanged(theme_area_height_); | 367 instant_.ThemeAreaHeightChanged(theme_area_height_); |
| 371 } | 368 } |
| 372 | 369 |
| 373 } // namespace chrome | 370 } // namespace chrome |
| OLD | NEW |