Continue deleting code in ui/.
This moves ui/base/hit_test.h into its one consumer,
services/window_manager/, and moves the only part of cursor.h that is
still used into platform_window.h.
BUG=443439
R=sky@chromium.org
Review URL: https://codereview.chromium.org/860873002
diff --git a/services/window_manager/BUILD.gn b/services/window_manager/BUILD.gn
index 9309721..97c1d6e 100644
--- a/services/window_manager/BUILD.gn
+++ b/services/window_manager/BUILD.gn
@@ -49,7 +49,6 @@
deps = [
"//base",
- "//ui/base",
"//ui/events",
"//ui/gfx",
"//ui/gfx/geometry",
diff --git a/ui/base/hit_test.h b/services/window_manager/hit_test.h
similarity index 77%
rename from ui/base/hit_test.h
rename to services/window_manager/hit_test.h
index a91ce89..93126c5 100644
--- a/ui/base/hit_test.h
+++ b/services/window_manager/hit_test.h
@@ -1,11 +1,9 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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 UI_BASE_HIT_TEST_H_
-#define UI_BASE_HIT_TEST_H_
-
-#if !defined(OS_WIN)
+#ifndef SERVICES_WINDOW_MANAGER_HIT_TEST_H_
+#define SERVICES_WINDOW_MANAGER_HIT_TEST_H_
// Defines the same symbolic names used by the WM_NCHITTEST Notification under
// win32 (the integer values are not guaranteed to be equivalent). We do this
@@ -40,6 +38,4 @@
HTZOOM
};
-#endif // !defined(OS_WIN)
-
-#endif // UI_BASE_HIT_TEST_H_
+#endif // SERVICES_WINDOW_MANAGER_HIT_TEST_H_
diff --git a/services/window_manager/window_manager_app.cc b/services/window_manager/window_manager_app.cc
index 56dbbc4..da49468 100644
--- a/services/window_manager/window_manager_app.cc
+++ b/services/window_manager/window_manager_app.cc
@@ -16,11 +16,11 @@
#include "services/window_manager/capture_controller.h"
#include "services/window_manager/focus_controller.h"
#include "services/window_manager/focus_rules.h"
+#include "services/window_manager/hit_test.h"
#include "services/window_manager/view_event_dispatcher.h"
#include "services/window_manager/view_target.h"
#include "services/window_manager/view_targeter.h"
#include "services/window_manager/window_manager_delegate.h"
-#include "ui/base/hit_test.h"
#include "ui/events/gestures/gesture_recognizer.h"
using mojo::ApplicationConnection;
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
index 3535e21..68a8ded 100644
--- a/ui/base/BUILD.gn
+++ b/ui/base/BUILD.gn
@@ -21,41 +21,7 @@
"android/window_android.h",
"android/window_android_compositor.h",
"android/window_android_observer.h",
- "cursor/cursor.h",
- "hit_test.h",
"ui_base_export.h",
- "ui_base_switches.cc",
- "ui_base_switches.h",
- "view_prop.cc",
- "view_prop.h",
- "win/accessibility_ids_win.h",
- "win/accessibility_misc_utils.cc",
- "win/accessibility_misc_utils.h",
- "win/atl_module.h",
- "win/foreground_helper.cc",
- "win/foreground_helper.h",
- "win/hidden_window.cc",
- "win/hidden_window.h",
- "win/hwnd_subclass.cc",
- "win/hwnd_subclass.h",
- "win/internal_constants.cc",
- "win/internal_constants.h",
- "win/lock_state.cc",
- "win/lock_state.h",
- "win/open_file_name_win.cc",
- "win/open_file_name_win.h",
- "win/message_box_win.cc",
- "win/message_box_win.h",
- "win/mouse_wheel_util.cc",
- "win/mouse_wheel_util.h",
- "win/scoped_ole_initializer.cc",
- "win/scoped_ole_initializer.h",
- "win/shell.cc",
- "win/shell.h",
- "win/touch_input.cc",
- "win/touch_input.h",
- "win/window_event_target.cc",
- "win/window_event_target.h",
]
defines = [ "UI_BASE_IMPLEMENTATION" ]
@@ -78,15 +44,6 @@
"//url",
]
- if (use_x11) {
- sources += [
- "x/x11_util.cc",
- "x/x11_util.h",
- "x/x11_util_internal.h",
- ]
- deps += [ "//ui/gfx/x" ]
- }
-
if (is_linux) {
configs += [
"//build/config/linux:fontconfig",
@@ -115,11 +72,6 @@
"dwmapi.lib",
"oleacc.lib",
]
- } else {
- sources -= [
- "view_prop.cc",
- "view_prop.h",
- ]
}
if (is_mac) {
@@ -181,10 +133,7 @@
"test/run_all_unittests.cc",
]
- sources += [
- "test/data/resource.h",
- "view_prop_unittest.cc",
- ]
+ sources += [ "test/data/resource.h" ]
deps = [
"//base",
@@ -203,11 +152,6 @@
]
if (is_win) {
- sources += [
- "win/hwnd_subclass_unittest.cc",
- "win/open_file_name_win_unittest.cc",
- ]
-
ldflags = [
"/DELAYLOAD:d2d1.dll",
"/DELAYLOAD:d3d10_1.dll",
diff --git a/ui/base/cursor/DEPS b/ui/base/cursor/DEPS
deleted file mode 100644
index de08167..0000000
--- a/ui/base/cursor/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+ui/ozone/public",
-]
diff --git a/ui/base/cursor/OWNERS b/ui/base/cursor/OWNERS
deleted file mode 100644
index c3e460e..0000000
--- a/ui/base/cursor/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-per-file *x11*=derat@chromium.org
diff --git a/ui/base/cursor/cursor.h b/ui/base/cursor/cursor.h
deleted file mode 100644
index 5e6a8fb..0000000
--- a/ui/base/cursor/cursor.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_CURSOR_CURSOR_H_
-#define UI_BASE_CURSOR_CURSOR_H_
-
-#include "build/build_config.h"
-#include "ui/base/ui_base_export.h"
-
-namespace gfx {
-class Point;
-class Size;
-}
-
-#if defined(OS_WIN)
-typedef struct HINSTANCE__* HINSTANCE;
-typedef struct HICON__* HICON;
-typedef HICON HCURSOR;
-#endif
-
-namespace ui {
-
-#if defined(OS_WIN)
-typedef ::HCURSOR PlatformCursor;
-#elif defined(USE_X11)
-typedef unsigned long PlatformCursor;
-#else
-typedef void* PlatformCursor;
-#endif
-
-} // namespace ui
-
-#endif // UI_BASE_CURSOR_CURSOR_H_
diff --git a/ui/base/ui_base_switches.cc b/ui/base/ui_base_switches.cc
deleted file mode 100644
index 2163397..0000000
--- a/ui/base/ui_base_switches.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/ui_base_switches.h"
-
-namespace switches {
-
-#if defined(OS_MACOSX) && !defined(OS_IOS)
-// Enable use of cross-process CALayers to display content directly from the
-// GPU process on Mac.
-const char kDisableRemoteCoreAnimation[] = "disable-remote-core-animation";
-#endif
-
-// Disables use of DWM composition for top level windows.
-const char kDisableDwmComposition[] = "disable-dwm-composition";
-
-// Disables an experimental focus manager to track text input clients.
-const char kDisableTextInputFocusManager[] = "disable-text-input-focus-manager";
-
-// Disables touch adjustment.
-const char kDisableTouchAdjustment[] = "disable-touch-adjustment";
-
-// Disables touch event based drag and drop.
-const char kDisableTouchDragDrop[] = "disable-touch-drag-drop";
-
-// Disables controls that support touch base text editing.
-const char kDisableTouchEditing[] = "disable-touch-editing";
-
-// Enables an experimental focus manager to track text input clients.
-const char kEnableTextInputFocusManager[] = "enable-text-input-focus-manager";
-
-// Enables touch event based drag and drop.
-const char kEnableTouchDragDrop[] = "enable-touch-drag-drop";
-
-// Enables controls that support touch base text editing.
-const char kEnableTouchEditing[] = "enable-touch-editing";
-
-// Enables additional visual feedback to touch input.
-const char kEnableTouchFeedback[] = "enable-touch-feedback";
-
-// The language file that we want to try to open. Of the form
-// language[-country] where language is the 2 letter code from ISO-639.
-const char kLang[] = "lang";
-
-// Disable ui::MessageBox. This is useful when running as part of scripts that
-// do not have a user interface.
-const char kNoMessageBox[] = "no-message-box";
-
-// On Windows only: requests that Chrome connect to the running Metro viewer
-// process.
-const char kViewerConnect[] = "connect-to-metro-viewer";
-
-} // namespace switches
diff --git a/ui/base/ui_base_switches.h b/ui/base/ui_base_switches.h
deleted file mode 100644
index 629f9af..0000000
--- a/ui/base/ui_base_switches.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2012 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.
-
-// Defines all the command-line switches used by ui/base.
-
-#ifndef UI_BASE_UI_BASE_SWITCHES_H_
-#define UI_BASE_UI_BASE_SWITCHES_H_
-
-#include "base/compiler_specific.h"
-#include "ui/base/ui_base_export.h"
-
-namespace switches {
-
-#if defined(OS_MACOSX) && !defined(OS_IOS)
-UI_BASE_EXPORT extern const char kDisableRemoteCoreAnimation[];
-#endif
-
-UI_BASE_EXPORT extern const char kDisableDwmComposition[];
-UI_BASE_EXPORT extern const char kDisableTextInputFocusManager[];
-UI_BASE_EXPORT extern const char kDisableTouchAdjustment[];
-UI_BASE_EXPORT extern const char kDisableTouchDragDrop[];
-UI_BASE_EXPORT extern const char kDisableTouchEditing[];
-UI_BASE_EXPORT extern const char kEnableTextInputFocusManager[];
-UI_BASE_EXPORT extern const char kEnableTouchDragDrop[];
-UI_BASE_EXPORT extern const char kEnableTouchEditing[];
-UI_BASE_EXPORT extern const char kEnableTouchFeedback[];
-UI_BASE_EXPORT extern const char kLang[];
-UI_BASE_EXPORT extern const char kNoMessageBox[];
-UI_BASE_EXPORT extern const char kViewerConnect[];
-
-} // namespace switches
-
-#endif // UI_BASE_UI_BASE_SWITCHES_H_
diff --git a/ui/base/view_prop.cc b/ui/base/view_prop.cc
deleted file mode 100644
index cb58553..0000000
--- a/ui/base/view_prop.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (c) 2011 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 "ui/base/view_prop.h"
-
-#include <set>
-
-namespace ui {
-
-// Maints the actual view, key and data.
-class ViewProp::Data : public base::RefCounted<ViewProp::Data> {
- public:
- // Returns the Data* for the view/key pair. If |create| is false and |Get|
- // has not been invoked for the view/key pair, NULL is returned.
- static void Get(gfx::AcceleratedWidget view,
- const char* key,
- bool create,
- scoped_refptr<Data>* data) {
- if (!data_set_)
- data_set_ = new DataSet;
- scoped_refptr<Data> new_data(new Data(view, key));
- DataSet::const_iterator i = data_set_->find(new_data.get());
- if (i != data_set_->end()) {
- *data = *i;
- return;
- }
- if (!create)
- return;
- data_set_->insert(new_data.get());
- *data = new_data.get();
- }
-
- // The data.
- void set_data(void* data) { data_ = data; }
- void* data() const { return data_; }
-
- const char* key() const { return key_; }
-
- private:
- friend class base::RefCounted<Data>;
-
- // Used to order the Data in the map.
- class DataComparator {
- public:
- bool operator()(const Data* d1, const Data* d2) const {
- return (d1->view_ == d2->view_) ? (d1->key_ < d2->key_) :
- (d1->view_ < d2->view_);
- }
- };
-
- typedef std::set<Data*, DataComparator> DataSet;
-
- Data(gfx::AcceleratedWidget view, const char* key)
- : view_(view),
- key_(key),
- data_(NULL) {}
-
- ~Data() {
- DataSet::iterator i = data_set_->find(this);
- // Also check for equality using == as |Get| creates dummy values in order
- // to look up a value.
- if (i != data_set_->end() && *i == this)
- data_set_->erase(i);
- }
-
- // The existing set of Data is stored here. ~Data removes from the set.
- static DataSet* data_set_;
-
- const gfx::AcceleratedWidget view_;
- const char* key_;
- void* data_;
-
- DISALLOW_COPY_AND_ASSIGN(Data);
-};
-
-// static
-ViewProp::Data::DataSet* ViewProp::Data::data_set_ = NULL;
-
-ViewProp::ViewProp(gfx::AcceleratedWidget view, const char* key, void* data) {
- Data::Get(view, key, true, &data_);
- data_->set_data(data);
-}
-
-ViewProp::~ViewProp() {
- // This is done to provide similar semantics to SetProp. In particular it's
- // assumed that ~ViewProp should behave as though RemoveProp was invoked.
- data_->set_data(NULL);
-}
-
-// static
-void* ViewProp::GetValue(gfx::AcceleratedWidget view, const char* key) {
- scoped_refptr<Data> data;
- Data::Get(view, key, false, &data);
- return data.get() ? data->data() : NULL;
-}
-
-// static
-const char* ViewProp::Key() const {
- return data_->key();
-}
-
-} // namespace ui
diff --git a/ui/base/view_prop.h b/ui/base/view_prop.h
deleted file mode 100644
index f042962..0000000
--- a/ui/base/view_prop.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2011 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 UI_BASE_VIEW_PROP_H_
-#define UI_BASE_VIEW_PROP_H_
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "ui/base/ui_base_export.h"
-#include "ui/gfx/native_widget_types.h"
-
-#if !defined(OS_WIN)
-#error view_prop.h is only for windows builds.
-#endif
-
-namespace ui {
-
-// ViewProp maintains a key/value pair for a particular view. ViewProp is
-// designed as a replacement for the Win32's SetProp, but does not make use of
-// window manager memory. ViewProp shares similar semantics as SetProp, the
-// value for a particular view/key pair comes from the last ViewProp created.
-class UI_BASE_EXPORT ViewProp {
- public:
- // Associates data with a view/key pair. If a ViewProp has already been
- // created for the specified pair |data| replaces the current value.
- //
- // ViewProp does *not* make a copy of the char*, the pointer is used for
- // sorting.
- ViewProp(gfx::AcceleratedWidget view, const char* key, void* data);
- ~ViewProp();
-
- // Returns the value associated with the view/key pair, or NULL if there is
- // none.
- static void* GetValue(gfx::AcceleratedWidget view, const char* key);
-
- // Returns the key.
- const char* Key() const;
-
- private:
- class Data;
-
- // Stores the actual data.
- scoped_refptr<Data> data_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewProp);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_VIEW_PROP_H_
diff --git a/ui/base/view_prop_unittest.cc b/ui/base/view_prop_unittest.cc
deleted file mode 100644
index d369c94..0000000
--- a/ui/base/view_prop_unittest.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "ui/base/view_prop.h"
-
-namespace {
-const char kKey1[] = "key_1";
-const char kKey2[] = "key_2";
-} // namespace
-
-namespace ui {
-
-// Test a handful of viewprop assertions.
-TEST(ViewPropTest, Basic) {
- gfx::AcceleratedWidget nv1 = reinterpret_cast<gfx::AcceleratedWidget>(1);
- gfx::AcceleratedWidget nv2 = reinterpret_cast<gfx::AcceleratedWidget>(2);
-
- void* data1 = reinterpret_cast<void*>(11);
- void* data2 = reinterpret_cast<void*>(12);
-
- // Initial value for a new view/key pair should be NULL.
- EXPECT_EQ(NULL, ViewProp::GetValue(nv1, kKey1));
-
- {
- // Register a value for a view/key pair.
- ViewProp prop(nv1, kKey1, data1);
- EXPECT_EQ(data1, ViewProp::GetValue(nv1, kKey1));
- }
-
- // The property fell out of scope, so the value should now be NULL.
- EXPECT_EQ(NULL, ViewProp::GetValue(nv1, kKey1));
-
- {
- // Register a value for a view/key pair.
- scoped_ptr<ViewProp> v1(new ViewProp(nv1, kKey1, data1));
- EXPECT_EQ(data1, ViewProp::GetValue(nv1, kKey1));
-
- // Register a value for the same view/key pair.
- scoped_ptr<ViewProp> v2(new ViewProp(nv1, kKey1, data2));
- // The new value should take over.
- EXPECT_EQ(data2, ViewProp::GetValue(nv1, kKey1));
-
- // Null out the first ViewProp, which should NULL out the value.
- v1.reset(NULL);
- EXPECT_EQ(NULL, ViewProp::GetValue(nv1, kKey1));
- }
-
- // The property fell out of scope, so the value should now be NULL.
- EXPECT_EQ(NULL, ViewProp::GetValue(nv1, kKey1));
-
- {
- // Register a value for a view/key pair.
- scoped_ptr<ViewProp> v1(new ViewProp(nv1, kKey1, data1));
- scoped_ptr<ViewProp> v2(new ViewProp(nv2, kKey2, data2));
- EXPECT_EQ(data1, ViewProp::GetValue(nv1, kKey1));
- EXPECT_EQ(data2, ViewProp::GetValue(nv2, kKey2));
-
- v1.reset(NULL);
- EXPECT_EQ(NULL, ViewProp::GetValue(nv1, kKey1));
- EXPECT_EQ(data2, ViewProp::GetValue(nv2, kKey2));
-
- v2.reset(NULL);
- EXPECT_EQ(NULL, ViewProp::GetValue(nv1, kKey1));
- EXPECT_EQ(NULL, ViewProp::GetValue(nv2, kKey2));
- }
-}
-
-} // namespace ui
diff --git a/ui/base/win/accessibility_ids_win.h b/ui/base/win/accessibility_ids_win.h
deleted file mode 100644
index af8041c..0000000
--- a/ui/base/win/accessibility_ids_win.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2013 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 UI_BASE_WIN_ACCESSIBILITY_IDS_WIN_H_
-#define UI_BASE_WIN_ACCESSIBILITY_IDS_WIN_H_
-
-namespace base {
-namespace win {
-
-// Windows accessibility (MSAA) notifications are posted on an
-// accessible object using its owning HWND and a long integer child id.
-// Positive child ids can be used to enumerate the children of an object,
-// so in Chromium we use only negative values to represent ids of specific
-// accessible objects.
-//
-// Chromium currently has two separate systems that use accessibility ids:
-// * views (ui/views/accessibility), and
-// * web (content/browser/accessibility)
-//
-// These constants ensure they use non-overlapping id ranges.
-
-const long kFirstViewsAccessibilityId = -1;
-const long kLastViewsAccessibilityId = -999;
-const long kFirstBrowserAccessibilityManagerAccessibilityId = -1000;
-const long kLastBrowserAccessibilityManagerAccessibilityId = INT_MIN;
-
-} // win
-} // base
-
-#endif // UI_BASE_WIN_ACCESSIBILITY_IDS_WIN_H_
diff --git a/ui/base/win/accessibility_misc_utils.cc b/ui/base/win/accessibility_misc_utils.cc
deleted file mode 100644
index 621048f..0000000
--- a/ui/base/win/accessibility_misc_utils.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/accessibility_misc_utils.h"
-
-#include "base/logging.h"
-#include "ui/base/win/atl_module.h"
-
-namespace base {
-namespace win {
-
-// UIA TextProvider implementation.
-UIATextProvider::UIATextProvider()
- : editable_(false) {}
-
-// static
-bool UIATextProvider::CreateTextProvider(const string16& value,
- bool editable,
- IUnknown** provider) {
- // Make sure ATL is initialized in this module.
- ui::win::CreateATLModuleIfNeeded();
-
- CComObject<UIATextProvider>* text_provider = NULL;
- HRESULT hr = CComObject<UIATextProvider>::CreateInstance(&text_provider);
- if (SUCCEEDED(hr)) {
- DCHECK(text_provider);
- text_provider->set_editable(editable);
- text_provider->set_value(value);
- text_provider->AddRef();
- *provider = static_cast<ITextProvider*>(text_provider);
- return true;
- }
- return false;
-}
-
-STDMETHODIMP UIATextProvider::get_IsReadOnly(BOOL* read_only) {
- *read_only = !editable_;
- return S_OK;
-}
-
-STDMETHODIMP UIATextProvider::get_Value(BSTR* value) {
- *value = SysAllocString(value_.c_str());
- return S_OK;
-}
-
-} // namespace win
-} // namespace base
diff --git a/ui/base/win/accessibility_misc_utils.h b/ui/base/win/accessibility_misc_utils.h
deleted file mode 100644
index e17f1d3..0000000
--- a/ui/base/win/accessibility_misc_utils.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_WIN_ACCESSIBILITY_MISC_UTILS_H_
-#define UI_BASE_WIN_ACCESSIBILITY_MISC_UTILS_H_
-
-#include <atlbase.h>
-#include <atlcom.h>
-#include <UIAutomationCore.h>
-
-#include "base/compiler_specific.h"
-#include "base/strings/string16.h"
-#include "ui/base/ui_base_export.h"
-
-namespace base {
-namespace win {
-
- // UIA Text provider implementation for edit controls.
-class UI_BASE_EXPORT UIATextProvider
- : public NON_EXPORTED_BASE(CComObjectRootEx<CComMultiThreadModel>),
- public IValueProvider,
- public ITextProvider {
- public:
- BEGIN_COM_MAP(UIATextProvider)
- COM_INTERFACE_ENTRY2(IUnknown, ITextProvider)
- COM_INTERFACE_ENTRY(IValueProvider)
- COM_INTERFACE_ENTRY(ITextProvider)
- END_COM_MAP()
-
- UIATextProvider();
-
- // Creates an instance of the UIATextProvider class.
- // Returns true on success
- static bool CreateTextProvider(const string16& value,
- bool editable,
- IUnknown** provider);
-
- void set_editable(bool editable) {
- editable_ = editable;
- }
-
- void set_value(const string16& value) { value_ = value; }
-
- //
- // IValueProvider methods.
- //
- STDMETHOD(get_IsReadOnly)(BOOL* read_only);
-
- //
- // IValueProvider methods not implemented.
- //
- STDMETHOD(SetValue)(const wchar_t* val) {
- return E_NOTIMPL;
- }
-
- STDMETHOD(get_Value)(BSTR* value);
-
- //
- // ITextProvider methods.
- //
- STDMETHOD(GetSelection)(SAFEARRAY** ret) {
- return E_NOTIMPL;
- }
-
- STDMETHOD(GetVisibleRanges)(SAFEARRAY** ret) {
- return E_NOTIMPL;
- }
-
- STDMETHOD(RangeFromChild)(IRawElementProviderSimple* child,
- ITextRangeProvider** ret) {
- return E_NOTIMPL;
- }
-
- STDMETHOD(RangeFromPoint)(struct UiaPoint point,
- ITextRangeProvider** ret) {
- return E_NOTIMPL;
- }
-
- STDMETHOD(get_DocumentRange)(ITextRangeProvider** ret) {
- return E_NOTIMPL;
- }
-
- STDMETHOD(get_SupportedTextSelection)(enum SupportedTextSelection* ret) {
- return E_NOTIMPL;
- }
-
- private:
- bool editable_;
- string16 value_;
-};
-
-} // win
-} // base
-
-#endif // UI_BASE_WIN_ACCESSIBILITY_MISC_UTILS_H_
diff --git a/ui/base/win/atl_module.h b/ui/base/win/atl_module.h
deleted file mode 100644
index 1d1adb4..0000000
--- a/ui/base/win/atl_module.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2011 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 UI_BASE_WIN_ATL_MODULE_H_
-#define UI_BASE_WIN_ATL_MODULE_H_
-
-#include <atlbase.h>
-#include <atlcom.h>
-
-#include "base/basictypes.h"
-
-namespace ui {
-namespace win {
-
-// Ensure that we have exactly one ATL module registered. It's safe to
-// call this more than once. ATL functions will crash if there's no
-// ATL module registered, or if you try to register two of them, so
-// dynamically registering one if needed makes it much easier for us
-// to support different build configurations like multi-dll without
-// worrying about which side of a module boundary each ATL module object
-// belongs on.
-//
-// This function must be implemented in this header file rather than a
-// source file so that it's inlined into the module where it's included,
-// rather than in the "ui" module.
-static void CreateATLModuleIfNeeded() {
- if (_pAtlModule == NULL) {
- // This creates the module and automatically updates _pAtlModule.
- CR_DEFINE_STATIC_LOCAL(CComModule, module, ());
- }
-}
-
-} // namespace win
-} // namespace ui
-
-#endif // UI_BASE_WIN_ATL_MODULE_H_
diff --git a/ui/base/win/foreground_helper.cc b/ui/base/win/foreground_helper.cc
deleted file mode 100644
index 7283012..0000000
--- a/ui/base/win/foreground_helper.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/foreground_helper.h"
-
-#include "base/logging.h"
-#include "ui/gfx/win/window_impl.h"
-
-namespace ui {
-
-// static
-HRESULT ForegroundHelper::SetForeground(HWND window) {
- DCHECK(::IsWindow(window));
- ForegroundHelper foreground_helper;
- return foreground_helper.ForegroundHotKey(window);
-}
-
-HRESULT ForegroundHelper::ForegroundHotKey(HWND window) {
- // This implementation registers a hot key (F22) and then
- // triggers the hot key. When receiving the hot key, we'll
- // be in the foreground and allowed to move the target window
- // into the foreground too.
-
- set_window_style(WS_POPUP);
- Init(NULL, gfx::Rect());
-
- static const int kHotKeyId = 0x0000baba;
- static const int kHotKeyWaitTimeout = 2000;
-
- // Store the target window into our USERDATA for use in our
- // HotKey handler.
- window_ = window;
- RegisterHotKey(hwnd(), kHotKeyId, 0, VK_F22);
-
- // If the calling thread is not yet a UI thread, call PeekMessage
- // to ensure creation of its message queue.
- MSG msg = {0};
- PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
-
- // Send the Hotkey.
- INPUT hotkey = {0};
- hotkey.type = INPUT_KEYBOARD;
- hotkey.ki.wVk = VK_F22;
- if (1 != SendInput(1, &hotkey, sizeof(hotkey))) {
- LOG(WARNING) << "Failed to send input; GetLastError(): " << GetLastError();
- return E_FAIL;
- }
-
- // There are scenarios where the WM_HOTKEY is not dispatched by the
- // the corresponding foreground thread. To prevent us from indefinitely
- // waiting for the hotkey, we set a timer and exit the loop.
- SetTimer(hwnd(), kHotKeyId, kHotKeyWaitTimeout, NULL);
-
- // Loop until we get the key or the timer fires.
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
-
- if (WM_HOTKEY == msg.message)
- break;
- if (WM_TIMER == msg.message) {
- SetForegroundWindow(window);
- break;
- }
- }
-
- UnregisterHotKey(hwnd(), kHotKeyId);
- KillTimer(hwnd(), kHotKeyId);
- DestroyWindow(hwnd());
-
- return S_OK;
-}
-
-// Handle the registered Hotkey being pressed.
-void ForegroundHelper::OnHotKey(int id, UINT vcode, UINT modifiers) {
- SetForegroundWindow(window_);
-}
-
-} // namespace ui
diff --git a/ui/base/win/foreground_helper.h b/ui/base/win/foreground_helper.h
deleted file mode 100644
index 8387c13..0000000
--- a/ui/base/win/foreground_helper.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_WIN_FOREGROUND_HELPER_H_
-#define UI_BASE_WIN_FOREGROUND_HELPER_H_
-
-#include "base/logging.h"
-#include "ui/base/ui_base_export.h"
-#include "ui/gfx/win/window_impl.h"
-
-namespace ui {
-
-// Helper class for moving a window to the foreground.
-// Windows XP and later will not allow a window which is in the background to
-// move to the foreground, unless requested by the current window in the
-// foreground. For automated testing, we really want some of our windows
-// to be capable of moving to the foreground.
-//
-// This is probably leveraging a windows bug.
-class UI_BASE_EXPORT ForegroundHelper : public gfx::WindowImpl {
- public:
- ForegroundHelper() : window_(NULL) { }
-
- CR_BEGIN_MSG_MAP_EX(ForegroundHelper)
- CR_MSG_WM_HOTKEY(OnHotKey)
- CR_END_MSG_MAP()
-
- // Brings a window into the foreground.
- // Can be called from any window, even if the caller is not the
- // foreground window.
- static HRESULT SetForeground(HWND window);
-
- private:
- HRESULT ForegroundHotKey(HWND window);
-
- // Handle the registered Hotkey being pressed.
- void OnHotKey(int id, UINT vcode, UINT modifiers);
-
- HWND window_;
-
- DISALLOW_COPY_AND_ASSIGN(ForegroundHelper);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_FOREGROUND_HELPER_H_
diff --git a/ui/base/win/hidden_window.cc b/ui/base/win/hidden_window.cc
deleted file mode 100644
index d04f2a3..0000000
--- a/ui/base/win/hidden_window.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/hidden_window.h"
-
-#include "ui/gfx/win/window_impl.h"
-
-namespace ui {
-
-namespace {
-
-// We need to have a parent window for the compositing code to work correctly.
-//
-// A tab will not have a parent HWND whenever it is not active in its
-// host window - for example at creation time and when it's in the
-// background, so we provide a default widget to host them.
-//
-// It may be tempting to use GetDesktopWindow() instead, but this is
-// problematic as the shell sends messages to children of the desktop
-// window that interact poorly with us.
-//
-// See: http://crbug.com/16476
-class TempParent : public gfx::WindowImpl {
- public:
- static TempParent* Get() {
- static TempParent* g_temp_parent;
- if (!g_temp_parent) {
- g_temp_parent = new TempParent();
-
- g_temp_parent->set_window_style(WS_POPUP);
- g_temp_parent->set_window_ex_style(WS_EX_TOOLWINDOW);
- g_temp_parent->Init(GetDesktopWindow(), gfx::Rect());
- EnableWindow(g_temp_parent->hwnd(), FALSE);
- }
- return g_temp_parent;
- }
-
- private:
- // Explicitly do nothing in Close. We do this as some external apps may get a
- // handle to this window and attempt to close it.
- void OnClose() {
- }
-
- CR_BEGIN_MSG_MAP_EX(WebContentsViewWin)
- CR_MSG_WM_CLOSE(OnClose)
- CR_END_MSG_MAP()
-};
-
-} // namespace
-
-HWND GetHiddenWindow() {
- return TempParent::Get()->hwnd();
-}
-
-} // namespace ui
diff --git a/ui/base/win/hidden_window.h b/ui/base/win/hidden_window.h
deleted file mode 100644
index 6cc2fd0..0000000
--- a/ui/base/win/hidden_window.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_WIN_HIDDEN_WINDOW_H_
-#define UI_BASE_WIN_HIDDEN_WINDOW_H_
-
-#include <windows.h>
-
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// Returns an HWND that can be used as a temporary parent. The returned HWND is
-// never destroyed.
-UI_BASE_EXPORT HWND GetHiddenWindow();
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_HIDDEN_WINDOW_H_
diff --git a/ui/base/win/hwnd_subclass.cc b/ui/base/win/hwnd_subclass.cc
deleted file mode 100644
index 8628a7c..0000000
--- a/ui/base/win/hwnd_subclass.cc
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/hwnd_subclass.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/singleton.h"
-#include "ui/gfx/win/dpi.h"
-#include "ui/gfx/win/hwnd_util.h"
-
-namespace {
-const char kHWNDSubclassKey[] = "__UI_BASE_WIN_HWND_SUBCLASS_PROC__";
-
-LRESULT CALLBACK WndProc(HWND hwnd,
- UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- ui::HWNDSubclass* wrapped_wnd_proc =
- reinterpret_cast<ui::HWNDSubclass*>(
- ui::ViewProp::GetValue(hwnd, kHWNDSubclassKey));
- return wrapped_wnd_proc ? wrapped_wnd_proc->OnWndProc(hwnd,
- message,
- w_param,
- l_param)
- : DefWindowProc(hwnd, message, w_param, l_param);
-}
-
-WNDPROC GetCurrentWndProc(HWND target) {
- return reinterpret_cast<WNDPROC>(GetWindowLongPtr(target, GWLP_WNDPROC));
-}
-
-// Not defined before Win7
-BOOL GetTouchInputInfoWrapper(HTOUCHINPUT handle, UINT count,
- PTOUCHINPUT pointer, int size) {
- typedef BOOL(WINAPI *GetTouchInputInfoPtr)(HTOUCHINPUT, UINT,
- PTOUCHINPUT, int);
- GetTouchInputInfoPtr get_touch_input_info_func =
- reinterpret_cast<GetTouchInputInfoPtr>(
- GetProcAddress(GetModuleHandleA("user32.dll"), "GetTouchInputInfo"));
- if (get_touch_input_info_func)
- return get_touch_input_info_func(handle, count, pointer, size);
- return FALSE;
-}
-
-} // namespace
-
-namespace ui {
-
-// Singleton factory that creates and manages the lifetime of all
-// ui::HWNDSubclass objects.
-class HWNDSubclass::HWNDSubclassFactory {
- public:
- static HWNDSubclassFactory* GetInstance() {
- return Singleton<HWNDSubclassFactory,
- LeakySingletonTraits<HWNDSubclassFactory> >::get();
- }
-
- // Returns a non-null HWNDSubclass corresponding to the HWND |target|. Creates
- // one if none exists. Retains ownership of the returned pointer.
- HWNDSubclass* GetHwndSubclassForTarget(HWND target) {
- DCHECK(target);
- HWNDSubclass* subclass = reinterpret_cast<HWNDSubclass*>(
- ui::ViewProp::GetValue(target, kHWNDSubclassKey));
- if (!subclass) {
- subclass = new ui::HWNDSubclass(target);
- hwnd_subclasses_.push_back(subclass);
- }
- return subclass;
- }
-
- const ScopedVector<HWNDSubclass>& hwnd_subclasses() {
- return hwnd_subclasses_;
- }
-
- private:
- friend struct DefaultSingletonTraits<HWNDSubclassFactory>;
-
- HWNDSubclassFactory() {}
-
- ScopedVector<HWNDSubclass> hwnd_subclasses_;
-
- DISALLOW_COPY_AND_ASSIGN(HWNDSubclassFactory);
-};
-
-// static
-void HWNDSubclass::AddFilterToTarget(HWND target, HWNDMessageFilter* filter) {
- HWNDSubclassFactory::GetInstance()->GetHwndSubclassForTarget(
- target)->AddFilter(filter);
-}
-
-// static
-void HWNDSubclass::RemoveFilterFromAllTargets(HWNDMessageFilter* filter) {
- HWNDSubclassFactory* factory = HWNDSubclassFactory::GetInstance();
- ScopedVector<ui::HWNDSubclass>::const_iterator it;
- for (it = factory->hwnd_subclasses().begin();
- it != factory->hwnd_subclasses().end(); ++it)
- (*it)->RemoveFilter(filter);
-}
-
-// static
-HWNDSubclass* HWNDSubclass::GetHwndSubclassForTarget(HWND target) {
- return HWNDSubclassFactory::GetInstance()->GetHwndSubclassForTarget(target);
-}
-
-void HWNDSubclass::AddFilter(HWNDMessageFilter* filter) {
- DCHECK(filter);
- if (std::find(filters_.begin(), filters_.end(), filter) == filters_.end())
- filters_.push_back(filter);
-}
-
-void HWNDSubclass::RemoveFilter(HWNDMessageFilter* filter) {
- std::vector<HWNDMessageFilter*>::iterator it =
- std::find(filters_.begin(), filters_.end(), filter);
- if (it != filters_.end())
- filters_.erase(it);
-}
-
-HWNDSubclass::HWNDSubclass(HWND target)
- : target_(target),
- original_wnd_proc_(GetCurrentWndProc(target)),
- prop_(target, kHWNDSubclassKey, this) {
- gfx::SetWindowProc(target_, &WndProc);
-}
-
-HWNDSubclass::~HWNDSubclass() {
-}
-
-LRESULT HWNDSubclass::OnWndProc(HWND hwnd,
- UINT message,
- WPARAM w_param,
- LPARAM l_param) {
-
- // Touch messages are always passed in screen coordinates. If the OS is
- // scaled, but the app is not DPI aware, then then WM_TOUCH might be
- // intended for a different window.
- if (message == WM_TOUCH) {
- TOUCHINPUT point;
-
- if (GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), 1,
- &point, sizeof(TOUCHINPUT))) {
- POINT touch_location = {TOUCH_COORD_TO_PIXEL(point.x),
- TOUCH_COORD_TO_PIXEL(point.y)};
- HWND actual_target = WindowFromPoint(touch_location);
- if (actual_target != hwnd) {
- return SendMessage(actual_target, message, w_param, l_param);
- }
- }
- }
-
- for (std::vector<HWNDMessageFilter*>::iterator it = filters_.begin();
- it != filters_.end(); ++it) {
- LRESULT l_result = 0;
- if ((*it)->FilterMessage(hwnd, message, w_param, l_param, &l_result))
- return l_result;
- }
-
- // In most cases, |original_wnd_proc_| will take care of calling
- // DefWindowProc.
- return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param);
-}
-
-HWNDMessageFilter::~HWNDMessageFilter() {
- HWNDSubclass::RemoveFilterFromAllTargets(this);
-}
-
-} // namespace ui
diff --git a/ui/base/win/hwnd_subclass.h b/ui/base/win/hwnd_subclass.h
deleted file mode 100644
index 0a371cb..0000000
--- a/ui/base/win/hwnd_subclass.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_WIN_HWND_SUBCLASS_H_
-#define UI_BASE_WIN_HWND_SUBCLASS_H_
-
-#include <windows.h>
-#include <vector>
-
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "ui/base/ui_base_export.h"
-#include "ui/base/view_prop.h"
-
-namespace ui {
-
-// Classes implementing this interface get the opportunity to handle and consume
-// messages before they are sent to their target HWND.
-class UI_BASE_EXPORT HWNDMessageFilter {
- public:
- virtual ~HWNDMessageFilter();
-
- // A derived class overrides this method to perform filtering of the messages.
- // Return true to prevent other HWNDMessageFilter's of the target HWND and the
- // system message handler |original_wnd_proc_| from receiving the message.
- // Return false to propagate the message further to other HWNDMessageFilters
- // and eventually to |original_wnd_proc|.
- // The order in which HWNDMessageFilters are added in HWNDSubclass::AddFilter
- // determines which filter gets to see the message first (a filter added first
- // will see the message first).
- virtual bool FilterMessage(HWND hwnd,
- UINT message,
- WPARAM w_param,
- LPARAM l_param,
- LRESULT* l_result) = 0;
-};
-
-// An object that instance-subclasses a window. If the window has already been
-// instance-subclassed, that subclassing is lost.
-class UI_BASE_EXPORT HWNDSubclass {
- public:
- ~HWNDSubclass();
-
- // Adds |filter| to the HWNDSubclass of |target|. Caller retains ownership of
- // |filter|. See the comment about the order in which filters are added in
- // HWNDMessageFilter::FilterMessage.
- static void AddFilterToTarget(HWND target, HWNDMessageFilter* filter);
-
- // Removes |filter| from any HWNDSubclass that has it.
- static void RemoveFilterFromAllTargets(HWNDMessageFilter* filter);
-
- // Returns a non-null HWNDSubclass corresponding to the HWND |target|. Creates
- // one if none exists. Retains ownership of the returned pointer.
- static HWNDSubclass* GetHwndSubclassForTarget(HWND target);
-
- // Adds |filter| if not already added to this HWNDSubclass. Caller retains
- // ownership of |filter|. See the comment about the order in which filters are
- // added in HWNDMessageFilter::FilterMessage.
- void AddFilter(HWNDMessageFilter* filter);
-
- // Removes |filter| from this HWNDSubclass instance if present.
- void RemoveFilter(HWNDMessageFilter* filter);
-
- LRESULT OnWndProc(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param);
-
- private:
- class HWNDSubclassFactory;
- friend class HWNDSubclassFactory;
-
- explicit HWNDSubclass(HWND target);
-
- HWND target_;
- std::vector<HWNDMessageFilter*> filters_;
- WNDPROC original_wnd_proc_;
- ui::ViewProp prop_;
-
- DISALLOW_COPY_AND_ASSIGN(HWNDSubclass);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_HWND_SUBCLASS_H_
diff --git a/ui/base/win/hwnd_subclass_unittest.cc b/ui/base/win/hwnd_subclass_unittest.cc
deleted file mode 100644
index b037db9..0000000
--- a/ui/base/win/hwnd_subclass_unittest.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/hwnd_subclass.h"
-
-#include "base/basictypes.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/win/window_impl.h"
-
-namespace ui {
-
-namespace {
-
-class TestWindow : public gfx::WindowImpl {
- public:
- TestWindow() : saw_message(false) {}
- virtual ~TestWindow() {}
-
- bool saw_message;
-
- private:
- // Overridden from gfx::WindowImpl:
- virtual BOOL ProcessWindowMessage(HWND window,
- UINT message,
- WPARAM w_param,
- LPARAM l_param,
- LRESULT& result,
- DWORD msg_map_id) override {
- if (message == WM_NCHITTEST)
- saw_message = true;
-
- return FALSE; // Results in DefWindowProc().
- }
-
- DISALLOW_COPY_AND_ASSIGN(TestWindow);
-};
-
-class TestMessageFilter : public HWNDMessageFilter {
- public:
- TestMessageFilter() : consume_messages(false), saw_message(false) {}
- virtual ~TestMessageFilter() {}
-
- // Setting to true causes the filter subclass to stop messages from reaching
- // the subclassed window procedure.
- bool consume_messages;
-
- // True if the message filter saw the message.
- bool saw_message;
-
- private:
- // Overridden from HWNDMessageFilter:
- virtual bool FilterMessage(HWND hwnd,
- UINT message,
- WPARAM w_param,
- LPARAM l_param,
- LRESULT* l_result) override {
- if (message == WM_NCHITTEST) {
- saw_message = true;
- return consume_messages;
- }
- return false;
- }
-
- DISALLOW_COPY_AND_ASSIGN(TestMessageFilter);
-};
-
-} // namespace
-
-TEST(HWNDSubclassTest, Filtering) {
- TestWindow window;
- window.Init(NULL, gfx::Rect(0, 0, 100, 100));
- EXPECT_TRUE(window.hwnd() != NULL);
-
- {
- TestMessageFilter mf;
- HWNDSubclass::AddFilterToTarget(window.hwnd(), &mf);
-
- // We are not filtering, so both the filter and the window should receive
- // this message:
- ::SendMessage(window.hwnd(), WM_NCHITTEST, 0, 0);
-
- EXPECT_TRUE(mf.saw_message);
- EXPECT_TRUE(window.saw_message);
-
- mf.saw_message = false;
- window.saw_message = false;
-
- mf.consume_messages = true;
-
- // We are now filtering, so only the filter should see this message:
- ::SendMessage(window.hwnd(), WM_NCHITTEST, 0, 0);
-
- EXPECT_TRUE(mf.saw_message);
- EXPECT_FALSE(window.saw_message);
- }
-}
-
-TEST(HWNDSubclassTest, FilteringMultipleFilters) {
- TestWindow window;
- window.Init(NULL, gfx::Rect(0, 0, 100, 100));
- EXPECT_TRUE(window.hwnd() != NULL);
-
- {
- TestMessageFilter mf1;
- TestMessageFilter mf2;
- HWNDSubclass::AddFilterToTarget(window.hwnd(), &mf1);
- HWNDSubclass::AddFilterToTarget(window.hwnd(), &mf2);
-
- // We are not filtering, so both the filter and the window should receive
- // this message:
- ::SendMessage(window.hwnd(), WM_NCHITTEST, 0, 0);
-
- EXPECT_TRUE(mf1.saw_message);
- EXPECT_TRUE(mf2.saw_message);
- EXPECT_TRUE(window.saw_message);
-
- mf1.saw_message = false;
- mf2.saw_message = false;
- window.saw_message = false;
-
- mf1.consume_messages = true;
-
- // We are now filtering, so only the filter |mf1| should see this message:
- ::SendMessage(window.hwnd(), WM_NCHITTEST, 0, 0);
-
- EXPECT_TRUE(mf1.saw_message);
- EXPECT_FALSE(mf2.saw_message);
- EXPECT_FALSE(window.saw_message);
- }
-}
-
-TEST(HWNDSubclassTest, RemoveFilter) {
- TestWindow window;
- window.Init(NULL, gfx::Rect(0, 0, 100, 100));
- EXPECT_TRUE(window.hwnd() != NULL);
-
- {
- TestMessageFilter mf1;
- TestMessageFilter mf2;
- HWNDSubclass::AddFilterToTarget(window.hwnd(), &mf1);
- HWNDSubclass::AddFilterToTarget(window.hwnd(), &mf2);
-
- ::SendMessage(window.hwnd(), WM_NCHITTEST, 0, 0);
- EXPECT_TRUE(mf1.saw_message);
- EXPECT_TRUE(mf2.saw_message);
- EXPECT_TRUE(window.saw_message);
-
- mf1.saw_message = false;
- mf2.saw_message = false;
- window.saw_message = false;
-
- // Remove a filter and try sending message again.
- HWNDSubclass::RemoveFilterFromAllTargets(&mf1);
- ::SendMessage(window.hwnd(), WM_NCHITTEST, 0, 0);
- EXPECT_FALSE(mf1.saw_message);
- EXPECT_TRUE(mf2.saw_message);
- EXPECT_TRUE(window.saw_message);
- }
-}
-
-} // namespace ui
diff --git a/ui/base/win/internal_constants.cc b/ui/base/win/internal_constants.cc
deleted file mode 100644
index 325ab90..0000000
--- a/ui/base/win/internal_constants.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2014 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 "ui/base/win/internal_constants.h"
-
-namespace ui {
-
-const wchar_t kIgnoreTouchMouseActivateForWindow[] =
- L"Chrome.IgnoreMouseActivate";
-
-} // namespace ui
-
diff --git a/ui/base/win/internal_constants.h b/ui/base/win/internal_constants.h
deleted file mode 100644
index d81c34d..0000000
--- a/ui/base/win/internal_constants.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2014 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 UI_BASE_WIN_INTERNAL_CONSTANTS_H_
-#define UI_BASE_WIN_INTERNAL_CONSTANTS_H_
-
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// This window property if set on the window does not activate the window for a
-// touch based WM_MOUSEACTIVATE message.
-UI_BASE_EXPORT extern const wchar_t kIgnoreTouchMouseActivateForWindow[];
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_INTERNAL_CONSTANTS_H_
-
-
diff --git a/ui/base/win/lock_state.cc b/ui/base/win/lock_state.cc
deleted file mode 100644
index c56eae4..0000000
--- a/ui/base/win/lock_state.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2014 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 "ui/base/win/lock_state.h"
-
-#include <windows.h>
-
-namespace ui {
-
-bool IsWorkstationLocked() {
- bool is_locked = true;
- HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ);
- if (input_desk) {
- wchar_t name[256] = {0};
- DWORD needed = 0;
- if (::GetUserObjectInformation(
- input_desk, UOI_NAME, name, sizeof(name), &needed)) {
- is_locked = lstrcmpi(name, L"default") != 0;
- }
- ::CloseDesktop(input_desk);
- }
- return is_locked;
-}
-
-} // namespace ui
diff --git a/ui/base/win/lock_state.h b/ui/base/win/lock_state.h
deleted file mode 100644
index be9c912..0000000
--- a/ui/base/win/lock_state.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2014 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 UI_BASE_WIN_LOCK_STATE_H_
-#define UI_BASE_WIN_LOCK_STATE_H_
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// Returns true if the screen is currently locked.
-UI_BASE_EXPORT bool IsWorkstationLocked();
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_LOCK_STATE_H_
diff --git a/ui/base/win/message_box_win.cc b/ui/base/win/message_box_win.cc
deleted file mode 100644
index 6500f98..0000000
--- a/ui/base/win/message_box_win.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/message_box_win.h"
-
-#include "base/command_line.h"
-#include "base/i18n/rtl.h"
-#include "ui/base/ui_base_switches.h"
-
-namespace ui {
-
-// In addition to passing the RTL flags to ::MessageBox if we are running in an
-// RTL locale, we need to make sure that LTR strings are rendered correctly by
-// adding the appropriate Unicode directionality marks.
-int MessageBox(HWND hwnd,
- const base::string16& text,
- const base::string16& caption,
- UINT flags) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox))
- return IDOK;
-
- UINT actual_flags = flags;
- if (base::i18n::IsRTL())
- actual_flags |= MB_RIGHT | MB_RTLREADING;
-
- base::string16 localized_text = text;
- base::i18n::AdjustStringForLocaleDirection(&localized_text);
- const wchar_t* text_ptr = localized_text.c_str();
-
- base::string16 localized_caption = caption;
- base::i18n::AdjustStringForLocaleDirection(&localized_caption);
- const wchar_t* caption_ptr = localized_caption.c_str();
-
- return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
-}
-
-} // namespace ui
diff --git a/ui/base/win/message_box_win.h b/ui/base/win/message_box_win.h
deleted file mode 100644
index f48bec3..0000000
--- a/ui/base/win/message_box_win.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_WIN_MESSAGE_BOX_WIN_H_
-#define UI_BASE_WIN_MESSAGE_BOX_WIN_H_
-
-#include <windows.h>
-
-#include "base/strings/string16.h"
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// A wrapper around Windows' MessageBox function. Using a Chrome specific
-// MessageBox function allows us to control certain RTL locale flags so that
-// callers don't have to worry about adding these flags when running in a
-// right-to-left locale.
-UI_BASE_EXPORT int MessageBox(HWND hwnd,
- const base::string16& text,
- const base::string16& caption,
- UINT flags);
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_MESSAGE_BOX_WIN_H_
diff --git a/ui/base/win/mouse_wheel_util.cc b/ui/base/win/mouse_wheel_util.cc
deleted file mode 100644
index 223e3a8..0000000
--- a/ui/base/win/mouse_wheel_util.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) 2009 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 "ui/base/win/mouse_wheel_util.h"
-
-#include <windowsx.h>
-
-#include "base/auto_reset.h"
-#include "ui/base/view_prop.h"
-#include "ui/gfx/win/hwnd_util.h"
-
-namespace ui {
-
-// Property used to indicate the HWND supports having mouse wheel messages
-// rerouted to it.
-static const char* const kHWNDSupportMouseWheelRerouting =
- "__HWND_MW_REROUTE_OK";
-
-static bool WindowSupportsRerouteMouseWheel(HWND window) {
- while (GetWindowLong(window, GWL_STYLE) & WS_CHILD) {
- if (!IsWindow(window))
- break;
-
- if (ViewProp::GetValue(window, kHWNDSupportMouseWheelRerouting) != NULL) {
- return true;
- }
- window = GetParent(window);
- }
- return false;
-}
-
-static bool IsCompatibleWithMouseWheelRedirection(HWND window) {
- std::wstring class_name = gfx::GetClassName(window);
- // Mousewheel redirection to comboboxes is a surprising and
- // undesireable user behavior.
- return !(class_name == L"ComboBox" ||
- class_name == L"ComboBoxEx32");
-}
-
-static bool CanRedirectMouseWheelFrom(HWND window) {
- std::wstring class_name = gfx::GetClassName(window);
-
- // Older Thinkpad mouse wheel drivers create a window under mouse wheel
- // pointer. Detect if we are dealing with this window. In this case we
- // don't need to do anything as the Thinkpad mouse driver will send
- // mouse wheel messages to the right window.
- if ((class_name == L"Syn Visual Class") ||
- (class_name == L"SynTrackCursorWindowClass"))
- return false;
-
- return true;
-}
-
-ViewProp* SetWindowSupportsRerouteMouseWheel(HWND hwnd) {
- return new ViewProp(hwnd, kHWNDSupportMouseWheelRerouting,
- reinterpret_cast<HANDLE>(true));
-}
-
-bool RerouteMouseWheel(HWND window, WPARAM w_param, LPARAM l_param) {
- // Since this is called from a subclass for every window, we can get
- // here recursively. This will happen if, for example, a control
- // reflects wheel scroll messages to its parent. Bail out if we got
- // here recursively.
- static bool recursion_break = false;
- if (recursion_break)
- return false;
- // Check if this window's class has a bad interaction with rerouting.
- if (!IsCompatibleWithMouseWheelRedirection(window))
- return false;
-
- DWORD current_process = GetCurrentProcessId();
- POINT wheel_location = { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) };
- HWND window_under_wheel = WindowFromPoint(wheel_location);
-
- if (!CanRedirectMouseWheelFrom(window_under_wheel))
- return false;
-
- // Find the lowest Chrome window in the hierarchy that can be the
- // target of mouse wheel redirection.
- while (window != window_under_wheel) {
- // If window_under_wheel is not a valid Chrome window, then return true to
- // suppress further processing of the message.
- if (!::IsWindow(window_under_wheel))
- return true;
- DWORD wheel_window_process = 0;
- GetWindowThreadProcessId(window_under_wheel, &wheel_window_process);
- if (current_process != wheel_window_process) {
- if (IsChild(window, window_under_wheel)) {
- // If this message is reflected from a child window in a different
- // process (happens with out of process windowed plugins) then
- // we don't want to reroute the wheel message.
- return false;
- } else {
- // The wheel is scrolling over an unrelated window. Make sure that we
- // have marked that window as supporting mouse wheel rerouting.
- // Otherwise, we cannot send random WM_MOUSEWHEEL messages to arbitrary
- // windows. So just drop the message.
- if (!WindowSupportsRerouteMouseWheel(window_under_wheel))
- return true;
- }
- }
-
- // window_under_wheel is a Chrome window. If allowed, redirect.
- if (IsCompatibleWithMouseWheelRedirection(window_under_wheel)) {
- base::AutoReset<bool> auto_reset_recursion_break(&recursion_break, true);
- SendMessage(window_under_wheel, WM_MOUSEWHEEL, w_param, l_param);
- return true;
- }
- // If redirection is disallowed, try the parent.
- window_under_wheel = GetAncestor(window_under_wheel, GA_PARENT);
- }
- // If we traversed back to the starting point, we should process
- // this message normally; return false.
- return false;
-}
-
-} // namespace ui
diff --git a/ui/base/win/mouse_wheel_util.h b/ui/base/win/mouse_wheel_util.h
deleted file mode 100644
index b9f5872..0000000
--- a/ui/base/win/mouse_wheel_util.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2011 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 UI_BASE_WIN_MOUSE_WHEEL_UTIL_H_
-#define UI_BASE_WIN_MOUSE_WHEEL_UTIL_H_
-
-#include <windows.h>
-
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-class ViewProp;
-
-// Marks the passed |hwnd| as supporting mouse-wheel message rerouting.
-// We reroute the mouse wheel messages to such HWND when they are under the
-// mouse pointer (but are not the active window). Callers own the returned
-// object.
-UI_BASE_EXPORT ViewProp* SetWindowSupportsRerouteMouseWheel(HWND hwnd);
-
-// Forwards mouse wheel messages to the window under it.
-// Windows sends mouse wheel messages to the currently active window.
-// This causes a window to scroll even if it is not currently under the mouse
-// wheel. The following code gives mouse wheel messages to the window under the
-// mouse wheel in order to scroll that window. This is arguably a better user
-// experience. The returns value says whether the mouse wheel message was
-// successfully redirected.
-UI_BASE_EXPORT bool RerouteMouseWheel(HWND window,
- WPARAM w_param,
- LPARAM l_param);
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_MOUSE_WHEEL_UTIL_H_
diff --git a/ui/base/win/open_file_name_win.cc b/ui/base/win/open_file_name_win.cc
deleted file mode 100644
index 3914fa5..0000000
--- a/ui/base/win/open_file_name_win.cc
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright (c) 2014 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 "ui/base/win/open_file_name_win.h"
-
-#include "base/files/file_path.h"
-#include "base/strings/string_util.h"
-#include "base/win/windows_version.h"
-
-namespace ui {
-namespace win {
-
-namespace {
-
-// Ensures that the Save As dialog is on-screen.
-UINT_PTR CALLBACK SaveAsDialogHook(HWND dialog, UINT message,
- WPARAM wparam, LPARAM lparam) {
- static const UINT kPrivateMessage = 0x2F3F;
- switch (message) {
- case WM_INITDIALOG: {
- // Do nothing here. Just post a message to defer actual processing.
- ::PostMessage(dialog, kPrivateMessage, 0, 0);
- return TRUE;
- }
- case kPrivateMessage: {
- // The dialog box is the parent of the current handle.
- HWND real_dialog = ::GetParent(dialog);
-
- // Retrieve the final size.
- RECT dialog_rect;
- ::GetWindowRect(real_dialog, &dialog_rect);
-
- // Verify that the upper left corner is visible.
- POINT point = { dialog_rect.left, dialog_rect.top };
- HMONITOR monitor1 = ::MonitorFromPoint(point, MONITOR_DEFAULTTONULL);
- point.x = dialog_rect.right;
- point.y = dialog_rect.bottom;
-
- // Verify that the lower right corner is visible.
- HMONITOR monitor2 = ::MonitorFromPoint(point, MONITOR_DEFAULTTONULL);
- if (monitor1 && monitor2)
- return 0;
-
- // Some part of the dialog box is not visible, fix it by moving is to the
- // client rect position of the browser window.
- HWND parent_window = ::GetParent(real_dialog);
- if (!parent_window)
- return 0;
- WINDOWINFO parent_info;
- parent_info.cbSize = sizeof(WINDOWINFO);
- ::GetWindowInfo(parent_window, &parent_info);
- ::SetWindowPos(
- real_dialog,
- NULL,
- parent_info.rcClient.left,
- parent_info.rcClient.top,
- 0,
- 0, // Size.
- SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
-
- return 0;
- }
- }
- return 0;
-}
-
-} // namespace
-
-OpenFileName::OpenFileName(HWND parent_window, DWORD flags) {
- ::ZeroMemory(&openfilename_, sizeof(openfilename_));
- openfilename_.lStructSize = sizeof(openfilename_);
-
- // According to http://support.microsoft.com/?scid=kb;en-us;222003&x=8&y=12,
- // The lpstrFile Buffer MUST be NULL Terminated.
- filename_buffer_[0] = 0;
- openfilename_.lpstrFile = filename_buffer_;
- openfilename_.nMaxFile = arraysize(filename_buffer_);
-
- openfilename_.Flags = flags;
- openfilename_.hwndOwner = parent_window;
-}
-
-OpenFileName::~OpenFileName() {
-}
-
-void OpenFileName::SetFilters(
- const std::vector<Tuple2<base::string16, base::string16> >& filters) {
- openfilename_.lpstrFilter = NULL;
- filter_buffer_.clear();
- if (filters.empty())
- return;
- for (std::vector<Tuple2<base::string16, base::string16> >::const_iterator
- it = filters.begin();
- it != filters.end();
- ++it) {
- filter_buffer_.append(it->a);
- filter_buffer_.push_back(0);
- filter_buffer_.append(it->b);
- filter_buffer_.push_back(0);
- }
- filter_buffer_.push_back(0);
- openfilename_.lpstrFilter = filter_buffer_.c_str();
-}
-
-void OpenFileName::SetInitialSelection(const base::FilePath& initial_directory,
- const base::FilePath& initial_filename) {
- // First reset to the default case.
- // According to http://support.microsoft.com/?scid=kb;en-us;222003&x=8&y=12,
- // The lpstrFile Buffer MUST be NULL Terminated.
- filename_buffer_[0] = 0;
- openfilename_.lpstrFile = filename_buffer_;
- openfilename_.nMaxFile = arraysize(filename_buffer_);
- openfilename_.lpstrInitialDir = NULL;
- initial_directory_buffer_.clear();
-
- if (initial_directory.empty())
- return;
-
- initial_directory_buffer_ = initial_directory.value();
- openfilename_.lpstrInitialDir = initial_directory_buffer_.c_str();
-
- if (initial_filename.empty())
- return;
-
- // The filename is ignored if no initial directory is supplied.
- base::wcslcpy(filename_buffer_,
- initial_filename.value().c_str(),
- arraysize(filename_buffer_));
-}
-
-void OpenFileName::MaybeInstallWindowPositionHookForSaveAsOnXP() {
- if (base::win::GetVersion() >= base::win::VERSION_VISTA)
- return;
-
- openfilename_.Flags |= OFN_ENABLEHOOK;
- DCHECK(!openfilename_.lpfnHook);
- openfilename_.lpfnHook = &SaveAsDialogHook;
-}
-
-base::FilePath OpenFileName::GetSingleResult() {
- base::FilePath directory;
- std::vector<base::FilePath> filenames;
- GetResult(&directory, &filenames);
- if (filenames.size() != 1)
- return base::FilePath();
- return directory.Append(filenames[0]);
-}
-
-void OpenFileName::GetResult(base::FilePath* directory,
- std::vector<base::FilePath>* filenames) {
- DCHECK(filenames->empty());
- const wchar_t* selection = openfilename_.lpstrFile;
- // The return value of |openfilename_.lpstrFile| is dependent on the
- // value of the Multi-Select flag within |openfilename_|. If the flag is
- // not set the return value will be a single null-terminated wide string.
- // If it is set it will be more than one null-terminated wide string, itself
- // terminated by an empty null-terminated wide string.
- if (openfilename_.Flags & OFN_ALLOWMULTISELECT) {
- while (*selection) { // Empty string indicates end of list.
- filenames->push_back(base::FilePath(selection));
- // Skip over filename and null-terminator.
- selection += filenames->back().value().length() + 1;
- }
- } else {
- filenames->push_back(base::FilePath(selection));
- }
- if (filenames->size() == 1) {
- // When there is one file, it contains the path and filename.
- *directory = (*filenames)[0].DirName();
- (*filenames)[0] = (*filenames)[0].BaseName();
- } else if (filenames->size() > 1) {
- // Otherwise, the first string is the path, and the remainder are
- // filenames.
- *directory = (*filenames)[0];
- filenames->erase(filenames->begin());
- }
-}
-
-// static
-void OpenFileName::SetResult(const base::FilePath& directory,
- const std::vector<base::FilePath>& filenames,
- OPENFILENAME* openfilename) {
- base::string16 filename_value;
- if (filenames.size() == 1) {
- filename_value = directory.Append(filenames[0]).value();
- } else {
- filename_value = directory.value();
- filename_value.push_back(0);
- for (std::vector<base::FilePath>::const_iterator it = filenames.begin();
- it != filenames.end();
- ++it) {
- filename_value.append(it->value());
- filename_value.push_back(0);
- }
- }
- if (filename_value.size() + 1 < openfilename->nMaxFile) {
- // Because the result has embedded nulls, we must memcpy.
- memcpy(openfilename->lpstrFile,
- filename_value.c_str(),
- (filename_value.size() + 1) * sizeof(filename_value[0]));
- } else if (openfilename->nMaxFile) {
- openfilename->lpstrFile[0] = 0;
- }
-}
-
-// static
-std::vector<Tuple2<base::string16, base::string16> > OpenFileName::GetFilters(
- const OPENFILENAME* openfilename) {
- std::vector<Tuple2<base::string16, base::string16> > filters;
-
- const base::char16* display_string = openfilename->lpstrFilter;
- if (!display_string)
- return filters;
-
- while (*display_string) {
- const base::char16* display_string_end = display_string;
- while (*display_string_end)
- ++display_string_end;
- const base::char16* pattern = display_string_end + 1;
- const base::char16* pattern_end = pattern;
- while (*pattern_end)
- ++pattern_end;
- filters.push_back(
- MakeTuple(base::string16(display_string, display_string_end),
- base::string16(pattern, pattern_end)));
- display_string = pattern_end + 1;
- }
-
- return filters;
-}
-
-} // namespace win
-} // namespace ui
diff --git a/ui/base/win/open_file_name_win.h b/ui/base/win/open_file_name_win.h
deleted file mode 100644
index bdf01f4..0000000
--- a/ui/base/win/open_file_name_win.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2014 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 UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_
-#define UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_
-
-#include <Windows.h>
-#include <Commdlg.h>
-
-#include <vector>
-
-#include "base/macros.h"
-#include "base/strings/string16.h"
-#include "base/tuple.h"
-#include "ui/base/ui_base_export.h"
-
-namespace base {
-class FilePath;
-} // namespace base
-
-namespace ui {
-namespace win {
-
-// Encapsulates an OPENFILENAME struct and related buffers. Also provides static
-// methods for interpreting the properties of an OPENFILENAME.
-class UI_BASE_EXPORT OpenFileName {
- public:
- // Initializes the OPENFILENAME, which may be accessed using Get(). All fields
- // will be NULL except for |lStructSize|, |lpstrFile|, and |nMaxFile|. The
- // file buffer will initially contain a null-terminated empty string.
- OpenFileName(HWND parent_window, DWORD flags);
- ~OpenFileName();
-
- // Initializes |lpstrFilter| from the label/pattern pairs in |filters|.
- void SetFilters(
- const std::vector<Tuple2<base::string16, base::string16> >& filters);
-
- // Sets |lpstrInitialDir| and |lpstrFile|.
- void SetInitialSelection(const base::FilePath& initial_directory,
- const base::FilePath& initial_filename);
-
- // The save as dialog on Windows XP remembers its last position, and if the
- // screen resolution has changed it may be off screen. This method will check
- // if we are running on XP and if so install a hook to reposition the dialog
- // if necessary.
- void MaybeInstallWindowPositionHookForSaveAsOnXP();
-
- // Returns the single selected file, or an empty path if there are more or
- // less than one results.
- base::FilePath GetSingleResult();
-
- // Returns the selected file or files.
- void GetResult(base::FilePath* directory,
- std::vector<base::FilePath>* filenames);
-
- // Returns the OPENFILENAME structure.
- OPENFILENAME* GetOPENFILENAME() { return &openfilename_; }
-
- // Returns the OPENFILENAME structure.
- const OPENFILENAME* GetOPENFILENAME() const { return &openfilename_; }
-
- // Stores directory and filenames in the buffer pointed to by
- // |openfilename->lpstrFile| and sized |openfilename->nMaxFile|.
- static void SetResult(const base::FilePath& directory,
- const std::vector<base::FilePath>& filenames,
- OPENFILENAME* openfilename);
-
- // Returns a vector of label/pattern pairs built from
- // |openfilename->lpstrFilter|.
- static std::vector<Tuple2<base::string16, base::string16> > GetFilters(
- const OPENFILENAME* openfilename);
-
- private:
- OPENFILENAME openfilename_;
- base::string16 initial_directory_buffer_;
- wchar_t filename_buffer_[UNICODE_STRING_MAX_CHARS];
- base::string16 filter_buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(OpenFileName);
-};
-
-} // namespace win
-} // namespace ui
-
-#endif // UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_
diff --git a/ui/base/win/open_file_name_win_unittest.cc b/ui/base/win/open_file_name_win_unittest.cc
deleted file mode 100644
index 9eaee79..0000000
--- a/ui/base/win/open_file_name_win_unittest.cc
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright (c) 2014 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 "ui/base/win/open_file_name_win.h"
-
-#include "base/files/file_path.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-const HWND kHwnd = reinterpret_cast<HWND>(0xDEADBEEF);
-const DWORD kFlags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING;
-
-void SetResult(const base::string16& result, ui::win::OpenFileName* ofn) {
- if (ofn->GetOPENFILENAME()->nMaxFile <= result.size()) {
- ADD_FAILURE() << "filename buffer insufficient.";
- return;
- }
- if (!result.size()) {
- ofn->GetOPENFILENAME()->lpstrFile[0] = 0;
- } else {
- // Because the result has embedded nulls, we must memcpy.
- memcpy(ofn->GetOPENFILENAME()->lpstrFile,
- result.c_str(),
- (result.size() + 1) * sizeof(result[0]));
- }
-}
-
-void CheckFilters(
- const std::vector<Tuple2<base::string16, base::string16> >& expected,
- const std::vector<Tuple2<base::string16, base::string16> >& actual) {
- if (expected.size() != actual.size()) {
- ADD_FAILURE() << "filter count mismatch. Got " << actual.size()
- << " expected " << expected.size() << ".";
- return;
- }
-
- for (size_t i = 0; i < expected.size(); ++i) {
- EXPECT_EQ(expected[i].a, actual[i].a) << "Mismatch at index " << i;
- EXPECT_EQ(expected[i].b, actual[i].b) << "Mismatch at index " << i;
- }
-}
-
-void CheckFilterString(const base::string16& expected,
- const ui::win::OpenFileName& ofn) {
- if (!ofn.GetOPENFILENAME()->lpstrFilter) {
- ADD_FAILURE() << "Filter string is NULL.";
- return;
- }
- if (expected.size() == 0) {
- EXPECT_EQ(0, ofn.GetOPENFILENAME()->lpstrFilter[0]);
- } else {
- EXPECT_EQ(0,
- memcmp(expected.c_str(),
- ofn.GetOPENFILENAME()->lpstrFilter,
- expected.size() + 1 * sizeof(expected[0])));
- }
-}
-
-void CheckResult(const base::string16& expected,
- const ui::win::OpenFileName& ofn) {
- if (!ofn.GetOPENFILENAME()->lpstrFile) {
- ADD_FAILURE() << "File string is NULL.";
- return;
- }
- if (expected.size() == 0) {
- EXPECT_EQ(0, ofn.GetOPENFILENAME()->lpstrFile[0]);
- } else {
- EXPECT_EQ(0,
- memcmp(expected.c_str(),
- ofn.GetOPENFILENAME()->lpstrFile,
- expected.size() + 1 * sizeof(expected[0])));
- }
-}
-
-} // namespace
-
-TEST(OpenFileNameTest, Initialization) {
- ui::win::OpenFileName ofn(kHwnd, kFlags);
- EXPECT_EQ(kHwnd, ofn.GetOPENFILENAME()->hwndOwner);
- EXPECT_EQ(kFlags, ofn.GetOPENFILENAME()->Flags);
- EXPECT_EQ(sizeof(OPENFILENAME), ofn.GetOPENFILENAME()->lStructSize);
- ASSERT_TRUE(ofn.GetOPENFILENAME()->lpstrFile);
- ASSERT_GT(ofn.GetOPENFILENAME()->nMaxFile, 0u);
- EXPECT_EQ(0, ofn.GetOPENFILENAME()->lpstrFile[0]);
-}
-
-TEST(OpenFileNameTest, SetInitialSelection) {
- const base::FilePath kDirectory(L"C:\\directory\\child_directory");
- const base::FilePath kFile(L"file_name.ext");
- ui::win::OpenFileName ofn(kHwnd, kFlags);
- ofn.SetInitialSelection(kDirectory, kFile);
- EXPECT_EQ(kDirectory, base::FilePath(ofn.GetOPENFILENAME()->lpstrInitialDir));
- EXPECT_EQ(kFile, base::FilePath(ofn.GetOPENFILENAME()->lpstrFile));
-
- ofn.SetInitialSelection(kDirectory, base::FilePath());
- EXPECT_EQ(kDirectory, base::FilePath(ofn.GetOPENFILENAME()->lpstrInitialDir));
- // Filename buffer will still be a valid pointer, to receive a result.
- ASSERT_TRUE(ofn.GetOPENFILENAME()->lpstrFile);
- EXPECT_EQ(base::FilePath(), base::FilePath(ofn.GetOPENFILENAME()->lpstrFile));
-
- ofn.SetInitialSelection(base::FilePath(), base::FilePath());
- // No initial directory will lead to a NULL buffer.
- ASSERT_FALSE(ofn.GetOPENFILENAME()->lpstrInitialDir);
- ASSERT_TRUE(ofn.GetOPENFILENAME()->lpstrFile);
- EXPECT_EQ(base::FilePath(), base::FilePath(ofn.GetOPENFILENAME()->lpstrFile));
-
- // Make sure that both values are cleared when directory is missing.
- ofn.SetInitialSelection(kDirectory, kFile);
- EXPECT_EQ(kDirectory, base::FilePath(ofn.GetOPENFILENAME()->lpstrInitialDir));
- EXPECT_EQ(kFile, base::FilePath(ofn.GetOPENFILENAME()->lpstrFile));
- ofn.SetInitialSelection(base::FilePath(), base::FilePath());
- ASSERT_FALSE(ofn.GetOPENFILENAME()->lpstrInitialDir);
- ASSERT_TRUE(ofn.GetOPENFILENAME()->lpstrFile);
- EXPECT_EQ(base::FilePath(), base::FilePath(ofn.GetOPENFILENAME()->lpstrFile));
-
- // File is ignored in absence of a directory.
- ofn.SetInitialSelection(base::FilePath(), kFile);
- ASSERT_FALSE(ofn.GetOPENFILENAME()->lpstrInitialDir);
- ASSERT_TRUE(ofn.GetOPENFILENAME()->lpstrFile);
- EXPECT_EQ(base::FilePath(), base::FilePath(ofn.GetOPENFILENAME()->lpstrFile));
-}
-
-TEST(OpenFileNameTest, GetSingleResultFromSingleSelect) {
- ui::win::OpenFileName ofn(kHwnd, kFlags);
- base::FilePath result;
-
- SetResult(L"C:\\dir\\file", &ofn);
- result = ofn.GetSingleResult();
- EXPECT_EQ(base::FilePath(L"C:\\dir\\file"), result);
-
- SetResult(L"", &ofn);
- result = ofn.GetSingleResult();
- EXPECT_EQ(base::FilePath(), result);
-}
-
-TEST(OpenFileNameTest, GetSingleResultFromMultiSelect) {
- const base::string16 kNull(L"\0", 1);
- ui::win::OpenFileName ofn(kHwnd, kFlags | OFN_ALLOWMULTISELECT);
- base::FilePath result;
-
- SetResult(L"C:\\dir\\file" + kNull, &ofn);
- result = ofn.GetSingleResult();
- EXPECT_EQ(base::FilePath(L"C:\\dir\\file"), result);
-
- SetResult(L"C:\\dir" + kNull + L"file" + kNull, &ofn);
- result = ofn.GetSingleResult();
- EXPECT_EQ(base::FilePath(L"C:\\dir\\file"), result);
-
- SetResult(L"C:\\dir" + kNull + L"file" + kNull + L"otherfile" + kNull, &ofn);
- result = ofn.GetSingleResult();
- EXPECT_EQ(base::FilePath(), result);
-
- SetResult(L"", &ofn);
- result = ofn.GetSingleResult();
- EXPECT_EQ(base::FilePath(), result);
-}
-
-TEST(OpenFileNameTest, GetResult) {
- const base::string16 kNull(L"\0", 1);
-
- ui::win::OpenFileName ofn(kHwnd, kFlags | OFN_ALLOWMULTISELECT);
- base::FilePath directory;
- std::vector<base::FilePath> filenames;
-
- SetResult(L"C:\\dir\\file" + kNull, &ofn);
- ofn.GetResult(&directory, &filenames);
- EXPECT_EQ(base::FilePath(L"C:\\dir"), directory);
- ASSERT_EQ(1u, filenames.size());
- EXPECT_EQ(base::FilePath(L"file"), filenames[0]);
-
- directory.clear();
- filenames.clear();
-
- SetResult(L"C:\\dir" + kNull + L"file" + kNull, &ofn);
- ofn.GetResult(&directory, &filenames);
- EXPECT_EQ(base::FilePath(L"C:\\dir"), directory);
- ASSERT_EQ(1u, filenames.size());
- EXPECT_EQ(base::FilePath(L"file"), filenames[0]);
-
- directory.clear();
- filenames.clear();
-
- SetResult(L"C:\\dir" + kNull + L"file" + kNull + L"otherfile" + kNull, &ofn);
- ofn.GetResult(&directory, &filenames);
- EXPECT_EQ(base::FilePath(L"C:\\dir"), directory);
- ASSERT_EQ(2u, filenames.size());
- EXPECT_EQ(base::FilePath(L"file"), filenames[0]);
- EXPECT_EQ(base::FilePath(L"otherfile"), filenames[1]);
-
- directory.clear();
- filenames.clear();
-
- SetResult(L"", &ofn);
- ofn.GetResult(&directory, &filenames);
- EXPECT_EQ(base::FilePath(), directory);
- ASSERT_EQ(0u, filenames.size());
-}
-
-TEST(OpenFileNameTest, SetAndGetFilters) {
- const base::string16 kNull(L"\0", 1);
-
- ui::win::OpenFileName ofn(kHwnd, kFlags);
- std::vector<Tuple2<base::string16, base::string16> > filters;
- ofn.SetFilters(filters);
- EXPECT_FALSE(ofn.GetOPENFILENAME()->lpstrFilter);
- CheckFilters(filters,
- ui::win::OpenFileName::GetFilters(ofn.GetOPENFILENAME()));
-
- filters.push_back(MakeTuple(base::string16(L"a"), base::string16(L"b")));
- ofn.SetFilters(filters);
- CheckFilterString(L"a" + kNull + L"b" + kNull, ofn);
- CheckFilters(filters,
- ui::win::OpenFileName::GetFilters(ofn.GetOPENFILENAME()));
-
- filters.push_back(MakeTuple(base::string16(L"X"), base::string16(L"Y")));
- ofn.SetFilters(filters);
- CheckFilterString(L"a" + kNull + L"b" + kNull + L"X" + kNull + L"Y" + kNull,
- ofn);
- CheckFilters(filters,
- ui::win::OpenFileName::GetFilters(ofn.GetOPENFILENAME()));
-}
-
-TEST(OpenFileNameTest, SetResult) {
- const base::string16 kNull(L"\0", 1);
-
- ui::win::OpenFileName ofn(kHwnd, kFlags);
- base::FilePath directory;
- std::vector<base::FilePath> filenames;
-
- ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME());
- CheckResult(L"", ofn);
-
- directory = base::FilePath(L"C:\\dir");
- filenames.push_back(base::FilePath(L"file"));
- ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME());
- CheckResult(L"C:\\dir\\file" + kNull, ofn);
-
- filenames.push_back(base::FilePath(L"otherfile"));
- ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME());
- CheckResult(L"C:\\dir" + kNull + L"file" + kNull + L"otherfile" + kNull, ofn);
-
- base::char16 short_buffer[10] = L"";
-
- ofn.GetOPENFILENAME()->lpstrFile = short_buffer;
- ofn.GetOPENFILENAME()->nMaxFile = arraysize(short_buffer);
- ui::win::OpenFileName::SetResult(directory, filenames, ofn.GetOPENFILENAME());
- CheckResult(L"", ofn);
-}
diff --git a/ui/base/win/scoped_ole_initializer.cc b/ui/base/win/scoped_ole_initializer.cc
deleted file mode 100644
index 48361aa..0000000
--- a/ui/base/win/scoped_ole_initializer.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/scoped_ole_initializer.h"
-
-#include "base/logging.h"
-
-namespace ui {
-
-ScopedOleInitializer::ScopedOleInitializer()
- :
-#ifndef NDEBUG
- // Using the windows API directly to avoid dependency on platform_thread.
- thread_id_(GetCurrentThreadId()),
-#endif
- hr_(OleInitialize(NULL)) {
-#ifndef NDEBUG
- if (hr_ == S_FALSE) {
- LOG(ERROR) << "Multiple OleInitialize() calls for thread " << thread_id_;
- } else {
- DCHECK_NE(OLE_E_WRONGCOMPOBJ, hr_) << "Incompatible DLLs on machine";
- DCHECK_NE(RPC_E_CHANGED_MODE, hr_) << "Invalid COM thread model change";
- }
-#endif
-}
-
-ScopedOleInitializer::~ScopedOleInitializer() {
-#ifndef NDEBUG
- DCHECK_EQ(thread_id_, GetCurrentThreadId());
-#endif
- if (SUCCEEDED(hr_))
- OleUninitialize();
-}
-
-} // namespace ui
diff --git a/ui/base/win/scoped_ole_initializer.h b/ui/base/win/scoped_ole_initializer.h
deleted file mode 100644
index b2e81d2..0000000
--- a/ui/base/win/scoped_ole_initializer.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_WIN_SCOPED_OLE_INITIALIZER_H_
-#define UI_BASE_WIN_SCOPED_OLE_INITIALIZER_H_
-
-#include <ole2.h>
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-class UI_BASE_EXPORT ScopedOleInitializer {
- public:
- ScopedOleInitializer();
- ~ScopedOleInitializer();
-
- private:
-#ifndef NDEBUG
- // In debug builds we use this variable to catch a potential bug where a
- // ScopedOleInitializer instance is deleted on a different thread than it
- // was initially created on. If that ever happens it can have bad
- // consequences and the cause can be tricky to track down.
- DWORD thread_id_;
-#endif
- HRESULT hr_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedOleInitializer);
-};
-
-} // namespace
-
-#endif // UI_BASE_WIN_SCOPED_OLE_INITIALIZER_H_
diff --git a/ui/base/win/shell.cc b/ui/base/win/shell.cc
deleted file mode 100644
index 5cc3daa..0000000
--- a/ui/base/win/shell.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/win/shell.h"
-
-#include <dwmapi.h>
-#include <shlobj.h> // Must be before propkey.
-#include <propkey.h>
-#include <shellapi.h>
-
-#include "base/command_line.h"
-#include "base/files/file_path.h"
-#include "base/native_library.h"
-#include "base/strings/string_util.h"
-#include "base/win/metro.h"
-#include "base/win/scoped_comptr.h"
-#include "base/win/win_util.h"
-#include "base/win/windows_version.h"
-#include "ui/base/ui_base_switches.h"
-
-namespace ui {
-namespace win {
-
-namespace {
-
-// Show the Windows "Open With" dialog box to ask the user to pick an app to
-// open the file with.
-bool OpenItemWithExternalApp(const base::string16& full_path) {
- SHELLEXECUTEINFO sei = { sizeof(sei) };
- sei.fMask = SEE_MASK_FLAG_DDEWAIT;
- sei.nShow = SW_SHOWNORMAL;
- sei.lpVerb = L"openas";
- sei.lpFile = full_path.c_str();
- return (TRUE == ::ShellExecuteExW(&sei));
-}
-
-} // namespace
-
-bool OpenAnyViaShell(const base::string16& full_path,
- const base::string16& directory,
- const base::string16& args,
- DWORD mask) {
- SHELLEXECUTEINFO sei = { sizeof(sei) };
- sei.fMask = mask;
- sei.nShow = SW_SHOWNORMAL;
- sei.lpFile = full_path.c_str();
- sei.lpDirectory = directory.c_str();
- if (!args.empty())
- sei.lpParameters = args.c_str();
-
- if (::ShellExecuteExW(&sei))
- return true;
- if (::GetLastError() == ERROR_NO_ASSOCIATION)
- return OpenItemWithExternalApp(full_path);
- return false;
-}
-
-bool OpenItemViaShell(const base::FilePath& full_path) {
- return OpenAnyViaShell(full_path.value(), full_path.DirName().value(),
- base::string16(), 0);
-}
-
-bool PreventWindowFromPinning(HWND hwnd) {
- // This functionality is only available on Win7+. It also doesn't make sense
- // to do this for Chrome Metro.
- if (base::win::GetVersion() < base::win::VERSION_WIN7 ||
- base::win::IsMetroProcess())
- return false;
- base::win::ScopedComPtr<IPropertyStore> pps;
- HRESULT result = SHGetPropertyStoreForWindow(
- hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive()));
- if (FAILED(result))
- return false;
-
- return base::win::SetBooleanValueForPropertyStore(
- pps.get(), PKEY_AppUserModel_PreventPinning, true);
-}
-
-// TODO(calamity): investigate moving this out of the UI thread as COM
-// operations may spawn nested message loops which can cause issues.
-void SetAppDetailsForWindow(const base::string16& app_id,
- const base::string16& app_icon,
- const base::string16& relaunch_command,
- const base::string16& relaunch_display_name,
- HWND hwnd) {
- // This functionality is only available on Win7+. It also doesn't make sense
- // to do this for Chrome Metro.
- if (base::win::GetVersion() < base::win::VERSION_WIN7 ||
- base::win::IsMetroProcess())
- return;
- base::win::ScopedComPtr<IPropertyStore> pps;
- HRESULT result = SHGetPropertyStoreForWindow(
- hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive()));
- if (S_OK == result) {
- if (!app_id.empty())
- base::win::SetAppIdForPropertyStore(pps.get(), app_id.c_str());
- if (!app_icon.empty()) {
- base::win::SetStringValueForPropertyStore(
- pps.get(), PKEY_AppUserModel_RelaunchIconResource, app_icon.c_str());
- }
- if (!relaunch_command.empty()) {
- base::win::SetStringValueForPropertyStore(
- pps.get(), PKEY_AppUserModel_RelaunchCommand, relaunch_command.c_str());
- }
- if (!relaunch_display_name.empty()) {
- base::win::SetStringValueForPropertyStore(
- pps.get(), PKEY_AppUserModel_RelaunchDisplayNameResource,
- relaunch_display_name.c_str());
- }
- }
-}
-
-void SetAppIdForWindow(const base::string16& app_id, HWND hwnd) {
- SetAppDetailsForWindow(app_id,
- base::string16(),
- base::string16(),
- base::string16(),
- hwnd);
-}
-
-void SetAppIconForWindow(const base::string16& app_icon, HWND hwnd) {
- SetAppDetailsForWindow(base::string16(),
- app_icon,
- base::string16(),
- base::string16(),
- hwnd);
-}
-
-void SetRelaunchDetailsForWindow(const base::string16& relaunch_command,
- const base::string16& display_name,
- HWND hwnd) {
- SetAppDetailsForWindow(base::string16(),
- base::string16(),
- relaunch_command,
- display_name,
- hwnd);
-}
-
-bool IsAeroGlassEnabled() {
- // For testing in Win8 (where it is not possible to disable composition) the
- // user can specify this command line switch to mimic the behavior. In this
- // mode, cross-HWND transparency is not supported and various types of
- // widgets fallback to more simplified rendering behavior.
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableDwmComposition))
- return false;
-
- if (base::win::GetVersion() < base::win::VERSION_VISTA)
- return false;
- // If composition is not enabled, we behave like on XP.
- BOOL enabled = FALSE;
- return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled;
-}
-
-} // namespace win
-} // namespace ui
diff --git a/ui/base/win/shell.h b/ui/base/win/shell.h
deleted file mode 100644
index 3b64ce7..0000000
--- a/ui/base/win/shell.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2011 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 UI_BASE_WIN_SHELL_H_
-#define UI_BASE_WIN_SHELL_H_
-
-#include <windows.h>
-
-#include "base/strings/string16.h"
-#include "ui/base/ui_base_export.h"
-
-namespace base {
-class FilePath;
-}
-
-namespace ui {
-namespace win {
-
-// Open or run a file via the Windows shell. In the event that there is no
-// default application registered for the file specified by 'full_path',
-// ask the user, via the Windows "Open With" dialog.
-// Returns 'true' on successful open, 'false' otherwise.
-UI_BASE_EXPORT bool OpenItemViaShell(const base::FilePath& full_path);
-
-// Lower level function that allows opening of non-files like urls or GUIDs
-// don't use it if one of the above will do. |mask| is a valid combination
-// of SEE_MASK_FLAG_XXX as stated in msdn. If there is no default application
-// registered for the item, it behaves the same as OpenItemViaShell.
-UI_BASE_EXPORT bool OpenAnyViaShell(const base::string16& full_path,
- const base::string16& directory,
- const base::string16& args,
- DWORD mask);
-
-// Disables the ability of the specified window to be pinned to the taskbar or
-// the Start menu. This will remove "Pin this program to taskbar" from the
-// taskbar menu of the specified window.
-UI_BASE_EXPORT bool PreventWindowFromPinning(HWND hwnd);
-
-// Sets the application id, app icon, relaunch command and relaunch display name
-// for the given window.
-UI_BASE_EXPORT void SetAppDetailsForWindow(
- const base::string16& app_id,
- const base::string16& app_icon,
- const base::string16& relaunch_command,
- const base::string16& relaunch_display_name,
- HWND hwnd);
-
-// Sets the application id given as the Application Model ID for the window
-// specified. This method is used to insure that different web applications
-// do not group together on the Win7 task bar.
-UI_BASE_EXPORT void SetAppIdForWindow(const base::string16& app_id, HWND hwnd);
-
-// Sets the application icon for the window specified.
-UI_BASE_EXPORT void SetAppIconForWindow(const base::string16& app_icon,
- HWND hwnd);
-
-// Sets the relaunch command and relaunch display name for the window specified.
-// Windows will use this information for grouping on the taskbar, and to create
-// a shortcut if the window is pinned to the taskbar.
-UI_BASE_EXPORT void SetRelaunchDetailsForWindow(
- const base::string16& relaunch_command,
- const base::string16& display_name,
- HWND hwnd);
-
-// Returns true if composition is available and turned on on the current
-// platform.
-UI_BASE_EXPORT bool IsAeroGlassEnabled();
-
-} // namespace win
-} // namespace ui
-
-#endif // UI_BASE_WIN_SHELL_H_
diff --git a/ui/base/win/touch_input.cc b/ui/base/win/touch_input.cc
deleted file mode 100644
index 0114bdd..0000000
--- a/ui/base/win/touch_input.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2013 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 "ui/base/win/touch_input.h"
-
-namespace ui {
-
-BOOL GetTouchInputInfoWrapper(HTOUCHINPUT handle,
- UINT count,
- PTOUCHINPUT pointer,
- int size) {
- typedef BOOL(WINAPI *GetTouchInputInfoPtr)(HTOUCHINPUT, UINT,
- PTOUCHINPUT, int);
- static GetTouchInputInfoPtr get_touch_input_info_func =
- reinterpret_cast<GetTouchInputInfoPtr>(
- GetProcAddress(GetModuleHandleA("user32.dll"), "GetTouchInputInfo"));
- if (get_touch_input_info_func)
- return get_touch_input_info_func(handle, count, pointer, size);
- return FALSE;
-}
-
-} // namespace ui
diff --git a/ui/base/win/touch_input.h b/ui/base/win/touch_input.h
deleted file mode 100644
index f113ec5..0000000
--- a/ui/base/win/touch_input.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2013 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 UI_BASE_WIN_TOUCH_INPUT_H_
-#define UI_BASE_WIN_TOUCH_INPUT_H_
-
-#include <windows.h>
-
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// Wrapper for GetTouchInputInfo, which is not defined before Win7. For
-// earlier OS's, this function returns FALSE.
-UI_BASE_EXPORT BOOL GetTouchInputInfoWrapper(HTOUCHINPUT handle,
- UINT count,
- PTOUCHINPUT pointer,
- int size);
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_TOUCH_INPUT_H_
diff --git a/ui/base/win/window_event_target.cc b/ui/base/win/window_event_target.cc
deleted file mode 100644
index 555cd5a..0000000
--- a/ui/base/win/window_event_target.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2014 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 "ui/base/win/window_event_target.h"
-
-namespace ui {
-
-const char WindowEventTarget::kWin32InputEventTarget[]
- = "Win32_InputEventTarget";
-
-WindowEventTarget::WindowEventTarget() {}
-
-WindowEventTarget::~WindowEventTarget() {}
-
-} // namespace ui
diff --git a/ui/base/win/window_event_target.h b/ui/base/win/window_event_target.h
deleted file mode 100644
index e8e7d83..0000000
--- a/ui/base/win/window_event_target.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2014 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 UI_BASE_WIN_WINDOW_EVENT_TARGET_H_
-#define UI_BASE_WIN_WINDOW_EVENT_TARGET_H_
-
-#include <windows.h>
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// This interface is implemented by classes who get input events forwarded to
-// them from others. E.g. would be a win32 parent child relationship where the
-// child forwards input events to the parent after doing minimal processing.
-class UI_BASE_EXPORT WindowEventTarget {
- public:
- static const char kWin32InputEventTarget[];
-
- // Handles mouse events like WM_MOUSEMOVE, WM_LBUTTONDOWN, etc.
- // The |message| parameter identifies the message.
- // The |w_param| and |l_param| values are dependent on the type of the
- // message.
- // The |handled| parameter is an output parameter which when set to false
- // indicates that the message should be DefProc'ed.
- // Returns the result of processing the message.
- virtual LRESULT HandleMouseMessage(unsigned int message,
- WPARAM w_param,
- LPARAM l_param,
- bool* handled) = 0;
-
- // Handles keyboard events like WM_KEYDOWN/WM_KEYUP, etc.
- // The |message| parameter identifies the message.
- // The |w_param| and |l_param| values are dependent on the type of the
- // message.
- // The |handled| parameter is an output parameter which when set to false
- // indicates that the message should be DefProc'ed.
- // Returns the result of processing the message.
- virtual LRESULT HandleKeyboardMessage(unsigned int message,
- WPARAM w_param,
- LPARAM l_param,
- bool* handled) = 0;
-
- // Handles WM_TOUCH events.
- // The |message| parameter identifies the message.
- // The |w_param| and |l_param| values are as per MSDN docs.
- // The |handled| parameter is an output parameter which when set to false
- // indicates that the message should be DefProc'ed.
- // Returns the result of processing the message.
- virtual LRESULT HandleTouchMessage(unsigned int message,
- WPARAM w_param,
- LPARAM l_param,
- bool* handled) = 0;
-
- // Handles scroll messages like WM_VSCROLL and WM_HSCROLL.
- // The |message| parameter identifies the scroll message.
- // The |w_param| and |l_param| values are dependent on the type of scroll.
- // The |handled| parameter is an output parameter which when set to false
- // indicates that the message should be DefProc'ed.
- virtual LRESULT HandleScrollMessage(unsigned int message,
- WPARAM w_param,
- LPARAM l_param,
- bool* handled) = 0;
-
- // Handles the WM_NCHITTEST message
- // The |message| parameter identifies the message.
- // The |w_param| and |l_param| values are as per MSDN docs.
- // The |handled| parameter is an output parameter which when set to false
- // indicates that the message should be DefProc'ed.
- // Returns the result of processing the message.
- virtual LRESULT HandleNcHitTestMessage(unsigned int message,
- WPARAM w_param,
- LPARAM l_param,
- bool* handled) = 0;
- protected:
- WindowEventTarget();
- virtual ~WindowEventTarget();
-};
-
-} // namespace ui
-
-#endif // UI_BASE_WIN_WINDOW_EVENT_TARGET_H_
-
-
diff --git a/ui/base/x/OWNERS b/ui/base/x/OWNERS
deleted file mode 100644
index 20cb707..0000000
--- a/ui/base/x/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-davemoore@chromium.org
-sadrul@chromium.org
-derat@chromium.org
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
deleted file mode 100644
index dedc882..0000000
--- a/ui/base/x/x11_util.cc
+++ /dev/null
@@ -1,1375 +0,0 @@
-// Copyright (c) 2012 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.
-
-// This file defines utility functions for X11 (Linux only). This code has been
-// ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
-// remains woefully incomplete.
-
-#include "ui/base/x/x11_util.h"
-
-#include <ctype.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#include <list>
-#include <map>
-#include <utility>
-#include <vector>
-
-#include <X11/extensions/shape.h>
-#include <X11/extensions/XInput2.h>
-#include <X11/Xcursor/Xcursor.h>
-
-#include "base/bind.h"
-#include "base/debug/trace_event.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop.h"
-#include "base/metrics/histogram.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/sys_byteorder.h"
-#include "base/threading/thread.h"
-#include "skia/ext/image_operations.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkPostConfig.h"
-#include "ui/base/x/x11_util_internal.h"
-#include "ui/events/event_utils.h"
-#include "ui/events/keycodes/keyboard_code_conversion_x.h"
-#include "ui/events/x/device_data_manager_x11.h"
-#include "ui/events/x/touch_factory_x11.h"
-#include "ui/gfx/geometry/insets.h"
-#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/point_conversions.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/skia_util.h"
-#include "ui/gfx/x/x11_error_tracker.h"
-
-#if defined(OS_FREEBSD)
-#include <sys/sysctl.h>
-#include <sys/types.h>
-#endif
-
-namespace ui {
-
-namespace {
-
-int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) {
- if (base::MessageLoop::current()) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&LogErrorEventDescription, d, *e));
- } else {
- LOG(ERROR)
- << "X error received: "
- << "serial " << e->serial << ", "
- << "error_code " << static_cast<int>(e->error_code) << ", "
- << "request_code " << static_cast<int>(e->request_code) << ", "
- << "minor_code " << static_cast<int>(e->minor_code);
- }
- return 0;
-}
-
-int DefaultX11IOErrorHandler(XDisplay* d) {
- // If there's an IO error it likely means the X server has gone away
- LOG(ERROR) << "X IO error received (X server probably went away)";
- _exit(1);
-}
-
-// Note: The caller should free the resulting value data.
-bool GetProperty(XID window, const std::string& property_name, long max_length,
- XAtom* type, int* format, unsigned long* num_items,
- unsigned char** property) {
- XAtom property_atom = GetAtom(property_name.c_str());
- unsigned long remaining_bytes = 0;
- return XGetWindowProperty(gfx::GetXDisplay(),
- window,
- property_atom,
- 0, // offset into property data to read
- max_length, // max length to get
- False, // deleted
- AnyPropertyType,
- type,
- format,
- num_items,
- &remaining_bytes,
- property);
-}
-
-bool SupportsEWMH() {
- static bool supports_ewmh = false;
- static bool supports_ewmh_cached = false;
- if (!supports_ewmh_cached) {
- supports_ewmh_cached = true;
-
- int wm_window = 0u;
- if (!GetIntProperty(GetX11RootWindow(),
- "_NET_SUPPORTING_WM_CHECK",
- &wm_window)) {
- supports_ewmh = false;
- return false;
- }
-
- // It's possible that a window manager started earlier in this X session
- // left a stale _NET_SUPPORTING_WM_CHECK property when it was replaced by a
- // non-EWMH window manager, so we trap errors in the following requests to
- // avoid crashes (issue 23860).
-
- // EWMH requires the supporting-WM window to also have a
- // _NET_SUPPORTING_WM_CHECK property pointing to itself (to avoid a stale
- // property referencing an ID that's been recycled for another window), so
- // we check that too.
- gfx::X11ErrorTracker err_tracker;
- int wm_window_property = 0;
- bool result = GetIntProperty(
- wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property);
- supports_ewmh = !err_tracker.FoundNewError() &&
- result &&
- wm_window_property == wm_window;
- }
-
- return supports_ewmh;
-}
-
-bool GetWindowManagerName(std::string* wm_name) {
- DCHECK(wm_name);
- if (!SupportsEWMH())
- return false;
-
- int wm_window = 0;
- if (!GetIntProperty(GetX11RootWindow(),
- "_NET_SUPPORTING_WM_CHECK",
- &wm_window)) {
- return false;
- }
-
- gfx::X11ErrorTracker err_tracker;
- bool result = GetStringProperty(
- static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name);
- return !err_tracker.FoundNewError() && result;
-}
-
-// A process wide singleton that manages the usage of X cursors.
-class XCursorCache {
- public:
- XCursorCache() {}
- ~XCursorCache() {
- Clear();
- }
-
- ::Cursor GetCursor(int cursor_shape) {
- // Lookup cursor by attempting to insert a null value, which avoids
- // a second pass through the map after a cache miss.
- std::pair<std::map<int, ::Cursor>::iterator, bool> it = cache_.insert(
- std::make_pair(cursor_shape, 0));
- if (it.second) {
- XDisplay* display = gfx::GetXDisplay();
- it.first->second = XCreateFontCursor(display, cursor_shape);
- }
- return it.first->second;
- }
-
- void Clear() {
- XDisplay* display = gfx::GetXDisplay();
- for (std::map<int, ::Cursor>::iterator it =
- cache_.begin(); it != cache_.end(); ++it) {
- XFreeCursor(display, it->second);
- }
- cache_.clear();
- }
-
- private:
- // Maps X11 font cursor shapes to Cursor IDs.
- std::map<int, ::Cursor> cache_;
-
- DISALLOW_COPY_AND_ASSIGN(XCursorCache);
-};
-
-XCursorCache* cursor_cache = NULL;
-
-// A process wide singleton cache for custom X cursors.
-class XCustomCursorCache {
- public:
- static XCustomCursorCache* GetInstance() {
- return Singleton<XCustomCursorCache>::get();
- }
-
- ::Cursor InstallCustomCursor(XcursorImage* image) {
- XCustomCursor* custom_cursor = new XCustomCursor(image);
- ::Cursor xcursor = custom_cursor->cursor();
- cache_[xcursor] = custom_cursor;
- return xcursor;
- }
-
- void Ref(::Cursor cursor) {
- cache_[cursor]->Ref();
- }
-
- void Unref(::Cursor cursor) {
- if (cache_[cursor]->Unref())
- cache_.erase(cursor);
- }
-
- void Clear() {
- cache_.clear();
- }
-
- const XcursorImage* GetXcursorImage(::Cursor cursor) const {
- return cache_.find(cursor)->second->image();
- }
-
- private:
- friend struct DefaultSingletonTraits<XCustomCursorCache>;
-
- class XCustomCursor {
- public:
- // This takes ownership of the image.
- XCustomCursor(XcursorImage* image)
- : image_(image),
- ref_(1) {
- cursor_ = XcursorImageLoadCursor(gfx::GetXDisplay(), image);
- }
-
- ~XCustomCursor() {
- XcursorImageDestroy(image_);
- XFreeCursor(gfx::GetXDisplay(), cursor_);
- }
-
- ::Cursor cursor() const { return cursor_; }
-
- void Ref() {
- ++ref_;
- }
-
- // Returns true if the cursor was destroyed because of the unref.
- bool Unref() {
- if (--ref_ == 0) {
- delete this;
- return true;
- }
- return false;
- }
-
- const XcursorImage* image() const {
- return image_;
- };
-
- private:
- XcursorImage* image_;
- int ref_;
- ::Cursor cursor_;
-
- DISALLOW_COPY_AND_ASSIGN(XCustomCursor);
- };
-
- XCustomCursorCache() {}
- ~XCustomCursorCache() {
- Clear();
- }
-
- std::map< ::Cursor, XCustomCursor*> cache_;
- DISALLOW_COPY_AND_ASSIGN(XCustomCursorCache);
-};
-
-} // namespace
-
-bool IsXInput2Available() {
- return DeviceDataManagerX11::GetInstance()->IsXInput2Available();
-}
-
-static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) {
- int dummy;
- Bool pixmaps_supported;
- // Query the server's support for XSHM.
- if (!XShmQueryVersion(dpy, &dummy, &dummy, &pixmaps_supported))
- return SHARED_MEMORY_NONE;
-
-#if defined(OS_FREEBSD)
- // On FreeBSD we can't access the shared memory after it was marked for
- // deletion, unless this behaviour is explicitly enabled by the user.
- // In case it's not enabled disable shared memory support.
- int allow_removed;
- size_t length = sizeof(allow_removed);
-
- if ((sysctlbyname("kern.ipc.shm_allow_removed", &allow_removed, &length,
- NULL, 0) < 0) || allow_removed < 1) {
- return SHARED_MEMORY_NONE;
- }
-#endif
-
- // Next we probe to see if shared memory will really work
- int shmkey = shmget(IPC_PRIVATE, 1, 0600);
- if (shmkey == -1) {
- LOG(WARNING) << "Failed to get shared memory segment.";
- return SHARED_MEMORY_NONE;
- } else {
- VLOG(1) << "Got shared memory segment " << shmkey;
- }
-
- void* address = shmat(shmkey, NULL, 0);
- // Mark the shared memory region for deletion
- shmctl(shmkey, IPC_RMID, NULL);
-
- XShmSegmentInfo shminfo;
- memset(&shminfo, 0, sizeof(shminfo));
- shminfo.shmid = shmkey;
-
- gfx::X11ErrorTracker err_tracker;
- bool result = XShmAttach(dpy, &shminfo);
- if (result)
- VLOG(1) << "X got shared memory segment " << shmkey;
- else
- LOG(WARNING) << "X failed to attach to shared memory segment " << shmkey;
- if (err_tracker.FoundNewError())
- result = false;
- shmdt(address);
- if (!result) {
- LOG(WARNING) << "X failed to attach to shared memory segment " << shmkey;
- return SHARED_MEMORY_NONE;
- }
-
- VLOG(1) << "X attached to shared memory segment " << shmkey;
-
- XShmDetach(dpy, &shminfo);
- return pixmaps_supported ? SHARED_MEMORY_PIXMAP : SHARED_MEMORY_PUTIMAGE;
-}
-
-SharedMemorySupport QuerySharedMemorySupport(XDisplay* dpy) {
- static SharedMemorySupport shared_memory_support = SHARED_MEMORY_NONE;
- static bool shared_memory_support_cached = false;
-
- if (shared_memory_support_cached)
- return shared_memory_support;
-
- shared_memory_support = DoQuerySharedMemorySupport(dpy);
- shared_memory_support_cached = true;
-
- return shared_memory_support;
-}
-
-bool QueryRenderSupport(Display* dpy) {
- int dummy;
- // We don't care about the version of Xrender since all the features which
- // we use are included in every version.
- static bool render_supported = XRenderQueryExtension(dpy, &dummy, &dummy);
-
- return render_supported;
-}
-
-::Cursor GetXCursor(int cursor_shape) {
- if (!cursor_cache)
- cursor_cache = new XCursorCache;
- return cursor_cache->GetCursor(cursor_shape);
-}
-
-::Cursor CreateReffedCustomXCursor(XcursorImage* image) {
- return XCustomCursorCache::GetInstance()->InstallCustomCursor(image);
-}
-
-void RefCustomXCursor(::Cursor cursor) {
- XCustomCursorCache::GetInstance()->Ref(cursor);
-}
-
-void UnrefCustomXCursor(::Cursor cursor) {
- XCustomCursorCache::GetInstance()->Unref(cursor);
-}
-
-XcursorImage* SkBitmapToXcursorImage(const SkBitmap* cursor_image,
- const gfx::Point& hotspot) {
- DCHECK(cursor_image->colorType() == kN32_SkColorType);
- gfx::Point hotspot_point = hotspot;
- SkBitmap scaled;
-
- // X11 seems to have issues with cursors when images get larger than 64
- // pixels. So rescale the image if necessary.
- const float kMaxPixel = 64.f;
- bool needs_scale = false;
- if (cursor_image->width() > kMaxPixel || cursor_image->height() > kMaxPixel) {
- float scale = 1.f;
- if (cursor_image->width() > cursor_image->height())
- scale = kMaxPixel / cursor_image->width();
- else
- scale = kMaxPixel / cursor_image->height();
-
- scaled = skia::ImageOperations::Resize(*cursor_image,
- skia::ImageOperations::RESIZE_BETTER,
- static_cast<int>(cursor_image->width() * scale),
- static_cast<int>(cursor_image->height() * scale));
- hotspot_point = gfx::ToFlooredPoint(gfx::ScalePoint(hotspot, scale));
- needs_scale = true;
- }
-
- const SkBitmap* bitmap = needs_scale ? &scaled : cursor_image;
- XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height());
- image->xhot = std::min(bitmap->width() - 1, hotspot_point.x());
- image->yhot = std::min(bitmap->height() - 1, hotspot_point.y());
-
- if (bitmap->width() && bitmap->height()) {
- bitmap->lockPixels();
- // The |bitmap| contains ARGB image, so just copy it.
- memcpy(image->pixels,
- bitmap->getPixels(),
- bitmap->width() * bitmap->height() * 4);
- bitmap->unlockPixels();
- }
-
- return image;
-}
-
-
-int CoalescePendingMotionEvents(const XEvent* xev,
- XEvent* last_event) {
- XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
- int num_coalesced = 0;
- XDisplay* display = xev->xany.display;
- int event_type = xev->xgeneric.evtype;
-
- DCHECK(event_type == XI_Motion || event_type == XI_TouchUpdate);
-
- while (XPending(display)) {
- XEvent next_event;
- XPeekEvent(display, &next_event);
-
- // If we can't get the cookie, abort the check.
- if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie))
- return num_coalesced;
-
- // If this isn't from a valid device, throw the event away, as
- // that's what the message pump would do. Device events come in pairs
- // with one from the master and one from the slave so there will
- // always be at least one pending.
- if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) {
- XFreeEventData(display, &next_event.xcookie);
- XNextEvent(display, &next_event);
- continue;
- }
-
- if (next_event.type == GenericEvent &&
- next_event.xgeneric.evtype == event_type &&
- !ui::DeviceDataManagerX11::GetInstance()->IsCMTGestureEvent(
- &next_event)) {
- XIDeviceEvent* next_xievent =
- static_cast<XIDeviceEvent*>(next_event.xcookie.data);
- // Confirm that the motion event is targeted at the same window
- // and that no buttons or modifiers have changed.
- if (xievent->event == next_xievent->event &&
- xievent->child == next_xievent->child &&
- xievent->detail == next_xievent->detail &&
- xievent->buttons.mask_len == next_xievent->buttons.mask_len &&
- (memcmp(xievent->buttons.mask,
- next_xievent->buttons.mask,
- xievent->buttons.mask_len) == 0) &&
- xievent->mods.base == next_xievent->mods.base &&
- xievent->mods.latched == next_xievent->mods.latched &&
- xievent->mods.locked == next_xievent->mods.locked &&
- xievent->mods.effective == next_xievent->mods.effective) {
- XFreeEventData(display, &next_event.xcookie);
- // Free the previous cookie.
- if (num_coalesced > 0)
- XFreeEventData(display, &last_event->xcookie);
- // Get the event and its cookie data.
- XNextEvent(display, last_event);
- XGetEventData(display, &last_event->xcookie);
- ++num_coalesced;
- continue;
- }
- }
- // This isn't an event we want so free its cookie data.
- XFreeEventData(display, &next_event.xcookie);
- break;
- }
-
- if (event_type == XI_Motion && num_coalesced > 0) {
- base::TimeDelta delta = ui::EventTimeFromNative(last_event) -
- ui::EventTimeFromNative(const_cast<XEvent*>(xev));
- UMA_HISTOGRAM_COUNTS_10000("Event.CoalescedCount.Mouse", num_coalesced);
- UMA_HISTOGRAM_TIMES("Event.CoalescedLatency.Mouse", delta);
- }
- return num_coalesced;
-}
-
-void HideHostCursor() {
- CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor,
- (CreateInvisibleCursor(), gfx::GetXDisplay()));
- XDefineCursor(gfx::GetXDisplay(), DefaultRootWindow(gfx::GetXDisplay()),
- invisible_cursor.get());
-}
-
-::Cursor CreateInvisibleCursor() {
- XDisplay* xdisplay = gfx::GetXDisplay();
- ::Cursor invisible_cursor;
- char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- XColor black;
- black.red = black.green = black.blue = 0;
- Pixmap blank = XCreateBitmapFromData(xdisplay,
- DefaultRootWindow(xdisplay),
- nodata, 8, 8);
- invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank,
- &black, &black, 0, 0);
- XFreePixmap(xdisplay, blank);
- return invisible_cursor;
-}
-
-void SetUseOSWindowFrame(XID window, bool use_os_window_frame) {
- // This data structure represents additional hints that we send to the window
- // manager and has a direct lineage back to Motif, which defined this de facto
- // standard. This struct doesn't seem 64-bit safe though, but it's what GDK
- // does.
- typedef struct {
- unsigned long flags;
- unsigned long functions;
- unsigned long decorations;
- long input_mode;
- unsigned long status;
- } MotifWmHints;
-
- MotifWmHints motif_hints;
- memset(&motif_hints, 0, sizeof(motif_hints));
- // Signals that the reader of the _MOTIF_WM_HINTS property should pay
- // attention to the value of |decorations|.
- motif_hints.flags = (1L << 1);
- motif_hints.decorations = use_os_window_frame ? 1 : 0;
-
- XAtom hint_atom = GetAtom("_MOTIF_WM_HINTS");
- XChangeProperty(gfx::GetXDisplay(),
- window,
- hint_atom,
- hint_atom,
- 32,
- PropModeReplace,
- reinterpret_cast<unsigned char*>(&motif_hints),
- sizeof(MotifWmHints)/sizeof(long));
-}
-
-bool IsShapeExtensionAvailable() {
- int dummy;
- static bool is_shape_available =
- XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy);
- return is_shape_available;
-}
-
-XID GetX11RootWindow() {
- return DefaultRootWindow(gfx::GetXDisplay());
-}
-
-bool GetCurrentDesktop(int* desktop) {
- return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop);
-}
-
-void SetHideTitlebarWhenMaximizedProperty(XID window,
- HideTitlebarWhenMaximized property) {
- // XChangeProperty() expects "hide" to be long.
- unsigned long hide = property;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- GetAtom("_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"),
- XA_CARDINAL,
- 32, // size in bits
- PropModeReplace,
- reinterpret_cast<unsigned char*>(&hide),
- 1);
-}
-
-void ClearX11DefaultRootWindow() {
- XDisplay* display = gfx::GetXDisplay();
- XID root_window = GetX11RootWindow();
- gfx::Rect root_bounds;
- if (!GetOuterWindowBounds(root_window, &root_bounds)) {
- LOG(ERROR) << "Failed to get the bounds of the X11 root window";
- return;
- }
-
- XGCValues gc_values = {0};
- gc_values.foreground = BlackPixel(display, DefaultScreen(display));
- GC gc = XCreateGC(display, root_window, GCForeground, &gc_values);
- XFillRectangle(display, root_window, gc,
- root_bounds.x(),
- root_bounds.y(),
- root_bounds.width(),
- root_bounds.height());
- XFreeGC(display, gc);
-}
-
-bool IsWindowVisible(XID window) {
- TRACE_EVENT0("ui", "IsWindowVisible");
-
- XWindowAttributes win_attributes;
- if (!XGetWindowAttributes(gfx::GetXDisplay(), window, &win_attributes))
- return false;
- if (win_attributes.map_state != IsViewable)
- return false;
-
- // Minimized windows are not visible.
- std::vector<XAtom> wm_states;
- if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) {
- XAtom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN");
- if (std::find(wm_states.begin(), wm_states.end(), hidden_atom) !=
- wm_states.end()) {
- return false;
- }
- }
-
- // Some compositing window managers (notably kwin) do not actually unmap
- // windows on desktop switch, so we also must check the current desktop.
- int window_desktop, current_desktop;
- return (!GetWindowDesktop(window, &window_desktop) ||
- !GetCurrentDesktop(¤t_desktop) ||
- window_desktop == kAllDesktops ||
- window_desktop == current_desktop);
-}
-
-bool GetInnerWindowBounds(XID window, gfx::Rect* rect) {
- Window root, child;
- int x, y;
- unsigned int width, height;
- unsigned int border_width, depth;
-
- if (!XGetGeometry(gfx::GetXDisplay(), window, &root, &x, &y,
- &width, &height, &border_width, &depth))
- return false;
-
- if (!XTranslateCoordinates(gfx::GetXDisplay(), window, root,
- 0, 0, &x, &y, &child))
- return false;
-
- *rect = gfx::Rect(x, y, width, height);
-
- return true;
-}
-
-bool GetWindowExtents(XID window, gfx::Insets* extents) {
- std::vector<int> insets;
- if (!GetIntArrayProperty(window, "_NET_FRAME_EXTENTS", &insets))
- return false;
- if (insets.size() != 4)
- return false;
-
- int left = insets[0];
- int right = insets[1];
- int top = insets[2];
- int bottom = insets[3];
- extents->Set(-top, -left, -bottom, -right);
- return true;
-}
-
-bool GetOuterWindowBounds(XID window, gfx::Rect* rect) {
- if (!GetInnerWindowBounds(window, rect))
- return false;
-
- gfx::Insets extents;
- if (GetWindowExtents(window, &extents))
- rect->Inset(extents);
- // Not all window managers support _NET_FRAME_EXTENTS so return true even if
- // requesting the property fails.
-
- return true;
-}
-
-
-bool WindowContainsPoint(XID window, gfx::Point screen_loc) {
- TRACE_EVENT0("ui", "WindowContainsPoint");
-
- gfx::Rect window_rect;
- if (!GetOuterWindowBounds(window, &window_rect))
- return false;
-
- if (!window_rect.Contains(screen_loc))
- return false;
-
- if (!IsShapeExtensionAvailable())
- return true;
-
- // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html,
- // if an X display supports the shape extension the bounds of a window are
- // defined as the intersection of the window bounds and the interior
- // rectangles. This means to determine if a point is inside a window for the
- // purpose of input handling we have to check the rectangles in the ShapeInput
- // list.
- // According to http://www.x.org/releases/current/doc/xextproto/shape.html,
- // we need to also respect the ShapeBounding rectangles.
- // The effective input region of a window is defined to be the intersection
- // of the client input region with both the default input region and the
- // client bounding region. Any portion of the client input region that is not
- // included in both the default input region and the client bounding region
- // will not be included in the effective input region on the screen.
- int rectangle_kind[] = {ShapeInput, ShapeBounding};
- for (size_t kind_index = 0;
- kind_index < arraysize(rectangle_kind);
- kind_index++) {
- int dummy;
- int shape_rects_size = 0;
- XRectangle* shape_rects = XShapeGetRectangles(gfx::GetXDisplay(),
- window,
- rectangle_kind[kind_index],
- &shape_rects_size,
- &dummy);
- if (!shape_rects) {
- // The shape is empty. This can occur when |window| is minimized.
- DCHECK_EQ(0, shape_rects_size);
- return false;
- }
- bool is_in_shape_rects = false;
- for (int i = 0; i < shape_rects_size; ++i) {
- // The ShapeInput and ShapeBounding rects are to be in window space, so we
- // have to translate by the window_rect's offset to map to screen space.
- gfx::Rect shape_rect =
- gfx::Rect(shape_rects[i].x + window_rect.x(),
- shape_rects[i].y + window_rect.y(),
- shape_rects[i].width, shape_rects[i].height);
- if (shape_rect.Contains(screen_loc)) {
- is_in_shape_rects = true;
- break;
- }
- }
- XFree(shape_rects);
- if (!is_in_shape_rects)
- return false;
- }
- return true;
-}
-
-
-bool PropertyExists(XID window, const std::string& property_name) {
- XAtom type = None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = NULL;
-
- int result = GetProperty(window, property_name, 1,
- &type, &format, &num_items, &property);
- if (result != Success)
- return false;
-
- XFree(property);
- return num_items > 0;
-}
-
-bool GetRawBytesOfProperty(XID window,
- XAtom property,
- scoped_refptr<base::RefCountedMemory>* out_data,
- size_t* out_data_items,
- XAtom* out_type) {
- // Retrieve the data from our window.
- unsigned long nitems = 0;
- unsigned long nbytes = 0;
- XAtom prop_type = None;
- int prop_format = 0;
- unsigned char* property_data = NULL;
- if (XGetWindowProperty(gfx::GetXDisplay(), window, property,
- 0, 0x1FFFFFFF /* MAXINT32 / 4 */, False,
- AnyPropertyType, &prop_type, &prop_format,
- &nitems, &nbytes, &property_data) != Success) {
- return false;
- }
-
- if (prop_type == None)
- return false;
-
- size_t bytes = 0;
- // So even though we should theoretically have nbytes (and we can't
- // pass NULL there), we need to manually calculate the byte length here
- // because nbytes always returns zero.
- switch (prop_format) {
- case 8:
- bytes = nitems;
- break;
- case 16:
- bytes = sizeof(short) * nitems;
- break;
- case 32:
- bytes = sizeof(long) * nitems;
- break;
- default:
- NOTREACHED();
- break;
- }
-
- if (out_data)
- *out_data = new XRefcountedMemory(property_data, bytes);
- else
- XFree(property_data);
-
- if (out_data_items)
- *out_data_items = nitems;
-
- if (out_type)
- *out_type = prop_type;
-
- return true;
-}
-
-bool GetIntProperty(XID window, const std::string& property_name, int* value) {
- XAtom type = None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = NULL;
-
- int result = GetProperty(window, property_name, 1,
- &type, &format, &num_items, &property);
- if (result != Success)
- return false;
-
- if (format != 32 || num_items != 1) {
- XFree(property);
- return false;
- }
-
- *value = static_cast<int>(*(reinterpret_cast<long*>(property)));
- XFree(property);
- return true;
-}
-
-bool GetXIDProperty(XID window, const std::string& property_name, XID* value) {
- XAtom type = None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = NULL;
-
- int result = GetProperty(window, property_name, 1,
- &type, &format, &num_items, &property);
- if (result != Success)
- return false;
-
- if (format != 32 || num_items != 1) {
- XFree(property);
- return false;
- }
-
- *value = *(reinterpret_cast<XID*>(property));
- XFree(property);
- return true;
-}
-
-bool GetIntArrayProperty(XID window,
- const std::string& property_name,
- std::vector<int>* value) {
- XAtom type = None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* properties = NULL;
-
- int result = GetProperty(window, property_name,
- (~0L), // (all of them)
- &type, &format, &num_items, &properties);
- if (result != Success)
- return false;
-
- if (format != 32) {
- XFree(properties);
- return false;
- }
-
- long* int_properties = reinterpret_cast<long*>(properties);
- value->clear();
- for (unsigned long i = 0; i < num_items; ++i) {
- value->push_back(static_cast<int>(int_properties[i]));
- }
- XFree(properties);
- return true;
-}
-
-bool GetAtomArrayProperty(XID window,
- const std::string& property_name,
- std::vector<XAtom>* value) {
- XAtom type = None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* properties = NULL;
-
- int result = GetProperty(window, property_name,
- (~0L), // (all of them)
- &type, &format, &num_items, &properties);
- if (result != Success)
- return false;
-
- if (type != XA_ATOM) {
- XFree(properties);
- return false;
- }
-
- XAtom* atom_properties = reinterpret_cast<XAtom*>(properties);
- value->clear();
- value->insert(value->begin(), atom_properties, atom_properties + num_items);
- XFree(properties);
- return true;
-}
-
-bool GetStringProperty(
- XID window, const std::string& property_name, std::string* value) {
- XAtom type = None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = NULL;
-
- int result = GetProperty(window, property_name, 1024,
- &type, &format, &num_items, &property);
- if (result != Success)
- return false;
-
- if (format != 8) {
- XFree(property);
- return false;
- }
-
- value->assign(reinterpret_cast<char*>(property), num_items);
- XFree(property);
- return true;
-}
-
-bool SetIntProperty(XID window,
- const std::string& name,
- const std::string& type,
- int value) {
- std::vector<int> values(1, value);
- return SetIntArrayProperty(window, name, type, values);
-}
-
-bool SetIntArrayProperty(XID window,
- const std::string& name,
- const std::string& type,
- const std::vector<int>& value) {
- DCHECK(!value.empty());
- XAtom name_atom = GetAtom(name.c_str());
- XAtom type_atom = GetAtom(type.c_str());
-
- // XChangeProperty() expects values of type 32 to be longs.
- scoped_ptr<long[]> data(new long[value.size()]);
- for (size_t i = 0; i < value.size(); ++i)
- data[i] = value[i];
-
- gfx::X11ErrorTracker err_tracker;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- name_atom,
- type_atom,
- 32, // size in bits of items in 'value'
- PropModeReplace,
- reinterpret_cast<const unsigned char*>(data.get()),
- value.size()); // num items
- return !err_tracker.FoundNewError();
-}
-
-bool SetAtomProperty(XID window,
- const std::string& name,
- const std::string& type,
- XAtom value) {
- std::vector<XAtom> values(1, value);
- return SetAtomArrayProperty(window, name, type, values);
-}
-
-bool SetAtomArrayProperty(XID window,
- const std::string& name,
- const std::string& type,
- const std::vector<XAtom>& value) {
- DCHECK(!value.empty());
- XAtom name_atom = GetAtom(name.c_str());
- XAtom type_atom = GetAtom(type.c_str());
-
- // XChangeProperty() expects values of type 32 to be longs.
- scoped_ptr<XAtom[]> data(new XAtom[value.size()]);
- for (size_t i = 0; i < value.size(); ++i)
- data[i] = value[i];
-
- gfx::X11ErrorTracker err_tracker;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- name_atom,
- type_atom,
- 32, // size in bits of items in 'value'
- PropModeReplace,
- reinterpret_cast<const unsigned char*>(data.get()),
- value.size()); // num items
- return !err_tracker.FoundNewError();
-}
-
-bool SetStringProperty(XID window,
- XAtom property,
- XAtom type,
- const std::string& value) {
- gfx::X11ErrorTracker err_tracker;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- property,
- type,
- 8,
- PropModeReplace,
- reinterpret_cast<const unsigned char*>(value.c_str()),
- value.size());
- return !err_tracker.FoundNewError();
-}
-
-XAtom GetAtom(const char* name) {
- // TODO(derat): Cache atoms to avoid round-trips to the server.
- return XInternAtom(gfx::GetXDisplay(), name, false);
-}
-
-void SetWindowClassHint(XDisplay* display,
- XID window,
- const std::string& res_name,
- const std::string& res_class) {
- XClassHint class_hints;
- // const_cast is safe because XSetClassHint does not modify the strings.
- // Just to be safe, the res_name and res_class parameters are local copies,
- // not const references.
- class_hints.res_name = const_cast<char*>(res_name.c_str());
- class_hints.res_class = const_cast<char*>(res_class.c_str());
- XSetClassHint(display, window, &class_hints);
-}
-
-void SetWindowRole(XDisplay* display, XID window, const std::string& role) {
- if (role.empty()) {
- XDeleteProperty(display, window, GetAtom("WM_WINDOW_ROLE"));
- } else {
- char* role_c = const_cast<char*>(role.c_str());
- XChangeProperty(display, window, GetAtom("WM_WINDOW_ROLE"), XA_STRING, 8,
- PropModeReplace,
- reinterpret_cast<unsigned char*>(role_c),
- role.size());
- }
-}
-
-bool GetCustomFramePrefDefault() {
- // If the window manager doesn't support enough of EWMH to tell us its name,
- // assume that it doesn't want custom frames. For example, _NET_WM_MOVERESIZE
- // is needed for frame-drag-initiated window movement.
- std::string wm_name;
- if (!GetWindowManagerName(&wm_name))
- return false;
-
- // Also disable custom frames for (at-least-partially-)EWMH-supporting tiling
- // window managers.
- ui::WindowManagerName wm = GuessWindowManager();
- if (wm == WM_AWESOME ||
- wm == WM_I3 ||
- wm == WM_ION3 ||
- wm == WM_MATCHBOX ||
- wm == WM_NOTION ||
- wm == WM_QTILE ||
- wm == WM_RATPOISON ||
- wm == WM_STUMPWM ||
- wm == WM_WMII)
- return false;
-
- // Handle a few more window managers that don't get along well with custom
- // frames.
- if (wm == WM_ICE_WM ||
- wm == WM_KWIN)
- return false;
-
- // For everything else, use custom frames.
- return true;
-}
-
-bool GetWindowDesktop(XID window, int* desktop) {
- return GetIntProperty(window, "_NET_WM_DESKTOP", desktop);
-}
-
-std::string GetX11ErrorString(XDisplay* display, int err) {
- char buffer[256];
- XGetErrorText(display, err, buffer, arraysize(buffer));
- return buffer;
-}
-
-// Returns true if |window| is a named window.
-bool IsWindowNamed(XID window) {
- XTextProperty prop;
- if (!XGetWMName(gfx::GetXDisplay(), window, &prop) || !prop.value)
- return false;
-
- XFree(prop.value);
- return true;
-}
-
-bool GetXWindowStack(Window window, std::vector<XID>* windows) {
- windows->clear();
-
- Atom type;
- int format;
- unsigned long count;
- unsigned char *data = NULL;
- if (GetProperty(window,
- "_NET_CLIENT_LIST_STACKING",
- ~0L,
- &type,
- &format,
- &count,
- &data) != Success) {
- return false;
- }
-
- bool result = false;
- if (type == XA_WINDOW && format == 32 && data && count > 0) {
- result = true;
- XID* stack = reinterpret_cast<XID*>(data);
- for (long i = static_cast<long>(count) - 1; i >= 0; i--)
- windows->push_back(stack[i]);
- }
-
- if (data)
- XFree(data);
-
- return result;
-}
-
-WindowManagerName GuessWindowManager() {
- std::string name;
- if (GetWindowManagerName(&name)) {
- // These names are taken from the WMs' source code.
- if (name == "awesome")
- return WM_AWESOME;
- if (name == "Blackbox")
- return WM_BLACKBOX;
- if (name == "Compiz" || name == "compiz")
- return WM_COMPIZ;
- if (name == "e16" || name == "Enlightenment")
- return WM_ENLIGHTENMENT;
- if (name == "i3")
- return WM_I3;
- if (StartsWithASCII(name, "IceWM", true))
- return WM_ICE_WM;
- if (name == "ion3")
- return WM_ION3;
- if (name == "KWin")
- return WM_KWIN;
- if (name == "matchbox")
- return WM_MATCHBOX;
- if (name == "Metacity")
- return WM_METACITY;
- if (name == "Mutter (Muffin)")
- return WM_MUFFIN;
- if (name == "GNOME Shell")
- return WM_MUTTER; // GNOME Shell uses Mutter
- if (name == "Mutter")
- return WM_MUTTER;
- if (name == "notion")
- return WM_NOTION;
- if (name == "Openbox")
- return WM_OPENBOX;
- if (name == "qtile")
- return WM_QTILE;
- if (name == "ratpoison")
- return WM_RATPOISON;
- if (name == "stumpwm")
- return WM_STUMPWM;
- if (name == "wmii")
- return WM_WMII;
- if (name == "Xfwm4")
- return WM_XFWM4;
- }
- return WM_UNKNOWN;
-}
-
-std::string GuessWindowManagerName() {
- std::string name;
- if (GetWindowManagerName(&name))
- return name;
- return "Unknown";
-}
-
-void SetDefaultX11ErrorHandlers() {
- SetX11ErrorHandlers(NULL, NULL);
-}
-
-bool IsX11WindowFullScreen(XID window) {
- // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or
- // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine
- // whether we're fullscreen.
- XAtom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN");
- if (WmSupportsHint(fullscreen_atom)) {
- std::vector<XAtom> atom_properties;
- if (GetAtomArrayProperty(window,
- "_NET_WM_STATE",
- &atom_properties)) {
- return std::find(atom_properties.begin(),
- atom_properties.end(),
- fullscreen_atom) !=
- atom_properties.end();
- }
- }
-
- gfx::Rect window_rect;
- if (!ui::GetOuterWindowBounds(window, &window_rect))
- return false;
-
- // We can't use gfx::Screen here because we don't have an aura::Window. So
- // instead just look at the size of the default display.
- //
- // TODO(erg): Actually doing this correctly would require pulling out xrandr,
- // which we don't even do in the desktop screen yet.
- ::XDisplay* display = gfx::GetXDisplay();
- ::Screen* screen = DefaultScreenOfDisplay(display);
- int width = WidthOfScreen(screen);
- int height = HeightOfScreen(screen);
- return window_rect.size() == gfx::Size(width, height);
-}
-
-bool WmSupportsHint(XAtom atom) {
- if (!SupportsEWMH())
- return false;
-
- std::vector<XAtom> supported_atoms;
- if (!GetAtomArrayProperty(GetX11RootWindow(),
- "_NET_SUPPORTED",
- &supported_atoms)) {
- return false;
- }
-
- return std::find(supported_atoms.begin(), supported_atoms.end(), atom) !=
- supported_atoms.end();
-}
-
-const unsigned char* XRefcountedMemory::front() const {
- return x11_data_;
-}
-
-size_t XRefcountedMemory::size() const {
- return length_;
-}
-
-XRefcountedMemory::~XRefcountedMemory() {
- XFree(x11_data_);
-}
-
-XScopedString::~XScopedString() {
- XFree(string_);
-}
-
-XScopedImage::~XScopedImage() {
- reset(NULL);
-}
-
-void XScopedImage::reset(XImage* image) {
- if (image_ == image)
- return;
- if (image_)
- XDestroyImage(image_);
- image_ = image;
-}
-
-XScopedCursor::XScopedCursor(::Cursor cursor, XDisplay* display)
- : cursor_(cursor),
- display_(display) {
-}
-
-XScopedCursor::~XScopedCursor() {
- reset(0U);
-}
-
-::Cursor XScopedCursor::get() const {
- return cursor_;
-}
-
-void XScopedCursor::reset(::Cursor cursor) {
- if (cursor_)
- XFreeCursor(display_, cursor_);
- cursor_ = cursor;
-}
-
-namespace test {
-
-void ResetXCursorCache() {
- delete cursor_cache;
- cursor_cache = NULL;
-}
-
-const XcursorImage* GetCachedXcursorImage(::Cursor cursor) {
- return XCustomCursorCache::GetInstance()->GetXcursorImage(cursor);
-}
-}
-
-// ----------------------------------------------------------------------------
-// These functions are declared in x11_util_internal.h because they require
-// XLib.h to be included, and it conflicts with many other headers.
-XRenderPictFormat* GetRenderARGB32Format(XDisplay* dpy) {
- static XRenderPictFormat* pictformat = NULL;
- if (pictformat)
- return pictformat;
-
- // First look for a 32-bit format which ignores the alpha value
- XRenderPictFormat templ;
- templ.depth = 32;
- templ.type = PictTypeDirect;
- templ.direct.red = 16;
- templ.direct.green = 8;
- templ.direct.blue = 0;
- templ.direct.redMask = 0xff;
- templ.direct.greenMask = 0xff;
- templ.direct.blueMask = 0xff;
- templ.direct.alphaMask = 0;
-
- static const unsigned long kMask =
- PictFormatType | PictFormatDepth |
- PictFormatRed | PictFormatRedMask |
- PictFormatGreen | PictFormatGreenMask |
- PictFormatBlue | PictFormatBlueMask |
- PictFormatAlphaMask;
-
- pictformat = XRenderFindFormat(dpy, kMask, &templ, 0 /* first result */);
-
- if (!pictformat) {
- // Not all X servers support xRGB32 formats. However, the XRENDER spec says
- // that they must support an ARGB32 format, so we can always return that.
- pictformat = XRenderFindStandardFormat(dpy, PictStandardARGB32);
- CHECK(pictformat) << "XRENDER ARGB32 not supported.";
- }
-
- return pictformat;
-}
-
-void SetX11ErrorHandlers(XErrorHandler error_handler,
- XIOErrorHandler io_error_handler) {
- XSetErrorHandler(error_handler ? error_handler : DefaultX11ErrorHandler);
- XSetIOErrorHandler(
- io_error_handler ? io_error_handler : DefaultX11IOErrorHandler);
-}
-
-void LogErrorEventDescription(XDisplay* dpy,
- const XErrorEvent& error_event) {
- char error_str[256];
- char request_str[256];
-
- XGetErrorText(dpy, error_event.error_code, error_str, sizeof(error_str));
-
- strncpy(request_str, "Unknown", sizeof(request_str));
- if (error_event.request_code < 128) {
- std::string num = base::UintToString(error_event.request_code);
- XGetErrorDatabaseText(
- dpy, "XRequest", num.c_str(), "Unknown", request_str,
- sizeof(request_str));
- } else {
- int num_ext;
- char** ext_list = XListExtensions(dpy, &num_ext);
-
- for (int i = 0; i < num_ext; i++) {
- int ext_code, first_event, first_error;
- XQueryExtension(dpy, ext_list[i], &ext_code, &first_event, &first_error);
- if (error_event.request_code == ext_code) {
- std::string msg = base::StringPrintf(
- "%s.%d", ext_list[i], error_event.minor_code);
- XGetErrorDatabaseText(
- dpy, "XRequest", msg.c_str(), "Unknown", request_str,
- sizeof(request_str));
- break;
- }
- }
- XFreeExtensionList(ext_list);
- }
-
- LOG(WARNING)
- << "X error received: "
- << "serial " << error_event.serial << ", "
- << "error_code " << static_cast<int>(error_event.error_code)
- << " (" << error_str << "), "
- << "request_code " << static_cast<int>(error_event.request_code) << ", "
- << "minor_code " << static_cast<int>(error_event.minor_code)
- << " (" << request_str << ")";
-}
-
-// ----------------------------------------------------------------------------
-// End of x11_util_internal.h
-
-
-} // namespace ui
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
deleted file mode 100644
index e8e5f04..0000000
--- a/ui/base/x/x11_util.h
+++ /dev/null
@@ -1,352 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_X_X11_UTIL_H_
-#define UI_BASE_X_X11_UTIL_H_
-
-// This file declares utility functions for X11 (Linux only).
-//
-// These functions do not require the Xlib headers to be included (which is why
-// we use a void* for Visual*). The Xlib headers are highly polluting so we try
-// hard to limit their spread into the rest of the code.
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/event_types.h"
-#include "base/memory/ref_counted_memory.h"
-#include "ui/base/ui_base_export.h"
-#include "ui/events/event_constants.h"
-#include "ui/events/keycodes/keyboard_codes.h"
-#include "ui/gfx/x/x11_types.h"
-
-typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers.
-typedef unsigned long Cursor;
-typedef struct _XcursorImage XcursorImage;
-typedef union _XEvent XEvent;
-
-namespace gfx {
-class Canvas;
-class Insets;
-class Point;
-class Rect;
-}
-class SkBitmap;
-
-namespace ui {
-
-// These functions use the default display and this /must/ be called from
-// the UI thread. Thus, they don't support multiple displays.
-
-// These functions cache their results ---------------------------------
-
-// Returns true if the system supports XINPUT2.
-UI_BASE_EXPORT bool IsXInput2Available();
-
-// X shared memory comes in three flavors:
-// 1) No SHM support,
-// 2) SHM putimage,
-// 3) SHM pixmaps + putimage.
-enum SharedMemorySupport {
- SHARED_MEMORY_NONE,
- SHARED_MEMORY_PUTIMAGE,
- SHARED_MEMORY_PIXMAP
-};
-// Return the shared memory type of our X connection.
-UI_BASE_EXPORT SharedMemorySupport QuerySharedMemorySupport(XDisplay* dpy);
-
-// Return true iff the display supports Xrender
-UI_BASE_EXPORT bool QueryRenderSupport(XDisplay* dpy);
-
-// Returns an X11 Cursor, sharable across the process.
-// |cursor_shape| is an X font cursor shape, see XCreateFontCursor().
-UI_BASE_EXPORT ::Cursor GetXCursor(int cursor_shape);
-
-// Creates a custom X cursor from the image. This takes ownership of image. The
-// caller must not free/modify the image. The refcount of the newly created
-// cursor is set to 1.
-UI_BASE_EXPORT ::Cursor CreateReffedCustomXCursor(XcursorImage* image);
-
-// Increases the refcount of the custom cursor.
-UI_BASE_EXPORT void RefCustomXCursor(::Cursor cursor);
-
-// Decreases the refcount of the custom cursor, and destroys it if it reaches 0.
-UI_BASE_EXPORT void UnrefCustomXCursor(::Cursor cursor);
-
-// Creates a XcursorImage and copies the SkBitmap |bitmap| on it. |bitmap|
-// should be non-null. Caller owns the returned object.
-UI_BASE_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap,
- const gfx::Point& hotspot);
-
-// Coalesce all pending motion events (touch or mouse) that are at the top of
-// the queue, and return the number eliminated, storing the last one in
-// |last_event|.
-UI_BASE_EXPORT int CoalescePendingMotionEvents(const XEvent* xev,
- XEvent* last_event);
-
-// Hides the host cursor.
-UI_BASE_EXPORT void HideHostCursor();
-
-// Returns an invisible cursor.
-UI_BASE_EXPORT ::Cursor CreateInvisibleCursor();
-
-// Sets whether |window| should use the OS window frame.
-UI_BASE_EXPORT void SetUseOSWindowFrame(XID window, bool use_os_window_frame);
-
-// These functions do not cache their results --------------------------
-
-// Returns true if the shape extension is supported.
-UI_BASE_EXPORT bool IsShapeExtensionAvailable();
-
-// Get the X window id for the default root window
-UI_BASE_EXPORT XID GetX11RootWindow();
-
-// Returns the user's current desktop.
-UI_BASE_EXPORT bool GetCurrentDesktop(int* desktop);
-
-enum HideTitlebarWhenMaximized {
- SHOW_TITLEBAR_WHEN_MAXIMIZED = 0,
- HIDE_TITLEBAR_WHEN_MAXIMIZED = 1,
-};
-// Sets _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED on |window|.
-UI_BASE_EXPORT void SetHideTitlebarWhenMaximizedProperty(
- XID window,
- HideTitlebarWhenMaximized property);
-
-// Clears all regions of X11's default root window by filling black pixels.
-UI_BASE_EXPORT void ClearX11DefaultRootWindow();
-
-// Returns true if |window| is visible.
-UI_BASE_EXPORT bool IsWindowVisible(XID window);
-
-// Returns the inner bounds of |window| (excluding the non-client area).
-UI_BASE_EXPORT bool GetInnerWindowBounds(XID window, gfx::Rect* rect);
-
-// Returns the non-client area extents of |window|. This is a negative inset; it
-// represents the negative size of the window border on all sides.
-// InnerWindowBounds.Inset(WindowExtents) = OuterWindowBounds.
-// Returns false if the window manager does not provide extents information.
-UI_BASE_EXPORT bool GetWindowExtents(XID window, gfx::Insets* extents);
-
-// Returns the outer bounds of |window| (including the non-client area).
-UI_BASE_EXPORT bool GetOuterWindowBounds(XID window, gfx::Rect* rect);
-
-// Returns true if |window| contains the point |screen_loc|.
-UI_BASE_EXPORT bool WindowContainsPoint(XID window, gfx::Point screen_loc);
-
-// Return true if |window| has any property with |property_name|.
-UI_BASE_EXPORT bool PropertyExists(XID window,
- const std::string& property_name);
-
-// Returns the raw bytes from a property with minimal
-// interpretation. |out_data| should be freed by XFree() after use.
-UI_BASE_EXPORT bool GetRawBytesOfProperty(
- XID window,
- XAtom property,
- scoped_refptr<base::RefCountedMemory>* out_data,
- size_t* out_data_items,
- XAtom* out_type);
-
-// Get the value of an int, int array, atom array or string property. On
-// success, true is returned and the value is stored in |value|.
-//
-// TODO(erg): Once we remove the gtk port and are 100% aura, all of these
-// should accept an XAtom instead of a string.
-UI_BASE_EXPORT bool GetIntProperty(XID window,
- const std::string& property_name,
- int* value);
-UI_BASE_EXPORT bool GetXIDProperty(XID window,
- const std::string& property_name,
- XID* value);
-UI_BASE_EXPORT bool GetIntArrayProperty(XID window,
- const std::string& property_name,
- std::vector<int>* value);
-UI_BASE_EXPORT bool GetAtomArrayProperty(XID window,
- const std::string& property_name,
- std::vector<XAtom>* value);
-UI_BASE_EXPORT bool GetStringProperty(XID window,
- const std::string& property_name,
- std::string* value);
-
-// These setters all make round trips.
-UI_BASE_EXPORT bool SetIntProperty(XID window,
- const std::string& name,
- const std::string& type,
- int value);
-UI_BASE_EXPORT bool SetIntArrayProperty(XID window,
- const std::string& name,
- const std::string& type,
- const std::vector<int>& value);
-UI_BASE_EXPORT bool SetAtomProperty(XID window,
- const std::string& name,
- const std::string& type,
- XAtom value);
-UI_BASE_EXPORT bool SetAtomArrayProperty(XID window,
- const std::string& name,
- const std::string& type,
- const std::vector<XAtom>& value);
-UI_BASE_EXPORT bool SetStringProperty(XID window,
- XAtom property,
- XAtom type,
- const std::string& value);
-
-// Gets the X atom for default display corresponding to atom_name.
-UI_BASE_EXPORT XAtom GetAtom(const char* atom_name);
-
-// Sets the WM_CLASS attribute for a given X11 window.
-UI_BASE_EXPORT void SetWindowClassHint(XDisplay* display,
- XID window,
- const std::string& res_name,
- const std::string& res_class);
-
-// Sets the WM_WINDOW_ROLE attribute for a given X11 window.
-UI_BASE_EXPORT void SetWindowRole(XDisplay* display,
- XID window,
- const std::string& role);
-
-// Determine whether we should default to native decorations or the custom
-// frame based on the currently-running window manager.
-UI_BASE_EXPORT bool GetCustomFramePrefDefault();
-
-static const int kAllDesktops = -1;
-// Queries the desktop |window| is on, kAllDesktops if sticky. Returns false if
-// property not found.
-bool GetWindowDesktop(XID window, int* desktop);
-
-// Translates an X11 error code into a printable string.
-UI_BASE_EXPORT std::string GetX11ErrorString(XDisplay* display, int err);
-
-// Returns all children windows of a given window in top-to-bottom stacking
-// order.
-UI_BASE_EXPORT bool GetXWindowStack(XID window, std::vector<XID>* windows);
-
-enum WindowManagerName {
- WM_UNKNOWN,
-
- WM_AWESOME,
- WM_BLACKBOX,
- WM_COMPIZ,
- WM_ENLIGHTENMENT,
- WM_I3,
- WM_ICE_WM,
- WM_ION3,
- WM_KWIN,
- WM_MATCHBOX,
- WM_METACITY,
- WM_MUFFIN,
- WM_MUTTER,
- WM_NOTION,
- WM_OPENBOX,
- WM_QTILE,
- WM_RATPOISON,
- WM_STUMPWM,
- WM_WMII,
- WM_XFWM4,
-};
-// Attempts to guess the window maager. Returns WM_UNKNOWN if we can't
-// determine it for one reason or another.
-UI_BASE_EXPORT WindowManagerName GuessWindowManager();
-
-// The same as GuessWindowManager(), but returns the raw string. If we
-// can't determine it, return "Unknown".
-UI_BASE_EXPORT std::string GuessWindowManagerName();
-
-// Enable the default X error handlers. These will log the error and abort
-// the process if called. Use SetX11ErrorHandlers() from x11_util_internal.h
-// to set your own error handlers.
-UI_BASE_EXPORT void SetDefaultX11ErrorHandlers();
-
-// Returns true if a given window is in full-screen mode.
-UI_BASE_EXPORT bool IsX11WindowFullScreen(XID window);
-
-// Returns true if the window manager supports the given hint.
-UI_BASE_EXPORT bool WmSupportsHint(XAtom atom);
-
-// Manages a piece of X11 allocated memory as a RefCountedMemory segment. This
-// object takes ownership over the passed in memory and will free it with the
-// X11 allocator when done.
-class UI_BASE_EXPORT XRefcountedMemory : public base::RefCountedMemory {
- public:
- XRefcountedMemory(unsigned char* x11_data, size_t length)
- : x11_data_(length ? x11_data : NULL), length_(length) {}
-
- // Overridden from RefCountedMemory:
- virtual const unsigned char* front() const override;
- virtual size_t size() const override;
-
- private:
- virtual ~XRefcountedMemory();
-
- unsigned char* x11_data_;
- size_t length_;
-
- DISALLOW_COPY_AND_ASSIGN(XRefcountedMemory);
-};
-
-// Keeps track of a string returned by an X function (e.g. XGetAtomName) and
-// makes sure it's XFree'd.
-class UI_BASE_EXPORT XScopedString {
- public:
- explicit XScopedString(char* str) : string_(str) {}
- ~XScopedString();
-
- const char* string() const { return string_; }
-
- private:
- char* string_;
-
- DISALLOW_COPY_AND_ASSIGN(XScopedString);
-};
-
-// Keeps track of an image returned by an X function (e.g. XGetImage) and
-// makes sure it's XDestroyImage'd.
-class UI_BASE_EXPORT XScopedImage {
- public:
- explicit XScopedImage(XImage* image) : image_(image) {}
- ~XScopedImage();
-
- XImage* get() const { return image_; }
-
- XImage* operator->() const { return image_; }
-
- void reset(XImage* image);
-
- private:
- XImage* image_;
-
- DISALLOW_COPY_AND_ASSIGN(XScopedImage);
-};
-
-// Keeps track of a cursor returned by an X function and makes sure it's
-// XFreeCursor'd.
-class UI_BASE_EXPORT XScopedCursor {
- public:
- // Keeps track of |cursor| created with |display|.
- XScopedCursor(::Cursor cursor, XDisplay* display);
- ~XScopedCursor();
-
- ::Cursor get() const;
- void reset(::Cursor cursor);
-
- private:
- ::Cursor cursor_;
- XDisplay* display_;
-
- DISALLOW_COPY_AND_ASSIGN(XScopedCursor);
-};
-
-namespace test {
-// Resets the cache used by GetXCursor(). Only useful for tests that may delete
-// the display.
-UI_BASE_EXPORT void ResetXCursorCache();
-
-// Returns the cached XcursorImage for |cursor|.
-UI_BASE_EXPORT const XcursorImage* GetCachedXcursorImage(::Cursor cursor);
-
-} // namespace test
-
-} // namespace ui
-
-#endif // UI_BASE_X_X11_UTIL_H_
diff --git a/ui/base/x/x11_util_internal.h b/ui/base/x/x11_util_internal.h
deleted file mode 100644
index f663fc5a..0000000
--- a/ui/base/x/x11_util_internal.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2011 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 UI_BASE_X_X11_UTIL_INTERNAL_H_
-#define UI_BASE_X_X11_UTIL_INTERNAL_H_
-
-// This file declares utility functions for X11 (Linux only).
-//
-// These functions require the inclusion of the Xlib headers. Since the Xlib
-// headers pollute so much of the namespace, this should only be included
-// when needed.
-
-extern "C" {
-#include <X11/extensions/Xrender.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-}
-
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// --------------------------------------------------------------------------
-// NOTE: these functions cache the results and must be called from the UI
-// thread.
-// Get the XRENDER format id for ARGB32 (Skia's format).
-//
-// NOTE:Currently this don't support multiple screens/displays.
-UI_BASE_EXPORT XRenderPictFormat* GetRenderARGB32Format(Display* dpy);
-
-// --------------------------------------------------------------------------
-// X11 error handling.
-// Sets the X Error Handlers. Passing NULL for either will enable the default
-// error handler, which if called will log the error and abort the process.
-UI_BASE_EXPORT void SetX11ErrorHandlers(XErrorHandler error_handler,
- XIOErrorHandler io_error_handler);
-
-// NOTE: This function should not be called directly from the
-// X11 Error handler because it queries the server to decode the
-// error message, which may trigger other errors. A suitable workaround
-// is to post a task in the error handler to call this function.
-UI_BASE_EXPORT void LogErrorEventDescription(Display* dpy,
- const XErrorEvent& error_event);
-
-} // namespace ui
-
-#endif // UI_BASE_X_X11_UTIL_INTERNAL_H_
diff --git a/ui/platform_window/BUILD.gn b/ui/platform_window/BUILD.gn
index 835fc70..09e9213 100644
--- a/ui/platform_window/BUILD.gn
+++ b/ui/platform_window/BUILD.gn
@@ -13,7 +13,6 @@
deps = [
"//base",
- "//ui/base",
"//ui/gfx",
]
}
diff --git a/ui/platform_window/DEPS b/ui/platform_window/DEPS
index 726e962..b273ae3 100644
--- a/ui/platform_window/DEPS
+++ b/ui/platform_window/DEPS
@@ -1,4 +1,3 @@
include_rules = [
- "+ui/base/cursor",
"+ui/gfx",
]
diff --git a/ui/platform_window/platform_window.h b/ui/platform_window/platform_window.h
index d5f5750..ac32463 100644
--- a/ui/platform_window/platform_window.h
+++ b/ui/platform_window/platform_window.h
@@ -6,14 +6,27 @@
#define UI_PLATFORM_WINDOW_PLATFORM_WINDOW_H_
#include "base/memory/scoped_ptr.h"
-#include "ui/base/cursor/cursor.h"
namespace gfx {
class Rect;
}
+#if defined(OS_WIN)
+typedef struct HINSTANCE__* HINSTANCE;
+typedef struct HICON__* HICON;
+typedef HICON HCURSOR;
+#endif
+
namespace ui {
+#if defined(OS_WIN)
+typedef ::HCURSOR PlatformCursor;
+#elif defined(USE_X11)
+typedef unsigned long PlatformCursor;
+#else
+typedef void* PlatformCursor;
+#endif
+
class PlatformWindowDelegate;
// Platform window.