forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make avatar badged on the top left of the browser window in ChromeOS …
…draggable. Also add two test cases: 1) Teleport a browser window to another desktop. Avatar icon should show on the top left corner of the teleported browser window. (Test case for bug 433420) 2) The avatar icon of the teleported browser window should be draggable. BUG=342933 Review URL: https://codereview.chromium.org/843153002 Cr-Commit-Position: refs/heads/master@{#312016}
- Loading branch information
xdai
authored and
Commit bot
committed
Jan 17, 2015
1 parent
747ff24
commit f7e24a2
Showing
6 changed files
with
232 additions
and
132 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
chrome/browser/ui/ash/multi_user/multi_user_window_manager_test.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_test.h" | ||
|
||
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | ||
#include "chrome/browser/ui/browser_window.h" | ||
#include "ui/aura/window.h" | ||
|
||
TestMultiUserWindowManager::TestMultiUserWindowManager( | ||
Browser* visiting_browser, | ||
const std::string& desktop_owner) | ||
: browser_window_(visiting_browser->window()->GetNativeWindow()), | ||
browser_owner_( | ||
multi_user_util::GetUserIDFromProfile(visiting_browser->profile())), | ||
desktop_owner_(desktop_owner), | ||
created_window_(NULL), | ||
created_window_shown_for_(browser_owner_), | ||
current_user_id_(desktop_owner) { | ||
// Register this object with the system (which will take ownership). It will | ||
// be deleted by ChromeLauncherController::~ChromeLauncherController(). | ||
chrome::MultiUserWindowManager::SetInstanceForTest( | ||
this, chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); | ||
} | ||
|
||
TestMultiUserWindowManager::~TestMultiUserWindowManager() { | ||
// This object is owned by the MultiUserWindowManager since the | ||
// SetInstanceForTest call. As such no uninstall is required. | ||
} | ||
|
||
void TestMultiUserWindowManager::SetWindowOwner(aura::Window* window, | ||
const std::string& user_id) { | ||
NOTREACHED(); | ||
} | ||
|
||
const std::string& TestMultiUserWindowManager::GetWindowOwner( | ||
aura::Window* window) const { | ||
// No matter which window will get queried - all browsers belong to the | ||
// original browser's user. | ||
return browser_owner_; | ||
} | ||
|
||
void TestMultiUserWindowManager::ShowWindowForUser(aura::Window* window, | ||
const std::string& user_id) { | ||
// This class is only able to handle one additional window <-> user | ||
// association beside the creation parameters. | ||
// If no association has yet been requested remember it now. | ||
DCHECK(!created_window_); | ||
created_window_ = window; | ||
created_window_shown_for_ = user_id; | ||
|
||
if (browser_window_ == window) | ||
desktop_owner_ = user_id; | ||
|
||
if (user_id == current_user_id_) | ||
return; | ||
|
||
// Change the visibility of the window to update the view recursively. | ||
window->Hide(); | ||
window->Show(); | ||
current_user_id_ = user_id; | ||
} | ||
|
||
bool TestMultiUserWindowManager::AreWindowsSharedAmongUsers() const { | ||
return browser_owner_ != desktop_owner_; | ||
} | ||
|
||
void TestMultiUserWindowManager::GetOwnersOfVisibleWindows( | ||
std::set<std::string>* user_ids) const { | ||
} | ||
|
||
bool TestMultiUserWindowManager::IsWindowOnDesktopOfUser( | ||
aura::Window* window, | ||
const std::string& user_id) const { | ||
return GetUserPresentingWindow(window) == user_id; | ||
} | ||
|
||
const std::string& TestMultiUserWindowManager::GetUserPresentingWindow( | ||
aura::Window* window) const { | ||
if (window == browser_window_) | ||
return desktop_owner_; | ||
if (created_window_ && window == created_window_) | ||
return created_window_shown_for_; | ||
// We can come here before the window gets registered. | ||
return browser_owner_; | ||
} | ||
|
||
void TestMultiUserWindowManager::AddUser(content::BrowserContext* profile) { | ||
} | ||
|
||
void TestMultiUserWindowManager::AddObserver(Observer* observer) { | ||
} | ||
|
||
void TestMultiUserWindowManager::RemoveObserver(Observer* observer) { | ||
} |
58 changes: 58 additions & 0 deletions
58
chrome/browser/ui/ash/multi_user/multi_user_window_manager_test.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_TEST_H_ | ||
#define CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_TEST_H_ | ||
|
||
#include "base/macros.h" | ||
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | ||
|
||
// This is a test implementation of a MultiUserWindowManager which allows to | ||
// test a visiting window on another desktop. It will install and remove itself | ||
// from the system upon creation / destruction. | ||
// The creation function gets a |browser| which is shown on |desktop_owner|'s | ||
// desktop. | ||
class TestMultiUserWindowManager : public chrome::MultiUserWindowManager { | ||
public: | ||
TestMultiUserWindowManager(Browser* visiting_browser, | ||
const std::string& desktop_owner); | ||
~TestMultiUserWindowManager() override; | ||
|
||
aura::Window* created_window() { return created_window_; } | ||
|
||
// MultiUserWindowManager overrides: | ||
void SetWindowOwner(aura::Window* window, | ||
const std::string& user_id) override; | ||
const std::string& GetWindowOwner(aura::Window* window) const override; | ||
void ShowWindowForUser(aura::Window* window, | ||
const std::string& user_id) override; | ||
bool AreWindowsSharedAmongUsers() const override; | ||
void GetOwnersOfVisibleWindows( | ||
std::set<std::string>* user_ids) const override; | ||
bool IsWindowOnDesktopOfUser(aura::Window* window, | ||
const std::string& user_id) const override; | ||
const std::string& GetUserPresentingWindow( | ||
aura::Window* window) const override; | ||
void AddUser(content::BrowserContext* profile) override; | ||
void AddObserver(Observer* observer) override; | ||
void RemoveObserver(Observer* observer) override; | ||
|
||
private: | ||
// The window of the visiting browser. | ||
aura::Window* browser_window_; | ||
// The owner of the visiting browser. | ||
std::string browser_owner_; | ||
// The owner of the currently shown desktop. | ||
std::string desktop_owner_; | ||
// The created window. | ||
aura::Window* created_window_; | ||
// The location of the window. | ||
std::string created_window_shown_for_; | ||
// The current selected active user. | ||
std::string current_user_id_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(TestMultiUserWindowManager); | ||
}; | ||
|
||
#endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WINDOW_MANAGER_TEST_H_ |
132 changes: 2 additions & 130 deletions
132
chrome/browser/ui/browser_navigator_browsertest_chromeos.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.