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

Side by Side Diff: chrome/browser/ui/panels/docked_panel_collection.cc

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 years, 6 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/panels/docked_panel_collection.h" 5 #include "chrome/browser/ui/panels/docked_panel_collection.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <queue>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/auto_reset.h" 13 #include "base/auto_reset.h"
13 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/location.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/message_loop/message_loop.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/thread_task_runner_handle.h"
16 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/ui/panels/panel_drag_controller.h" 20 #include "chrome/browser/ui/panels/panel_drag_controller.h"
18 #include "chrome/browser/ui/panels/panel_manager.h" 21 #include "chrome/browser/ui/panels/panel_manager.h"
19 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
20 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
22 25
23 namespace { 26 namespace {
24 // Width of spacing around panel collection and the left/right edges of the 27 // Width of spacing around panel collection and the left/right edges of the
25 // screen. 28 // screen.
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 534 }
532 535
533 // OnAutoHidingDesktopBarVisibilityChanged will handle this. 536 // OnAutoHidingDesktopBarVisibilityChanged will handle this.
534 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN; 537 delayed_titlebar_action_ = bring_up ? BRING_UP : BRING_DOWN;
535 538
536 // If user moves the mouse in and out of mouse tracking area, we might have 539 // If user moves the mouse in and out of mouse tracking area, we might have
537 // previously posted but not yet dispatched task in the queue. New action 540 // previously posted but not yet dispatched task in the queue. New action
538 // should always 'reset' the delays so cancel any tasks that haven't run yet 541 // should always 'reset' the delays so cancel any tasks that haven't run yet
539 // and post a new one. 542 // and post a new one.
540 titlebar_action_factory_.InvalidateWeakPtrs(); 543 titlebar_action_factory_.InvalidateWeakPtrs();
541 base::MessageLoop::current()->PostDelayedTask( 544 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
542 FROM_HERE, 545 FROM_HERE,
543 base::Bind(&DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck, 546 base::Bind(&DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck,
544 titlebar_action_factory_.GetWeakPtr()), 547 titlebar_action_factory_.GetWeakPtr()),
545 base::TimeDelta::FromMilliseconds( 548 base::TimeDelta::FromMilliseconds(
546 PanelManager::AdjustTimeInterval(task_delay_ms))); 549 PanelManager::AdjustTimeInterval(task_delay_ms)));
547 } 550 }
548 551
549 void DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck() { 552 void DockedPanelCollection::DelayedBringUpOrDownTitlebarsCheck() {
550 // Task was already processed or cancelled - bail out. 553 // Task was already processed or cancelled - bail out.
551 if (delayed_titlebar_action_ == NO_ACTION) 554 if (delayed_titlebar_action_ == NO_ACTION)
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 747
745 void DockedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) { 748 void DockedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
746 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); 749 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION);
747 panel->ShowShadow(true); 750 panel->ShowShadow(true);
748 panel->UpdateMinimizeRestoreButtonVisibility(); 751 panel->UpdateMinimizeRestoreButtonVisibility();
749 panel->SetWindowCornerStyle(panel::TOP_ROUNDED); 752 panel->SetWindowCornerStyle(panel::TOP_ROUNDED);
750 } 753 }
751 754
752 void DockedPanelCollection::ScheduleLayoutRefresh() { 755 void DockedPanelCollection::ScheduleLayoutRefresh() {
753 refresh_action_factory_.InvalidateWeakPtrs(); 756 refresh_action_factory_.InvalidateWeakPtrs();
754 base::MessageLoop::current()->PostDelayedTask( 757 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
755 FROM_HERE, 758 FROM_HERE, base::Bind(&DockedPanelCollection::RefreshLayout,
756 base::Bind(&DockedPanelCollection::RefreshLayout, 759 refresh_action_factory_.GetWeakPtr()),
757 refresh_action_factory_.GetWeakPtr()),
758 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( 760 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval(
759 kRefreshLayoutAfterActivePanelChangeDelayMs))); 761 kRefreshLayoutAfterActivePanelChangeDelayMs)));
760 } 762 }
761 763
762 void DockedPanelCollection::OnPanelActiveStateChanged(Panel* panel) { 764 void DockedPanelCollection::OnPanelActiveStateChanged(Panel* panel) {
763 // Refresh layout, but wait till active states settle. 765 // Refresh layout, but wait till active states settle.
764 // This lets us avoid refreshing too many times when one panel loses 766 // This lets us avoid refreshing too many times when one panel loses
765 // focus and another gains it. 767 // focus and another gains it.
766 ScheduleLayoutRefresh(); 768 ScheduleLayoutRefresh();
767 } 769 }
768 770
769 gfx::Rect DockedPanelCollection::GetInitialPanelBounds( 771 gfx::Rect DockedPanelCollection::GetInitialPanelBounds(
770 const gfx::Rect& requested_bounds) const { 772 const gfx::Rect& requested_bounds) const {
771 gfx::Rect initial_bounds = requested_bounds; 773 gfx::Rect initial_bounds = requested_bounds;
772 initial_bounds.set_origin( 774 initial_bounds.set_origin(
773 GetDefaultPositionForPanel(requested_bounds.size())); 775 GetDefaultPositionForPanel(requested_bounds.size()));
774 return initial_bounds; 776 return initial_bounds;
775 } 777 }
776 778
777 bool DockedPanelCollection::HasPanel(Panel* panel) const { 779 bool DockedPanelCollection::HasPanel(Panel* panel) const {
778 return find(panels_.begin(), panels_.end(), panel) != panels_.end(); 780 return find(panels_.begin(), panels_.end(), panel) != panels_.end();
779 } 781 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc ('k') | chrome/browser/ui/panels/panel_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698