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 | |
| 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) { | |
|
Peter Kasting
2017/03/07 00:28:36
Can this condition actually fail? When?
Nit: No
chrishtr
2017/03/07 00:36:48
I know of no cases. Would you prefer I skip the co
Peter Kasting
2017/03/07 00:51:20
My concern is that a null-check implies to future
nasko
2017/03/08 23:11:32
The GetMainFrame() call is guaranteed to return no
| |
| 1053 new_view->SetBackgroundColor(old_view->background_color()); | |
| 1054 } | |
| 1055 } | |
| 1056 | |
| 1044 content::RecordAction(UserMetricsAction("ActiveTabChanged")); | 1057 content::RecordAction(UserMetricsAction("ActiveTabChanged")); |
| 1045 | 1058 |
| 1046 // Update the bookmark state, since the BrowserWindow may query it during | 1059 // Update the bookmark state, since the BrowserWindow may query it during |
| 1047 // OnActiveTabChanged() below. | 1060 // OnActiveTabChanged() below. |
| 1048 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | 1061 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); |
| 1049 | 1062 |
| 1050 // Let the BrowserWindow do its handling. On e.g. views this changes the | 1063 // 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, | 1064 // 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 | 1065 // since the omnibox expects the correct element to already be focused when it |
| 1053 // is updated. | 1066 // 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. | 2689 // new window later, thus we need to navigate the window now. |
| 2677 if (contents) { | 2690 if (contents) { |
| 2678 contents->web_contents()->GetController().LoadURL( | 2691 contents->web_contents()->GetController().LoadURL( |
| 2679 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2692 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2680 std::string()); // No extra headers. | 2693 std::string()); // No extra headers. |
| 2681 } | 2694 } |
| 2682 } | 2695 } |
| 2683 | 2696 |
| 2684 return contents != NULL; | 2697 return contents != NULL; |
| 2685 } | 2698 } |
| OLD | NEW |