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

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

Issue 2869063002: mac: Don't transfer background color to new tabs (Closed)
Patch Set: s/DISABLE/DISABLED/g Created 3 years, 7 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 window_->GetLocationBar()->SaveStateToContents(contents); 1028 window_->GetLocationBar()->SaveStateToContents(contents);
1029 1029
1030 if (instant_controller_) 1030 if (instant_controller_)
1031 instant_controller_->TabDeactivated(contents); 1031 instant_controller_->TabDeactivated(contents);
1032 } 1032 }
1033 1033
1034 void Browser::ActiveTabChanged(WebContents* old_contents, 1034 void Browser::ActiveTabChanged(WebContents* old_contents,
1035 WebContents* new_contents, 1035 WebContents* new_contents,
1036 int index, 1036 int index,
1037 int reason) { 1037 int reason) {
1038 // Mac correctly sets the initial background color of new tabs to the theme
1039 // background color, so it does not need this block of code. Aura should
1040 // implement this as well.
1041 // https://crbug.com/719230
1042 #if !defined(OS_MACOSX)
1038 // Copies the background color from an old WebContents to a new one that 1043 // Copies the background color from an old WebContents to a new one that
1039 // replaces it on the screen. This allows the new WebContents to use the 1044 // replaces it on the screen. This allows the new WebContents to use the
1040 // old one's background color as the starting background color, before having 1045 // old one's background color as the starting background color, before having
1041 // loaded any contents. As a result, we avoid flashing white when moving to 1046 // loaded any contents. As a result, we avoid flashing white when moving to
1042 // a new tab. (There is also code in RenderFrameHostManager to do something 1047 // a new tab. (There is also code in RenderFrameHostManager to do something
1043 // similar for intra-tab navigations.) 1048 // similar for intra-tab navigations.)
1044 if (old_contents && new_contents) { 1049 if (old_contents && new_contents) {
1045 // While GetMainFrame() is guaranteed to return non-null, GetView() is not, 1050 // While GetMainFrame() is guaranteed to return non-null, GetView() is not,
1046 // e.g. between WebContents creation and creation of the 1051 // e.g. between WebContents creation and creation of the
1047 // RenderWidgetHostView. 1052 // RenderWidgetHostView.
1048 RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView(); 1053 RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView();
1049 RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView(); 1054 RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView();
1050 if (old_view && new_view) 1055 if (old_view && new_view)
1051 new_view->SetBackgroundColor(old_view->background_color()); 1056 new_view->SetBackgroundColor(old_view->background_color());
1052 } 1057 }
1058 #endif
1053 1059
1054 base::RecordAction(UserMetricsAction("ActiveTabChanged")); 1060 base::RecordAction(UserMetricsAction("ActiveTabChanged"));
1055 1061
1056 // Update the bookmark state, since the BrowserWindow may query it during 1062 // Update the bookmark state, since the BrowserWindow may query it during
1057 // OnActiveTabChanged() below. 1063 // OnActiveTabChanged() below.
1058 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); 1064 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH);
1059 1065
1060 // Let the BrowserWindow do its handling. On e.g. views this changes the 1066 // Let the BrowserWindow do its handling. On e.g. views this changes the
1061 // focused object, which should happen before we update the toolbar below, 1067 // focused object, which should happen before we update the toolbar below,
1062 // since the omnibox expects the correct element to already be focused when it 1068 // since the omnibox expects the correct element to already be focused when it
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 // new window later, thus we need to navigate the window now. 2634 // new window later, thus we need to navigate the window now.
2629 if (contents) { 2635 if (contents) {
2630 contents->web_contents()->GetController().LoadURL( 2636 contents->web_contents()->GetController().LoadURL(
2631 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, 2637 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK,
2632 std::string()); // No extra headers. 2638 std::string()); // No extra headers.
2633 } 2639 }
2634 } 2640 }
2635 2641
2636 return contents != NULL; 2642 return contents != NULL;
2637 } 2643 }
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