1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/views_delegate.h"
7 #include "base/command_line.h"
8 #include "ui/views/views_touch_selection_controller_factory.h"
11 #include "ui/views/touchui/touch_selection_menu_runner_views.h"
17 ViewsDelegate
* views_delegate
= nullptr;
21 ViewsDelegate::~ViewsDelegate() {
22 ui::TouchEditingControllerFactory::SetInstance(nullptr);
24 DCHECK_EQ(this, views_delegate
);
25 views_delegate
= nullptr;
28 ViewsDelegate
* ViewsDelegate::GetInstance() {
29 return views_delegate
;
32 void ViewsDelegate::SaveWindowPlacement(const Widget
* widget
,
33 const std::string
& window_name
,
34 const gfx::Rect
& bounds
,
35 ui::WindowShowState show_state
) {
38 bool ViewsDelegate::GetSavedWindowPlacement(
40 const std::string
& window_name
,
42 ui::WindowShowState
* show_state
) const {
46 void ViewsDelegate::NotifyAccessibilityEvent(View
* view
,
47 ui::AXEvent event_type
) {
50 void ViewsDelegate::NotifyMenuItemFocused(const base::string16
& menu_name
,
51 const base::string16
& menu_item_name
,
58 HICON
ViewsDelegate::GetDefaultWindowIcon() const {
62 bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window
) const {
65 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
66 gfx::ImageSkia
* ViewsDelegate::GetDefaultWindowIcon() const {
71 NonClientFrameView
* ViewsDelegate::CreateDefaultNonClientFrameView(
76 void ViewsDelegate::AddRef() {
79 void ViewsDelegate::ReleaseRef() {
82 content::WebContents
* ViewsDelegate::CreateWebContents(
83 content::BrowserContext
* browser_context
,
84 content::SiteInstance
* site_instance
) {
88 base::TimeDelta
ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() {
89 return base::TimeDelta();
92 bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized
) {
96 ui::ContextFactory
* ViewsDelegate::GetContextFactory() {
100 std::string
ViewsDelegate::GetApplicationName() {
101 base::FilePath program
= base::CommandLine::ForCurrentProcess()->GetProgram();
102 return program
.BaseName().AsUTF8Unsafe();
106 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor
,
107 const base::Closure
& callback
) {
112 scoped_refptr
<base::TaskRunner
> ViewsDelegate::GetBlockingPoolTaskRunner() {
116 ViewsDelegate::ViewsDelegate()
117 : views_tsc_factory_(new ViewsTouchEditingControllerFactory
) {
118 DCHECK(!views_delegate
);
119 views_delegate
= this;
121 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_
.get());
123 #if defined(USE_AURA)
124 touch_selection_menu_runner_
.reset(new TouchSelectionMenuRunnerViews());