Skip to content

Commit

Permalink
Added an ActivationReason parameter to ActivationChangeObserver::OnWi…
Browse files Browse the repository at this point in the history
…ndowActivated(...).

TEST=FocusControllerApiTest.DuplicateActivationEvents
TEST=FocusControllerApiTest.ActivationEvents
TEST=FocusControllerMouseEventTest.DuplicateActivationEvents
TEST=FocusControllerMouseEventTest.ActivationEvents
TEST=FocusControllerGestureEventTest.DuplicateActivationEvents
TEST=FocusControllerGestureEventTest.ActivationEvents
TEST=FocusControllerHideTest.ActivationEvents
TEST=FocusControllerDestructionTest.ActivationEvents
TEST=FocusControllerRemovalTest.ActivationEvents

BUG=489813, 489814

Review URL: https://codereview.chromium.org/1151133003

Cr-Commit-Position: refs/heads/master@{#333048}
  • Loading branch information
bruthig-chromium authored and Commit bot committed Jun 5, 2015
1 parent 74f13dc commit 5681d88
Show file tree
Hide file tree
Showing 40 changed files with 326 additions and 153 deletions.
6 changes: 4 additions & 2 deletions ash/content/display/screen_orientation_controller_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ void ScreenOrientationController::SetDisplayRotation(
}
}

void ScreenOrientationController::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void ScreenOrientationController::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
ApplyLockForActiveWindow();
}

Expand Down
6 changes: 4 additions & 2 deletions ash/content/display/screen_orientation_controller_chromeos.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ class ASH_EXPORT ScreenOrientationController
gfx::Display::RotationSource source);

// aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// aura::WindowObserver:
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
Expand Down
6 changes: 4 additions & 2 deletions ash/display/display_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ class TestObserver : public DisplayController::Observer,
}

// Overridden from aura::client::ActivationChangeObserver
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override {
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override {
activation_changed_count_++;
}
void OnAttemptToReactivateWindow(aura::Window* request_active,
Expand Down
6 changes: 4 additions & 2 deletions ash/shelf/shelf_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ void ShelfLayoutManager::OnLockStateChanged(bool locked) {
UpdateShelfVisibilityAfterLoginUIChange();
}

void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void ShelfLayoutManager::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
UpdateAutoHideStateNow();
}

Expand Down
6 changes: 4 additions & 2 deletions ash/shelf/shelf_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ class ASH_EXPORT ShelfLayoutManager
void OnLockStateChanged(bool locked) override;

// Overriden from aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// Overridden from ash::LockStateObserver:
void OnLockStateEvent(LockStateObserver::EventType event) override;
Expand Down
6 changes: 4 additions & 2 deletions ash/shelf/shelf_window_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ void ShelfWindowWatcher::FinishObservingRemovedWindow(aura::Window* window) {
RemoveShelfItem(window);
}

void ShelfWindowWatcher::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void ShelfWindowWatcher::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (gained_active && HasShelfItemForWindow(gained_active))
UpdateShelfItemStatus(gained_active, true);
if (lost_active && HasShelfItemForWindow(lost_active))
Expand Down
6 changes: 4 additions & 2 deletions ash/shelf/shelf_window_watcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ class ShelfWindowWatcher : public aura::client::ActivationChangeObserver,
void FinishObservingRemovedWindow(aura::Window* window);

// aura::client::ActivationChangeObserver overrides:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// aura::WindowObserver overrides:
void OnWindowAdded(aura::Window* window) override;
Expand Down
6 changes: 4 additions & 2 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,10 @@ void Shell::OnEvent(ui::Event* event) {
////////////////////////////////////////////////////////////////////////////////
// Shell, aura::client::ActivationChangeObserver implementation:

void Shell::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void Shell::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (gained_active)
target_root_window_ = gained_active->GetRootWindow();
}
Expand Down
6 changes: 4 additions & 2 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,10 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
void OnEvent(ui::Event* event) override;

// Overridden from aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

static Shell* instance_;

Expand Down
6 changes: 4 additions & 2 deletions ash/test/test_activation_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ bool TestActivationDelegate::ShouldActivate() const {
return activate_;
}

void TestActivationDelegate::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void TestActivationDelegate::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
DCHECK(window_ == gained_active || window_ == lost_active);
if (window_ == gained_active) {
activated_count_++;
Expand Down
6 changes: 4 additions & 2 deletions ash/test/test_activation_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ class TestActivationDelegate : public aura::client::ActivationDelegate,

private:
// Overridden from aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

aura::Window* window_;
bool window_was_active_;
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/dock/docked_window_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,10 @@ void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
// DockedWindowLayoutManager, aura::client::ActivationChangeObserver
// implementation:

void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void DockedWindowLayoutManager::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (gained_active && IsPopupOrTransient(gained_active))
return;
// Ignore if the window that is not managed by this was activated.
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/dock/docked_window_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ class ASH_EXPORT DockedWindowLayoutManager
void OnWindowDestroying(aura::Window* window) override;

// aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

private:
class ShelfWindowObserver;
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/mru_window_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ void MruWindowTracker::SetActiveWindow(aura::Window* active_window) {
mru_windows_.push_front(active_window);
}

void MruWindowTracker::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void MruWindowTracker::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (!ignore_window_activations_)
SetActiveWindow(gained_active);
}
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/mru_window_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class ASH_EXPORT MruWindowTracker
void SetActiveWindow(aura::Window* active_window);

// Overridden from aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// Overridden from WindowObserver:
void OnWindowDestroyed(aura::Window* window) override;
Expand Down
10 changes: 7 additions & 3 deletions ash/wm/overview/window_selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,10 @@ void WindowSelector::OnWindowDestroying(aura::Window* window) {
restore_focus_window_ = nullptr;
}

void WindowSelector::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void WindowSelector::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (ignore_activations_ ||
!gained_active ||
gained_active == text_filter_widget_->GetNativeWindow()) {
Expand Down Expand Up @@ -534,7 +536,9 @@ void WindowSelector::OnWindowActivated(aura::Window* gained_active,

void WindowSelector::OnAttemptToReactivateWindow(aura::Window* request_active,
aura::Window* actual_active) {
OnWindowActivated(request_active, actual_active);
OnWindowActivated(aura::client::ActivationChangeObserver::ActivationReason::
ACTIVATION_CLIENT,
request_active, actual_active);
}

void WindowSelector::ContentsChanged(views::Textfield* sender,
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/overview/window_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ class ASH_EXPORT WindowSelector
void OnWindowDestroying(aura::Window* window) override;

// aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
void OnAttemptToReactivateWindow(aura::Window* request_active,
aura::Window* actual_active) override;

Expand Down
6 changes: 4 additions & 2 deletions ash/wm/panels/panel_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,10 @@ void PanelLayoutManager::OnPostWindowStateTypeChange(
////////////////////////////////////////////////////////////////////////////////
// PanelLayoutManager, aura::client::ActivationChangeObserver implementation:

void PanelLayoutManager::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void PanelLayoutManager::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
// Ignore if the panel that is not managed by this was activated.
if (gained_active && gained_active->type() == ui::wm::WINDOW_TYPE_PANEL &&
gained_active->parent() == panel_container_) {
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/panels/panel_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ class ASH_EXPORT PanelLayoutManager
wm::WindowStateType old_type) override;

// Overridden from aura::client::ActivationChangeObserver
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// Overridden from DisplayController::Observer
void OnDisplayConfigurationChanged() override;
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/workspace/workspace_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,10 @@ void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window,
// WorkspaceLayoutManager,
// aura::client::ActivationChangeObserver implementation:

void WorkspaceLayoutManager::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void WorkspaceLayoutManager::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
wm::WindowState* window_state = wm::GetWindowState(gained_active);
if (window_state && window_state->IsMinimized() &&
!gained_active->IsVisible()) {
Expand Down
6 changes: 4 additions & 2 deletions ash/wm/workspace/workspace_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class ASH_EXPORT WorkspaceLayoutManager
const gfx::Rect& new_bounds) override;

// aura::client::ActivationChangeObserver overrides:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// keyboard::KeyboardControllerObserver overrides:
void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ void AppWindowLauncherController::OnWindowDestroying(aura::Window* window) {
UnregisterApp(window);
}

void AppWindowLauncherController::OnWindowActivated(aura::Window* new_active,
aura::Window* old_active) {
void AppWindowLauncherController::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* new_active,
aura::Window* old_active) {
// Make the newly active window the active (first) entry in the controller.
AppWindowLauncherItemController* new_controller =
ControllerForWindow(new_active);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ class AppWindowLauncherController
void OnWindowDestroying(aura::Window* window) override;

// Overriden from client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

protected:
// Registers a app window with the shelf and this object.
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/ui/ash/launcher/browser_status_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ void BrowserStatusMonitor::UpdateBrowserItemState() {
UpdateBrowserItemState();
}

void BrowserStatusMonitor::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void BrowserStatusMonitor::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
Browser* browser = NULL;
content::WebContents* contents_from_gained = NULL;
content::WebContents* contents_from_lost = NULL;
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/ui/ash/launcher/browser_status_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ class BrowserStatusMonitor : public aura::client::ActivationChangeObserver,
void UpdateBrowserItemState();

// aura::client::ActivationChangeObserver overrides:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

// aura::WindowObserver overrides:
void OnWindowDestroyed(aura::Window* window) override;
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/ui/views/extensions/extension_popup_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ void ExtensionPopupAura::OnWidgetDestroying(views::Widget* widget) {
}
}

void ExtensionPopupAura::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void ExtensionPopupAura::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
// Close on anchor window activation (ie. user clicked the browser window).
// DesktopNativeWidgetAura does not trigger the expected browser widget
// [de]activation events when activating widgets in its own root window.
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/ui/views/extensions/extension_popup_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ class ExtensionPopupAura : public ExtensionPopup,
void OnWidgetDestroying(views::Widget* widget) override;

// aura::client::ActivationChangeObserver overrides.
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override;
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;

private:
DISALLOW_COPY_AND_ASSIGN(ExtensionPopupAura);
Expand Down
6 changes: 4 additions & 2 deletions ui/views/controls/menu/menu_message_loop_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ class ActivationChangeObserverImpl
~ActivationChangeObserverImpl() override { Cleanup(); }

// aura::client::ActivationChangeObserver:
void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) override {
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override {
if (!controller_->drag_in_progress())
controller_->CancelAll();
}
Expand Down
6 changes: 4 additions & 2 deletions ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,10 @@ bool DesktopNativeWidgetAura::ShouldActivate() const {
// DesktopNativeWidgetAura, aura::client::ActivationChangeObserver
// implementation:

void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
void DesktopNativeWidgetAura::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
DCHECK(content_window_ == gained_active || content_window_ == lost_active);
if (gained_active == content_window_ && restore_focus_on_activate_) {
restore_focus_on_activate_ = false;
Expand Down
Loading

0 comments on commit 5681d88

Please sign in to comment.