OLD | NEW |
---|---|
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/views/chrome_views_delegate.h" | 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/task_scheduler/post_task.h" | |
15 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/lifetime/keep_alive_types.h" | 21 #include "chrome/browser/lifetime/keep_alive_types.h" |
21 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 22 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/ui/ash/ash_util.h" | 24 #include "chrome/browser/ui/ash/ash_util.h" |
24 #include "chrome/browser/ui/browser_window_state.h" | 25 #include "chrome/browser/ui/browser_window_state.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
36 #include "ui/display/screen.h" | 37 #include "ui/display/screen.h" |
37 #include "ui/gfx/geometry/rect.h" | 38 #include "ui/gfx/geometry/rect.h" |
38 #include "ui/views/controls/menu/menu_controller.h" | 39 #include "ui/views/controls/menu/menu_controller.h" |
39 #include "ui/views/widget/native_widget.h" | 40 #include "ui/views/widget/native_widget.h" |
40 #include "ui/views/widget/widget.h" | 41 #include "ui/views/widget/widget.h" |
41 | 42 |
42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
43 #include <dwmapi.h> | 44 #include <dwmapi.h> |
44 #include <shellapi.h> | 45 #include <shellapi.h> |
45 #include "base/profiler/scoped_tracker.h" | 46 #include "base/profiler/scoped_tracker.h" |
46 #include "base/task_runner_util.h" | |
47 #include "base/win/windows_version.h" | 47 #include "base/win/windows_version.h" |
48 #include "chrome/browser/win/app_icon.h" | 48 #include "chrome/browser/win/app_icon.h" |
49 #include "ui/base/win/shell.h" | 49 #include "ui/base/win/shell.h" |
50 #endif | 50 #endif |
51 | 51 |
52 #if defined(USE_AURA) | 52 #if defined(USE_AURA) |
53 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 53 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" |
54 #include "ui/aura/window.h" | 54 #include "ui/aura/window.h" |
55 #include "ui/aura/window_event_dispatcher.h" | 55 #include "ui/aura/window_event_dispatcher.h" |
56 #endif | 56 #endif |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 // in us thinking there is no auto-hide edges. By returning at least one edge | 499 // in us thinking there is no auto-hide edges. By returning at least one edge |
500 // we don't initially go fullscreen until we figure out the real auto-hide | 500 // we don't initially go fullscreen until we figure out the real auto-hide |
501 // edges. | 501 // edges. |
502 if (!appbar_autohide_edge_map_.count(monitor)) | 502 if (!appbar_autohide_edge_map_.count(monitor)) |
503 appbar_autohide_edge_map_[monitor] = EDGE_BOTTOM; | 503 appbar_autohide_edge_map_[monitor] = EDGE_BOTTOM; |
504 | 504 |
505 // We use the SHAppBarMessage API to get the taskbar autohide state. This API | 505 // We use the SHAppBarMessage API to get the taskbar autohide state. This API |
506 // spins a modal loop which could cause callers to be reentered. To avoid | 506 // spins a modal loop which could cause callers to be reentered. To avoid |
507 // that we retrieve the taskbar state in a worker thread. | 507 // that we retrieve the taskbar state in a worker thread. |
508 if (monitor && !in_autohide_edges_callback_) { | 508 if (monitor && !in_autohide_edges_callback_) { |
509 base::PostTaskAndReplyWithResult( | 509 // TODO(robliao): Annotate this task with .WithCOM() once supported. |
510 content::BrowserThread::GetBlockingPool(), | 510 // https://crbug.com/662122 |
fdoray
2017/02/17 20:47:23
Currently, all TaskScheduler threads are CoInitial
| |
511 FROM_HERE, | 511 base::PostTaskWithTraitsAndReplyWithResult( |
512 base::Bind(&GetAppbarAutohideEdgesOnWorkerThread, | 512 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
513 monitor), | 513 base::TaskPriority::USER_BLOCKING), |
514 base::Bind(&GetAppbarAutohideEdgesOnWorkerThread, monitor), | |
514 base::Bind(&ChromeViewsDelegate::OnGotAppbarAutohideEdges, | 515 base::Bind(&ChromeViewsDelegate::OnGotAppbarAutohideEdges, |
515 weak_factory_.GetWeakPtr(), | 516 weak_factory_.GetWeakPtr(), callback, monitor, |
516 callback, | |
517 monitor, | |
518 appbar_autohide_edge_map_[monitor])); | 517 appbar_autohide_edge_map_[monitor])); |
519 } | 518 } |
520 return appbar_autohide_edge_map_[monitor]; | 519 return appbar_autohide_edge_map_[monitor]; |
521 } | 520 } |
522 | 521 |
523 void ChromeViewsDelegate::OnGotAppbarAutohideEdges( | 522 void ChromeViewsDelegate::OnGotAppbarAutohideEdges( |
524 const base::Closure& callback, | 523 const base::Closure& callback, |
525 HMONITOR monitor, | 524 HMONITOR monitor, |
526 int returned_edges, | 525 int returned_edges, |
527 int edges) { | 526 int edges) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); | 577 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); |
579 } | 578 } |
580 | 579 |
581 #if !defined(USE_ASH) | 580 #if !defined(USE_ASH) |
582 views::Widget::InitParams::WindowOpacity | 581 views::Widget::InitParams::WindowOpacity |
583 ChromeViewsDelegate::GetOpacityForInitParams( | 582 ChromeViewsDelegate::GetOpacityForInitParams( |
584 const views::Widget::InitParams& params) { | 583 const views::Widget::InitParams& params) { |
585 return views::Widget::InitParams::OPAQUE_WINDOW; | 584 return views::Widget::InitParams::OPAQUE_WINDOW; |
586 } | 585 } |
587 #endif | 586 #endif |
OLD | NEW |