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.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 window_->GetLocationBar()->SaveStateToContents(contents); | 1034 window_->GetLocationBar()->SaveStateToContents(contents); |
| 1035 | 1035 |
| 1036 if (instant_controller_) | 1036 if (instant_controller_) |
| 1037 instant_controller_->TabDeactivated(contents); | 1037 instant_controller_->TabDeactivated(contents); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 void Browser::ActiveTabChanged(WebContents* old_contents, | 1040 void Browser::ActiveTabChanged(WebContents* old_contents, |
| 1041 WebContents* new_contents, | 1041 WebContents* new_contents, |
| 1042 int index, | 1042 int index, |
| 1043 int reason) { | 1043 int reason) { |
| 1044 // Copies the background color from an old WebContents to a new one that | |
| 1045 // replaces it on the screen. This allows the new WebContents to use the | |
| 1046 // old one's background color as the starting background color, before having | |
| 1047 // loaded any contents. As a result, we avoid flashing white when navigating | |
|
nasko
2017/03/08 23:11:32
nit: Is it when navigating or when switching tabs?
chrishtr
2017/03/09 00:04:53
Fixed.
| |
| 1048 // from a site whith a dark background to another site with a dark background. | |
| 1049 if (old_contents && new_contents) { | |
| 1050 RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView(); | |
| 1051 RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView(); | |
| 1052 if (old_view && new_view) | |
| 1053 new_view->SetBackgroundColor(old_view->background_color()); | |
| 1054 } | |
| 1055 | |
| 1044 content::RecordAction(UserMetricsAction("ActiveTabChanged")); | 1056 content::RecordAction(UserMetricsAction("ActiveTabChanged")); |
| 1045 | 1057 |
| 1046 // Update the bookmark state, since the BrowserWindow may query it during | 1058 // Update the bookmark state, since the BrowserWindow may query it during |
| 1047 // OnActiveTabChanged() below. | 1059 // OnActiveTabChanged() below. |
| 1048 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | 1060 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); |
| 1049 | 1061 |
| 1050 // Let the BrowserWindow do its handling. On e.g. views this changes the | 1062 // Let the BrowserWindow do its handling. On e.g. views this changes the |
| 1051 // focused object, which should happen before we update the toolbar below, | 1063 // focused object, which should happen before we update the toolbar below, |
| 1052 // since the omnibox expects the correct element to already be focused when it | 1064 // since the omnibox expects the correct element to already be focused when it |
| 1053 // is updated. | 1065 // is updated. |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2676 // new window later, thus we need to navigate the window now. | 2688 // new window later, thus we need to navigate the window now. |
| 2677 if (contents) { | 2689 if (contents) { |
| 2678 contents->web_contents()->GetController().LoadURL( | 2690 contents->web_contents()->GetController().LoadURL( |
| 2679 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2691 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2680 std::string()); // No extra headers. | 2692 std::string()); // No extra headers. |
| 2681 } | 2693 } |
| 2682 } | 2694 } |
| 2683 | 2695 |
| 2684 return contents != NULL; | 2696 return contents != NULL; |
| 2685 } | 2697 } |
| OLD | NEW |