OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compact_nav/compact_location_bar_view_host.h" | 5 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 int to_index) { | 320 int to_index) { |
321 if (from_index == current_tab_model_index_) { | 321 if (from_index == current_tab_model_index_) { |
322 UpdateOnTabChange(to_index, false); | 322 UpdateOnTabChange(to_index, false); |
323 StartAutoHideTimer(); | 323 StartAutoHideTimer(); |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 void CompactLocationBarViewHost::TabChangedAt(TabContentsWrapper* contents, | 327 void CompactLocationBarViewHost::TabChangedAt(TabContentsWrapper* contents, |
328 int index, | 328 int index, |
329 TabChangeType change_type) { | 329 TabChangeType change_type) { |
330 if (IsCurrentTabIndex(index) && change_type == | 330 if (IsCurrentTabIndex(index) && |
331 TabStripModelObserver::LOADING_ONLY) { | 331 change_type == TabStripModelObserver::LOADING_ONLY) { |
332 TabContents* tab_contents = contents->tab_contents(); | |
332 bool was_not_visible = !IsVisible(); | 333 bool was_not_visible = !IsVisible(); |
333 TabContents* tab_contents = contents->tab_contents(); | 334 if (was_not_visible) { |
335 // Only show the compact navigation bar when we change hosts or scheme. | |
336 const GURL& new_url = tab_contents->GetURL(); | |
337 GURL old_url = GetCompactLocationBarView()->location_bar_view()-> | |
338 location_entry()->model()->PermanentURL(); | |
339 if (old_url.has_host() && new_url.host() == old_url.host() && | |
SteveT
2011/05/25 04:30:29
Just checking your logic here. What is an example
| |
340 new_url.scheme() == old_url.scheme()) { | |
341 return; | |
342 } | |
343 } | |
334 Update(tab_contents, false); | 344 Update(tab_contents, false); |
335 if (was_not_visible) { | 345 if (was_not_visible) { |
336 if (tab_contents->is_loading()) { | 346 if (tab_contents->is_loading()) { |
337 // Register to NavigationController LOAD_STOP so that we can autohide | 347 // Register to NavigationController LOAD_STOP so that we can autohide |
338 // when loading is done. | 348 // when loading is done. |
339 if (!registrar_.IsRegistered(this, NotificationType::LOAD_STOP, | 349 if (!registrar_.IsRegistered(this, NotificationType::LOAD_STOP, |
340 Source<NavigationController>(&tab_contents->controller()))) { | 350 Source<NavigationController>(&tab_contents->controller()))) { |
341 registrar_.Add(this, NotificationType::LOAD_STOP, | 351 registrar_.Add(this, NotificationType::LOAD_STOP, |
342 Source<NavigationController>(&tab_contents->controller())); | 352 Source<NavigationController>(&tab_contents->controller())); |
343 } | 353 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 bool CompactLocationBarViewHost::IsCurrentTabIndex(int index) { | 518 bool CompactLocationBarViewHost::IsCurrentTabIndex(int index) { |
509 return current_tab_model_index_ == index; | 519 return current_tab_model_index_ == index; |
510 } | 520 } |
511 | 521 |
512 bool CompactLocationBarViewHost::IsCurrentTab(TabContents* contents) { | 522 bool CompactLocationBarViewHost::IsCurrentTab(TabContents* contents) { |
513 TabStripModel* tab_strip_model = browser_view()->browser()->tabstrip_model(); | 523 TabStripModel* tab_strip_model = browser_view()->browser()->tabstrip_model(); |
514 return tab_strip_model->ContainsIndex(current_tab_model_index_) && | 524 return tab_strip_model->ContainsIndex(current_tab_model_index_) && |
515 tab_strip_model->GetTabContentsAt(current_tab_model_index_)-> | 525 tab_strip_model->GetTabContentsAt(current_tab_model_index_)-> |
516 tab_contents() == contents; | 526 tab_contents() == contents; |
517 } | 527 } |
OLD | NEW |