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

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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 window_->GetLocationBar()->SaveStateToContents(contents); 1033 window_->GetLocationBar()->SaveStateToContents(contents);
1034 1034
1035 if (instant_controller_) 1035 if (instant_controller_)
1036 instant_controller_->TabDeactivated(contents); 1036 instant_controller_->TabDeactivated(contents);
1037 } 1037 }
1038 1038
1039 void Browser::ActiveTabChanged(WebContents* old_contents, 1039 void Browser::ActiveTabChanged(WebContents* old_contents,
1040 WebContents* new_contents, 1040 WebContents* new_contents,
1041 int index, 1041 int index,
1042 int reason) { 1042 int reason) {
1043 // Copies the background color from an old WebContents to a new one that
1044 // replaces it on the screen. This allows the new WebContents to use the
1045 // old one's background color as the starting background color, before having
1046 // loaded any contents. As a result, we avoid flashing white when moving to
1047 // a new tab. (There is also code in RenderFrameHostManager to do something
1048 // similar for intra-tab navigations.)
1049 if (old_contents && new_contents) {
1050 RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView();
Peter Kasting 2017/03/09 00:02:03 NIt: Document the null check, e.g. "While GetMainF
chrishtr 2017/03/09 00:04:53 Done.
1051 RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView();
1052 if (old_view && new_view)
1053 new_view->SetBackgroundColor(old_view->background_color());
1054 }
1055
1043 content::RecordAction(UserMetricsAction("ActiveTabChanged")); 1056 content::RecordAction(UserMetricsAction("ActiveTabChanged"));
1044 1057
1045 // Update the bookmark state, since the BrowserWindow may query it during 1058 // Update the bookmark state, since the BrowserWindow may query it during
1046 // OnActiveTabChanged() below. 1059 // OnActiveTabChanged() below.
1047 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); 1060 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH);
1048 1061
1049 // 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
1050 // focused object, which should happen before we update the toolbar below, 1063 // focused object, which should happen before we update the toolbar below,
1051 // 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
1052 // is updated. 1065 // is updated.
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 // new window later, thus we need to navigate the window now. 2675 // new window later, thus we need to navigate the window now.
2663 if (contents) { 2676 if (contents) {
2664 contents->web_contents()->GetController().LoadURL( 2677 contents->web_contents()->GetController().LoadURL(
2665 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, 2678 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK,
2666 std::string()); // No extra headers. 2679 std::string()); // No extra headers.
2667 } 2680 }
2668 } 2681 }
2669 2682
2670 return contents != NULL; 2683 return contents != NULL;
2671 } 2684 }
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