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

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

Issue 2644733004: Chrome OS: New window on teleported browser window should show on current desktop (Closed)
Patch Set: add test coverage Created 3 years, 11 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
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_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/macros.h" 10 #include "base/macros.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
34 #include "content/public/browser/browser_url_handler.h" 34 #include "content/public/browser/browser_url_handler.h"
35 #include "content/public/browser/navigation_entry.h" 35 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
39 #include "extensions/features/features.h" 39 #include "extensions/features/features.h"
40 40
41 #if defined(USE_ASH) 41 #if defined(USE_ASH)
42 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 42 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
43 #include "components/signin/core/account_id/account_id.h" 43 #include "components/signin/core/account_id/account_id.h"
44 #endif 44 #endif
45 45
46 #if defined(USE_AURA) 46 #if defined(USE_AURA)
47 #include "ui/aura/window.h" 47 #include "ui/aura/window.h"
48 #endif 48 #endif
49 49
50 #if BUILDFLAG(ENABLE_EXTENSIONS) 50 #if BUILDFLAG(ENABLE_EXTENSIONS)
51 #include "chrome/browser/extensions/tab_helper.h" 51 #include "chrome/browser/extensions/tab_helper.h"
52 #include "chrome/browser/web_applications/web_app.h" 52 #include "chrome/browser/web_applications/web_app.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 params->disposition = 430 params->disposition =
431 source_browser->window()->GetDispositionForPopupBounds( 431 source_browser->window()->GetDispositionForPopupBounds(
432 params->window_bounds); 432 params->window_bounds);
433 } 433 }
434 434
435 params->browser = GetBrowserForDisposition(params); 435 params->browser = GetBrowserForDisposition(params);
436 if (!params->browser) 436 if (!params->browser)
437 return; 437 return;
438 438
439 #if defined(USE_ASH) 439 #if defined(USE_ASH)
440 if (source_browser && source_browser != params->browser) { 440 // In ChromeOS multiprofile scenario we might need to teleport the window back
441 // When the newly created browser was spawned by a browser which visits 441 // to the current user desktop.
442 // another user's desktop, it should be shown on the same desktop as the 442 aura::Window* new_window = params->browser->window()->GetNativeWindow();
443 // originating one. (This is part of the desktop separation per profile). 443 multi_user_util::MoveWindowToCurrentDesktop(new_window);
sky 2017/01/20 01:03:08 This seems wrong to me. When we create the browser
oshima 2017/01/24 21:22:58 I agree. warx@, please see my comment in the bug.
Mr4D (OOO till 08-26) 2017/01/25 18:08:44 If I remember it correctly there was the possibili
444 MultiUserWindowManager* manager = MultiUserWindowManager::GetInstance();
445 // Some unit tests have no manager instantiated.
446 if (manager) {
447 aura::Window* src_window = source_browser->window()->GetNativeWindow();
448 aura::Window* new_window = params->browser->window()->GetNativeWindow();
449 const AccountId& src_account_id =
450 manager->GetUserPresentingWindow(src_window);
451 if (src_account_id != manager->GetUserPresentingWindow(new_window)) {
452 // Once the window gets presented, it should be shown on the same
453 // desktop as the desktop of the creating browser. Note that this
454 // command will not show the window if it wasn't shown yet by the
455 // browser creation.
456 manager->ShowWindowForUser(new_window, src_account_id);
457 }
458 }
459 }
460 #endif 444 #endif
461 445
462 // Navigate() must not return early after this point. 446 // Navigate() must not return early after this point.
463 447
464 if (GetSourceProfile(params) != params->browser->profile()) { 448 if (GetSourceProfile(params) != params->browser->profile()) {
465 // A tab is being opened from a link from a different profile, we must reset 449 // A tab is being opened from a link from a different profile, we must reset
466 // source information that may cause state to be shared. 450 // source information that may cause state to be shared.
467 params->source_contents = nullptr; 451 params->source_contents = nullptr;
468 params->source_site_instance = nullptr; 452 params->source_site_instance = nullptr;
469 params->referrer = content::Referrer(); 453 params->referrer = content::Referrer();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 bool reverse_on_redirect = false; 651 bool reverse_on_redirect = false;
668 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 652 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
669 &rewritten_url, browser_context, &reverse_on_redirect); 653 &rewritten_url, browser_context, &reverse_on_redirect);
670 654
671 // Some URLs are mapped to uber subpages. Do not allow them in incognito. 655 // Some URLs are mapped to uber subpages. Do not allow them in incognito.
672 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && 656 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme &&
673 rewritten_url.host_piece() == chrome::kChromeUIUberHost); 657 rewritten_url.host_piece() == chrome::kChromeUIUberHost);
674 } 658 }
675 659
676 } // namespace chrome 660 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698