OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/views/search_view_controller.h" | 5 #include "chrome/browser/ui/views/search_view_controller.h" |
6 | 6 |
7 #include "chrome/browser/ui/search/search_model.h" | 7 #include "chrome/browser/ui/search/search_model.h" |
8 #include "chrome/browser/ui/search/search_tab_helper.h" | 8 #include "chrome/browser/ui/search/search_tab_helper.h" |
9 #include "chrome/browser/ui/search/search_types.h" | 9 #include "chrome/browser/ui/search/search_types.h" |
10 #include "chrome/browser/ui/search/search_ui.h" | 10 #include "chrome/browser/ui/search/search_ui.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } else { | 333 } else { |
334 // Only enter into MODE_SEARCH if the omnibox is visible. | 334 // Only enter into MODE_SEARCH if the omnibox is visible. |
335 if (omnibox_popup_view_parent_->is_child_visible()) | 335 if (omnibox_popup_view_parent_->is_child_visible()) |
336 new_state = STATE_SEARCH; | 336 new_state = STATE_SEARCH; |
337 else | 337 else |
338 new_state = STATE_NOT_VISIBLE; | 338 new_state = STATE_NOT_VISIBLE; |
339 } | 339 } |
340 break; | 340 break; |
341 } | 341 } |
342 SetState(new_state); | 342 SetState(new_state); |
| 343 MaybeLoadNTP(); |
343 } | 344 } |
344 | 345 |
345 void SearchViewController::SetState(State state) { | 346 void SearchViewController::SetState(State state) { |
346 if (state_ == state) | 347 if (state_ == state) |
347 return; | 348 return; |
348 | 349 |
349 State old_state = state_; | 350 State old_state = state_; |
350 state_ = state; | 351 state_ = state; |
351 switch (state_) { | 352 switch (state_) { |
352 case STATE_NOT_VISIBLE: | 353 case STATE_NOT_VISIBLE: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 451 |
451 void SearchViewController::DestroyViews() { | 452 void SearchViewController::DestroyViews() { |
452 if (!search_container_) | 453 if (!search_container_) |
453 return; | 454 return; |
454 | 455 |
455 // We persist the parent of the omnibox so that we don't have to inject a new | 456 // We persist the parent of the omnibox so that we don't have to inject a new |
456 // parent into ToolbarView. | 457 // parent into ToolbarView. |
457 omnibox_popup_view_parent_->parent()->RemoveChildView( | 458 omnibox_popup_view_parent_->parent()->RemoveChildView( |
458 omnibox_popup_view_parent_); | 459 omnibox_popup_view_parent_); |
459 | 460 |
| 461 if (content_view_) |
| 462 content_view_->SetWebContents(NULL); |
| 463 |
460 contents_container_->SetOverlay(NULL); | 464 contents_container_->SetOverlay(NULL); |
461 delete search_container_; | 465 delete search_container_; |
462 search_container_ = NULL; | 466 search_container_ = NULL; |
463 ntp_view_ = NULL; | 467 ntp_view_ = NULL; |
464 logo_view_ = NULL; | 468 logo_view_ = NULL; |
465 content_view_ = NULL; | 469 content_view_ = NULL; |
466 | 470 |
467 state_ = STATE_NOT_VISIBLE; | 471 state_ = STATE_NOT_VISIBLE; |
468 } | 472 } |
469 | 473 |
470 void SearchViewController::PopupVisibilityChanged() { | 474 void SearchViewController::PopupVisibilityChanged() { |
471 // Don't do anything while animating if the child is visible. Otherwise we'll | 475 // Don't do anything while animating if the child is visible. Otherwise we'll |
472 // prematurely cancel the animation. | 476 // prematurely cancel the animation. |
473 if (state_ != STATE_ANIMATING || | 477 if (state_ != STATE_ANIMATING || |
474 !omnibox_popup_view_parent_->is_child_visible()) { | 478 !omnibox_popup_view_parent_->is_child_visible()) { |
475 UpdateState(); | 479 UpdateState(); |
476 } | 480 } |
477 } | 481 } |
478 | 482 |
| 483 void SearchViewController::MaybeLoadNTP() { |
| 484 if (state_ != STATE_NTP || !content_view_) |
| 485 return; |
| 486 |
| 487 content_view_->SetWebContents( |
| 488 tab_contents_->search_tab_helper()->GetNTPWebContents()); |
| 489 } |
| 490 |
479 chrome::search::SearchModel* SearchViewController::search_model() { | 491 chrome::search::SearchModel* SearchViewController::search_model() { |
480 return tab_contents_ ? tab_contents_->search_tab_helper()->model() : NULL; | 492 return tab_contents_ ? tab_contents_->search_tab_helper()->model() : NULL; |
481 } | 493 } |
482 | 494 |
483 content::WebContents* SearchViewController::web_contents() { | 495 content::WebContents* SearchViewController::web_contents() { |
484 return tab_contents_ ? tab_contents_->web_contents() : NULL; | 496 return tab_contents_ ? tab_contents_->web_contents() : NULL; |
485 } | 497 } |
OLD | NEW |