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_navigator.h" | 5 #include "chrome/browser/ui/browser_navigator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 | 286 |
287 // This class makes sure the Browser object held in |params| is made visible | 287 // This class makes sure the Browser object held in |params| is made visible |
288 // by the time it goes out of scope, provided |params| wants it to be shown. | 288 // by the time it goes out of scope, provided |params| wants it to be shown. |
289 class ScopedBrowserShower { | 289 class ScopedBrowserShower { |
290 public: | 290 public: |
291 explicit ScopedBrowserShower(chrome::NavigateParams* params) | 291 explicit ScopedBrowserShower(chrome::NavigateParams* params) |
292 : params_(params) { | 292 : params_(params) { |
293 } | 293 } |
294 ~ScopedBrowserShower() { | 294 ~ScopedBrowserShower() { |
295 if (params_->window_action == chrome::NavigateParams::SHOW_WINDOW_INACTIVE) | 295 if (params_->window_action == |
| 296 chrome::NavigateParams::SHOW_WINDOW_INACTIVE) { |
296 params_->browser->window()->ShowInactive(); | 297 params_->browser->window()->ShowInactive(); |
297 else if (params_->window_action == chrome::NavigateParams::SHOW_WINDOW) | 298 } else if (params_->window_action == chrome::NavigateParams::SHOW_WINDOW) { |
298 params_->browser->window()->Show(); | 299 params_->browser->window()->Show(); |
| 300 // If a user gesture opened a popup window, focus the contents. |
| 301 if (params_->user_gesture && params_->disposition == NEW_POPUP && |
| 302 params_->target_contents) { |
| 303 params_->target_contents->Focus(); |
| 304 } |
| 305 } |
299 } | 306 } |
| 307 |
300 private: | 308 private: |
301 chrome::NavigateParams* params_; | 309 chrome::NavigateParams* params_; |
302 DISALLOW_COPY_AND_ASSIGN(ScopedBrowserShower); | 310 DISALLOW_COPY_AND_ASSIGN(ScopedBrowserShower); |
303 }; | 311 }; |
304 | 312 |
305 // This class manages the lifetime of a WebContents created by the | 313 // This class manages the lifetime of a WebContents created by the |
306 // Navigate() function. When Navigate() creates a WebContents for a URL, | 314 // Navigate() function. When Navigate() creates a WebContents for a URL, |
307 // an instance of this class takes ownership of it via TakeOwnership() until the | 315 // an instance of this class takes ownership of it via TakeOwnership() until the |
308 // WebContents is added to a tab strip at which time ownership is | 316 // WebContents is added to a tab strip at which time ownership is |
309 // relinquished via ReleaseOwnership(). If this object goes out of scope without | 317 // relinquished via ReleaseOwnership(). If this object goes out of scope without |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 bool reverse_on_redirect = false; | 765 bool reverse_on_redirect = false; |
758 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 766 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
759 &rewritten_url, browser_context, &reverse_on_redirect); | 767 &rewritten_url, browser_context, &reverse_on_redirect); |
760 | 768 |
761 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 769 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
762 return !(rewritten_url.scheme() == content::kChromeUIScheme && | 770 return !(rewritten_url.scheme() == content::kChromeUIScheme && |
763 rewritten_url.host() == chrome::kChromeUIUberHost); | 771 rewritten_url.host() == chrome::kChromeUIUberHost); |
764 } | 772 } |
765 | 773 |
766 } // namespace chrome | 774 } // namespace chrome |
OLD | NEW |