Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 2737553004: Set background color when adding a new tab. (Closed)
Patch Set: none Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/browser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698