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

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

Issue 10409034: Fixing activation problem: Pages which refresh themselves should not get focus (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed fourth review Created 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 GetStatusBubble()->Hide(); 2690 GetStatusBubble()->Hide();
2691 2691
2692 // Update the location bar. This is synchronous. We specifically don't 2692 // Update the location bar. This is synchronous. We specifically don't
2693 // update the load state since the load hasn't started yet and updating it 2693 // update the load state since the load hasn't started yet and updating it
2694 // will put it out of sync with the actual state like whether we're 2694 // will put it out of sync with the actual state like whether we're
2695 // displaying a favicon, which controls the throbber. If we updated it here, 2695 // displaying a favicon, which controls the throbber. If we updated it here,
2696 // the throbber will show the default favicon for a split second when 2696 // the throbber will show the default favicon for a split second when
2697 // navigating away from the new tab page. 2697 // navigating away from the new tab page.
2698 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); 2698 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL);
2699 2699
2700 if (contents_is_selected) 2700 // Focus on the content if the content is active and it is user initated
2701 // or if the window is active as well as the tab - or in other words:
2702 // Don't focus when the user did not initate the navigation or the window
2703 // and tab are not active.
2704 if (contents_is_selected && (user_initiated || window()->IsActive()))
2701 contents->web_contents()->Focus(); 2705 contents->web_contents()->Focus();
2702 } 2706 }
2703 2707
2704 void Browser::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) { 2708 void Browser::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) {
2705 browser::ShowCollectedCookiesDialog(window()->GetNativeHandle(), wrapper); 2709 browser::ShowCollectedCookiesDialog(window()->GetNativeHandle(), wrapper);
2706 } 2710 }
2707 2711
2708 /////////////////////////////////////////////////////////////////////////////// 2712 ///////////////////////////////////////////////////////////////////////////////
2709 // Browser, PageNavigator implementation: 2713 // Browser, PageNavigator implementation:
2710 2714
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
3402 // Browser, content::WebContentsDelegate implementation: 3406 // Browser, content::WebContentsDelegate implementation:
3403 3407
3404 WebContents* Browser::OpenURLFromTab(WebContents* source, 3408 WebContents* Browser::OpenURLFromTab(WebContents* source,
3405 const OpenURLParams& params) { 3409 const OpenURLParams& params) {
3406 browser::NavigateParams nav_params(this, params.url, params.transition); 3410 browser::NavigateParams nav_params(this, params.url, params.transition);
3407 nav_params.source_contents = GetTabContentsWrapperAt( 3411 nav_params.source_contents = GetTabContentsWrapperAt(
3408 tab_strip_model_->GetWrapperIndex(source)); 3412 tab_strip_model_->GetWrapperIndex(source));
3409 nav_params.referrer = params.referrer; 3413 nav_params.referrer = params.referrer;
3410 nav_params.disposition = params.disposition; 3414 nav_params.disposition = params.disposition;
3411 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; 3415 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE;
3412 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; 3416
3417 // Show the tab if the window and tab was already active.
3418 if (GetSelectedWebContents() == source && window()->IsActive())
3419 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW;
3420
3413 nav_params.user_gesture = true; 3421 nav_params.user_gesture = true;
3414 nav_params.override_encoding = params.override_encoding; 3422 nav_params.override_encoding = params.override_encoding;
3415 nav_params.is_renderer_initiated = params.is_renderer_initiated; 3423 nav_params.is_renderer_initiated = params.is_renderer_initiated;
3416 nav_params.transferred_global_request_id = 3424 nav_params.transferred_global_request_id =
3417 params.transferred_global_request_id; 3425 params.transferred_global_request_id;
3418 browser::Navigate(&nav_params); 3426 browser::Navigate(&nav_params);
3419 3427
3420 return nav_params.target_contents ? 3428 return nav_params.target_contents ?
3421 nav_params.target_contents->web_contents() : NULL; 3429 nav_params.target_contents->web_contents() : NULL;
3422 } 3430 }
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
5425 if (contents && !allow_js_access) { 5433 if (contents && !allow_js_access) {
5426 contents->web_contents()->GetController().LoadURL( 5434 contents->web_contents()->GetController().LoadURL(
5427 target_url, 5435 target_url,
5428 content::Referrer(), 5436 content::Referrer(),
5429 content::PAGE_TRANSITION_LINK, 5437 content::PAGE_TRANSITION_LINK,
5430 std::string()); // No extra headers. 5438 std::string()); // No extra headers.
5431 } 5439 }
5432 5440
5433 return contents != NULL; 5441 return contents != NULL;
5434 } 5442 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698