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

Unified Diff: chrome/browser/ui/ash/chrome_new_window_client.cc

Issue 2599833003: ChromeOS: Fix NewWindow's bug with browser on other user's desktop and no browser on current's (Closed)
Patch Set: get active browser with active browser window 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/chrome_new_window_client.cc
diff --git a/chrome/browser/ui/ash/chrome_new_window_client.cc b/chrome/browser/ui/ash/chrome_new_window_client.cc
index 27f1ecb4c14cde1484d615614d1b51db9d0129e3..3209e22a3873bd03e47aa5797a5c1372dc29bdfa 100644
--- a/chrome/browser/ui/ash/chrome_new_window_client.cc
+++ b/chrome/browser/ui/ash/chrome_new_window_client.cc
@@ -33,6 +33,7 @@
#include "extensions/common/constants.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/window_open_disposition.h"
+#include "ui/wm/public/activation_client.h"
namespace {
@@ -42,6 +43,19 @@ void RestoreTabUsingProfile(Profile* profile) {
service->RestoreMostRecentEntry(nullptr);
}
+// Returns the active browser that has active browser window, if any.
+Browser* GetActiveBrowser() {
+ Browser* browser = BrowserList::GetInstance()->GetLastActive();
+ if (browser) {
+ aura::Window* window = browser->window()->GetNativeWindow();
+ aura::client::ActivationClient* client =
oshima 2017/01/30 18:09:24 nit: include activation_client.h
Qiang(Joe) Xu 2017/01/31 06:55:55 It is added in this patch.
+ aura::client::GetActivationClient(window->GetRootWindow());
+ if (client->GetActiveWindow() == window)
+ return browser;
+ }
+ return nullptr;
+}
+
} // namespace
ChromeNewWindowClient::ChromeNewWindowClient() : binding_(this) {
@@ -102,7 +116,7 @@ class ChromeNewWindowClient::TabRestoreHelper
};
void ChromeNewWindowClient::NewTab() {
- Browser* browser = BrowserList::GetInstance()->GetLastActive();
+ Browser* browser = GetActiveBrowser();
if (browser && browser->is_type_tabbed()) {
chrome::NewTab(browser);
return;
@@ -120,7 +134,7 @@ void ChromeNewWindowClient::NewTab() {
}
void ChromeNewWindowClient::NewWindow(bool is_incognito) {
- Browser* browser = BrowserList::GetInstance()->GetLastActive();
+ Browser* browser = GetActiveBrowser();
Profile* profile = (browser && browser->profile())
? browser->profile()->GetOriginalProfile()
: ProfileManager::GetActiveUserProfile();
@@ -173,8 +187,8 @@ void ChromeNewWindowClient::RestoreTab() {
return;
}
- Browser* browser = BrowserList::GetInstance()->GetLastActive();
- Profile* profile = browser ? browser->profile() : NULL;
+ Browser* browser = GetActiveBrowser();
+ Profile* profile = browser ? browser->profile() : nullptr;
if (!profile)
profile = ProfileManager::GetActiveUserProfile();
if (profile->IsOffTheRecord())
@@ -201,9 +215,9 @@ void ChromeNewWindowClient::ShowKeyboardOverlay() {
}
void ChromeNewWindowClient::ShowTaskManager() {
- chrome::OpenTaskManager(NULL);
+ chrome::OpenTaskManager(nullptr);
}
void ChromeNewWindowClient::OpenFeedbackPage() {
- chrome::OpenFeedbackDialog(BrowserList::GetInstance()->GetLastActive());
+ chrome::OpenFeedbackDialog(GetActiveBrowser());
}
« 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