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