| OLD | NEW |
| 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 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 GetStatusBubble()->Hide(); | 2375 GetStatusBubble()->Hide(); |
| 2376 | 2376 |
| 2377 // Update the location bar. This is synchronous. We specifically don't | 2377 // Update the location bar. This is synchronous. We specifically don't |
| 2378 // update the load state since the load hasn't started yet and updating it | 2378 // update the load state since the load hasn't started yet and updating it |
| 2379 // will put it out of sync with the actual state like whether we're | 2379 // will put it out of sync with the actual state like whether we're |
| 2380 // displaying a favicon, which controls the throbber. If we updated it here, | 2380 // displaying a favicon, which controls the throbber. If we updated it here, |
| 2381 // the throbber will show the default favicon for a split second when | 2381 // the throbber will show the default favicon for a split second when |
| 2382 // navigating away from the new tab page. | 2382 // navigating away from the new tab page. |
| 2383 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); | 2383 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); |
| 2384 | 2384 |
| 2385 // Focus on the content if the content is active and it is user initated | 2385 if (contents_is_selected) |
| 2386 // or if the window is active as well as the tab - or in other words: | |
| 2387 // Don't focus when the user did not initate the navigation or the window | |
| 2388 // and tab are not active. | |
| 2389 if (contents_is_selected && (user_initiated || window()->IsActive())) | |
| 2390 contents->web_contents()->Focus(); | 2386 contents->web_contents()->Focus(); |
| 2391 } | 2387 } |
| 2392 | 2388 |
| 2393 void Browser::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) { | 2389 void Browser::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) { |
| 2394 browser::ShowCollectedCookiesDialog(window()->GetNativeHandle(), wrapper); | 2390 browser::ShowCollectedCookiesDialog(window()->GetNativeHandle(), wrapper); |
| 2395 } | 2391 } |
| 2396 | 2392 |
| 2397 /////////////////////////////////////////////////////////////////////////////// | 2393 /////////////////////////////////////////////////////////////////////////////// |
| 2398 // Browser, PageNavigator implementation: | 2394 // Browser, PageNavigator implementation: |
| 2399 | 2395 |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3091 // Browser, content::WebContentsDelegate implementation: | 3087 // Browser, content::WebContentsDelegate implementation: |
| 3092 | 3088 |
| 3093 WebContents* Browser::OpenURLFromTab(WebContents* source, | 3089 WebContents* Browser::OpenURLFromTab(WebContents* source, |
| 3094 const OpenURLParams& params) { | 3090 const OpenURLParams& params) { |
| 3095 browser::NavigateParams nav_params(this, params.url, params.transition); | 3091 browser::NavigateParams nav_params(this, params.url, params.transition); |
| 3096 nav_params.source_contents = GetTabContentsWrapperAt( | 3092 nav_params.source_contents = GetTabContentsWrapperAt( |
| 3097 tab_strip_model_->GetWrapperIndex(source)); | 3093 tab_strip_model_->GetWrapperIndex(source)); |
| 3098 nav_params.referrer = params.referrer; | 3094 nav_params.referrer = params.referrer; |
| 3099 nav_params.disposition = params.disposition; | 3095 nav_params.disposition = params.disposition; |
| 3100 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; | 3096 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; |
| 3101 | |
| 3102 // Show the tab if the window and tab was already active. | |
| 3103 if (GetSelectedWebContents() == source && window()->IsActive()) | |
| 3104 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; | 3097 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| 3105 | |
| 3106 nav_params.user_gesture = true; | 3098 nav_params.user_gesture = true; |
| 3107 nav_params.override_encoding = params.override_encoding; | 3099 nav_params.override_encoding = params.override_encoding; |
| 3108 nav_params.is_renderer_initiated = params.is_renderer_initiated; | 3100 nav_params.is_renderer_initiated = params.is_renderer_initiated; |
| 3109 nav_params.transferred_global_request_id = | 3101 nav_params.transferred_global_request_id = |
| 3110 params.transferred_global_request_id; | 3102 params.transferred_global_request_id; |
| 3111 browser::Navigate(&nav_params); | 3103 browser::Navigate(&nav_params); |
| 3112 | 3104 |
| 3113 return nav_params.target_contents ? | 3105 return nav_params.target_contents ? |
| 3114 nav_params.target_contents->web_contents() : NULL; | 3106 nav_params.target_contents->web_contents() : NULL; |
| 3115 } | 3107 } |
| (...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5121 if (contents && !allow_js_access) { | 5113 if (contents && !allow_js_access) { |
| 5122 contents->web_contents()->GetController().LoadURL( | 5114 contents->web_contents()->GetController().LoadURL( |
| 5123 target_url, | 5115 target_url, |
| 5124 content::Referrer(), | 5116 content::Referrer(), |
| 5125 content::PAGE_TRANSITION_LINK, | 5117 content::PAGE_TRANSITION_LINK, |
| 5126 std::string()); // No extra headers. | 5118 std::string()); // No extra headers. |
| 5127 } | 5119 } |
| 5128 | 5120 |
| 5129 return contents != NULL; | 5121 return contents != NULL; |
| 5130 } | 5122 } |
| OLD | NEW |