From 2191196d13b2896f5ba7bc1c6a3371cb86a7e8eb Mon Sep 17 00:00:00 2001 From: reillyg Date: Fri, 12 Sep 2014 22:37:18 -0700 Subject: Reland: Convert device::UsbConfigDescriptor and friends to structs. These classes do not need to be classes and expecially don't need to be abstract classes as this leads to a complicated implementation and complicated tests. All USB devices no matter the platform will have the same descriptor data. This change follows the model of device::HidDeviceInfo. Relanding this patch (reverted in crrev.com/294640) after restoring the call to libusb_free_config_descriptor that was removed during refactoring and caused failures in the Linux ASan LSan tests. BUG= Review URL: https://codereview.chromium.org/568943002 Cr-Commit-Position: refs/heads/master@{#294734} --- .../devtools/device/usb/android_usb_browsertest.cc | 154 ++++--------------- .../devtools/device/usb/android_usb_device.cc | 88 +++++------ device/usb/BUILD.gn | 5 +- device/usb/usb.gyp | 5 +- device/usb/usb_descriptors.cc | 43 ++++++ device/usb/usb_descriptors.h | 83 ++++++++++ device/usb/usb_device.h | 7 +- device/usb/usb_device_filter.cc | 28 ++-- device/usb/usb_device_filter_unittest.cc | 153 ++++--------------- device/usb/usb_device_handle.h | 2 +- device/usb/usb_device_handle_impl.cc | 41 ++--- device/usb/usb_device_handle_impl.h | 7 +- device/usb/usb_device_impl.cc | 153 +++++++++++++++++-- device/usb/usb_device_impl.h | 8 +- device/usb/usb_interface.h | 112 -------------- device/usb/usb_interface_impl.cc | 168 --------------------- device/usb/usb_interface_impl.h | 117 -------------- extensions/browser/api/usb/usb_api.cc | 108 ++++++------- extensions/browser/api/usb/usb_api.h | 1 - extensions/browser/api/usb/usb_apitest.cc | 21 +-- 20 files changed, 461 insertions(+), 843 deletions(-) create mode 100644 device/usb/usb_descriptors.cc create mode 100644 device/usb/usb_descriptors.h delete mode 100644 device/usb/usb_interface.h delete mode 100644 device/usb/usb_interface_impl.cc delete mode 100644 device/usb/usb_interface_impl.h diff --git a/chrome/browser/devtools/device/usb/android_usb_browsertest.cc b/chrome/browser/devtools/device/usb/android_usb_browsertest.cc index ca52178..5852546 100644 --- a/chrome/browser/devtools/device/usb/android_usb_browsertest.cc +++ b/chrome/browser/devtools/device/usb/android_usb_browsertest.cc @@ -12,9 +12,9 @@ #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_utils.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device.h" #include "device/usb/usb_device_handle.h" -#include "device/usb/usb_interface.h" #include "device/usb/usb_service.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,7 +25,6 @@ using device::UsbDeviceHandle; using device::UsbEndpointDescriptor; using device::UsbEndpointDirection; using device::UsbInterfaceDescriptor; -using device::UsbInterfaceAltSettingDescriptor; using device::UsbService; using device::UsbSynchronizationType; using device::UsbTransferCallback; @@ -104,125 +103,6 @@ const char* GetMockShellResponse(std::string command) { return ""; } -class MockUsbEndpointDescriptor : public UsbEndpointDescriptor { - public: - virtual int GetAddress() const OVERRIDE { return address_; } - - virtual UsbEndpointDirection GetDirection() const OVERRIDE { - return direction_; - } - - virtual int GetMaximumPacketSize() const OVERRIDE { - return maximum_packet_size_; - } - - virtual UsbSynchronizationType GetSynchronizationType() const OVERRIDE { - return usb_synchronization_type_; - } - - virtual UsbTransferType GetTransferType() const OVERRIDE { - return usb_transfer_type_; - } - virtual UsbUsageType GetUsageType() const OVERRIDE { return usb_usage_type_; } - - virtual int GetPollingInterval() const OVERRIDE { return polling_interval_; } - - int address_; - UsbEndpointDirection direction_; - int maximum_packet_size_; - UsbSynchronizationType usb_synchronization_type_; - UsbTransferType usb_transfer_type_; - UsbUsageType usb_usage_type_; - int polling_interval_; - - private: - virtual ~MockUsbEndpointDescriptor() {} -}; - -template -class MockUsbInterfaceAltSettingDescriptor - : public UsbInterfaceAltSettingDescriptor { - public: - MockUsbInterfaceAltSettingDescriptor(int interface_number, - int alternate_setting) - : interface_number_(interface_number), - alternate_setting_(alternate_setting) {} - - virtual size_t GetNumEndpoints() const OVERRIDE { - // See IsAndroidInterface function in android_usb_device.cc - return 2; - } - - virtual scoped_refptr GetEndpoint( - size_t index) const OVERRIDE { - EXPECT_GT(static_cast(2), index); - MockUsbEndpointDescriptor* result = new MockUsbEndpointDescriptor(); - result->address_ = index + 1; - result->usb_transfer_type_ = device::USB_TRANSFER_BULK; - result->direction_ = ((index == 0) ? device::USB_DIRECTION_INBOUND - : device::USB_DIRECTION_OUTBOUND); - result->maximum_packet_size_ = 1 << 20; // 1Mb maximum packet size - return result; - } - - virtual int GetInterfaceNumber() const OVERRIDE { return interface_number_; } - - virtual int GetAlternateSetting() const OVERRIDE { - return alternate_setting_; - } - - virtual int GetInterfaceClass() const OVERRIDE { return T::kClass; } - - virtual int GetInterfaceSubclass() const OVERRIDE { return T::kSubclass; } - - virtual int GetInterfaceProtocol() const OVERRIDE { return T::kProtocol; } - - protected: - virtual ~MockUsbInterfaceAltSettingDescriptor() {}; - - private: - const int interface_number_; - const int alternate_setting_; -}; - -template -class MockUsbInterfaceDescriptor : public UsbInterfaceDescriptor { - public: - explicit MockUsbInterfaceDescriptor(int interface_number) - : interface_number_(interface_number) {} - - virtual size_t GetNumAltSettings() const OVERRIDE { - // See IsAndroidInterface function in android_usb_device.cc - return 1; - } - virtual scoped_refptr GetAltSetting( - size_t index) const OVERRIDE { - EXPECT_EQ(static_cast(0), index); - return new MockUsbInterfaceAltSettingDescriptor(interface_number_, 0); - } - - protected: - const int interface_number_; - virtual ~MockUsbInterfaceDescriptor() {} -}; - -template -class MockUsbConfigDescriptor : public UsbConfigDescriptor { - public: - MockUsbConfigDescriptor() {} - - virtual size_t GetNumInterfaces() const OVERRIDE { return 1; } - - virtual scoped_refptr GetInterface( - size_t index) const OVERRIDE { - EXPECT_EQ(static_cast(0), index); - return new MockUsbInterfaceDescriptor(index); - } - - protected: - virtual ~MockUsbConfigDescriptor() {}; -}; - template class MockUsbDevice; @@ -467,14 +347,37 @@ class MockUsbDeviceHandle : public UsbDeviceHandle { template class MockUsbDevice : public UsbDevice { public: - MockUsbDevice() : UsbDevice(0, 0, 0) {} + MockUsbDevice() : UsbDevice(0, 0, 0) { + UsbEndpointDescriptor bulk_in; + bulk_in.address = 0x81; + bulk_in.direction = device::USB_DIRECTION_INBOUND; + bulk_in.maximum_packet_size = 512; + bulk_in.transfer_type = device::USB_TRANSFER_BULK; + + UsbEndpointDescriptor bulk_out; + bulk_out.address = 0x01; + bulk_out.direction = device::USB_DIRECTION_OUTBOUND; + bulk_out.maximum_packet_size = 512; + bulk_out.transfer_type = device::USB_TRANSFER_BULK; + + UsbInterfaceDescriptor interface_desc; + interface_desc.interface_number = 0; + interface_desc.alternate_setting = 0; + interface_desc.interface_class = T::kClass; + interface_desc.interface_subclass = T::kSubclass; + interface_desc.interface_protocol = T::kProtocol; + interface_desc.endpoints.push_back(bulk_in); + interface_desc.endpoints.push_back(bulk_out); + + config_desc_.interfaces.push_back(interface_desc); + } virtual scoped_refptr Open() OVERRIDE { return new MockUsbDeviceHandle(this); } - virtual scoped_refptr ListInterfaces() OVERRIDE { - return new MockUsbConfigDescriptor(); + virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE { + return config_desc_; } virtual bool Close(scoped_refptr handle) OVERRIDE { @@ -497,6 +400,9 @@ class MockUsbDevice : public UsbDevice { protected: virtual ~MockUsbDevice() {} + + private: + UsbConfigDescriptor config_desc_; }; class MockUsbService : public UsbService { diff --git a/chrome/browser/devtools/device/usb/android_usb_device.cc b/chrome/browser/devtools/device/usb/android_usb_device.cc index 8ef9416..55b47c7 100644 --- a/chrome/browser/devtools/device/usb/android_usb_device.cc +++ b/chrome/browser/devtools/device/usb/android_usb_device.cc @@ -19,8 +19,8 @@ #include "content/public/browser/browser_thread.h" #include "crypto/rsa_private_key.h" #include "device/core/device_client.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device.h" -#include "device/usb/usb_interface.h" #include "device/usb/usb_service.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" @@ -29,7 +29,6 @@ using device::UsbConfigDescriptor; using device::UsbDevice; using device::UsbDeviceHandle; -using device::UsbInterfaceAltSettingDescriptor; using device::UsbInterfaceDescriptor; using device::UsbEndpointDescriptor; using device::UsbService; @@ -59,17 +58,12 @@ typedef std::set > UsbDeviceSet; base::LazyInstance >::Leaky g_devices = LAZY_INSTANCE_INITIALIZER; -bool IsAndroidInterface(scoped_refptr interface) { - if (interface->GetNumAltSettings() == 0) - return false; - - scoped_refptr idesc = - interface->GetAltSetting(0); - - if (idesc->GetInterfaceClass() != kAdbClass || - idesc->GetInterfaceSubclass() != kAdbSubclass || - idesc->GetInterfaceProtocol() != kAdbProtocol || - idesc->GetNumEndpoints() != 2) { +bool IsAndroidInterface(const UsbInterfaceDescriptor& interface) { + if (interface.alternate_setting != 0 || + interface.interface_class != kAdbClass || + interface.interface_subclass != kAdbSubclass || + interface.interface_protocol != kAdbProtocol || + interface.endpoints.size() != 2) { return false; } return true; @@ -78,40 +72,40 @@ bool IsAndroidInterface(scoped_refptr interface) { scoped_refptr ClaimInterface( crypto::RSAPrivateKey* rsa_key, scoped_refptr usb_handle, - scoped_refptr interface, - int interface_id) { - scoped_refptr idesc = - interface->GetAltSetting(0); - + const UsbInterfaceDescriptor& interface) { int inbound_address = 0; int outbound_address = 0; int zero_mask = 0; - for (size_t i = 0; i < idesc->GetNumEndpoints(); ++i) { - scoped_refptr edesc = - idesc->GetEndpoint(i); - if (edesc->GetTransferType() != device::USB_TRANSFER_BULK) + for (UsbEndpointDescriptor::Iterator endpointIt = interface.endpoints.begin(); + endpointIt != interface.endpoints.end(); + ++endpointIt) { + if (endpointIt->transfer_type != device::USB_TRANSFER_BULK) continue; - if (edesc->GetDirection() == device::USB_DIRECTION_INBOUND) - inbound_address = edesc->GetAddress(); + if (endpointIt->direction == device::USB_DIRECTION_INBOUND) + inbound_address = endpointIt->address; else - outbound_address = edesc->GetAddress(); - zero_mask = edesc->GetMaximumPacketSize() - 1; + outbound_address = endpointIt->address; + zero_mask = endpointIt->maximum_packet_size - 1; } if (inbound_address == 0 || outbound_address == 0) return NULL; - if (!usb_handle->ClaimInterface(interface_id)) + if (!usb_handle->ClaimInterface(interface.interface_number)) return NULL; base::string16 serial; if (!usb_handle->GetSerial(&serial) || serial.empty()) return NULL; - return new AndroidUsbDevice(rsa_key, usb_handle, base::UTF16ToASCII(serial), - inbound_address, outbound_address, zero_mask, - interface_id); + return new AndroidUsbDevice(rsa_key, + usb_handle, + base::UTF16ToASCII(serial), + inbound_address, + outbound_address, + zero_mask, + interface.interface_number); } uint32 Checksum(const std::string& data) { @@ -207,12 +201,11 @@ static void OpenAndroidDeviceOnFileThread( bool success) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); if (success) { - scoped_refptr config = device->ListInterfaces(); + const UsbConfigDescriptor& config = device->GetConfiguration(); scoped_refptr usb_handle = device->Open(); if (usb_handle.get()) { scoped_refptr android_device = - ClaimInterface(rsa_key, usb_handle, config->GetInterface(interface_id), - interface_id); + ClaimInterface(rsa_key, usb_handle, config.interfaces[interface_id]); if (android_device.get()) devices->push_back(android_device.get()); else @@ -229,15 +222,17 @@ static int CountOnFileThread() { if (service != NULL) service->GetDevices(&usb_devices); int device_count = 0; - for (UsbDevices::iterator it = usb_devices.begin(); it != usb_devices.end(); - ++it) { - scoped_refptr config = (*it)->ListInterfaces(); - if (!config.get()) - continue; - - for (size_t j = 0; j < config->GetNumInterfaces(); ++j) { - if (IsAndroidInterface(config->GetInterface(j))) + for (UsbDevices::iterator deviceIt = usb_devices.begin(); + deviceIt != usb_devices.end(); + ++deviceIt) { + const UsbConfigDescriptor& config = (*deviceIt)->GetConfiguration(); + + for (UsbInterfaceDescriptor::Iterator ifaceIt = config.interfaces.begin(); + ifaceIt != config.interfaces.end(); + ++ifaceIt) { + if (IsAndroidInterface(*ifaceIt)) { ++device_count; + } } } return device_count; @@ -264,16 +259,13 @@ static void EnumerateOnFileThread( for (UsbDevices::iterator it = usb_devices.begin(); it != usb_devices.end(); ++it) { - scoped_refptr config = (*it)->ListInterfaces(); - if (!config.get()) { - barrier.Run(); - continue; - } + const UsbConfigDescriptor& config = (*it)->GetConfiguration(); bool has_android_interface = false; - for (size_t j = 0; j < config->GetNumInterfaces(); ++j) { - if (!IsAndroidInterface(config->GetInterface(j))) + for (size_t j = 0; j < config.interfaces.size(); ++j) { + if (!IsAndroidInterface(config.interfaces[j])) { continue; + } // Request permission on Chrome OS. #if defined(OS_CHROMEOS) diff --git a/device/usb/BUILD.gn b/device/usb/BUILD.gn index 0e97bfe..385bcb9 100644 --- a/device/usb/BUILD.gn +++ b/device/usb/BUILD.gn @@ -9,6 +9,8 @@ source_set("usb") { sources = [ "usb_context.cc", "usb_context.h", + "usb_descriptors.cc", + "usb_descriptors.h", "usb_device_impl.cc", "usb_device_impl.h", "usb_device.h", @@ -21,9 +23,6 @@ source_set("usb") { "usb_error.h", "usb_ids.cc", "usb_ids.h", - "usb_interface.h", - "usb_interface_impl.cc", - "usb_interface_impl.h", "usb_service.h", "usb_service_impl.cc", generated_ids, diff --git a/device/usb/usb.gyp b/device/usb/usb.gyp index 81bdf40..f0b5275 100644 --- a/device/usb/usb.gyp +++ b/device/usb/usb.gyp @@ -19,6 +19,8 @@ 'sources': [ 'usb_context.cc', 'usb_context.h', + 'usb_descriptors.cc', + 'usb_descriptors.h', 'usb_device_impl.cc', 'usb_device_impl.h', 'usb_device.h', @@ -31,9 +33,6 @@ 'usb_error.h', 'usb_ids.cc', 'usb_ids.h', - 'usb_interface.h', - 'usb_interface_impl.cc', - 'usb_interface_impl.h', 'usb_service.h', 'usb_service_impl.cc', ], diff --git a/device/usb/usb_descriptors.cc b/device/usb/usb_descriptors.cc new file mode 100644 index 0000000..d68d60e --- /dev/null +++ b/device/usb/usb_descriptors.cc @@ -0,0 +1,43 @@ +// 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 "device/usb/usb_descriptors.h" + +namespace device { + +UsbEndpointDescriptor::UsbEndpointDescriptor() + : address(0), + direction(USB_DIRECTION_INBOUND), + maximum_packet_size(0), + synchronization_type(USB_SYNCHRONIZATION_NONE), + transfer_type(USB_TRANSFER_CONTROL), + usage_type(USB_USAGE_DATA), + polling_interval(0) { +} + +UsbEndpointDescriptor::~UsbEndpointDescriptor() { +} + +UsbInterfaceDescriptor::UsbInterfaceDescriptor() + : interface_number(0), + alternate_setting(0), + interface_class(0), + interface_subclass(0), + interface_protocol(0) { +} + +UsbInterfaceDescriptor::~UsbInterfaceDescriptor() { +} + +UsbConfigDescriptor::UsbConfigDescriptor() + : configuration_value(0), + self_powered(false), + remote_wakeup(false), + maximum_power(0) { +} + +UsbConfigDescriptor::~UsbConfigDescriptor() { +} + +} // namespace device diff --git a/device/usb/usb_descriptors.h b/device/usb/usb_descriptors.h new file mode 100644 index 0000000..2881aba --- /dev/null +++ b/device/usb/usb_descriptors.h @@ -0,0 +1,83 @@ +// 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 DEVICE_USB_USB_DESCRIPTORS_H_ +#define DEVICE_USB_USB_DESCRIPTORS_H_ + +#include +#include + +namespace device { + +enum UsbTransferType { + USB_TRANSFER_CONTROL = 0, + USB_TRANSFER_ISOCHRONOUS, + USB_TRANSFER_BULK, + USB_TRANSFER_INTERRUPT, +}; + +enum UsbEndpointDirection { + USB_DIRECTION_INBOUND = 0, + USB_DIRECTION_OUTBOUND, +}; + +enum UsbSynchronizationType { + USB_SYNCHRONIZATION_NONE = 0, + USB_SYNCHRONIZATION_ASYNCHRONOUS, + USB_SYNCHRONIZATION_ADAPTIVE, + USB_SYNCHRONIZATION_SYNCHRONOUS, +}; + +enum UsbUsageType { + USB_USAGE_DATA = 0, + USB_USAGE_FEEDBACK, + USB_USAGE_EXPLICIT_FEEDBACK +}; + +struct UsbEndpointDescriptor { + UsbEndpointDescriptor(); + ~UsbEndpointDescriptor(); + + typedef std::vector::const_iterator Iterator; + + uint8_t address; + UsbEndpointDirection direction; + uint16_t maximum_packet_size; + UsbSynchronizationType synchronization_type; + UsbTransferType transfer_type; + UsbUsageType usage_type; + uint16_t polling_interval; + std::vector extra_data; +}; + +struct UsbInterfaceDescriptor { + UsbInterfaceDescriptor(); + ~UsbInterfaceDescriptor(); + + typedef std::vector::const_iterator Iterator; + + uint8_t interface_number; + uint8_t alternate_setting; + uint8_t interface_class; + uint8_t interface_subclass; + uint8_t interface_protocol; + std::vector endpoints; + std::vector extra_data; +}; + +struct UsbConfigDescriptor { + UsbConfigDescriptor(); + ~UsbConfigDescriptor(); + + uint8_t configuration_value; + bool self_powered; + bool remote_wakeup; + uint16_t maximum_power; + std::vector interfaces; + std::vector extra_data; +}; + +} // namespace device + +#endif // DEVICE_USB_USB_DESCRIPTORS_H_ diff --git a/device/usb/usb_device.h b/device/usb/usb_device.h index 586fd19..a012025 100644 --- a/device/usb/usb_device.h +++ b/device/usb/usb_device.h @@ -12,7 +12,7 @@ namespace device { class UsbDeviceHandle; -class UsbConfigDescriptor; +struct UsbConfigDescriptor; // A UsbDevice object represents a detected USB device, providing basic // information about it. For further manipulation of the device, a @@ -44,10 +44,9 @@ class UsbDevice : public base::RefCountedThreadSafe { // Blocking method. Must be called on FILE thread. virtual bool Close(scoped_refptr handle) = 0; - // Lists the interfaces provided by the device and fills the given - // UsbConfigDescriptor. + // Gets the UsbConfigDescriptor for the active device configuration. // Blocking method. Must be called on FILE thread. - virtual scoped_refptr ListInterfaces() = 0; + virtual const UsbConfigDescriptor& GetConfiguration() = 0; protected: UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id) diff --git a/device/usb/usb_device_filter.cc b/device/usb/usb_device_filter.cc index cc919e2..2d3f157 100644 --- a/device/usb/usb_device_filter.cc +++ b/device/usb/usb_device_filter.cc @@ -5,8 +5,8 @@ #include "device/usb/usb_device_filter.h" #include "base/values.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device.h" -#include "device/usb/usb_interface.h" namespace device { @@ -69,27 +69,21 @@ bool UsbDeviceFilter::Matches(scoped_refptr device) const { if (interface_class_set_) { bool foundMatch = false; - scoped_refptr config = device->ListInterfaces(); + const UsbConfigDescriptor& config = device->GetConfiguration(); // TODO(reillyg): Check device configuration if the class is not defined at // a per-interface level. This is not really important because most devices // have per-interface classes. The only counter-examples I know of are hubs. - for (size_t i = 0; i < config->GetNumInterfaces() && !foundMatch; ++i) { - scoped_refptr iface = - config->GetInterface(i); - - for (size_t j = 0; j < iface->GetNumAltSettings() && !foundMatch; ++j) { - scoped_refptr altSetting = - iface->GetAltSetting(j); - - if (altSetting->GetInterfaceClass() == interface_class_ && - (!interface_subclass_set_ || - (altSetting->GetInterfaceSubclass() == interface_subclass_ && - (!interface_protocol_set_ || - altSetting->GetInterfaceProtocol() == interface_protocol_)))) { - foundMatch = true; - } + for (UsbInterfaceDescriptor::Iterator ifaceIt = config.interfaces.begin(); + ifaceIt != config.interfaces.end() && !foundMatch; + ++ifaceIt) { + if (ifaceIt->interface_class == interface_class_ && + (!interface_subclass_set_ || + (ifaceIt->interface_subclass == interface_subclass_ && + (!interface_protocol_set_ || + ifaceIt->interface_protocol == interface_protocol_)))) { + foundMatch = true; } } diff --git a/device/usb/usb_device_filter_unittest.cc b/device/usb/usb_device_filter_unittest.cc index 1fdccd4..90097f6 100644 --- a/device/usb/usb_device_filter_unittest.cc +++ b/device/usb/usb_device_filter_unittest.cc @@ -5,156 +5,55 @@ #include #include "base/memory/ref_counted.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device.h" #include "device/usb/usb_device_filter.h" #include "device/usb/usb_device_handle.h" -#include "device/usb/usb_interface.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace device { namespace { -class MockUsbInterfaceAltSettingDescriptor - : public UsbInterfaceAltSettingDescriptor { - public: - MockUsbInterfaceAltSettingDescriptor(int interface_number, - int alternate_setting, - int interface_class, - int interface_subclass, - int interface_protocol) - : interface_number_(interface_number), - alternate_setting_(alternate_setting), - interface_class_(interface_class), - interface_subclass_(interface_subclass), - interface_protocol_(interface_protocol) {} - - virtual size_t GetNumEndpoints() const OVERRIDE { return 0; } - virtual scoped_refptr GetEndpoint( - size_t index) const OVERRIDE { - return NULL; - } - virtual int GetInterfaceNumber() const OVERRIDE { return interface_number_; } - virtual int GetAlternateSetting() const OVERRIDE { - return alternate_setting_; - } - virtual int GetInterfaceClass() const OVERRIDE { return interface_class_; } - virtual int GetInterfaceSubclass() const OVERRIDE { - return interface_subclass_; - } - virtual int GetInterfaceProtocol() const OVERRIDE { - return interface_protocol_; - } - - protected: - virtual ~MockUsbInterfaceAltSettingDescriptor() {} - - private: - int interface_number_; - int alternate_setting_; - int interface_class_; - int interface_subclass_; - int interface_protocol_; -}; - -typedef std::vector > - UsbInterfaceAltSettingDescriptorList; - -class MockUsbInterfaceDescriptor : public UsbInterfaceDescriptor { - public: - MockUsbInterfaceDescriptor( - const UsbInterfaceAltSettingDescriptorList& alt_settings) - : alt_settings_(alt_settings) {} - - virtual size_t GetNumAltSettings() const OVERRIDE { - return alt_settings_.size(); - } - virtual scoped_refptr GetAltSetting( - size_t index) const OVERRIDE { - return alt_settings_[index]; - } - - protected: - virtual ~MockUsbInterfaceDescriptor() {} - - private: - UsbInterfaceAltSettingDescriptorList alt_settings_; -}; - -typedef std::vector > - UsbInterfaceDescriptorList; - -class MockUsbConfigDescriptor : public UsbConfigDescriptor { - public: - MockUsbConfigDescriptor(const UsbInterfaceDescriptorList& interfaces) - : interfaces_(interfaces) {} - - virtual size_t GetNumInterfaces() const OVERRIDE { - return interfaces_.size(); - } - virtual scoped_refptr GetInterface( - size_t index) const OVERRIDE { - return interfaces_[index]; - } - - protected: - virtual ~MockUsbConfigDescriptor() {} - - private: - UsbInterfaceDescriptorList interfaces_; -}; +using testing::NiceMock; +using testing::ReturnRef; class MockUsbDevice : public UsbDevice { public: - MockUsbDevice(uint16 vendor_id, - uint16 product_id, - uint32 unique_id, - scoped_refptr config_desc) - : UsbDevice(vendor_id, product_id, unique_id), - config_desc_(config_desc) {} - - virtual scoped_refptr Open() OVERRIDE { return NULL; } - virtual bool Close(scoped_refptr handle) OVERRIDE { - NOTREACHED(); - return true; - } -#if defined(OS_CHROMEOS) - virtual void RequestUsbAccess( - int interface_id, - const base::Callback& callback) OVERRIDE { - NOTREACHED(); - } -#endif // OS_CHROMEOS - virtual scoped_refptr ListInterfaces() OVERRIDE { - return config_desc_; - } + MockUsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id) + : UsbDevice(vendor_id, product_id, unique_id) {} - protected: - virtual ~MockUsbDevice() {} + MOCK_METHOD0(Open, scoped_refptr()); + MOCK_METHOD1(Close, bool(scoped_refptr)); +#if defined(OS_CHROMEOS) + MOCK_METHOD2(RequestUsbAccess, void(int, const base::Callback&)); +#endif + MOCK_METHOD0(GetConfiguration, const UsbConfigDescriptor&()); private: - scoped_refptr config_desc_; + virtual ~MockUsbDevice() {} }; class UsbFilterTest : public testing::Test { public: virtual void SetUp() OVERRIDE { - UsbInterfaceAltSettingDescriptorList alt_settings; - alt_settings.push_back(make_scoped_refptr( - new MockUsbInterfaceAltSettingDescriptor(1, 0, 0xFF, 0x42, 1))); - - UsbInterfaceDescriptorList interfaces; - interfaces.push_back( - make_scoped_refptr(new MockUsbInterfaceDescriptor(alt_settings))); - - scoped_refptr config_desc( - new MockUsbConfigDescriptor(interfaces)); - - android_phone_ = new MockUsbDevice(0x18d1, 0x4ee2, 0, config_desc); + UsbInterfaceDescriptor interface; + interface.interface_number = 1; + interface.alternate_setting = 0; + interface.interface_class = 0xFF; + interface.interface_subclass = 0x42; + interface.interface_protocol = 0x01; + config_.interfaces.push_back(interface); + + android_phone_ = new MockUsbDevice(0x18d1, 0x4ee2, 0); + ON_CALL(*android_phone_.get(), GetConfiguration()) + .WillByDefault(ReturnRef(config_)); } protected: - scoped_refptr android_phone_; + UsbConfigDescriptor config_; + scoped_refptr android_phone_; }; TEST_F(UsbFilterTest, MatchAny) { diff --git a/device/usb/usb_device_handle.h b/device/usb/usb_device_handle.h index be7de09..08d97f8 100644 --- a/device/usb/usb_device_handle.h +++ b/device/usb/usb_device_handle.h @@ -12,7 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/strings/string16.h" #include "base/threading/thread_checker.h" -#include "device/usb/usb_interface.h" +#include "device/usb/usb_descriptors.h" #include "net/base/io_buffer.h" namespace device { diff --git a/device/usb/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc index c88fb9b..2d8c690 100644 --- a/device/usb/usb_device_handle_impl.cc +++ b/device/usb/usb_device_handle_impl.cc @@ -15,9 +15,9 @@ #include "base/synchronization/lock.h" #include "base/thread_task_runner_handle.h" #include "device/usb/usb_context.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device_impl.h" #include "device/usb/usb_error.h" -#include "device/usb/usb_interface.h" #include "device/usb/usb_service.h" #include "third_party/libusb/src/libusb/libusb.h" @@ -182,18 +182,16 @@ void UsbDeviceHandleImpl::Transfer::Complete(UsbTransferStatus status, } } -UsbDeviceHandleImpl::UsbDeviceHandleImpl( - scoped_refptr context, - UsbDeviceImpl* device, - PlatformUsbDeviceHandle handle, - scoped_refptr interfaces) +UsbDeviceHandleImpl::UsbDeviceHandleImpl(scoped_refptr context, + UsbDeviceImpl* device, + PlatformUsbDeviceHandle handle, + const UsbConfigDescriptor& config) : device_(device), handle_(handle), - interfaces_(interfaces), + config_(config), context_(context), task_runner_(base::ThreadTaskRunnerHandle::Get()) { DCHECK(handle) << "Cannot create device with NULL handle."; - DCHECK(interfaces_.get()) << "Unable to list interfaces"; } UsbDeviceHandleImpl::~UsbDeviceHandleImpl() { @@ -661,16 +659,23 @@ void UsbDeviceHandleImpl::IsochronousTransfer( void UsbDeviceHandleImpl::RefreshEndpointMap() { DCHECK(thread_checker_.CalledOnValidThread()); endpoint_map_.clear(); - for (ClaimedInterfaceMap::iterator it = claimed_interfaces_.begin(); - it != claimed_interfaces_.end(); - ++it) { - scoped_refptr interface_desc = - interfaces_->GetInterface(it->first) - ->GetAltSetting(it->second->alternate_setting()); - for (size_t i = 0; i < interface_desc->GetNumEndpoints(); i++) { - scoped_refptr endpoint = - interface_desc->GetEndpoint(i); - endpoint_map_[endpoint->GetAddress()] = it->first; + for (ClaimedInterfaceMap::iterator claimedIt = claimed_interfaces_.begin(); + claimedIt != claimed_interfaces_.end(); + ++claimedIt) { + for (UsbInterfaceDescriptor::Iterator ifaceIt = config_.interfaces.begin(); + ifaceIt != config_.interfaces.end(); + ++ifaceIt) { + if (ifaceIt->interface_number == claimedIt->first && + ifaceIt->alternate_setting == + claimedIt->second->alternate_setting()) { + for (UsbEndpointDescriptor::Iterator endpointIt = + ifaceIt->endpoints.begin(); + endpointIt != ifaceIt->endpoints.end(); + ++endpointIt) { + endpoint_map_[endpointIt->address] = claimedIt->first; + } + break; + } } } } diff --git a/device/usb/usb_device_handle_impl.h b/device/usb/usb_device_handle_impl.h index e4e5163..0498f26 100644 --- a/device/usb/usb_device_handle_impl.h +++ b/device/usb/usb_device_handle_impl.h @@ -13,7 +13,6 @@ #include "base/strings/string16.h" #include "base/threading/thread_checker.h" #include "device/usb/usb_device_handle.h" -#include "device/usb/usb_interface.h" #include "net/base/io_buffer.h" #include "third_party/libusb/src/libusb/libusb.h" @@ -24,7 +23,7 @@ class SingleThreadTaskRunner; namespace device { class UsbContext; -class UsbConfigDescriptor; +struct UsbConfigDescriptor; class UsbDeviceImpl; typedef libusb_device_handle* PlatformUsbDeviceHandle; @@ -89,7 +88,7 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { UsbDeviceHandleImpl(scoped_refptr context, UsbDeviceImpl* device, PlatformUsbDeviceHandle handle, - scoped_refptr interfaces); + const UsbConfigDescriptor& config); virtual ~UsbDeviceHandleImpl(); @@ -143,7 +142,7 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { PlatformUsbDeviceHandle handle_; - scoped_refptr interfaces_; + const UsbConfigDescriptor& config_; std::vector languages_; std::map strings_; diff --git a/device/usb/usb_device_impl.cc b/device/usb/usb_device_impl.cc index 03c8ee0..84f7143 100644 --- a/device/usb/usb_device_impl.cc +++ b/device/usb/usb_device_impl.cc @@ -12,9 +12,9 @@ #include "base/stl_util.h" #include "base/thread_task_runner_handle.h" #include "device/usb/usb_context.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device_handle_impl.h" #include "device/usb/usb_error.h" -#include "device/usb/usb_interface_impl.h" #include "third_party/libusb/src/libusb/libusb.h" #if defined(OS_CHROMEOS) @@ -23,6 +23,8 @@ #include "chromeos/dbus/permission_broker_client.h" #endif // defined(OS_CHROMEOS) +namespace device { + namespace { #if defined(OS_CHROMEOS) @@ -34,9 +36,67 @@ void OnRequestUsbAccessReplied( } #endif // defined(OS_CHROMEOS) -} // namespace +UsbEndpointDirection GetDirection( + const libusb_endpoint_descriptor* descriptor) { + switch (descriptor->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) { + case LIBUSB_ENDPOINT_IN: + return USB_DIRECTION_INBOUND; + case LIBUSB_ENDPOINT_OUT: + return USB_DIRECTION_OUTBOUND; + default: + NOTREACHED(); + return USB_DIRECTION_INBOUND; + } +} -namespace device { +UsbSynchronizationType GetSynchronizationType( + const libusb_endpoint_descriptor* descriptor) { + switch (descriptor->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) { + case LIBUSB_ISO_SYNC_TYPE_NONE: + return USB_SYNCHRONIZATION_NONE; + case LIBUSB_ISO_SYNC_TYPE_ASYNC: + return USB_SYNCHRONIZATION_ASYNCHRONOUS; + case LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: + return USB_SYNCHRONIZATION_ADAPTIVE; + case LIBUSB_ISO_SYNC_TYPE_SYNC: + return USB_SYNCHRONIZATION_SYNCHRONOUS; + default: + NOTREACHED(); + return USB_SYNCHRONIZATION_NONE; + } +} + +UsbTransferType GetTransferType(const libusb_endpoint_descriptor* descriptor) { + switch (descriptor->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) { + case LIBUSB_TRANSFER_TYPE_CONTROL: + return USB_TRANSFER_CONTROL; + case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: + return USB_TRANSFER_ISOCHRONOUS; + case LIBUSB_TRANSFER_TYPE_BULK: + return USB_TRANSFER_BULK; + case LIBUSB_TRANSFER_TYPE_INTERRUPT: + return USB_TRANSFER_INTERRUPT; + default: + NOTREACHED(); + return USB_TRANSFER_CONTROL; + } +} + +UsbUsageType GetUsageType(const libusb_endpoint_descriptor* descriptor) { + switch (descriptor->bmAttributes & LIBUSB_ISO_USAGE_TYPE_MASK) { + case LIBUSB_ISO_USAGE_TYPE_DATA: + return USB_USAGE_DATA; + case LIBUSB_ISO_USAGE_TYPE_FEEDBACK: + return USB_USAGE_FEEDBACK; + case LIBUSB_ISO_USAGE_TYPE_IMPLICIT: + return USB_USAGE_EXPLICIT_FEEDBACK; + default: + NOTREACHED(); + return USB_USAGE_DATA; + } +} + +} // namespace UsbDeviceImpl::UsbDeviceImpl( scoped_refptr context, @@ -47,6 +107,7 @@ UsbDeviceImpl::UsbDeviceImpl( uint32 unique_id) : UsbDevice(vendor_id, product_id, unique_id), platform_device_(platform_device), + current_configuration_cached_(false), context_(context), ui_task_runner_(ui_task_runner) { CHECK(platform_device) << "platform_device cannot be NULL"; @@ -101,11 +162,12 @@ scoped_refptr UsbDeviceImpl::Open() { PlatformUsbDeviceHandle handle; const int rv = libusb_open(platform_device_, &handle); if (LIBUSB_SUCCESS == rv) { - scoped_refptr interfaces = ListInterfaces(); - if (!interfaces.get()) + GetConfiguration(); + if (!current_configuration_cached_) { return NULL; + } scoped_refptr device_handle = - new UsbDeviceHandleImpl(context_, this, handle, interfaces); + new UsbDeviceHandleImpl(context_, this, handle, current_configuration_); handles_.push_back(device_handle); return device_handle; } else { @@ -128,19 +190,78 @@ bool UsbDeviceImpl::Close(scoped_refptr handle) { return false; } -scoped_refptr UsbDeviceImpl::ListInterfaces() { +const UsbConfigDescriptor& UsbDeviceImpl::GetConfiguration() { DCHECK(thread_checker_.CalledOnValidThread()); - PlatformUsbConfigDescriptor platform_config; - const int rv = - libusb_get_active_config_descriptor(platform_device_, &platform_config); - if (rv == LIBUSB_SUCCESS) { - return new UsbConfigDescriptorImpl(platform_config); - } else { - VLOG(1) << "Failed to get config descriptor: " - << ConvertPlatformUsbErrorToString(rv); - return NULL; + if (!current_configuration_cached_) { + libusb_config_descriptor* platform_config; + const int rv = + libusb_get_active_config_descriptor(platform_device_, &platform_config); + if (rv != LIBUSB_SUCCESS) { + VLOG(1) << "Failed to get config descriptor: " + << ConvertPlatformUsbErrorToString(rv); + return current_configuration_; + } + + current_configuration_.configuration_value = + platform_config->bConfigurationValue; + current_configuration_.self_powered = + (platform_config->bmAttributes & 0x40) != 0; + current_configuration_.remote_wakeup = + (platform_config->bmAttributes & 0x20) != 0; + current_configuration_.maximum_power = platform_config->MaxPower * 2; + + for (size_t i = 0; i < platform_config->bNumInterfaces; ++i) { + const struct libusb_interface* platform_interface = + &platform_config->interface[i]; + for (int j = 0; j < platform_interface->num_altsetting; ++j) { + const struct libusb_interface_descriptor* platform_alt_setting = + &platform_interface->altsetting[j]; + UsbInterfaceDescriptor interface; + + interface.interface_number = platform_alt_setting->bInterfaceNumber; + interface.alternate_setting = platform_alt_setting->bAlternateSetting; + interface.interface_class = platform_alt_setting->bInterfaceClass; + interface.interface_subclass = platform_alt_setting->bInterfaceSubClass; + interface.interface_protocol = platform_alt_setting->bInterfaceProtocol; + + for (size_t k = 0; k < platform_alt_setting->bNumEndpoints; ++k) { + const struct libusb_endpoint_descriptor* platform_endpoint = + &platform_alt_setting->endpoint[k]; + UsbEndpointDescriptor endpoint; + + endpoint.address = platform_endpoint->bEndpointAddress; + endpoint.direction = GetDirection(platform_endpoint); + endpoint.maximum_packet_size = platform_endpoint->wMaxPacketSize; + endpoint.synchronization_type = + GetSynchronizationType(platform_endpoint); + endpoint.transfer_type = GetTransferType(platform_endpoint); + endpoint.usage_type = GetUsageType(platform_endpoint); + endpoint.polling_interval = platform_endpoint->bInterval; + endpoint.extra_data = std::vector( + platform_endpoint->extra, + platform_endpoint->extra + platform_endpoint->extra_length); + + interface.endpoints.push_back(endpoint); + } + + interface.extra_data = std::vector( + platform_alt_setting->extra, + platform_alt_setting->extra + platform_alt_setting->extra_length); + + current_configuration_.interfaces.push_back(interface); + } + } + + current_configuration_.extra_data = std::vector( + platform_config->extra, + platform_config->extra + platform_config->extra_length); + + libusb_free_config_descriptor(platform_config); + current_configuration_cached_ = true; } + + return current_configuration_; } void UsbDeviceImpl::OnDisconnect() { diff --git a/device/usb/usb_device_impl.h b/device/usb/usb_device_impl.h index 1ece2e0..e95c8db 100644 --- a/device/usb/usb_device_impl.h +++ b/device/usb/usb_device_impl.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/callback.h" #include "base/threading/thread_checker.h" +#include "device/usb/usb_descriptors.h" #include "device/usb/usb_device.h" struct libusb_device; @@ -37,7 +38,7 @@ class UsbDeviceImpl : public UsbDevice { #endif // OS_CHROMEOS virtual scoped_refptr Open() OVERRIDE; virtual bool Close(scoped_refptr handle) OVERRIDE; - virtual scoped_refptr ListInterfaces() OVERRIDE; + virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE; protected: friend class UsbServiceImpl; @@ -59,6 +60,11 @@ class UsbDeviceImpl : public UsbDevice { base::ThreadChecker thread_checker_; PlatformUsbDevice platform_device_; + // The active configuration descriptor is not read immediately but cached for + // later use. + bool current_configuration_cached_; + UsbConfigDescriptor current_configuration_; + // Retain the context so that it will not be released before UsbDevice. scoped_refptr context_; diff --git a/device/usb/usb_interface.h b/device/usb/usb_interface.h deleted file mode 100644 index 9285718..0000000 --- a/device/usb/usb_interface.h +++ /dev/null @@ -1,112 +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 DEVICE_USB_USB_INTERFACE_H_ -#define DEVICE_USB_USB_INTERFACE_H_ - -#include "base/memory/ref_counted.h" - -namespace device { - -enum UsbTransferType { - USB_TRANSFER_CONTROL = 0, - USB_TRANSFER_ISOCHRONOUS, - USB_TRANSFER_BULK, - USB_TRANSFER_INTERRUPT, -}; - -enum UsbEndpointDirection { - USB_DIRECTION_INBOUND = 0, - USB_DIRECTION_OUTBOUND, -}; - -enum UsbSynchronizationType { - USB_SYNCHRONIZATION_NONE = 0, - USB_SYNCHRONIZATION_ASYNCHRONOUS, - USB_SYNCHRONIZATION_ADAPTIVE, - USB_SYNCHRONIZATION_SYNCHRONOUS, -}; - -enum UsbUsageType { - USB_USAGE_DATA = 0, - USB_USAGE_FEEDBACK, - USB_USAGE_EXPLICIT_FEEDBACK -}; - -class UsbEndpointDescriptor - : public base::RefCounted { - public: - virtual int GetAddress() const = 0; - virtual UsbEndpointDirection GetDirection() const = 0; - virtual int GetMaximumPacketSize() const = 0; - virtual UsbSynchronizationType GetSynchronizationType() const = 0; - virtual UsbTransferType GetTransferType() const = 0; - virtual UsbUsageType GetUsageType() const = 0; - virtual int GetPollingInterval() const = 0; - - protected: - friend class base::RefCounted; - - UsbEndpointDescriptor() {}; - virtual ~UsbEndpointDescriptor() {}; - - DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor); -}; - -class UsbInterfaceAltSettingDescriptor - : public base::RefCounted { - public: - virtual size_t GetNumEndpoints() const = 0; - virtual scoped_refptr GetEndpoint( - size_t index) const = 0; - - virtual int GetInterfaceNumber() const = 0; - virtual int GetAlternateSetting() const = 0; - virtual int GetInterfaceClass() const = 0; - virtual int GetInterfaceSubclass() const = 0; - virtual int GetInterfaceProtocol() const = 0; - - protected: - friend class base::RefCounted; - - UsbInterfaceAltSettingDescriptor() {}; - virtual ~UsbInterfaceAltSettingDescriptor() {}; - - DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor); -}; - -class UsbInterfaceDescriptor - : public base::RefCounted { - public: - virtual size_t GetNumAltSettings() const = 0; - virtual scoped_refptr GetAltSetting( - size_t index) const = 0; - - protected: - friend class base::RefCounted; - - UsbInterfaceDescriptor() {}; - virtual ~UsbInterfaceDescriptor() {}; - - DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor); -}; - -class UsbConfigDescriptor : public base::RefCounted { - public: - virtual size_t GetNumInterfaces() const = 0; - virtual scoped_refptr GetInterface( - size_t index) const = 0; - - protected: - friend class base::RefCounted; - - UsbConfigDescriptor() {}; - virtual ~UsbConfigDescriptor() {}; - - DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor); -}; - -} // namespace device - -#endif // DEVICE_USB_USB_INTERFACE_H_ diff --git a/device/usb/usb_interface_impl.cc b/device/usb/usb_interface_impl.cc deleted file mode 100644 index af3d0e3..0000000 --- a/device/usb/usb_interface_impl.cc +++ /dev/null @@ -1,168 +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 "device/usb/usb_interface_impl.h" - -#include "base/logging.h" -#include "third_party/libusb/src/libusb/libusb.h" - -namespace device { - -UsbEndpointDescriptorImpl::UsbEndpointDescriptorImpl( - scoped_refptr config, - PlatformUsbEndpointDescriptor descriptor) - : config_(config), descriptor_(descriptor) { -} - -UsbEndpointDescriptorImpl::~UsbEndpointDescriptorImpl() { -} - -int UsbEndpointDescriptorImpl::GetAddress() const { - return descriptor_->bEndpointAddress & LIBUSB_ENDPOINT_ADDRESS_MASK; -} - -UsbEndpointDirection UsbEndpointDescriptorImpl::GetDirection() const { - switch (descriptor_->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) { - case LIBUSB_ENDPOINT_IN: - return USB_DIRECTION_INBOUND; - case LIBUSB_ENDPOINT_OUT: - return USB_DIRECTION_OUTBOUND; - default: - NOTREACHED(); - return USB_DIRECTION_INBOUND; - } -} - -int UsbEndpointDescriptorImpl::GetMaximumPacketSize() const { - return descriptor_->wMaxPacketSize; -} - -UsbSynchronizationType UsbEndpointDescriptorImpl::GetSynchronizationType() - const { - switch (descriptor_->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) { - case LIBUSB_ISO_SYNC_TYPE_NONE: - return USB_SYNCHRONIZATION_NONE; - case LIBUSB_ISO_SYNC_TYPE_ASYNC: - return USB_SYNCHRONIZATION_ASYNCHRONOUS; - case LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: - return USB_SYNCHRONIZATION_ADAPTIVE; - case LIBUSB_ISO_SYNC_TYPE_SYNC: - return USB_SYNCHRONIZATION_SYNCHRONOUS; - default: - NOTREACHED(); - return USB_SYNCHRONIZATION_NONE; - } -} - -UsbTransferType UsbEndpointDescriptorImpl::GetTransferType() const { - switch (descriptor_->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) { - case LIBUSB_TRANSFER_TYPE_CONTROL: - return USB_TRANSFER_CONTROL; - case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: - return USB_TRANSFER_ISOCHRONOUS; - case LIBUSB_TRANSFER_TYPE_BULK: - return USB_TRANSFER_BULK; - case LIBUSB_TRANSFER_TYPE_INTERRUPT: - return USB_TRANSFER_INTERRUPT; - default: - NOTREACHED(); - return USB_TRANSFER_CONTROL; - } -} - -UsbUsageType UsbEndpointDescriptorImpl::GetUsageType() const { - switch (descriptor_->bmAttributes & LIBUSB_ISO_USAGE_TYPE_MASK) { - case LIBUSB_ISO_USAGE_TYPE_DATA: - return USB_USAGE_DATA; - case LIBUSB_ISO_USAGE_TYPE_FEEDBACK: - return USB_USAGE_FEEDBACK; - case LIBUSB_ISO_USAGE_TYPE_IMPLICIT: - return USB_USAGE_EXPLICIT_FEEDBACK; - default: - NOTREACHED(); - return USB_USAGE_DATA; - } -} - -int UsbEndpointDescriptorImpl::GetPollingInterval() const { - return descriptor_->bInterval; -} - -UsbInterfaceAltSettingDescriptorImpl::UsbInterfaceAltSettingDescriptorImpl( - scoped_refptr config, - PlatformUsbInterfaceDescriptor descriptor) - : config_(config), descriptor_(descriptor) { -} - -UsbInterfaceAltSettingDescriptorImpl::~UsbInterfaceAltSettingDescriptorImpl() { -} - -size_t UsbInterfaceAltSettingDescriptorImpl::GetNumEndpoints() const { - return descriptor_->bNumEndpoints; -} - -scoped_refptr -UsbInterfaceAltSettingDescriptorImpl::GetEndpoint(size_t index) const { - return new UsbEndpointDescriptorImpl(config_, &descriptor_->endpoint[index]); -} - -int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceNumber() const { - return descriptor_->bInterfaceNumber; -} - -int UsbInterfaceAltSettingDescriptorImpl::GetAlternateSetting() const { - return descriptor_->bAlternateSetting; -} - -int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceClass() const { - return descriptor_->bInterfaceClass; -} - -int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceSubclass() const { - return descriptor_->bInterfaceSubClass; -} - -int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceProtocol() const { - return descriptor_->bInterfaceProtocol; -} - -UsbInterfaceDescriptorImpl::UsbInterfaceDescriptorImpl( - scoped_refptr config, - PlatformUsbInterface usbInterface) - : config_(config), interface_(usbInterface) { -} - -UsbInterfaceDescriptorImpl::~UsbInterfaceDescriptorImpl() { -} - -size_t UsbInterfaceDescriptorImpl::GetNumAltSettings() const { - return interface_->num_altsetting; -} - -scoped_refptr -UsbInterfaceDescriptorImpl::GetAltSetting(size_t index) const { - return new UsbInterfaceAltSettingDescriptorImpl( - config_, &interface_->altsetting[index]); -} - -UsbConfigDescriptorImpl::UsbConfigDescriptorImpl( - PlatformUsbConfigDescriptor config) - : config_(config) { - DCHECK(config); -} - -UsbConfigDescriptorImpl::~UsbConfigDescriptorImpl() { - libusb_free_config_descriptor(config_); -} - -size_t UsbConfigDescriptorImpl::GetNumInterfaces() const { - return config_->bNumInterfaces; -} - -scoped_refptr -UsbConfigDescriptorImpl::GetInterface(size_t index) const { - return new UsbInterfaceDescriptorImpl(this, &config_->interface[index]); -} - -} // namespace device diff --git a/device/usb/usb_interface_impl.h b/device/usb/usb_interface_impl.h deleted file mode 100644 index 0f6b913..0000000 --- a/device/usb/usb_interface_impl.h +++ /dev/null @@ -1,117 +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 DEVICE_USB_USB_INTERFACE_IMPL_H_ -#define DEVICE_USB_USB_INTERFACE_IMPL_H_ - -#include "base/memory/ref_counted.h" -#include "device/usb/usb_interface.h" - -struct libusb_config_descriptor; -struct libusb_endpoint_descriptor; -struct libusb_interface; -struct libusb_interface_descriptor; - -namespace device { - -typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; -typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor; -typedef const libusb_interface* PlatformUsbInterface; -typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor; - -class UsbConfigDescriptorImpl; -class UsbInterfaceAltSettingDescriptor; - -class UsbEndpointDescriptorImpl : public UsbEndpointDescriptor { - public: - virtual int GetAddress() const OVERRIDE; - virtual UsbEndpointDirection GetDirection() const OVERRIDE; - virtual int GetMaximumPacketSize() const OVERRIDE; - virtual UsbSynchronizationType GetSynchronizationType() const OVERRIDE; - virtual UsbTransferType GetTransferType() const OVERRIDE; - virtual UsbUsageType GetUsageType() const OVERRIDE; - virtual int GetPollingInterval() const OVERRIDE; - - private: - friend class base::RefCounted; - friend class UsbInterfaceAltSettingDescriptorImpl; - - UsbEndpointDescriptorImpl(scoped_refptr config, - PlatformUsbEndpointDescriptor descriptor); - virtual ~UsbEndpointDescriptorImpl(); - - scoped_refptr config_; - PlatformUsbEndpointDescriptor descriptor_; - - DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptorImpl); -}; - -class UsbInterfaceAltSettingDescriptorImpl - : public UsbInterfaceAltSettingDescriptor { - public: - virtual size_t GetNumEndpoints() const OVERRIDE; - virtual scoped_refptr GetEndpoint( - size_t index) const OVERRIDE; - - virtual int GetInterfaceNumber() const OVERRIDE; - virtual int GetAlternateSetting() const OVERRIDE; - virtual int GetInterfaceClass() const OVERRIDE; - virtual int GetInterfaceSubclass() const OVERRIDE; - virtual int GetInterfaceProtocol() const OVERRIDE; - - private: - friend class UsbInterfaceDescriptorImpl; - - UsbInterfaceAltSettingDescriptorImpl( - scoped_refptr config, - PlatformUsbInterfaceDescriptor descriptor); - virtual ~UsbInterfaceAltSettingDescriptorImpl(); - - scoped_refptr config_; - PlatformUsbInterfaceDescriptor descriptor_; - - DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptorImpl); -}; - -class UsbInterfaceDescriptorImpl : public UsbInterfaceDescriptor { - public: - virtual size_t GetNumAltSettings() const OVERRIDE; - virtual scoped_refptr GetAltSetting( - size_t index) const OVERRIDE; - - private: - friend class base::RefCounted; - friend class UsbConfigDescriptorImpl; - - UsbInterfaceDescriptorImpl(scoped_refptr config, - PlatformUsbInterface usbInterface); - virtual ~UsbInterfaceDescriptorImpl(); - - scoped_refptr config_; - PlatformUsbInterface interface_; - - DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptorImpl); -}; - -class UsbConfigDescriptorImpl : public UsbConfigDescriptor { - public: - virtual size_t GetNumInterfaces() const OVERRIDE; - virtual scoped_refptr GetInterface( - size_t index) const OVERRIDE; - - private: - friend class base::RefCounted; - friend class UsbDeviceImpl; - - explicit UsbConfigDescriptorImpl(PlatformUsbConfigDescriptor config); - virtual ~UsbConfigDescriptorImpl(); - - PlatformUsbConfigDescriptor config_; - - DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptorImpl); -}; - -} // namespace device - -#endif // DEVICE_USB_USB_INTERFACE_IMPL_H_ diff --git a/extensions/browser/api/usb/usb_api.cc b/extensions/browser/api/usb/usb_api.cc index 53f5c5b..22e19c4 100644 --- a/extensions/browser/api/usb/usb_api.cc +++ b/extensions/browser/api/usb/usb_api.cc @@ -56,7 +56,6 @@ using device::UsbDeviceFilter; using device::UsbDeviceHandle; using device::UsbEndpointDescriptor; using device::UsbEndpointDirection; -using device::UsbInterfaceAltSettingDescriptor; using device::UsbInterfaceDescriptor; using device::UsbService; using device::UsbSynchronizationType; @@ -761,75 +760,58 @@ void UsbListInterfacesFunction::AsyncWorkStart() { if (!device_handle.get()) return; - scoped_refptr config = - device_handle->GetDevice()->ListInterfaces(); + const UsbConfigDescriptor& config = + device_handle->GetDevice()->GetConfiguration(); - if (!config.get()) { - SetError(kErrorCannotListInterfaces); - AsyncWorkCompleted(); - return; - } + scoped_ptr result(new base::ListValue()); - result_.reset(new base::ListValue()); - - for (size_t i = 0, num_interfaces = config->GetNumInterfaces(); - i < num_interfaces; - ++i) { - scoped_refptr usb_interface( - config->GetInterface(i)); - for (size_t j = 0, num_descriptors = usb_interface->GetNumAltSettings(); - j < num_descriptors; - ++j) { - scoped_refptr descriptor = - usb_interface->GetAltSetting(j); - std::vector > endpoints; - for (size_t k = 0, num_endpoints = descriptor->GetNumEndpoints(); - k < num_endpoints; - k++) { - scoped_refptr endpoint = - descriptor->GetEndpoint(k); - linked_ptr endpoint_desc(new EndpointDescriptor()); - - TransferType type; - Direction direction; - SynchronizationType synchronization; - UsageType usage; - - if (!ConvertTransferTypeSafely(endpoint->GetTransferType(), &type) || - !ConvertDirectionSafely(endpoint->GetDirection(), &direction) || - !ConvertSynchronizationTypeSafely( - endpoint->GetSynchronizationType(), &synchronization) || - !ConvertUsageTypeSafely(endpoint->GetUsageType(), &usage)) { - SetError(kErrorCannotListInterfaces); - AsyncWorkCompleted(); - return; - } - - endpoint_desc->address = endpoint->GetAddress(); - endpoint_desc->type = type; - endpoint_desc->direction = direction; - endpoint_desc->maximum_packet_size = endpoint->GetMaximumPacketSize(); - endpoint_desc->synchronization = synchronization; - endpoint_desc->usage = usage; - - int* polling_interval = new int; - endpoint_desc->polling_interval.reset(polling_interval); - *polling_interval = endpoint->GetPollingInterval(); - - endpoints.push_back(endpoint_desc); + for (UsbInterfaceDescriptor::Iterator interfaceIt = config.interfaces.begin(); + interfaceIt != config.interfaces.end(); + ++interfaceIt) { + std::vector > endpoints; + + for (UsbEndpointDescriptor::Iterator endpointIt = + interfaceIt->endpoints.begin(); + endpointIt != interfaceIt->endpoints.end(); + ++endpointIt) { + linked_ptr endpoint_desc(new EndpointDescriptor()); + + TransferType type; + Direction direction; + SynchronizationType synchronization; + UsageType usage; + + if (!ConvertTransferTypeSafely(endpointIt->transfer_type, &type) || + !ConvertDirectionSafely(endpointIt->direction, &direction) || + !ConvertSynchronizationTypeSafely(endpointIt->synchronization_type, + &synchronization) || + !ConvertUsageTypeSafely(endpointIt->usage_type, &usage)) { + SetError(kErrorCannotListInterfaces); + AsyncWorkCompleted(); + return; } - result_->Append( - PopulateInterfaceDescriptor(descriptor->GetInterfaceNumber(), - descriptor->GetAlternateSetting(), - descriptor->GetInterfaceClass(), - descriptor->GetInterfaceSubclass(), - descriptor->GetInterfaceProtocol(), - &endpoints)); + endpoint_desc->address = endpointIt->address; + endpoint_desc->type = type; + endpoint_desc->direction = direction; + endpoint_desc->maximum_packet_size = endpointIt->maximum_packet_size; + endpoint_desc->synchronization = synchronization; + endpoint_desc->usage = usage; + endpoint_desc->polling_interval.reset( + new int(endpointIt->polling_interval)); + + endpoints.push_back(endpoint_desc); } + + result->Append(PopulateInterfaceDescriptor(interfaceIt->interface_number, + interfaceIt->alternate_setting, + interfaceIt->interface_class, + interfaceIt->interface_subclass, + interfaceIt->interface_protocol, + &endpoints)); } - SetResult(result_.release()); + SetResult(result.release()); AsyncWorkCompleted(); } diff --git a/extensions/browser/api/usb/usb_api.h b/extensions/browser/api/usb/usb_api.h index fd02d80..2a0a6ef 100644 --- a/extensions/browser/api/usb/usb_api.h +++ b/extensions/browser/api/usb/usb_api.h @@ -168,7 +168,6 @@ class UsbListInterfacesFunction : public UsbAsyncApiFunction { bool ConvertUsageTypeSafely(const device::UsbUsageType& input, extensions::core_api::usb::UsageType* output); - scoped_ptr result_; scoped_ptr parameters_; }; diff --git a/extensions/browser/api/usb/usb_apitest.cc b/extensions/browser/api/usb/usb_apitest.cc index c3cd1a1..eea26c5 100644 --- a/extensions/browser/api/usb/usb_apitest.cc +++ b/extensions/browser/api/usb/usb_apitest.cc @@ -14,6 +14,7 @@ using testing::AnyNumber; using testing::_; using testing::Return; +using testing::ReturnRef; using content::BrowserThread; using device::UsbConfigDescriptor; using device::UsbDevice; @@ -106,16 +107,6 @@ class MockUsbDeviceHandle : public UsbDeviceHandle { virtual ~MockUsbDeviceHandle() {} }; -class MockUsbConfigDescriptor : public UsbConfigDescriptor { - public: - MOCK_CONST_METHOD0(GetNumInterfaces, size_t()); - MOCK_CONST_METHOD1(GetInterface, - scoped_refptr(size_t index)); - - protected: - virtual ~MockUsbConfigDescriptor() {} -}; - class MockUsbDevice : public UsbDevice { public: explicit MockUsbDevice(MockUsbDeviceHandle* mock_handle) @@ -141,7 +132,7 @@ class MockUsbDevice : public UsbDevice { } #endif // OS_CHROMEOS - MOCK_METHOD0(ListInterfaces, scoped_refptr()); + MOCK_METHOD0(GetConfiguration, const UsbConfigDescriptor&()); private: MockUsbDeviceHandle* mock_handle_; @@ -225,12 +216,10 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, ResetDevice) { } IN_PROC_BROWSER_TEST_F(UsbApiTest, ListInterfaces) { - scoped_refptr mock_descriptor = - new MockUsbConfigDescriptor(); + UsbConfigDescriptor config_descriptor; EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); - EXPECT_CALL(*mock_descriptor.get(), GetNumInterfaces()).WillOnce(Return(0)); - EXPECT_CALL(*mock_device_.get(), ListInterfaces()) - .WillOnce(Return(mock_descriptor)); + EXPECT_CALL(*mock_device_.get(), GetConfiguration()) + .WillOnce(ReturnRef(config_descriptor)); ASSERT_TRUE(RunExtensionTest("usb/list_interfaces")); } -- cgit v1.1 From 7b245aba250436867e5fd4dff77c08b9c5dc1a9d Mon Sep 17 00:00:00 2001 From: reillyg Date: Fri, 12 Sep 2014 23:15:04 -0700 Subject: Do not open or close IOHIDManager's IOHIDDeviceRefs. The IOHIDManager object manages the IOHIDDevice instances that it creates. Calling IOHIDDeviceOpen on such an instance is a no-op and calling IOHIDDeviceClose prevents the IOHIDManager from tracking the lifetime of the device. The solution is to never open nor close these devices. BUG=413976 Review URL: https://codereview.chromium.org/568873003 Cr-Commit-Position: refs/heads/master@{#294735} --- device/hid/hid_connection_mac.cc | 30 ++++++++++++++++++++++-------- device/hid/hid_connection_mac.h | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/device/hid/hid_connection_mac.cc b/device/hid/hid_connection_mac.cc index e06994c..ae1a142 100644 --- a/device/hid/hid_connection_mac.cc +++ b/device/hid/hid_connection_mac.cc @@ -17,21 +17,28 @@ HidConnectionMac::HidConnectionMac(HidDeviceInfo device_info) message_loop_ = base::MessageLoopProxy::current(); DCHECK(device_.get()); + size_t expected_report_size = device_info.max_input_report_size; if (device_info.has_report_id) { expected_report_size++; } - inbound_buffer_.reset(new uint8_t[expected_report_size]); - IOHIDDeviceRegisterInputReportCallback(device_.get(), - inbound_buffer_.get(), - expected_report_size, - &HidConnectionMac::InputReportCallback, - this); - IOHIDDeviceOpen(device_, kIOHIDOptionsTypeNone); + inbound_buffer_.resize(expected_report_size); + if (inbound_buffer_.size() > 0) { + IOHIDDeviceRegisterInputReportCallback( + device_.get(), + &inbound_buffer_[0], + inbound_buffer_.size(), + &HidConnectionMac::InputReportCallback, + this); + } } HidConnectionMac::~HidConnectionMac() { - IOHIDDeviceClose(device_, kIOHIDOptionsTypeNone); + if (inbound_buffer_.size() > 0) { + // Unregister the input report callback before this object is freed. + IOHIDDeviceRegisterInputReportCallback( + device_.get(), &inbound_buffer_[0], inbound_buffer_.size(), NULL, this); + } Flush(); } @@ -72,6 +79,7 @@ void HidConnectionMac::PlatformGetFeatureReport(uint8_t report_id, if (result == kIOReturnSuccess) { callback.Run(true, buffer, report_size); } else { + VLOG(1) << "Failed to get feature report: " << result; callback.Run(false, NULL, 0); } } @@ -90,6 +98,11 @@ void HidConnectionMac::InputReportCallback(void* context, uint32_t report_id, uint8_t* report_bytes, CFIndex report_length) { + if (result != kIOReturnSuccess) { + VLOG(1) << "Failed to read input report: " << result; + return; + } + HidConnectionMac* connection = static_cast(context); scoped_refptr buffer; if (connection->device_info().has_report_id) { @@ -131,6 +144,7 @@ void HidConnectionMac::WriteReport(IOHIDReportType type, if (res == kIOReturnSuccess) { callback.Run(true); } else { + VLOG(1) << "Failed to set report: " << res; callback.Run(false); } } diff --git a/device/hid/hid_connection_mac.h b/device/hid/hid_connection_mac.h index 81153b6..7282760 100644 --- a/device/hid/hid_connection_mac.h +++ b/device/hid/hid_connection_mac.h @@ -62,7 +62,7 @@ class HidConnectionMac : public HidConnection { base::ScopedCFTypeRef device_; scoped_refptr message_loop_; - scoped_ptr inbound_buffer_; + std::vector inbound_buffer_; std::queue pending_reports_; std::queue pending_reads_; -- cgit v1.1 From 87390022e9c1c9bf5e90e062184acce674233252 Mon Sep 17 00:00:00 2001 From: japhet Date: Fri, 12 Sep 2014 23:52:42 -0700 Subject: Normalize a couple of print preview browser tests. PrintWebViewHelperTest.PrintWithIframe document.write()s into a loaded iframe without a document.close(). This blocks the load event in the parent frame and will soon block load completion notifications. BlockScriptInitiatedPrinting operates on an initial empty document, which can have strange effects. Load one of the html strings provided in that file, just so we have a real document to work with. BUG= Review URL: https://codereview.chromium.org/568933002 Cr-Commit-Position: refs/heads/master@{#294736} --- chrome/renderer/printing/print_web_view_helper_browsertest.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chrome/renderer/printing/print_web_view_helper_browsertest.cc b/chrome/renderer/printing/print_web_view_helper_browsertest.cc index 3c777bd..ba5cc26 100644 --- a/chrome/renderer/printing/print_web_view_helper_browsertest.cc +++ b/chrome/renderer/printing/print_web_view_helper_browsertest.cc @@ -335,6 +335,7 @@ TEST_F(PrintWebViewHelperTest, PrintWithIframe) { " document.write(frames['sub1'].name);" " frames['sub1'].document.write(" " '

Cras tempus ante eu felis semper luctus!

');" + " frames['sub1'].document.close();" ""; LoadHTML(html); @@ -563,6 +564,7 @@ class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { #if defined(ENABLE_FULL_PRINTING) TEST_F(PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { + LoadHTML(kHelloWorldHTML); PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_); print_web_view_helper->SetScriptedPrintBlocked(true); PrintWithJavaScript(); -- cgit v1.1 From 19d61295f56988233119c544edeee25f4322a17f Mon Sep 17 00:00:00 2001 From: damienv Date: Fri, 12 Sep 2014 23:55:06 -0700 Subject: Support MPEG1 audio in the MPEG2-TS stream parser. BUG=None Review URL: https://codereview.chromium.org/506943003 Cr-Commit-Position: refs/heads/master@{#294737} --- media/BUILD.gn | 9 +- media/filters/stream_parser_factory.cc | 4 +- media/formats/mp2t/es_parser_adts_unittest.cc | 19 -- media/formats/mp2t/es_parser_mpeg1audio.cc | 210 +++++++++++++++ media/formats/mp2t/es_parser_mpeg1audio.h | 88 +++++++ .../formats/mp2t/es_parser_mpeg1audio_unittest.cc | 72 +++++ media/formats/mp2t/es_parser_test_base.cc | 17 ++ media/formats/mp2t/es_parser_test_base.h | 3 + media/formats/mp2t/mp2t_stream_parser.cc | 12 + media/formats/mpeg/mp3_stream_parser.cc | 280 -------------------- media/formats/mpeg/mp3_stream_parser.h | 34 --- media/formats/mpeg/mp3_stream_parser_unittest.cc | 95 ------- media/formats/mpeg/mpeg1_audio_stream_parser.cc | 291 +++++++++++++++++++++ media/formats/mpeg/mpeg1_audio_stream_parser.h | 88 +++++++ .../mpeg/mpeg1_audio_stream_parser_unittest.cc | 96 +++++++ media/media.gyp | 9 +- 16 files changed, 891 insertions(+), 436 deletions(-) create mode 100644 media/formats/mp2t/es_parser_mpeg1audio.cc create mode 100644 media/formats/mp2t/es_parser_mpeg1audio.h create mode 100644 media/formats/mp2t/es_parser_mpeg1audio_unittest.cc delete mode 100644 media/formats/mpeg/mp3_stream_parser.cc delete mode 100644 media/formats/mpeg/mp3_stream_parser.h delete mode 100644 media/formats/mpeg/mp3_stream_parser_unittest.cc create mode 100644 media/formats/mpeg/mpeg1_audio_stream_parser.cc create mode 100644 media/formats/mpeg/mpeg1_audio_stream_parser.h create mode 100644 media/formats/mpeg/mpeg1_audio_stream_parser_unittest.cc diff --git a/media/BUILD.gn b/media/BUILD.gn index 3931f2e..97e4480 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -369,6 +369,8 @@ component("media") { "formats/mp2t/es_parser_adts.h", "formats/mp2t/es_parser_h264.cc", "formats/mp2t/es_parser_h264.h", + "formats/mp2t/es_parser_mpeg1audio.cc", + "formats/mp2t/es_parser_mpeg1audio.h", "formats/mp2t/mp2t_common.h", "formats/mp2t/mp2t_stream_parser.cc", "formats/mp2t/mp2t_stream_parser.h", @@ -405,10 +407,10 @@ component("media") { "formats/mpeg/adts_constants.h", "formats/mpeg/adts_stream_parser.cc", "formats/mpeg/adts_stream_parser.h", - "formats/mpeg/mp3_stream_parser.cc", - "formats/mpeg/mp3_stream_parser.h", "formats/mpeg/mpeg_audio_stream_parser_base.cc", "formats/mpeg/mpeg_audio_stream_parser_base.h", + "formats/mpeg/mpeg1_audio_stream_parser.cc", + "formats/mpeg/mpeg1_audio_stream_parser.h", ] } @@ -536,6 +538,7 @@ test("media_unittests") { "formats/mp2t/es_adapter_video_unittest.cc", "formats/mp2t/es_parser_adts_unittest.cc", "formats/mp2t/es_parser_h264_unittest.cc", + "formats/mp2t/es_parser_mpeg1audio_unittest.cc", "formats/mp2t/es_parser_test_base.cc", "formats/mp2t/es_parser_test_base.h", "formats/mp2t/mp2t_stream_parser_unittest.cc", @@ -547,7 +550,7 @@ test("media_unittests") { "formats/mp4/sample_to_group_iterator_unittest.cc", "formats/mp4/track_run_iterator_unittest.cc", "formats/mpeg/adts_stream_parser_unittest.cc", - "formats/mpeg/mp3_stream_parser_unittest.cc", + "formats/mpeg/mpeg1_audio_stream_parser_unittest.cc", ] } diff --git a/media/filters/stream_parser_factory.cc b/media/filters/stream_parser_factory.cc index daeaea2..b47fa75 100644 --- a/media/filters/stream_parser_factory.cc +++ b/media/filters/stream_parser_factory.cc @@ -11,7 +11,7 @@ #include "media/base/media_log.h" #include "media/base/media_switches.h" #include "media/formats/mpeg/adts_stream_parser.h" -#include "media/formats/mpeg/mp3_stream_parser.h" +#include "media/formats/mpeg/mpeg1_audio_stream_parser.h" #include "media/formats/webm/webm_stream_parser.h" #if defined(OS_ANDROID) @@ -190,7 +190,7 @@ static const CodecInfo* kAudioMP3Codecs[] = { static StreamParser* BuildMP3Parser( const std::vector& codecs, const LogCB& log_cb) { - return new MP3StreamParser(); + return new MPEG1AudioStreamParser(); } static const CodecInfo kADTSCodecInfo = { NULL, CodecInfo::AUDIO, NULL, diff --git a/media/formats/mp2t/es_parser_adts_unittest.cc b/media/formats/mp2t/es_parser_adts_unittest.cc index c9dd47c..a65635a 100644 --- a/media/formats/mp2t/es_parser_adts_unittest.cc +++ b/media/formats/mp2t/es_parser_adts_unittest.cc @@ -27,8 +27,6 @@ class EsParserAdtsTest : public EsParserTestBase, protected: bool Process(const std::vector& pes_packets, bool force_timing); - std::vector GenerateFixedSizePesPacket(size_t pes_size); - private: DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest); }; @@ -46,23 +44,6 @@ bool EsParserAdtsTest::Process( return ProcessPesPackets(&es_parser, pes_packets, force_timing); } -std::vector -EsParserAdtsTest::GenerateFixedSizePesPacket(size_t pes_size) { - DCHECK_GT(stream_.size(), 0u); - std::vector pes_packets; - - Packet cur_pes_packet; - cur_pes_packet.offset = 0; - cur_pes_packet.pts = kNoTimestamp(); - while (cur_pes_packet.offset < stream_.size()) { - pes_packets.push_back(cur_pes_packet); - cur_pes_packet.offset += pes_size; - } - ComputePacketSize(&pes_packets); - - return pes_packets; -} - TEST_F(EsParserAdtsTest, NoInitialPts) { LoadStream("bear.adts"); std::vector pes_packets = GenerateFixedSizePesPacket(512); diff --git a/media/formats/mp2t/es_parser_mpeg1audio.cc b/media/formats/mp2t/es_parser_mpeg1audio.cc new file mode 100644 index 0000000..46729b0 --- /dev/null +++ b/media/formats/mp2t/es_parser_mpeg1audio.cc @@ -0,0 +1,210 @@ +// 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 "media/formats/mp2t/es_parser_mpeg1audio.h" + +#include + +#include "base/basictypes.h" +#include "base/bind.h" +#include "base/logging.h" +#include "base/strings/string_number_conversions.h" +#include "media/base/audio_timestamp_helper.h" +#include "media/base/bit_reader.h" +#include "media/base/buffers.h" +#include "media/base/channel_layout.h" +#include "media/base/stream_parser_buffer.h" +#include "media/formats/common/offset_byte_queue.h" +#include "media/formats/mp2t/mp2t_common.h" +#include "media/formats/mpeg/mpeg1_audio_stream_parser.h" + +namespace media { +namespace mp2t { + +struct EsParserMpeg1Audio::Mpeg1AudioFrame { + // Pointer to the ES data. + const uint8* data; + + // Frame size. + int size; + + // Number of samples in the frame. + int sample_count; + + // Frame offset in the ES queue. + int64 queue_offset; +}; + +EsParserMpeg1Audio::EsParserMpeg1Audio( + const NewAudioConfigCB& new_audio_config_cb, + const EmitBufferCB& emit_buffer_cb, + const LogCB& log_cb) + : log_cb_(log_cb), + new_audio_config_cb_(new_audio_config_cb), + emit_buffer_cb_(emit_buffer_cb) { +} + +EsParserMpeg1Audio::~EsParserMpeg1Audio() { +} + +bool EsParserMpeg1Audio::ParseFromEsQueue() { + // Look for every MPEG1 audio frame in the ES buffer. + Mpeg1AudioFrame mpeg1audio_frame; + while (LookForMpeg1AudioFrame(&mpeg1audio_frame)) { + // Update the audio configuration if needed. + DCHECK_GE(mpeg1audio_frame.size, MPEG1AudioStreamParser::kHeaderSize); + if (!UpdateAudioConfiguration(mpeg1audio_frame.data)) + return false; + + // Get the PTS & the duration of this access unit. + TimingDesc current_timing_desc = + GetTimingDescriptor(mpeg1audio_frame.queue_offset); + if (current_timing_desc.pts != kNoTimestamp()) + audio_timestamp_helper_->SetBaseTimestamp(current_timing_desc.pts); + + if (audio_timestamp_helper_->base_timestamp() == kNoTimestamp()) { + DVLOG(1) << "Audio frame with unknown timestamp"; + return false; + } + base::TimeDelta current_pts = audio_timestamp_helper_->GetTimestamp(); + base::TimeDelta frame_duration = + audio_timestamp_helper_->GetFrameDuration( + mpeg1audio_frame.sample_count); + + // Emit an audio frame. + bool is_key_frame = true; + + // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId + // type and allow multiple audio tracks. See https://crbug.com/341581. + scoped_refptr stream_parser_buffer = + StreamParserBuffer::CopyFrom( + mpeg1audio_frame.data, + mpeg1audio_frame.size, + is_key_frame, + DemuxerStream::AUDIO, 0); + stream_parser_buffer->set_timestamp(current_pts); + stream_parser_buffer->set_duration(frame_duration); + emit_buffer_cb_.Run(stream_parser_buffer); + + // Update the PTS of the next frame. + audio_timestamp_helper_->AddFrames(mpeg1audio_frame.sample_count); + + // Skip the current frame. + SkipMpeg1AudioFrame(mpeg1audio_frame); + } + + return true; +} + +void EsParserMpeg1Audio::Flush() { +} + +void EsParserMpeg1Audio::ResetInternal() { + last_audio_decoder_config_ = AudioDecoderConfig(); +} + +bool EsParserMpeg1Audio::LookForMpeg1AudioFrame( + Mpeg1AudioFrame* mpeg1audio_frame) { + int es_size; + const uint8* es; + es_queue_->Peek(&es, &es_size); + + int max_offset = es_size - MPEG1AudioStreamParser::kHeaderSize; + if (max_offset <= 0) + return false; + + for (int offset = 0; offset < max_offset; offset++) { + const uint8* cur_buf = &es[offset]; + if (cur_buf[0] != 0xff) + continue; + + int remaining_size = es_size - offset; + DCHECK_GE(remaining_size, MPEG1AudioStreamParser::kHeaderSize); + MPEG1AudioStreamParser::Header header; + if (!MPEG1AudioStreamParser::ParseHeader(log_cb_, cur_buf, &header)) + continue; + + if (remaining_size < header.frame_size) { + // Not a full frame: will resume when we have more data. + // Remove all the bytes located before the frame header, + // these bytes will not be used anymore. + es_queue_->Pop(offset); + return false; + } + + // Check whether there is another frame + // |frame_size| apart from the current one. + if (remaining_size >= header.frame_size + 1 && + cur_buf[header.frame_size] != 0xff) { + continue; + } + + es_queue_->Pop(offset); + es_queue_->Peek(&mpeg1audio_frame->data, &es_size); + mpeg1audio_frame->queue_offset = es_queue_->head(); + mpeg1audio_frame->size = header.frame_size; + mpeg1audio_frame->sample_count = header.sample_count; + DVLOG(LOG_LEVEL_ES) + << "MPEG1 audio syncword @ pos=" << mpeg1audio_frame->queue_offset + << " frame_size=" << mpeg1audio_frame->size; + DVLOG(LOG_LEVEL_ES) + << "MPEG1 audio header: " + << base::HexEncode(mpeg1audio_frame->data, + MPEG1AudioStreamParser::kHeaderSize); + return true; + } + + es_queue_->Pop(max_offset); + return false; +} + +bool EsParserMpeg1Audio::UpdateAudioConfiguration( + const uint8* mpeg1audio_header) { + MPEG1AudioStreamParser::Header header; + if (!MPEG1AudioStreamParser::ParseHeader(log_cb_, + mpeg1audio_header, + &header)) { + return false; + } + + // TODO(damienv): Verify whether Android playback requires the extra data + // field for Mpeg1 audio. If yes, we should generate this field. + AudioDecoderConfig audio_decoder_config( + kCodecMP3, + kSampleFormatS16, + header.channel_layout, + header.sample_rate, + NULL, 0, + false); + + if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { + DVLOG(1) << "Sampling frequency: " << header.sample_rate; + DVLOG(1) << "Channel layout: " << header.channel_layout; + // Reset the timestamp helper to use a new time scale. + if (audio_timestamp_helper_ && + audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { + base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); + audio_timestamp_helper_.reset( + new AudioTimestampHelper(header.sample_rate)); + audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); + } else { + audio_timestamp_helper_.reset( + new AudioTimestampHelper(header.sample_rate)); + } + // Audio config notification. + last_audio_decoder_config_ = audio_decoder_config; + new_audio_config_cb_.Run(audio_decoder_config); + } + + return true; +} + +void EsParserMpeg1Audio::SkipMpeg1AudioFrame( + const Mpeg1AudioFrame& mpeg1audio_frame) { + DCHECK_EQ(mpeg1audio_frame.queue_offset, es_queue_->head()); + es_queue_->Pop(mpeg1audio_frame.size); +} + +} // namespace mp2t +} // namespace media diff --git a/media/formats/mp2t/es_parser_mpeg1audio.h b/media/formats/mp2t/es_parser_mpeg1audio.h new file mode 100644 index 0000000..8ae1c1b --- /dev/null +++ b/media/formats/mp2t/es_parser_mpeg1audio.h @@ -0,0 +1,88 @@ +// 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 MEDIA_FORMATS_MP2T_ES_PARSER_MPEG1AUDIO_H_ +#define MEDIA_FORMATS_MP2T_ES_PARSER_MPEG1AUDIO_H_ + +#include +#include + +#include "base/callback.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "base/time/time.h" +#include "media/base/audio_decoder_config.h" +#include "media/base/media_export.h" +#include "media/base/media_log.h" +#include "media/formats/mp2t/es_parser.h" + +namespace media { +class AudioTimestampHelper; +class BitReader; +class OffsetByteQueue; +class StreamParserBuffer; +} + +namespace media { +namespace mp2t { + +class MEDIA_EXPORT EsParserMpeg1Audio : public EsParser { + public: + typedef base::Callback NewAudioConfigCB; + + EsParserMpeg1Audio(const NewAudioConfigCB& new_audio_config_cb, + const EmitBufferCB& emit_buffer_cb, + const LogCB& log_cb); + virtual ~EsParserMpeg1Audio(); + + // EsParser implementation. + virtual void Flush() OVERRIDE; + + private: + // Used to link a PTS with a byte position in the ES stream. + typedef std::pair EsPts; + typedef std::list EsPtsList; + + struct Mpeg1AudioFrame; + + // EsParser implementation. + virtual bool ParseFromEsQueue() OVERRIDE; + virtual void ResetInternal() OVERRIDE; + + // Synchronize the stream on a Mpeg1 audio syncword (consuming bytes from + // |es_queue_| if needed). + // Returns true when a full Mpeg1 audio frame has been found: in that case + // |mpeg1audio_frame| structure is filled up accordingly. + // Returns false otherwise (no Mpeg1 audio syncword found or partial Mpeg1 + // audio frame). + bool LookForMpeg1AudioFrame(Mpeg1AudioFrame* mpeg1audio_frame); + + // Signal any audio configuration change (if any). + // Return false if the current audio config is not + // a supported Mpeg1 audio config. + bool UpdateAudioConfiguration(const uint8* mpeg1audio_header); + + void SkipMpeg1AudioFrame(const Mpeg1AudioFrame& mpeg1audio_frame); + + LogCB log_cb_; + + // Callbacks: + // - to signal a new audio configuration, + // - to send ES buffers. + NewAudioConfigCB new_audio_config_cb_; + EmitBufferCB emit_buffer_cb_; + + // Interpolated PTS for frames that don't have one. + scoped_ptr audio_timestamp_helper_; + + // Last audio config. + AudioDecoderConfig last_audio_decoder_config_; + + DISALLOW_COPY_AND_ASSIGN(EsParserMpeg1Audio); +}; + +} // namespace mp2t +} // namespace media + +#endif // MEDIA_FORMATS_MP2T_ES_PARSER_MPEG1AUDIO_H_ diff --git a/media/formats/mp2t/es_parser_mpeg1audio_unittest.cc b/media/formats/mp2t/es_parser_mpeg1audio_unittest.cc new file mode 100644 index 0000000..0f88e8d --- /dev/null +++ b/media/formats/mp2t/es_parser_mpeg1audio_unittest.cc @@ -0,0 +1,72 @@ +// 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 + +#include "base/bind.h" +#include "base/logging.h" +#include "base/time/time.h" +#include "media/base/buffers.h" +#include "media/base/media_log.h" +#include "media/base/stream_parser_buffer.h" +#include "media/formats/mp2t/es_parser_mpeg1audio.h" +#include "media/formats/mp2t/es_parser_test_base.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace media { +class AudioDecoderConfig; + +namespace mp2t { + +class EsParserMpeg1AudioTest : public EsParserTestBase, + public testing::Test { + public: + EsParserMpeg1AudioTest(); + virtual ~EsParserMpeg1AudioTest() {} + + protected: + bool Process(const std::vector& pes_packets, bool force_timing); + + private: + DISALLOW_COPY_AND_ASSIGN(EsParserMpeg1AudioTest); +}; + +EsParserMpeg1AudioTest::EsParserMpeg1AudioTest() { +} + +bool EsParserMpeg1AudioTest::Process( + const std::vector& pes_packets, + bool force_timing) { + EsParserMpeg1Audio es_parser( + base::Bind(&EsParserMpeg1AudioTest::NewAudioConfig, + base::Unretained(this)), + base::Bind(&EsParserMpeg1AudioTest::EmitBuffer, + base::Unretained(this)), + LogCB()); + return ProcessPesPackets(&es_parser, pes_packets, force_timing); +} + +TEST_F(EsParserMpeg1AudioTest, SinglePts) { + LoadStream("sfx.mp3"); + + std::vector pes_packets = GenerateFixedSizePesPacket(512); + pes_packets.front().pts = base::TimeDelta::FromSeconds(10); + + // Note: there is no parsing of metadata as part of Mpeg2 TS, + // so the tag starting at 0x80d with 0x54 0x41 0x47 (ascii for "TAG") + // is not a valid Mpeg1 audio frame header. This makes the previous frame + // invalid since there is no start code following the previous frame. + // So instead of the 13 Mpeg1 audio frames, only 12 are considered valid. + // Offset of frames in the file: + // {0x20, 0x1c1, 0x277, 0x2f9, 0x3fd, 0x47f, 0x501, 0x583, + // 0x605, 0x687, 0x73d, 0x7a5, 0x80d} + // TODO(damienv): find a file that would be more relevant for Mpeg1 audio + // as part of Mpeg2 TS. + EXPECT_TRUE(Process(pes_packets, false)); + EXPECT_EQ(1u, config_count_); + EXPECT_EQ(12u, buffer_count_); +} + +} // namespace mp2t +} // namespace media diff --git a/media/formats/mp2t/es_parser_test_base.cc b/media/formats/mp2t/es_parser_test_base.cc index 49c0fe6..195cfd5b 100644 --- a/media/formats/mp2t/es_parser_test_base.cc +++ b/media/formats/mp2t/es_parser_test_base.cc @@ -104,5 +104,22 @@ void EsParserTestBase::ComputePacketSize(std::vector* packets) { cur->size = stream_.size() - cur->offset; } +std::vector +EsParserTestBase::GenerateFixedSizePesPacket(size_t pes_size) { + DCHECK_GT(stream_.size(), 0u); + std::vector pes_packets; + + Packet cur_pes_packet; + cur_pes_packet.offset = 0; + cur_pes_packet.pts = kNoTimestamp(); + while (cur_pes_packet.offset < stream_.size()) { + pes_packets.push_back(cur_pes_packet); + cur_pes_packet.offset += pes_size; + } + ComputePacketSize(&pes_packets); + + return pes_packets; +} + } // namespace mp2t } // namespace media diff --git a/media/formats/mp2t/es_parser_test_base.h b/media/formats/mp2t/es_parser_test_base.h index 4b18efa..433bbe1 100644 --- a/media/formats/mp2t/es_parser_test_base.h +++ b/media/formats/mp2t/es_parser_test_base.h @@ -60,6 +60,9 @@ class EsParserTestBase { // Packets are assumed to be in stream order. void ComputePacketSize(std::vector* packets); + // Generate some fixed size PES packets of |stream_|. + std::vector GenerateFixedSizePesPacket(size_t pes_size); + // ES stream. std::vector stream_; diff --git a/media/formats/mp2t/mp2t_stream_parser.cc b/media/formats/mp2t/mp2t_stream_parser.cc index 35c61d6..673f787 100644 --- a/media/formats/mp2t/mp2t_stream_parser.cc +++ b/media/formats/mp2t/mp2t_stream_parser.cc @@ -16,6 +16,7 @@ #include "media/formats/mp2t/es_parser.h" #include "media/formats/mp2t/es_parser_adts.h" #include "media/formats/mp2t/es_parser_h264.h" +#include "media/formats/mp2t/es_parser_mpeg1audio.h" #include "media/formats/mp2t/mp2t_common.h" #include "media/formats/mp2t/ts_packet.h" #include "media/formats/mp2t/ts_section.h" @@ -349,6 +350,17 @@ void Mp2tStreamParser::RegisterPes(int pmt_pid, pes_pid), sbr_in_mimetype_)); is_audio = true; + } else if (stream_type == kStreamTypeMpeg1Audio) { + es_parser.reset( + new EsParserMpeg1Audio( + base::Bind(&Mp2tStreamParser::OnAudioConfigChanged, + base::Unretained(this), + pes_pid), + base::Bind(&Mp2tStreamParser::OnEmitAudioBuffer, + base::Unretained(this), + pes_pid), + log_cb_)); + is_audio = true; } else { return; } diff --git a/media/formats/mpeg/mp3_stream_parser.cc b/media/formats/mpeg/mp3_stream_parser.cc deleted file mode 100644 index f5b7438..0000000 --- a/media/formats/mpeg/mp3_stream_parser.cc +++ /dev/null @@ -1,280 +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 "media/formats/mpeg/mp3_stream_parser.h" - -namespace media { - -static const uint32 kMP3StartCodeMask = 0xffe00000; - -// Map that determines which bitrate_index & channel_mode combinations -// are allowed. -// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html -static const bool kIsAllowed[17][4] = { - { true, true, true, true }, // free - { true, false, false, false }, // 32 - { true, false, false, false }, // 48 - { true, false, false, false }, // 56 - { true, true, true, true }, // 64 - { true, false, false, false }, // 80 - { true, true, true, true }, // 96 - { true, true, true, true }, // 112 - { true, true, true, true }, // 128 - { true, true, true, true }, // 160 - { true, true, true, true }, // 192 - { false, true, true, true }, // 224 - { false, true, true, true }, // 256 - { false, true, true, true }, // 320 - { false, true, true, true }, // 384 - { false, false, false, false } // bad -}; - -// Maps version and layer information in the frame header -// into an index for the |kBitrateMap|. -// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html -static const int kVersionLayerMap[4][4] = { - // { reserved, L3, L2, L1 } - { 5, 4, 4, 3 }, // MPEG 2.5 - { 5, 5, 5, 5 }, // reserved - { 5, 4, 4, 3 }, // MPEG 2 - { 5, 2, 1, 0 } // MPEG 1 -}; - -// Maps the bitrate index field in the header and an index -// from |kVersionLayerMap| to a frame bitrate. -// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html -static const int kBitrateMap[16][6] = { - // { V1L1, V1L2, V1L3, V2L1, V2L2 & V2L3, reserved } - { 0, 0, 0, 0, 0, 0 }, - { 32, 32, 32, 32, 8, 0 }, - { 64, 48, 40, 48, 16, 0 }, - { 96, 56, 48, 56, 24, 0 }, - { 128, 64, 56, 64, 32, 0 }, - { 160, 80, 64, 80, 40, 0 }, - { 192, 96, 80, 96, 48, 0 }, - { 224, 112, 96, 112, 56, 0 }, - { 256, 128, 112, 128, 64, 0 }, - { 288, 160, 128, 144, 80, 0 }, - { 320, 192, 160, 160, 96, 0 }, - { 352, 224, 192, 176, 112, 0 }, - { 384, 256, 224, 192, 128, 0 }, - { 416, 320, 256, 224, 144, 0 }, - { 448, 384, 320, 256, 160, 0 }, - { 0, 0, 0, 0, 0} -}; - -// Maps the sample rate index and version fields from the frame header -// to a sample rate. -// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html -static const int kSampleRateMap[4][4] = { - // { V2.5, reserved, V2, V1 } - { 11025, 0, 22050, 44100 }, - { 12000, 0, 24000, 48000 }, - { 8000, 0, 16000, 32000 }, - { 0, 0, 0, 0 } -}; - -// Offset in bytes from the end of the MP3 header to "Xing" or "Info" tags which -// indicate a frame is silent metadata frame. Values taken from FFmpeg. -static const int kXingHeaderMap[2][2] = {{32, 17}, {17, 9}}; - -// Frame header field constants. -static const int kVersion2 = 2; -static const int kVersionReserved = 1; -static const int kVersion2_5 = 0; -static const int kLayerReserved = 0; -static const int kLayer1 = 3; -static const int kLayer2 = 2; -static const int kLayer3 = 1; -static const int kBitrateFree = 0; -static const int kBitrateBad = 0xf; -static const int kSampleRateReserved = 3; -static const int kCodecDelay = 529; - -MP3StreamParser::MP3StreamParser() - : MPEGAudioStreamParserBase(kMP3StartCodeMask, kCodecMP3, kCodecDelay) {} - -MP3StreamParser::~MP3StreamParser() {} - -int MP3StreamParser::ParseFrameHeader(const uint8* data, - int size, - int* frame_size, - int* sample_rate, - ChannelLayout* channel_layout, - int* sample_count, - bool* metadata_frame) const { - DCHECK(data); - DCHECK_GE(size, 0); - DCHECK(frame_size); - - if (size < 4) - return 0; - - BitReader reader(data, size); - int sync; - int version; - int layer; - int is_protected; - int bitrate_index; - int sample_rate_index; - int has_padding; - int is_private; - int channel_mode; - int other_flags; - - if (!reader.ReadBits(11, &sync) || - !reader.ReadBits(2, &version) || - !reader.ReadBits(2, &layer) || - !reader.ReadBits(1, &is_protected) || - !reader.ReadBits(4, &bitrate_index) || - !reader.ReadBits(2, &sample_rate_index) || - !reader.ReadBits(1, &has_padding) || - !reader.ReadBits(1, &is_private) || - !reader.ReadBits(2, &channel_mode) || - !reader.ReadBits(6, &other_flags)) { - return -1; - } - - DVLOG(2) << "Header data :" << std::hex - << " sync 0x" << sync - << " version 0x" << version - << " layer 0x" << layer - << " bitrate_index 0x" << bitrate_index - << " sample_rate_index 0x" << sample_rate_index - << " channel_mode 0x" << channel_mode; - - if (sync != 0x7ff || - version == kVersionReserved || - layer == kLayerReserved || - bitrate_index == kBitrateFree || bitrate_index == kBitrateBad || - sample_rate_index == kSampleRateReserved) { - MEDIA_LOG(log_cb()) << "Invalid header data :" << std::hex - << " sync 0x" << sync - << " version 0x" << version - << " layer 0x" << layer - << " bitrate_index 0x" << bitrate_index - << " sample_rate_index 0x" << sample_rate_index - << " channel_mode 0x" << channel_mode; - return -1; - } - - if (layer == kLayer2 && kIsAllowed[bitrate_index][channel_mode]) { - MEDIA_LOG(log_cb()) << "Invalid (bitrate_index, channel_mode) combination :" - << std::hex - << " bitrate_index " << bitrate_index - << " channel_mode " << channel_mode; - return -1; - } - - int bitrate = kBitrateMap[bitrate_index][kVersionLayerMap[version][layer]]; - - if (bitrate == 0) { - MEDIA_LOG(log_cb()) << "Invalid bitrate :" << std::hex - << " version " << version - << " layer " << layer - << " bitrate_index " << bitrate_index; - return -1; - } - - DVLOG(2) << " bitrate " << bitrate; - - int frame_sample_rate = kSampleRateMap[sample_rate_index][version]; - if (frame_sample_rate == 0) { - MEDIA_LOG(log_cb()) << "Invalid sample rate :" << std::hex - << " version " << version - << " sample_rate_index " << sample_rate_index; - return -1; - } - - if (sample_rate) - *sample_rate = frame_sample_rate; - - // http://teslabs.com/openplayer/docs/docs/specs/mp3_structure2.pdf - // Table 2.1.5 - int samples_per_frame; - switch (layer) { - case kLayer1: - samples_per_frame = 384; - break; - - case kLayer2: - samples_per_frame = 1152; - break; - - case kLayer3: - if (version == kVersion2 || version == kVersion2_5) - samples_per_frame = 576; - else - samples_per_frame = 1152; - break; - - default: - return -1; - } - - if (sample_count) - *sample_count = samples_per_frame; - - // http://teslabs.com/openplayer/docs/docs/specs/mp3_structure2.pdf - // Text just below Table 2.1.5. - if (layer == kLayer1) { - // This formulation is a slight variation on the equation below, - // but has slightly different truncation characteristics to deal - // with the fact that Layer 1 has 4 byte "slots" instead of single - // byte ones. - *frame_size = 4 * (12 * bitrate * 1000 / frame_sample_rate); - } else { - *frame_size = - ((samples_per_frame / 8) * bitrate * 1000) / frame_sample_rate; - } - - if (has_padding) - *frame_size += (layer == kLayer1) ? 4 : 1; - - if (channel_layout) { - // Map Stereo(0), Joint Stereo(1), and Dual Channel (2) to - // CHANNEL_LAYOUT_STEREO and Single Channel (3) to CHANNEL_LAYOUT_MONO. - *channel_layout = - (channel_mode == 3) ? CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO; - } - - if (metadata_frame) - *metadata_frame = false; - - const int header_bytes_read = reader.bits_read() / 8; - if (layer != kLayer3) - return header_bytes_read; - - // Check if this is a XING frame and tell the base parser to skip it if so. - const int xing_header_index = - kXingHeaderMap[version == kVersion2 || - version == kVersion2_5][channel_mode == 3]; - uint32_t tag = 0; - - // It's not a XING frame if the frame isn't big enough to be one. - if (*frame_size < - header_bytes_read + xing_header_index + static_cast(sizeof(tag))) { - return header_bytes_read; - } - - // If we don't have enough data available to check, return 0 so frame parsing - // will be retried once more data is available. - if (!reader.SkipBits(xing_header_index * 8) || - !reader.ReadBits(sizeof(tag) * 8, &tag)) { - return 0; - } - - // Check to see if the tag contains 'Xing' or 'Info' - if (tag == 0x496e666f || tag == 0x58696e67) { - MEDIA_LOG(log_cb()) << "Skipping XING header."; - if (metadata_frame) - *metadata_frame = true; - return reader.bits_read() / 8; - } - - // If it wasn't a XING frame, just return the number consumed bytes. - return header_bytes_read; -} - -} // namespace media diff --git a/media/formats/mpeg/mp3_stream_parser.h b/media/formats/mpeg/mp3_stream_parser.h deleted file mode 100644 index b5271d84..0000000 --- a/media/formats/mpeg/mp3_stream_parser.h +++ /dev/null @@ -1,34 +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 MEDIA_FORMATS_MPEG_MP3_STREAM_PARSER_H_ -#define MEDIA_FORMATS_MPEG_MP3_STREAM_PARSER_H_ - -#include "base/basictypes.h" -#include "media/base/media_export.h" -#include "media/formats/mpeg/mpeg_audio_stream_parser_base.h" - -namespace media { - -class MEDIA_EXPORT MP3StreamParser : public MPEGAudioStreamParserBase { - public: - MP3StreamParser(); - virtual ~MP3StreamParser(); - - private: - // MPEGAudioStreamParserBase overrides. - virtual int ParseFrameHeader(const uint8* data, - int size, - int* frame_size, - int* sample_rate, - ChannelLayout* channel_layout, - int* sample_count, - bool* metadata_frame) const OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(MP3StreamParser); -}; - -} // namespace media - -#endif // MEDIA_FORMATS_MPEG_MP3_STREAM_PARSER_H_ diff --git a/media/formats/mpeg/mp3_stream_parser_unittest.cc b/media/formats/mpeg/mp3_stream_parser_unittest.cc deleted file mode 100644 index 1638752..0000000 --- a/media/formats/mpeg/mp3_stream_parser_unittest.cc +++ /dev/null @@ -1,95 +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 "media/base/test_data_util.h" -#include "media/formats/common/stream_parser_test_base.h" -#include "media/formats/mpeg/mp3_stream_parser.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace media { - -class MP3StreamParserTest : public StreamParserTestBase, public testing::Test { - public: - MP3StreamParserTest() - : StreamParserTestBase( - scoped_ptr(new MP3StreamParser()).Pass()) {} - virtual ~MP3StreamParserTest() {} -}; - -// Test parsing with small prime sized chunks to smoke out "power of -// 2" field size assumptions. -TEST_F(MP3StreamParserTest, UnalignedAppend) { - const std::string expected = - "NewSegment" - "{ 0K }" - "{ 0K }" - "{ 0K }" - "{ 0K }" - "{ 0K }" - "{ 0K }" - "{ 0K }" - "EndOfSegment" - "NewSegment" - "{ 0K }" - "{ 0K }" - "{ 0K }" - "EndOfSegment" - "NewSegment" - "{ 0K }" - "{ 0K }" - "EndOfSegment"; - EXPECT_EQ(expected, ParseFile("sfx.mp3", 17)); - EXPECT_GT(last_audio_config().codec_delay(), 0); -} - -// Test parsing with a larger piece size to verify that multiple buffers -// are passed to |new_buffer_cb_|. -TEST_F(MP3StreamParserTest, UnalignedAppend512) { - const std::string expected = - "NewSegment" - "{ 0K 26K 52K 78K }" - "EndOfSegment" - "NewSegment" - "{ 0K 26K 52K }" - "{ 0K 26K 52K 78K }" - "{ 0K }" - "EndOfSegment"; - EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); - EXPECT_GT(last_audio_config().codec_delay(), 0); -} - -TEST_F(MP3StreamParserTest, MetadataParsing) { - scoped_refptr buffer = ReadTestDataFile("sfx.mp3"); - const uint8_t* buffer_ptr = buffer->data(); - - // The first 32 bytes of sfx.mp3 are an ID3 tag, so no segments should be - // extracted after appending those bytes. - const int kId3TagSize = 32; - EXPECT_EQ("", ParseData(buffer_ptr, kId3TagSize)); - EXPECT_FALSE(last_audio_config().IsValidConfig()); - buffer_ptr += kId3TagSize; - - // The next 417 bytes are a Xing frame; with the identifier 21 bytes into - // the frame. Appending less than 21 bytes, should result in no segments - // nor an AudioDecoderConfig being created. - const int kXingTagPosition = 21; - EXPECT_EQ("", ParseData(buffer_ptr, kXingTagPosition)); - EXPECT_FALSE(last_audio_config().IsValidConfig()); - buffer_ptr += kXingTagPosition; - - // Appending the rests of the Xing frame should result in no segments, but - // should generate a valid AudioDecoderConfig. - const int kXingRemainingSize = 417 - kXingTagPosition; - EXPECT_EQ("", ParseData(buffer_ptr, kXingRemainingSize)); - EXPECT_TRUE(last_audio_config().IsValidConfig()); - buffer_ptr += kXingRemainingSize; - - // Append the first real frame and ensure we get a segment. - const int kFirstRealFrameSize = 182; - EXPECT_EQ("NewSegment{ 0K }EndOfSegment", - ParseData(buffer_ptr, kFirstRealFrameSize)); - EXPECT_TRUE(last_audio_config().IsValidConfig()); -} - -} // namespace media diff --git a/media/formats/mpeg/mpeg1_audio_stream_parser.cc b/media/formats/mpeg/mpeg1_audio_stream_parser.cc new file mode 100644 index 0000000..92bd4ce --- /dev/null +++ b/media/formats/mpeg/mpeg1_audio_stream_parser.cc @@ -0,0 +1,291 @@ +// 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 "media/formats/mpeg/mpeg1_audio_stream_parser.h" + +namespace media { + +static const uint32 kMPEG1StartCodeMask = 0xffe00000; + +// Map that determines which bitrate_index & channel_mode combinations +// are allowed. +// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html +static const bool kIsAllowed[17][4] = { + { true, true, true, true }, // free + { true, false, false, false }, // 32 + { true, false, false, false }, // 48 + { true, false, false, false }, // 56 + { true, true, true, true }, // 64 + { true, false, false, false }, // 80 + { true, true, true, true }, // 96 + { true, true, true, true }, // 112 + { true, true, true, true }, // 128 + { true, true, true, true }, // 160 + { true, true, true, true }, // 192 + { false, true, true, true }, // 224 + { false, true, true, true }, // 256 + { false, true, true, true }, // 320 + { false, true, true, true }, // 384 + { false, false, false, false } // bad +}; + +// Maps version and layer information in the frame header +// into an index for the |kBitrateMap|. +// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html +static const int kVersionLayerMap[4][4] = { + // { reserved, L3, L2, L1 } + { 5, 4, 4, 3 }, // MPEG 2.5 + { 5, 5, 5, 5 }, // reserved + { 5, 4, 4, 3 }, // MPEG 2 + { 5, 2, 1, 0 } // MPEG 1 +}; + +// Maps the bitrate index field in the header and an index +// from |kVersionLayerMap| to a frame bitrate. +// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html +static const int kBitrateMap[16][6] = { + // { V1L1, V1L2, V1L3, V2L1, V2L2 & V2L3, reserved } + { 0, 0, 0, 0, 0, 0 }, + { 32, 32, 32, 32, 8, 0 }, + { 64, 48, 40, 48, 16, 0 }, + { 96, 56, 48, 56, 24, 0 }, + { 128, 64, 56, 64, 32, 0 }, + { 160, 80, 64, 80, 40, 0 }, + { 192, 96, 80, 96, 48, 0 }, + { 224, 112, 96, 112, 56, 0 }, + { 256, 128, 112, 128, 64, 0 }, + { 288, 160, 128, 144, 80, 0 }, + { 320, 192, 160, 160, 96, 0 }, + { 352, 224, 192, 176, 112, 0 }, + { 384, 256, 224, 192, 128, 0 }, + { 416, 320, 256, 224, 144, 0 }, + { 448, 384, 320, 256, 160, 0 }, + { 0, 0, 0, 0, 0} +}; + +// Maps the sample rate index and version fields from the frame header +// to a sample rate. +// Derived from: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html +static const int kSampleRateMap[4][4] = { + // { V2.5, reserved, V2, V1 } + { 11025, 0, 22050, 44100 }, + { 12000, 0, 24000, 48000 }, + { 8000, 0, 16000, 32000 }, + { 0, 0, 0, 0 } +}; + +// Offset in bytes from the end of the MP3 header to "Xing" or "Info" tags which +// indicate a frame is silent metadata frame. Values taken from FFmpeg. +static const int kXingHeaderMap[2][2] = {{32, 17}, {17, 9}}; + +// Frame header field constants. +static const int kBitrateFree = 0; +static const int kBitrateBad = 0xf; +static const int kSampleRateReserved = 3; +static const int kCodecDelay = 529; + +// static +bool MPEG1AudioStreamParser::ParseHeader( + const LogCB& log_cb, + const uint8* data, + Header* header) { + BitReader reader(data, kHeaderSize); + int sync; + int version; + int layer; + int is_protected; + int bitrate_index; + int sample_rate_index; + int has_padding; + int is_private; + int channel_mode; + int other_flags; + + if (!reader.ReadBits(11, &sync) || + !reader.ReadBits(2, &version) || + !reader.ReadBits(2, &layer) || + !reader.ReadBits(1, &is_protected) || + !reader.ReadBits(4, &bitrate_index) || + !reader.ReadBits(2, &sample_rate_index) || + !reader.ReadBits(1, &has_padding) || + !reader.ReadBits(1, &is_private) || + !reader.ReadBits(2, &channel_mode) || + !reader.ReadBits(6, &other_flags)) { + return false; + } + + DVLOG(2) << "Header data :" << std::hex + << " sync 0x" << sync + << " version 0x" << version + << " layer 0x" << layer + << " bitrate_index 0x" << bitrate_index + << " sample_rate_index 0x" << sample_rate_index + << " channel_mode 0x" << channel_mode; + + if (sync != 0x7ff || + version == kVersionReserved || + layer == kLayerReserved || + bitrate_index == kBitrateFree || bitrate_index == kBitrateBad || + sample_rate_index == kSampleRateReserved) { + MEDIA_LOG(log_cb) << "Invalid header data :" << std::hex + << " sync 0x" << sync + << " version 0x" << version + << " layer 0x" << layer + << " bitrate_index 0x" << bitrate_index + << " sample_rate_index 0x" << sample_rate_index + << " channel_mode 0x" << channel_mode; + return false; + } + + if (layer == kLayer2 && kIsAllowed[bitrate_index][channel_mode]) { + MEDIA_LOG(log_cb) << "Invalid (bitrate_index, channel_mode) combination :" + << std::hex + << " bitrate_index " << bitrate_index + << " channel_mode " << channel_mode; + return false; + } + + int bitrate = kBitrateMap[bitrate_index][kVersionLayerMap[version][layer]]; + + if (bitrate == 0) { + MEDIA_LOG(log_cb) << "Invalid bitrate :" << std::hex + << " version " << version + << " layer " << layer + << " bitrate_index " << bitrate_index; + return false; + } + + DVLOG(2) << " bitrate " << bitrate; + + int frame_sample_rate = kSampleRateMap[sample_rate_index][version]; + if (frame_sample_rate == 0) { + MEDIA_LOG(log_cb) << "Invalid sample rate :" << std::hex + << " version " << version + << " sample_rate_index " << sample_rate_index; + return false; + } + header->sample_rate = frame_sample_rate; + + // http://teslabs.com/openplayer/docs/docs/specs/mp3_structure2.pdf + // Table 2.1.5 + int samples_per_frame; + switch (layer) { + case kLayer1: + samples_per_frame = 384; + break; + + case kLayer2: + samples_per_frame = 1152; + break; + + case kLayer3: + if (version == kVersion2 || version == kVersion2_5) + samples_per_frame = 576; + else + samples_per_frame = 1152; + break; + + default: + return false; + } + header->sample_count = samples_per_frame; + + // http://teslabs.com/openplayer/docs/docs/specs/mp3_structure2.pdf + // Text just below Table 2.1.5. + if (layer == kLayer1) { + // This formulation is a slight variation on the equation below, + // but has slightly different truncation characteristics to deal + // with the fact that Layer 1 has 4 byte "slots" instead of single + // byte ones. + header->frame_size = 4 * (12 * bitrate * 1000 / frame_sample_rate); + } else { + header->frame_size = + ((samples_per_frame / 8) * bitrate * 1000) / frame_sample_rate; + } + + if (has_padding) + header->frame_size += (layer == kLayer1) ? 4 : 1; + + // Map Stereo(0), Joint Stereo(1), and Dual Channel (2) to + // CHANNEL_LAYOUT_STEREO and Single Channel (3) to CHANNEL_LAYOUT_MONO. + header->channel_layout = + (channel_mode == 3) ? CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO; + + header->version = static_cast(version); + header->layer = static_cast(layer); + header->channel_mode = channel_mode; + return true; +} + + +MPEG1AudioStreamParser::MPEG1AudioStreamParser() + : MPEGAudioStreamParserBase(kMPEG1StartCodeMask, kCodecMP3, kCodecDelay) {} + +MPEG1AudioStreamParser::~MPEG1AudioStreamParser() {} + +int MPEG1AudioStreamParser::ParseFrameHeader(const uint8* data, + int size, + int* frame_size, + int* sample_rate, + ChannelLayout* channel_layout, + int* sample_count, + bool* metadata_frame) const { + DCHECK(data); + DCHECK_GE(size, 0); + DCHECK(frame_size); + + if (size < kHeaderSize) + return 0; + + Header header; + if (!ParseHeader(log_cb(), data, &header)) + return -1; + + *frame_size = header.frame_size; + if (sample_rate) + *sample_rate = header.sample_rate; + if (sample_count) + *sample_count = header.sample_count; + if (channel_layout) + *channel_layout = header.channel_layout; + if (metadata_frame) + *metadata_frame = false; + + const int header_bytes_read = kHeaderSize; + if (header.layer != kLayer3) + return header_bytes_read; + + // Check if this is a XING frame and tell the base parser to skip it if so. + const int xing_header_index = + kXingHeaderMap[header.version == kVersion2 || + header.version == kVersion2_5][header.channel_mode == 3]; + uint32_t tag = 0; + + // It's not a XING frame if the frame isn't big enough to be one. + if (*frame_size < + header_bytes_read + xing_header_index + static_cast(sizeof(tag))) { + return header_bytes_read; + } + + // If we don't have enough data available to check, return 0 so frame parsing + // will be retried once more data is available. + BitReader reader(data + header_bytes_read, size - header_bytes_read); + if (!reader.SkipBits(xing_header_index * 8) || + !reader.ReadBits(sizeof(tag) * 8, &tag)) { + return 0; + } + + // Check to see if the tag contains 'Xing' or 'Info' + if (tag == 0x496e666f || tag == 0x58696e67) { + MEDIA_LOG(log_cb()) << "Skipping XING header."; + if (metadata_frame) + *metadata_frame = true; + return header_bytes_read + reader.bits_read() / 8; + } + + // If it wasn't a XING frame, just return the number consumed bytes. + return header_bytes_read; +} + +} // namespace media diff --git a/media/formats/mpeg/mpeg1_audio_stream_parser.h b/media/formats/mpeg/mpeg1_audio_stream_parser.h new file mode 100644 index 0000000..a5f9826 --- /dev/null +++ b/media/formats/mpeg/mpeg1_audio_stream_parser.h @@ -0,0 +1,88 @@ +// 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 MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_ +#define MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_ + +#include "base/basictypes.h" +#include "media/base/media_export.h" +#include "media/formats/mpeg/mpeg_audio_stream_parser_base.h" + +namespace media { + +// MPEG1AudioStreamParser handles MPEG-1 audio streams (ISO/IEC 11172-3) +// as well as the following extensions: +// - MPEG-2 audio (ISO/IEC 13818-3), +// - and MPEG2.5 (not an ISO standard). +class MEDIA_EXPORT MPEG1AudioStreamParser : public MPEGAudioStreamParserBase { + public: + // Size of an MPEG-1 frame header in bytes. + enum { + kHeaderSize = 4, + }; + + // Versions and layers as defined in ISO/IEC 11172-3. + enum Version { + kVersion1 = 3, + kVersion2 = 2, + kVersionReserved = 1, + kVersion2_5 = 0, + }; + + enum Layer { + kLayer1 = 3, + kLayer2 = 2, + kLayer3 = 1, + kLayerReserved = 0, + }; + + struct Header { + Version version; + + // Layer as defined in ISO/IEC 11172-3 bitstream specification. + Layer layer; + + // Frame size in bytes. + int frame_size; + + // Sample frequency. + int sample_rate; + + // Channel mode as defined in ISO/IEC 11172-3 bitstream specification. + int channel_mode; + + // Channel layout. + ChannelLayout channel_layout; + + // Number of samples per frame. + int sample_count; + }; + + // Parses the header starting at |data|. + // Assumption: size of array |data| should be at least |kHeaderSize|. + // Returns false if the header is not valid. + static bool ParseHeader( + const LogCB& log_cb, + const uint8* data, + Header* header); + + MPEG1AudioStreamParser(); + virtual ~MPEG1AudioStreamParser(); + + private: + // MPEGAudioStreamParserBase overrides. + virtual int ParseFrameHeader(const uint8* data, + int size, + int* frame_size, + int* sample_rate, + ChannelLayout* channel_layout, + int* sample_count, + bool* metadata_frame) const OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(MPEG1AudioStreamParser); +}; + +} // namespace media + +#endif // MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_ diff --git a/media/formats/mpeg/mpeg1_audio_stream_parser_unittest.cc b/media/formats/mpeg/mpeg1_audio_stream_parser_unittest.cc new file mode 100644 index 0000000..1c24516 --- /dev/null +++ b/media/formats/mpeg/mpeg1_audio_stream_parser_unittest.cc @@ -0,0 +1,96 @@ +// 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 "media/base/test_data_util.h" +#include "media/formats/common/stream_parser_test_base.h" +#include "media/formats/mpeg/mpeg1_audio_stream_parser.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace media { + +class MPEG1AudioStreamParserTest + : public StreamParserTestBase, public testing::Test { + public: + MPEG1AudioStreamParserTest() + : StreamParserTestBase( + scoped_ptr(new MPEG1AudioStreamParser()).Pass()) {} + virtual ~MPEG1AudioStreamParserTest() {} +}; + +// Test parsing with small prime sized chunks to smoke out "power of +// 2" field size assumptions. +TEST_F(MPEG1AudioStreamParserTest, UnalignedAppend) { + const std::string expected = + "NewSegment" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "EndOfSegment" + "NewSegment" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "EndOfSegment" + "NewSegment" + "{ 0K }" + "{ 0K }" + "EndOfSegment"; + EXPECT_EQ(expected, ParseFile("sfx.mp3", 17)); + EXPECT_GT(last_audio_config().codec_delay(), 0); +} + +// Test parsing with a larger piece size to verify that multiple buffers +// are passed to |new_buffer_cb_|. +TEST_F(MPEG1AudioStreamParserTest, UnalignedAppend512) { + const std::string expected = + "NewSegment" + "{ 0K 26K 52K 78K }" + "EndOfSegment" + "NewSegment" + "{ 0K 26K 52K }" + "{ 0K 26K 52K 78K }" + "{ 0K }" + "EndOfSegment"; + EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); + EXPECT_GT(last_audio_config().codec_delay(), 0); +} + +TEST_F(MPEG1AudioStreamParserTest, MetadataParsing) { + scoped_refptr buffer = ReadTestDataFile("sfx.mp3"); + const uint8_t* buffer_ptr = buffer->data(); + + // The first 32 bytes of sfx.mp3 are an ID3 tag, so no segments should be + // extracted after appending those bytes. + const int kId3TagSize = 32; + EXPECT_EQ("", ParseData(buffer_ptr, kId3TagSize)); + EXPECT_FALSE(last_audio_config().IsValidConfig()); + buffer_ptr += kId3TagSize; + + // The next 417 bytes are a Xing frame; with the identifier 21 bytes into + // the frame. Appending less than 21 bytes, should result in no segments + // nor an AudioDecoderConfig being created. + const int kXingTagPosition = 21; + EXPECT_EQ("", ParseData(buffer_ptr, kXingTagPosition)); + EXPECT_FALSE(last_audio_config().IsValidConfig()); + buffer_ptr += kXingTagPosition; + + // Appending the rests of the Xing frame should result in no segments, but + // should generate a valid AudioDecoderConfig. + const int kXingRemainingSize = 417 - kXingTagPosition; + EXPECT_EQ("", ParseData(buffer_ptr, kXingRemainingSize)); + EXPECT_TRUE(last_audio_config().IsValidConfig()); + buffer_ptr += kXingRemainingSize; + + // Append the first real frame and ensure we get a segment. + const int kFirstRealFrameSize = 182; + EXPECT_EQ("NewSegment{ 0K }EndOfSegment", + ParseData(buffer_ptr, kFirstRealFrameSize)); + EXPECT_TRUE(last_audio_config().IsValidConfig()); +} + +} // namespace media diff --git a/media/media.gyp b/media/media.gyp index 5c5169d..07a5ae9 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -936,6 +936,8 @@ 'formats/mp2t/es_parser_adts.h', 'formats/mp2t/es_parser_h264.cc', 'formats/mp2t/es_parser_h264.h', + 'formats/mp2t/es_parser_mpeg1audio.cc', + 'formats/mp2t/es_parser_mpeg1audio.h', 'formats/mp2t/mp2t_common.h', 'formats/mp2t/mp2t_stream_parser.cc', 'formats/mp2t/mp2t_stream_parser.h', @@ -972,10 +974,10 @@ 'formats/mpeg/adts_constants.h', 'formats/mpeg/adts_stream_parser.cc', 'formats/mpeg/adts_stream_parser.h', - 'formats/mpeg/mp3_stream_parser.cc', - 'formats/mpeg/mp3_stream_parser.h', 'formats/mpeg/mpeg_audio_stream_parser_base.cc', 'formats/mpeg/mpeg_audio_stream_parser_base.h', + 'formats/mpeg/mpeg1_audio_stream_parser.cc', + 'formats/mpeg/mpeg1_audio_stream_parser.h', ], }], ['target_arch=="ia32" or target_arch=="x64"', { @@ -1324,6 +1326,7 @@ 'formats/mp2t/es_adapter_video_unittest.cc', 'formats/mp2t/es_parser_adts_unittest.cc', 'formats/mp2t/es_parser_h264_unittest.cc', + 'formats/mp2t/es_parser_mpeg1audio_unittest.cc', 'formats/mp2t/es_parser_test_base.cc', 'formats/mp2t/es_parser_test_base.h', 'formats/mp2t/mp2t_stream_parser_unittest.cc', @@ -1335,7 +1338,7 @@ 'formats/mp4/sample_to_group_iterator_unittest.cc', 'formats/mp4/track_run_iterator_unittest.cc', 'formats/mpeg/adts_stream_parser_unittest.cc', - 'formats/mpeg/mp3_stream_parser_unittest.cc', + 'formats/mpeg/mpeg1_audio_stream_parser_unittest.cc', ], }], # TODO(wolenetz): Fix size_t to int truncations in win64. See -- cgit v1.1 From 820fa69d7d1247ad8ab07edde18ed927d11c2703 Mon Sep 17 00:00:00 2001 From: chromeos-commit-bot Date: Sat, 13 Sep 2014 00:05:18 -0700 Subject: Automated Commit: Committing new LKGM version 6256.0.0 for chromeos. Cr-Commit-Position: refs/heads/master@{#294738} --- chromeos/CHROMEOS_LKGM | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index ab9942b..5acdd54 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM @@ -1 +1 @@ -6253.0.0 \ No newline at end of file +6256.0.0 \ No newline at end of file -- cgit v1.1 From 711d923e3b9dd778e482f991f280e6dd937d1abf Mon Sep 17 00:00:00 2001 From: "shreeram.k" Date: Sat, 13 Sep 2014 00:15:28 -0700 Subject: Adding DumpAccessibilityTree Tests (8 of 20) HTML Tags: object, ins, mark, i, legend, frameset, caption, body, th Aria role: row, spinbutton Aria state/property: aria-atomic BUG=170580 Review URL: https://codereview.chromium.org/543953003 Cr-Commit-Position: refs/heads/master@{#294739} --- .../dump_accessibility_tree_browsertest.cc | 40 ++++++++++++++++++++++ .../accessibility/aria-atomic-expected-android.txt | 3 ++ .../accessibility/aria-atomic-expected-mac.txt | 5 +++ .../accessibility/aria-atomic-expected-win.txt | 5 +++ content/test/data/accessibility/aria-atomic.html | 12 +++++++ .../accessibility/aria-row-expected-android.txt | 14 ++++++++ .../data/accessibility/aria-row-expected-mac.txt | 20 +++++++++++ .../data/accessibility/aria-row-expected-win.txt | 20 +++++++++++ content/test/data/accessibility/aria-row.html | 19 ++++++++++ .../data/accessibility/body-expected-android.txt | 2 ++ .../test/data/accessibility/body-expected-mac.txt | 3 ++ .../test/data/accessibility/body-expected-win.txt | 3 ++ content/test/data/accessibility/body.html | 6 ++++ .../accessibility/caption-expected-android.txt | 14 ++++++++ .../data/accessibility/caption-expected-mac.txt | 20 +++++++++++ .../data/accessibility/caption-expected-win.txt | 20 +++++++++++ content/test/data/accessibility/caption.html | 22 ++++++++++++ .../accessibility/frameset-expected-android.txt | 1 + .../data/accessibility/frameset-expected-mac.txt | 16 +++++++++ .../data/accessibility/frameset-expected-win.txt | 16 +++++++++ content/test/data/accessibility/frameset.html | 9 +++++ .../test/data/accessibility/i-expected-android.txt | 2 ++ content/test/data/accessibility/i-expected-mac.txt | 5 +++ content/test/data/accessibility/i-expected-win.txt | 5 +++ content/test/data/accessibility/i.html | 8 +++++ .../data/accessibility/ins-expected-android.txt | 3 ++ .../test/data/accessibility/ins-expected-mac.txt | 6 ++++ .../test/data/accessibility/ins-expected-win.txt | 6 ++++ content/test/data/accessibility/ins.html | 8 +++++ .../data/accessibility/legend-expected-android.txt | 8 +++++ .../data/accessibility/legend-expected-mac.txt | 9 +++++ .../data/accessibility/legend-expected-win.txt | 9 +++++ content/test/data/accessibility/legend.html | 17 +++++++++ .../data/accessibility/mark-expected-android.txt | 3 ++ .../test/data/accessibility/mark-expected-mac.txt | 5 +++ .../test/data/accessibility/mark-expected-win.txt | 5 +++ content/test/data/accessibility/mark.html | 8 +++++ .../data/accessibility/object-expected-android.txt | 3 ++ .../data/accessibility/object-expected-mac.txt | 3 ++ .../data/accessibility/object-expected-win.txt | 3 ++ content/test/data/accessibility/object.html | 9 +++++ .../table-simple-expected-android.txt | 14 ++++---- .../accessibility/table-simple-expected-mac.txt | 18 +++++----- content/test/data/accessibility/table-simple.html | 12 ++++--- 44 files changed, 418 insertions(+), 21 deletions(-) create mode 100644 content/test/data/accessibility/aria-atomic-expected-android.txt create mode 100644 content/test/data/accessibility/aria-atomic-expected-mac.txt create mode 100644 content/test/data/accessibility/aria-atomic-expected-win.txt create mode 100644 content/test/data/accessibility/aria-atomic.html create mode 100644 content/test/data/accessibility/aria-row-expected-android.txt create mode 100644 content/test/data/accessibility/aria-row-expected-mac.txt create mode 100644 content/test/data/accessibility/aria-row-expected-win.txt create mode 100644 content/test/data/accessibility/aria-row.html create mode 100644 content/test/data/accessibility/body-expected-android.txt create mode 100644 content/test/data/accessibility/body-expected-mac.txt create mode 100644 content/test/data/accessibility/body-expected-win.txt create mode 100644 content/test/data/accessibility/body.html create mode 100644 content/test/data/accessibility/caption-expected-android.txt create mode 100644 content/test/data/accessibility/caption-expected-mac.txt create mode 100644 content/test/data/accessibility/caption-expected-win.txt create mode 100644 content/test/data/accessibility/caption.html create mode 100644 content/test/data/accessibility/frameset-expected-android.txt create mode 100644 content/test/data/accessibility/frameset-expected-mac.txt create mode 100644 content/test/data/accessibility/frameset-expected-win.txt create mode 100644 content/test/data/accessibility/frameset.html create mode 100644 content/test/data/accessibility/i-expected-android.txt create mode 100644 content/test/data/accessibility/i-expected-mac.txt create mode 100644 content/test/data/accessibility/i-expected-win.txt create mode 100644 content/test/data/accessibility/i.html create mode 100644 content/test/data/accessibility/ins-expected-android.txt create mode 100644 content/test/data/accessibility/ins-expected-mac.txt create mode 100644 content/test/data/accessibility/ins-expected-win.txt create mode 100644 content/test/data/accessibility/ins.html create mode 100644 content/test/data/accessibility/legend-expected-android.txt create mode 100644 content/test/data/accessibility/legend-expected-mac.txt create mode 100644 content/test/data/accessibility/legend-expected-win.txt create mode 100644 content/test/data/accessibility/legend.html create mode 100644 content/test/data/accessibility/mark-expected-android.txt create mode 100644 content/test/data/accessibility/mark-expected-mac.txt create mode 100644 content/test/data/accessibility/mark-expected-win.txt create mode 100644 content/test/data/accessibility/mark.html create mode 100644 content/test/data/accessibility/object-expected-android.txt create mode 100644 content/test/data/accessibility/object-expected-mac.txt create mode 100644 content/test/data/accessibility/object-expected-win.txt create mode 100644 content/test/data/accessibility/object.html diff --git a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc index 9c628a4..f73c624 100644 --- a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc @@ -319,6 +319,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("aria-application.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaAtomic) { + RunTest(FILE_PATH_LITERAL("aria-atomic.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaAutocomplete) { RunTest(FILE_PATH_LITERAL("aria-autocomplete.html")); @@ -395,6 +399,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("aria-progressbar.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaRow) { + RunTest(FILE_PATH_LITERAL("aria-row.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaReadonly) { RunTest(FILE_PATH_LITERAL("aria-readonly.html")); @@ -441,6 +449,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityBdo) { RunTest(FILE_PATH_LITERAL("bdo.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityBody) { + RunTest(FILE_PATH_LITERAL("body.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityBR) { RunTest(FILE_PATH_LITERAL("br.html")); } @@ -453,6 +465,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCanvas) { RunTest(FILE_PATH_LITERAL("canvas.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCaption) { + RunTest(FILE_PATH_LITERAL("caption.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCheckboxNameCalc) { RunTest(FILE_PATH_LITERAL("checkbox-name-calc.html")); @@ -495,6 +511,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityForm) { RunTest(FILE_PATH_LITERAL("form.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityFrameset) { + RunTest(FILE_PATH_LITERAL("frameset.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityHeading) { RunTest(FILE_PATH_LITERAL("heading.html")); } @@ -503,6 +523,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityHR) { RunTest(FILE_PATH_LITERAL("hr.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityI) { + RunTest(FILE_PATH_LITERAL("i.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityIframeCoordinates) { RunTest(FILE_PATH_LITERAL("iframe-coordinates.html")); @@ -542,6 +566,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("input-types.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityIns) { + RunTest(FILE_PATH_LITERAL("ins.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityLabel) { RunTest(FILE_PATH_LITERAL("label.html")); } @@ -550,10 +578,18 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityLandmark) { RunTest(FILE_PATH_LITERAL("landmark.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityLegend) { + RunTest(FILE_PATH_LITERAL("legend.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityListMarkers) { RunTest(FILE_PATH_LITERAL("list-markers.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityMark) { + RunTest(FILE_PATH_LITERAL("mark.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityMenutypecontext) { RunTest(FILE_PATH_LITERAL("menu-type-context.html")); @@ -588,6 +624,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityOl) { RunTest(FILE_PATH_LITERAL("ol.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityObject) { + RunTest(FILE_PATH_LITERAL("object.html")); +} + IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityOptionindatalist) { RunTest(FILE_PATH_LITERAL("option-in-datalist.html")); diff --git a/content/test/data/accessibility/aria-atomic-expected-android.txt b/content/test/data/accessibility/aria-atomic-expected-android.txt new file mode 100644 index 0000000..07e2fed --- /dev/null +++ b/content/test/data/accessibility/aria-atomic-expected-android.txt @@ -0,0 +1,3 @@ +android.webkit.WebView focusable focused scrollable + android.view.View clickable focusable name='This test is for aria-atomic="false"' live_region_type=1 + android.view.View clickable focusable name='This test is for aria-atomic="true"' live_region_type=1 diff --git a/content/test/data/accessibility/aria-atomic-expected-mac.txt b/content/test/data/accessibility/aria-atomic-expected-mac.txt new file mode 100644 index 0000000..b65645f --- /dev/null +++ b/content/test/data/accessibility/aria-atomic-expected-mac.txt @@ -0,0 +1,5 @@ +AXWebArea + AXGroup AXARIAAtomic='0' + AXStaticText AXValue='This test is for aria-atomic="false"' AXARIAAtomic='0' + AXGroup AXARIAAtomic='1' + AXStaticText AXValue='This test is for aria-atomic="true"' AXARIAAtomic='0' diff --git a/content/test/data/accessibility/aria-atomic-expected-win.txt b/content/test/data/accessibility/aria-atomic-expected-win.txt new file mode 100644 index 0000000..818e893 --- /dev/null +++ b/content/test/data/accessibility/aria-atomic-expected-win.txt @@ -0,0 +1,5 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + ROLE_SYSTEM_CLIENT FOCUSABLE atomic:false container-atomic:false + ROLE_SYSTEM_STATICTEXT name='This test is for aria-atomic="false"' container-atomic:false + ROLE_SYSTEM_CLIENT FOCUSABLE atomic:true container-atomic:true + ROLE_SYSTEM_STATICTEXT name='This test is for aria-atomic="true"' container-atomic:true diff --git a/content/test/data/accessibility/aria-atomic.html b/content/test/data/accessibility/aria-atomic.html new file mode 100644 index 0000000..3529969 --- /dev/null +++ b/content/test/data/accessibility/aria-atomic.html @@ -0,0 +1,12 @@ + + + + +

This test is for aria-atomic="false"

+

This test is for aria-atomic="true"

+ + diff --git a/content/test/data/accessibility/aria-row-expected-android.txt b/content/test/data/accessibility/aria-row-expected-android.txt new file mode 100644 index 0000000..2880436 --- /dev/null +++ b/content/test/data/accessibility/aria-row-expected-android.txt @@ -0,0 +1,14 @@ +android.webkit.WebView focusable focused scrollable + android.widget.GridView collection row_count=3 column_count=2 + android.view.View + android.view.View clickable collection_item name='Browser' row_span=1 column_span=1 + android.view.View clickable collection_item name='Rendering Engine' row_span=1 column_index=1 column_span=1 + android.view.View + android.view.View clickable collection_item name='Chrome' row_index=1 row_span=1 column_span=1 + android.view.View clickable collection_item name='Blink' row_index=1 row_span=1 column_index=1 column_span=1 + android.view.View + android.view.View clickable collection_item name='Safari' row_index=2 row_span=1 column_span=1 + android.view.View clickable collection_item name='WebKit' row_index=2 row_span=1 column_index=1 column_span=1 + android.view.View + android.view.View + android.view.View diff --git a/content/test/data/accessibility/aria-row-expected-mac.txt b/content/test/data/accessibility/aria-row-expected-mac.txt new file mode 100644 index 0000000..21e989d --- /dev/null +++ b/content/test/data/accessibility/aria-row-expected-mac.txt @@ -0,0 +1,20 @@ +AXWebArea + AXTable + AXRow + AXCell + AXStaticText AXValue='Browser' + AXCell + AXStaticText AXValue='Rendering Engine' + AXRow + AXCell + AXStaticText AXValue='Chrome' + AXCell + AXStaticText AXValue='Blink' + AXRow + AXCell + AXStaticText AXValue='Safari' + AXCell + AXStaticText AXValue='WebKit' + AXColumn + AXColumn + AXGroup diff --git a/content/test/data/accessibility/aria-row-expected-win.txt b/content/test/data/accessibility/aria-row-expected-win.txt new file mode 100644 index 0000000..c74d2db --- /dev/null +++ b/content/test/data/accessibility/aria-row-expected-win.txt @@ -0,0 +1,20 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + ROLE_SYSTEM_TABLE READONLY + ROLE_SYSTEM_ROW READONLY + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Browser' + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Rendering Engine' + ROLE_SYSTEM_ROW READONLY + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Chrome' + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Blink' + ROLE_SYSTEM_ROW READONLY + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Safari' + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='WebKit' + ROLE_SYSTEM_COLUMN + ROLE_SYSTEM_COLUMN + IA2_ROLE_SECTION diff --git a/content/test/data/accessibility/aria-row.html b/content/test/data/accessibility/aria-row.html new file mode 100644 index 0000000..e19da13 --- /dev/null +++ b/content/test/data/accessibility/aria-row.html @@ -0,0 +1,19 @@ + + + +
+
+ Browser + Rendering Engine +
+
+ Chrome + Blink +
+
+ Safari + WebKit +
+
+ + diff --git a/content/test/data/accessibility/body-expected-android.txt b/content/test/data/accessibility/body-expected-android.txt new file mode 100644 index 0000000..89003eb --- /dev/null +++ b/content/test/data/accessibility/body-expected-android.txt @@ -0,0 +1,2 @@ +android.webkit.WebView focusable focused scrollable + android.view.View clickable name='This test is for body tag' diff --git a/content/test/data/accessibility/body-expected-mac.txt b/content/test/data/accessibility/body-expected-mac.txt new file mode 100644 index 0000000..888b49e --- /dev/null +++ b/content/test/data/accessibility/body-expected-mac.txt @@ -0,0 +1,3 @@ +AXWebArea + AXGroup + AXStaticText AXValue='This test is for body tag' diff --git a/content/test/data/accessibility/body-expected-win.txt b/content/test/data/accessibility/body-expected-win.txt new file mode 100644 index 0000000..8beeb8f --- /dev/null +++ b/content/test/data/accessibility/body-expected-win.txt @@ -0,0 +1,3 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_PARAGRAPH + ROLE_SYSTEM_STATICTEXT name='This test is for body tag' diff --git a/content/test/data/accessibility/body.html b/content/test/data/accessibility/body.html new file mode 100644 index 0000000..ec450a05 --- /dev/null +++ b/content/test/data/accessibility/body.html @@ -0,0 +1,6 @@ + + + +

This test is for body tag

+ + diff --git a/content/test/data/accessibility/caption-expected-android.txt b/content/test/data/accessibility/caption-expected-android.txt new file mode 100644 index 0000000..47c7263 --- /dev/null +++ b/content/test/data/accessibility/caption-expected-android.txt @@ -0,0 +1,14 @@ +android.webkit.WebView focusable focused scrollable + android.widget.GridView collection name='Browser and Engine' row_count=3 column_count=2 + android.view.View + android.view.View clickable collection_item name='Browser' row_span=1 column_span=1 + android.view.View clickable collection_item name='Engine' row_span=1 column_index=1 column_span=1 + android.view.View + android.view.View clickable collection_item name='Chrome' row_index=1 row_span=1 column_span=1 + android.view.View clickable collection_item name='Blink' row_index=1 row_span=1 column_index=1 column_span=1 + android.view.View + android.view.View clickable collection_item name='Safari' row_index=2 row_span=1 column_span=1 + android.view.View clickable collection_item name='WebKit' row_index=2 row_span=1 column_index=1 column_span=1 + android.view.View + android.view.View + android.view.View diff --git a/content/test/data/accessibility/caption-expected-mac.txt b/content/test/data/accessibility/caption-expected-mac.txt new file mode 100644 index 0000000..e8cbaec --- /dev/null +++ b/content/test/data/accessibility/caption-expected-mac.txt @@ -0,0 +1,20 @@ +AXWebArea + AXTable AXTitle='Browser and Engine' + AXRow + AXCell + AXStaticText AXValue='Browser' + AXCell + AXStaticText AXValue='Engine' + AXRow + AXCell + AXStaticText AXValue='Chrome' + AXCell + AXStaticText AXValue='Blink' + AXRow + AXCell + AXStaticText AXValue='Safari' + AXCell + AXStaticText AXValue='WebKit' + AXColumn + AXColumn + AXGroup diff --git a/content/test/data/accessibility/caption-expected-win.txt b/content/test/data/accessibility/caption-expected-win.txt new file mode 100644 index 0000000..196e549 --- /dev/null +++ b/content/test/data/accessibility/caption-expected-win.txt @@ -0,0 +1,20 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + ROLE_SYSTEM_TABLE name='Browser and Engine' READONLY + ROLE_SYSTEM_ROW READONLY + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Browser' + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Engine' + ROLE_SYSTEM_ROW READONLY + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Chrome' + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Blink' + ROLE_SYSTEM_ROW READONLY + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='Safari' + ROLE_SYSTEM_CELL + ROLE_SYSTEM_STATICTEXT name='WebKit' + ROLE_SYSTEM_COLUMN + ROLE_SYSTEM_COLUMN + IA2_ROLE_SECTION diff --git a/content/test/data/accessibility/caption.html b/content/test/data/accessibility/caption.html new file mode 100644 index 0000000..69141eb --- /dev/null +++ b/content/test/data/accessibility/caption.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + +
Browser and Engine
BrowserEngine
ChromeBlink
SafariWebKit
+ + + diff --git a/content/test/data/accessibility/frameset-expected-android.txt b/content/test/data/accessibility/frameset-expected-android.txt new file mode 100644 index 0000000..81e1652 --- /dev/null +++ b/content/test/data/accessibility/frameset-expected-android.txt @@ -0,0 +1 @@ +# diff --git a/content/test/data/accessibility/frameset-expected-mac.txt b/content/test/data/accessibility/frameset-expected-mac.txt new file mode 100644 index 0000000..4740f61 --- /dev/null +++ b/content/test/data/accessibility/frameset-expected-mac.txt @@ -0,0 +1,16 @@ +AXWebArea + AXUnknown + AXUnknown + AXWebArea + AXGroup + AXStaticText AXValue='My favorite browser is' + AXStaticText AXValue='ABC' + AXStaticText AXValue='Chrome' + AXStaticText AXValue='!' + AXUnknown + AXUnknown + AXWebArea + AXGroup + AXStaticText AXValue='This test is to check ' + AXStaticText AXValue='mark tag' + AXStaticText AXValue='.' diff --git a/content/test/data/accessibility/frameset-expected-win.txt b/content/test/data/accessibility/frameset-expected-win.txt new file mode 100644 index 0000000..45de7f8 --- /dev/null +++ b/content/test/data/accessibility/frameset-expected-win.txt @@ -0,0 +1,16 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + ROLE_SYSTEM_CLIENT FOCUSABLE + IA2_ROLE_SCROLL_PANE + ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_PARAGRAPH + ROLE_SYSTEM_STATICTEXT name='My favorite browser is ' + ROLE_SYSTEM_STATICTEXT name='ABC' + ROLE_SYSTEM_STATICTEXT name='Chrome' + ROLE_SYSTEM_STATICTEXT name='!' + ROLE_SYSTEM_CLIENT FOCUSABLE + IA2_ROLE_SCROLL_PANE + ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_PARAGRAPH + ROLE_SYSTEM_STATICTEXT name='This test is to check ' + ROLE_SYSTEM_STATICTEXT name='mark tag' + ROLE_SYSTEM_STATICTEXT name='.' diff --git a/content/test/data/accessibility/frameset.html b/content/test/data/accessibility/frameset.html new file mode 100644 index 0000000..3240bf1 --- /dev/null +++ b/content/test/data/accessibility/frameset.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/content/test/data/accessibility/i-expected-android.txt b/content/test/data/accessibility/i-expected-android.txt new file mode 100644 index 0000000..00578de --- /dev/null +++ b/content/test/data/accessibility/i-expected-android.txt @@ -0,0 +1,2 @@ +android.webkit.WebView focusable focused scrollable + android.view.View clickable name='This is to checkitalic propertyusing i tag.' diff --git a/content/test/data/accessibility/i-expected-mac.txt b/content/test/data/accessibility/i-expected-mac.txt new file mode 100644 index 0000000..f3ae8837 --- /dev/null +++ b/content/test/data/accessibility/i-expected-mac.txt @@ -0,0 +1,5 @@ +AXWebArea + AXGroup + AXStaticText AXValue='This is to check ' + AXStaticText AXValue='italic property' + AXStaticText AXValue=' using i tag.' diff --git a/content/test/data/accessibility/i-expected-win.txt b/content/test/data/accessibility/i-expected-win.txt new file mode 100644 index 0000000..aabbfaa --- /dev/null +++ b/content/test/data/accessibility/i-expected-win.txt @@ -0,0 +1,5 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_PARAGRAPH + ROLE_SYSTEM_STATICTEXT name='This is to check ' + ROLE_SYSTEM_STATICTEXT name='italic property' + ROLE_SYSTEM_STATICTEXT name=' using i tag.' diff --git a/content/test/data/accessibility/i.html b/content/test/data/accessibility/i.html new file mode 100644 index 0000000..192cd73 --- /dev/null +++ b/content/test/data/accessibility/i.html @@ -0,0 +1,8 @@ + + + + +

This is to check italic property using i tag.

+ + + diff --git a/content/test/data/accessibility/ins-expected-android.txt b/content/test/data/accessibility/ins-expected-android.txt new file mode 100644 index 0000000..b1bf07a --- /dev/null +++ b/content/test/data/accessibility/ins-expected-android.txt @@ -0,0 +1,3 @@ +# +android.webkit.WebView focusable focused scrollable + android.view.View clickable name='My favorite browser isABCChrome!' diff --git a/content/test/data/accessibility/ins-expected-mac.txt b/content/test/data/accessibility/ins-expected-mac.txt new file mode 100644 index 0000000..17ce68f --- /dev/null +++ b/content/test/data/accessibility/ins-expected-mac.txt @@ -0,0 +1,6 @@ +AXWebArea + AXGroup + AXStaticText AXValue='My favorite browser is ' + AXStaticText AXValue='ABC' + AXStaticText AXValue='Chrome' + AXStaticText AXValue='!' diff --git a/content/test/data/accessibility/ins-expected-win.txt b/content/test/data/accessibility/ins-expected-win.txt new file mode 100644 index 0000000..4817f9b --- /dev/null +++ b/content/test/data/accessibility/ins-expected-win.txt @@ -0,0 +1,6 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_PARAGRAPH + ROLE_SYSTEM_STATICTEXT name='My favorite browser is ' + ROLE_SYSTEM_STATICTEXT name='ABC' + ROLE_SYSTEM_STATICTEXT name='Chrome' + ROLE_SYSTEM_STATICTEXT name='!' diff --git a/content/test/data/accessibility/ins.html b/content/test/data/accessibility/ins.html new file mode 100644 index 0000000..6f6da3c --- /dev/null +++ b/content/test/data/accessibility/ins.html @@ -0,0 +1,8 @@ + + + + +

My favorite browser is ABC Chrome!

+ + + diff --git a/content/test/data/accessibility/legend-expected-android.txt b/content/test/data/accessibility/legend-expected-android.txt new file mode 100644 index 0000000..89efde9 --- /dev/null +++ b/content/test/data/accessibility/legend-expected-android.txt @@ -0,0 +1,8 @@ +android.webkit.WebView focusable focused scrollable + android.view.View + android.view.View clickable name='Browser Engine's:' + android.view.View + android.view.View clickable name='Browser: ' + android.widget.EditText editable_text focusable input_type=1 + android.view.View clickable name='Rendering Engine: ' + android.widget.EditText editable_text focusable input_type=1 diff --git a/content/test/data/accessibility/legend-expected-mac.txt b/content/test/data/accessibility/legend-expected-mac.txt new file mode 100644 index 0000000..7c170da --- /dev/null +++ b/content/test/data/accessibility/legend-expected-mac.txt @@ -0,0 +1,9 @@ +AXWebArea + AXGroup AXTitleUIElement='AXUnknown' + AXUnknown + AXStaticText AXValue='Browser Engine's:' + AXGroup + AXStaticText AXValue='Browser: ' + AXTextField + AXStaticText AXValue='Rendering Engine: ' + AXTextField diff --git a/content/test/data/accessibility/legend-expected-win.txt b/content/test/data/accessibility/legend-expected-win.txt new file mode 100644 index 0000000..d0a3fc9 --- /dev/null +++ b/content/test/data/accessibility/legend-expected-win.txt @@ -0,0 +1,9 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + ROLE_SYSTEM_GROUPING name='Browser Engine's:' READONLY + ROLE_SYSTEM_CLIENT + ROLE_SYSTEM_STATICTEXT name='Browser Engine's:' + IA2_ROLE_SECTION READONLY + ROLE_SYSTEM_STATICTEXT name='Browser: ' + ROLE_SYSTEM_TEXT FOCUSABLE + ROLE_SYSTEM_STATICTEXT name='Rendering Engine: ' + ROLE_SYSTEM_TEXT FOCUSABLE diff --git a/content/test/data/accessibility/legend.html b/content/test/data/accessibility/legend.html new file mode 100644 index 0000000..8118b2f --- /dev/null +++ b/content/test/data/accessibility/legend.html @@ -0,0 +1,17 @@ + + + + + +
+
+ Browser Engine's: + Browser:
+ Rendering Engine:
+
+
+ + + diff --git a/content/test/data/accessibility/mark-expected-android.txt b/content/test/data/accessibility/mark-expected-android.txt new file mode 100644 index 0000000..c81d844 --- /dev/null +++ b/content/test/data/accessibility/mark-expected-android.txt @@ -0,0 +1,3 @@ +# +android.webkit.WebView focusable focused scrollable + android.view.View clickable name='This test is to checkmark tag.' diff --git a/content/test/data/accessibility/mark-expected-mac.txt b/content/test/data/accessibility/mark-expected-mac.txt new file mode 100644 index 0000000..b6158ac --- /dev/null +++ b/content/test/data/accessibility/mark-expected-mac.txt @@ -0,0 +1,5 @@ +AXWebArea + AXGroup + AXStaticText AXValue='This test is to check ' + AXStaticText AXValue='mark tag' + AXStaticText AXValue='.' diff --git a/content/test/data/accessibility/mark-expected-win.txt b/content/test/data/accessibility/mark-expected-win.txt new file mode 100644 index 0000000..69f8308d --- /dev/null +++ b/content/test/data/accessibility/mark-expected-win.txt @@ -0,0 +1,5 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_PARAGRAPH + ROLE_SYSTEM_STATICTEXT name='This test is to check ' + ROLE_SYSTEM_STATICTEXT name='mark tag' + ROLE_SYSTEM_STATICTEXT name='.' diff --git a/content/test/data/accessibility/mark.html b/content/test/data/accessibility/mark.html new file mode 100644 index 0000000..5afffec --- /dev/null +++ b/content/test/data/accessibility/mark.html @@ -0,0 +1,8 @@ + + + + +

This test is to check mark tag.

+ + + diff --git a/content/test/data/accessibility/object-expected-android.txt b/content/test/data/accessibility/object-expected-android.txt new file mode 100644 index 0000000..947af64 --- /dev/null +++ b/content/test/data/accessibility/object-expected-android.txt @@ -0,0 +1,3 @@ +android.webkit.WebView focusable focused scrollable + android.view.View + android.view.View focusable diff --git a/content/test/data/accessibility/object-expected-mac.txt b/content/test/data/accessibility/object-expected-mac.txt new file mode 100644 index 0000000..9ef0230 --- /dev/null +++ b/content/test/data/accessibility/object-expected-mac.txt @@ -0,0 +1,3 @@ +AXWebArea + AXGroup + AXUnknown diff --git a/content/test/data/accessibility/object-expected-win.txt b/content/test/data/accessibility/object-expected-win.txt new file mode 100644 index 0000000..342c9c5 --- /dev/null +++ b/content/test/data/accessibility/object-expected-win.txt @@ -0,0 +1,3 @@ +ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE + IA2_ROLE_SECTION READONLY + ROLE_SYSTEM_CLIENT FOCUSABLE diff --git a/content/test/data/accessibility/object.html b/content/test/data/accessibility/object.html new file mode 100644 index 0000000..00dd004 --- /dev/null +++ b/content/test/data/accessibility/object.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/content/test/data/accessibility/table-simple-expected-android.txt b/content/test/data/accessibility/table-simple-expected-android.txt index 831377b..139b3a0 100644 --- a/content/test/data/accessibility/table-simple-expected-android.txt +++ b/content/test/data/accessibility/table-simple-expected-android.txt @@ -1,14 +1,14 @@ android.webkit.WebView focusable focused scrollable name='Table example' - android.widget.GridView collection row_count=2 column_count=3 + android.widget.GridView collection row_count=3 column_count=2 android.view.View - android.view.View clickable collection_item name='A' row_span=1 column_span=1 - android.view.View clickable collection_item name='B' row_span=1 column_index=1 column_span=1 - android.view.View clickable collection_item name='C' row_span=1 column_index=2 column_span=1 + android.view.View clickable collection_item name='Pair' row_span=1 column_span=1 + android.view.View clickable collection_item name='Single' row_span=1 column_index=1 column_span=1 android.view.View - android.view.View clickable collection_item name='D' row_index=1 row_span=1 column_span=1 - android.view.View clickable collection_item name='E' row_index=1 row_span=1 column_index=1 column_span=1 - android.view.View clickable collection_item name='F' row_index=1 row_span=1 column_index=2 column_span=1 + android.view.View clickable collection_item name='AB' row_index=1 row_span=1 column_span=1 + android.view.View clickable collection_item name='B' row_index=1 row_span=1 column_index=1 column_span=1 android.view.View + android.view.View clickable collection_item name='CD' row_index=2 row_span=1 column_span=1 + android.view.View clickable collection_item name='D' row_index=2 row_span=1 column_index=1 column_span=1 android.view.View android.view.View android.view.View diff --git a/content/test/data/accessibility/table-simple-expected-mac.txt b/content/test/data/accessibility/table-simple-expected-mac.txt index 798e4c7..214a4c0 100644 --- a/content/test/data/accessibility/table-simple-expected-mac.txt +++ b/content/test/data/accessibility/table-simple-expected-mac.txt @@ -2,19 +2,19 @@ AXWebArea AXTitle='Table example' AXTable AXRow AXIndex='0' AXCell AXColumnIndexRange={"len":1,"loc":0} AXRowIndexRange={"len":1,"loc":0} - AXStaticText AXValue='A' + AXStaticText AXValue='Pair' AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":0} - AXStaticText AXValue='B' - AXCell AXColumnIndexRange={"len":1,"loc":2} AXRowIndexRange={"len":1,"loc":0} - AXStaticText AXValue='C' + AXStaticText AXValue='Single' AXRow AXIndex='1' AXCell AXColumnIndexRange={"len":1,"loc":0} AXRowIndexRange={"len":1,"loc":1} - AXStaticText AXValue='D' + AXStaticText AXValue='AB' AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":1} - AXStaticText AXValue='E' - AXCell AXColumnIndexRange={"len":1,"loc":2} AXRowIndexRange={"len":1,"loc":1} - AXStaticText AXValue='F' + AXStaticText AXValue='B' + AXRow AXIndex='2' + AXCell AXColumnIndexRange={"len":1,"loc":0} AXRowIndexRange={"len":1,"loc":2} + AXStaticText AXValue='CD' + AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":2} + AXStaticText AXValue='D' AXColumn AXIndex='0' AXColumn AXIndex='1' - AXColumn AXIndex='2' AXGroup diff --git a/content/test/data/accessibility/table-simple.html b/content/test/data/accessibility/table-simple.html index 9bfbbf8..72e2b4d 100644 --- a/content/test/data/accessibility/table-simple.html +++ b/content/test/data/accessibility/table-simple.html @@ -12,14 +12,16 @@ - - - + + + + + + + - -
ABCPairSingle
ABB
CD DEF
-- cgit v1.1 From 2ff9399027f8473add7f420c1d7fe68c73692694 Mon Sep 17 00:00:00 2001 From: joaodasilva Date: Sat, 13 Sep 2014 00:22:25 -0700 Subject: Updated the documentation of the SafeSearch policy. Since Chrome 38, this policy is also forcing Safety Mode for YouTube. BUG=344815 Review URL: https://codereview.chromium.org/559033002 Cr-Commit-Position: refs/heads/master@{#294740} --- components/policy/resources/policy_templates.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 84333b4..2be2406 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json @@ -796,11 +796,11 @@ 'example_value': False, 'id': 162, 'caption': '''Force SafeSearch''', - 'desc': '''Forces queries in Google Web Search to be done with SafeSearch set to active and prevents users from changing this setting. + 'desc': '''Forces queries in Google Web Search to be done with SafeSearch set to active and prevents users from changing this setting. This setting also forces Safety Mode on YouTube. - If you enable this setting, SafeSearch in Google Search is always active. + If you enable this setting, SafeSearch in Google Search and YouTube is always active. - If you disable this setting or do not set a value, SafeSearch in Google Search is not enforced.''', + If you disable this setting or do not set a value, SafeSearch in Google Search and YouTube is not enforced.''', }, { 'name': 'SafeBrowsingEnabled', -- cgit v1.1 From 7ce4adfebbda4208511fea7d58eb3e96e296337f Mon Sep 17 00:00:00 2001 From: "kulkarni.a" Date: Sat, 13 Sep 2014 01:49:34 -0700 Subject: Maintaing the proper order of initialization WeakPtrFactory Changing in the intialization order of WeakPtrFactory in "src/base" module such that all member variables should appear before the WeakPtrFactory to ensure that any WeakPtrs to Controller are invalidated before its members variable's destructors are executed, rendering them invalid. BUG=303818 Review URL: https://codereview.chromium.org/565123002 Cr-Commit-Position: refs/heads/master@{#294741} --- base/cancelable_callback.h | 5 ++--- base/task/cancelable_task_tracker.cc | 2 +- base/task/cancelable_task_tracker.h | 3 ++- base/win/object_watcher.cc | 6 +++--- base/win/object_watcher.h | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/base/cancelable_callback.h b/base/cancelable_callback.h index 1f534c3..159100f 100644 --- a/base/cancelable_callback.h +++ b/base/cancelable_callback.h @@ -253,15 +253,14 @@ class CancelableCallback { weak_factory_.GetWeakPtr()); } - // Used to ensure Forward() is not run when this object is destroyed. - base::WeakPtrFactory > weak_factory_; - // The wrapper closure. base::Callback forwarder_; // The stored closure that may be cancelled. base::Callback callback_; + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory > weak_factory_; DISALLOW_COPY_AND_ASSIGN(CancelableCallback); }; diff --git a/base/task/cancelable_task_tracker.cc b/base/task/cancelable_task_tracker.cc index 801223e..b6e4b6a 100644 --- a/base/task/cancelable_task_tracker.cc +++ b/base/task/cancelable_task_tracker.cc @@ -60,7 +60,7 @@ namespace base { const CancelableTaskTracker::TaskId CancelableTaskTracker::kBadTaskId = 0; CancelableTaskTracker::CancelableTaskTracker() - : weak_factory_(this), next_id_(1) {} + : next_id_(1),weak_factory_(this) {} CancelableTaskTracker::~CancelableTaskTracker() { DCHECK(thread_checker_.CalledOnValidThread()); diff --git a/base/task/cancelable_task_tracker.h b/base/task/cancelable_task_tracker.h index 3d849bf..b8a8b70 100644 --- a/base/task/cancelable_task_tracker.h +++ b/base/task/cancelable_task_tracker.h @@ -126,11 +126,12 @@ class BASE_EXPORT CancelableTaskTracker { void Untrack(TaskId id); base::hash_map task_flags_; - base::WeakPtrFactory weak_factory_; TaskId next_id_; base::ThreadChecker thread_checker_; + base::WeakPtrFactory weak_factory_; + DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); }; diff --git a/base/win/object_watcher.cc b/base/win/object_watcher.cc index 3bb1cd3..fe209f5 100644 --- a/base/win/object_watcher.cc +++ b/base/win/object_watcher.cc @@ -13,10 +13,10 @@ namespace win { //----------------------------------------------------------------------------- ObjectWatcher::ObjectWatcher() - : weak_factory_(this), - object_(NULL), + : object_(NULL), wait_object_(NULL), - origin_loop_(NULL) { + origin_loop_(NULL), + weak_factory_(this) { } ObjectWatcher::~ObjectWatcher() { diff --git a/base/win/object_watcher.h b/base/win/object_watcher.h index 4222c20..bf7f8b3 100644 --- a/base/win/object_watcher.h +++ b/base/win/object_watcher.h @@ -88,12 +88,13 @@ class BASE_EXPORT ObjectWatcher : public MessageLoop::DestructionObserver { virtual void WillDestroyCurrentMessageLoop(); // Internal state. - WeakPtrFactory weak_factory_; Closure callback_; HANDLE object_; // The object being watched HANDLE wait_object_; // Returned by RegisterWaitForSingleObject MessageLoop* origin_loop_; // Used to get back to the origin thread + WeakPtrFactory weak_factory_; + DISALLOW_COPY_AND_ASSIGN(ObjectWatcher); }; -- cgit v1.1 From 6a4d455b865020708af55792a4dd94b96dc049e4 Mon Sep 17 00:00:00 2001 From: torne Date: Sat, 13 Sep 2014 02:53:01 -0700 Subject: Roll src/tools/gyp from 94b57d39a88c to 46282cedf40f Picks up android.mk generator changes and emacs mode update. Summary of changes available at: https://chromium.googlesource.com/external/gyp/+log/94b57d39a88c..46282cedf40f BUG= Review URL: https://codereview.chromium.org/568833002 Cr-Commit-Position: refs/heads/master@{#294742} --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 305bfce..6e38b3b 100644 --- a/DEPS +++ b/DEPS @@ -152,7 +152,7 @@ deps = { Var('chromium_git') + '/external/grit-i18n.git' + '@' + '740badd5e3e44434a9a47b5d16749daac1e8ea80', # from svn revision 176 'src/tools/gyp': - Var('chromium_git') + '/external/gyp.git' + '@' + '94b57d39a88ceb03e228804eec4b9013c5ea8b4c', # from svn revision 1974 + Var('chromium_git') + '/external/gyp.git' + '@' + '46282cedf40ff7fe803be4af357b9d59050f02e4', # from svn revision 1977 'src/tools/swarming_client': Var('chromium_git') + '/external/swarming.client.git' + '@' + Var('swarming_revision'), -- cgit v1.1 From bb1951228bfc4c44e649f00d9a42c3d142a7227f Mon Sep 17 00:00:00 2001 From: "anujk.sharma" Date: Sat, 13 Sep 2014 05:43:14 -0700 Subject: Fix WeakPtrFactory member placement. Changing in the intialization order of WeakPtrFactory in src/extensions module such that all member variables should appear before the WeakPtrFactory to ensure that any WeakPtrs to Controller are invalidated before its members variable's destructors are executed, rendering them invalid. BUG=303818 Review URL: https://codereview.chromium.org/573513002 Cr-Commit-Position: refs/heads/master@{#294743} --- extensions/browser/guest_view/web_view/web_view_find_helper.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/browser/guest_view/web_view/web_view_find_helper.h b/extensions/browser/guest_view/web_view/web_view_find_helper.h index 425b440..db1c39d 100644 --- a/extensions/browser/guest_view/web_view/web_view_find_helper.h +++ b/extensions/browser/guest_view/web_view/web_view_find_helper.h @@ -155,12 +155,12 @@ class WebViewFindHelper { // request of a find session. std::vector > find_next_requests_; - // Weak pointer used to access the find info of fin. - base::WeakPtrFactory weak_ptr_factory_; - friend void WebViewFindHelper::EndFindSession(int session_request_id, bool canceled); +// Weak pointer used to access the find info of fin. + base::WeakPtrFactory weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(FindInfo); }; -- cgit v1.1 From b16c57177635dcc6d88f6eae2eee41af1acf5f58 Mon Sep 17 00:00:00 2001 From: mlamouri Date: Sat, 13 Sep 2014 05:46:59 -0700 Subject: Implement ManifestFetcher, helper to fetch Web Manifests. This is implemented on top of ResourceFetcher. BUG=410414 Review URL: https://codereview.chromium.org/532773002 Cr-Commit-Position: refs/heads/master@{#294744} --- chrome/renderer/net/net_error_helper.cc | 2 + content/content_renderer.gypi | 6 +- content/public/renderer/resource_fetcher.h | 9 +++ .../renderer/fetchers/image_resource_fetcher.cc | 1 + content/renderer/fetchers/manifest_fetcher.cc | 49 ++++++++++++ content/renderer/fetchers/manifest_fetcher.h | 56 ++++++++++++++ .../multi_resolution_image_resource_fetcher.cc | 1 + content/renderer/fetchers/resource_fetcher_impl.cc | 87 +++++----------------- content/renderer/fetchers/resource_fetcher_impl.h | 43 ++--------- .../fetchers/web_url_loader_client_impl.cc | 75 +++++++++++++++++++ .../renderer/fetchers/web_url_loader_client_impl.h | 82 ++++++++++++++++++++ content/renderer/resource_fetcher_browsertest.cc | 7 ++ content/renderer/web_ui_mojo_context_state.cc | 1 + 13 files changed, 314 insertions(+), 105 deletions(-) create mode 100644 content/renderer/fetchers/manifest_fetcher.cc create mode 100644 content/renderer/fetchers/manifest_fetcher.h create mode 100644 content/renderer/fetchers/web_url_loader_client_impl.cc create mode 100644 content/renderer/fetchers/web_url_loader_client_impl.h diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc index 0e75c06..3a85b2d 100644 --- a/chrome/renderer/net/net_error_helper.cc +++ b/chrome/renderer/net/net_error_helper.cc @@ -264,6 +264,7 @@ void NetErrorHelper::FetchNavigationCorrections( frame, blink::WebURLRequest::RequestContextInternal, blink::WebURLRequest::FrameTypeTopLevel, + content::ResourceFetcher::PLATFORM_LOADER, base::Bind(&NetErrorHelper::OnNavigationCorrectionsFetched, base::Unretained(this))); @@ -293,6 +294,7 @@ void NetErrorHelper::SendTrackingRequest( frame, blink::WebURLRequest::RequestContextInternal, blink::WebURLRequest::FrameTypeTopLevel, + content::ResourceFetcher::PLATFORM_LOADER, base::Bind(&NetErrorHelper::OnTrackingRequestComplete, base::Unretained(this))); } diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 3a99724..1a2e7bb 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -153,10 +153,14 @@ 'renderer/drop_data_builder.h', 'renderer/fetchers/image_resource_fetcher.cc', 'renderer/fetchers/image_resource_fetcher.h', + 'renderer/fetchers/manifest_fetcher.cc', + 'renderer/fetchers/manifest_fetcher.h', 'renderer/fetchers/multi_resolution_image_resource_fetcher.cc', 'renderer/fetchers/multi_resolution_image_resource_fetcher.h', 'renderer/fetchers/resource_fetcher_impl.cc', 'renderer/fetchers/resource_fetcher_impl.h', + 'renderer/fetchers/web_url_loader_client_impl.cc', + 'renderer/fetchers/web_url_loader_client_impl.h', 'renderer/gamepad_shared_memory_reader.cc', 'renderer/gamepad_shared_memory_reader.h', 'renderer/geolocation_dispatcher.cc', @@ -573,7 +577,7 @@ 'renderer/media/media_stream_audio_sink_owner.h', 'renderer/media/media_stream_audio_track_sink.h', 'renderer/media/media_stream_center.cc', - 'renderer/media/media_stream_dispatcher.cc', + 'renderer/media/media_stream_dispatcher.cc', 'renderer/media/media_stream_registry_interface.h', 'renderer/media/media_stream_audio_source.cc', 'renderer/media/media_stream_audio_source.h', diff --git a/content/public/renderer/resource_fetcher.h b/content/public/renderer/resource_fetcher.h index 4cb5689..5c010f9 100644 --- a/content/public/renderer/resource_fetcher.h +++ b/content/public/renderer/resource_fetcher.h @@ -27,6 +27,11 @@ namespace content { // Interface to download resources asynchronously. class CONTENT_EXPORT ResourceFetcher { public: + enum LoaderType { + PLATFORM_LOADER, // uses Platform::createURLLoader + FRAME_ASSOCIATED_LOADER, // uses WebFrame::createAssociatedURLLoader + }; + virtual ~ResourceFetcher() {} // This will be called asynchronously after the URL has been fetched, @@ -53,11 +58,15 @@ class CONTENT_EXPORT ResourceFetcher { virtual void Start(blink::WebFrame* frame, blink::WebURLRequest::RequestContext request_context, blink::WebURLRequest::FrameType frame_type, + LoaderType loader_type, const Callback& callback) = 0; // Sets how long to wait for the server to reply. By default, there is no // timeout. Must be called after a request is started. virtual void SetTimeout(const base::TimeDelta& timeout) = 0; + + // Manually cancel the request. + virtual void Cancel() = 0; }; } // namespace content diff --git a/content/renderer/fetchers/image_resource_fetcher.cc b/content/renderer/fetchers/image_resource_fetcher.cc index e7d7c8d..ec0798b 100644 --- a/content/renderer/fetchers/image_resource_fetcher.cc +++ b/content/renderer/fetchers/image_resource_fetcher.cc @@ -35,6 +35,7 @@ ImageResourceFetcher::ImageResourceFetcher( fetcher_->Start(frame, request_context, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, base::Bind(&ImageResourceFetcher::OnURLFetchComplete, base::Unretained(this))); diff --git a/content/renderer/fetchers/manifest_fetcher.cc b/content/renderer/fetchers/manifest_fetcher.cc new file mode 100644 index 0000000..c6a64c8 --- /dev/null +++ b/content/renderer/fetchers/manifest_fetcher.cc @@ -0,0 +1,49 @@ +// 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 "content/renderer/fetchers/manifest_fetcher.h" + +#include "base/bind.h" +#include "base/logging.h" +#include "content/public/renderer/resource_fetcher.h" +#include "third_party/WebKit/public/platform/WebURLRequest.h" +#include "third_party/WebKit/public/web/WebFrame.h" + +namespace content { + +ManifestFetcher::ManifestFetcher(const GURL& url) + : completed_(false) { + fetcher_.reset(ResourceFetcher::Create(url)); +} + +ManifestFetcher::~ManifestFetcher() { + if (!completed_) + Cancel(); +} + +void ManifestFetcher::Start(blink::WebFrame* frame, const Callback& callback) { + callback_ = callback; + fetcher_->Start(frame, + blink::WebURLRequest::RequestContextManifest, + blink::WebURLRequest::FrameTypeNone, + ResourceFetcher::FRAME_ASSOCIATED_LOADER, + base::Bind(&ManifestFetcher::OnLoadComplete, + base::Unretained(this))); +} + +void ManifestFetcher::Cancel() { + DCHECK(!completed_); + fetcher_->Cancel(); +} + +void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response, + const std::string& data) { + DCHECK(!completed_); + completed_ = true; + + Callback callback = callback_; + callback.Run(response, data); +} + +} // namespace content diff --git a/content/renderer/fetchers/manifest_fetcher.h b/content/renderer/fetchers/manifest_fetcher.h new file mode 100644 index 0000000..a3afaa3 --- /dev/null +++ b/content/renderer/fetchers/manifest_fetcher.h @@ -0,0 +1,56 @@ +// 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 CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_ +#define CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_ + +#include + +#include "base/basictypes.h" +#include "base/callback.h" +#include "base/memory/scoped_ptr.h" +#include "third_party/WebKit/public/platform/WebURLResponse.h" + +class GURL; + +namespace blink { +class WebFrame; +} + +namespace content { + +class ResourceFetcher; + +// Helper class to download a Web Manifest. When an instance is created, the +// caller need to call Start() and wait for the passed callback to be executed. +// If the fetch fails, the callback will be called with two empty objects. +class ManifestFetcher { + public: + // This will be called asynchronously after the URL has been fetched, + // successfully or not. If there is a failure, response and data will both be + // empty. |response| and |data| are both valid until the URLFetcher instance + // is destroyed. + typedef base::Callback Callback; + + explicit ManifestFetcher(const GURL& url); + virtual ~ManifestFetcher(); + + void Start(blink::WebFrame* frame, const Callback& callback); + void Cancel(); + + private: + void OnLoadComplete(const blink::WebURLResponse& response, + const std::string& data); + + bool completed_; + Callback callback_; + scoped_ptr fetcher_; + + DISALLOW_COPY_AND_ASSIGN(ManifestFetcher); +}; + +} // namespace content + +#endif // CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_ diff --git a/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc b/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc index 4a2ad63..d310f42 100644 --- a/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc +++ b/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc @@ -34,6 +34,7 @@ MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher( frame, request_context, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete, base::Unretained(this))); } diff --git a/content/renderer/fetchers/resource_fetcher_impl.cc b/content/renderer/fetchers/resource_fetcher_impl.cc index 7b25d12..c175abc 100644 --- a/content/renderer/fetchers/resource_fetcher_impl.cc +++ b/content/renderer/fetchers/resource_fetcher_impl.cc @@ -35,12 +35,11 @@ ResourceFetcher* ResourceFetcher::Create(const GURL& url) { } ResourceFetcherImpl::ResourceFetcherImpl(const GURL& url) - : request_(url), - completed_(false) { + : request_(url) { } ResourceFetcherImpl::~ResourceFetcherImpl() { - if (!completed_ && loader_) + if (!completed() && loader_) loader_->cancel(); } @@ -81,11 +80,12 @@ void ResourceFetcherImpl::SetHeader(const std::string& header, void ResourceFetcherImpl::Start(WebFrame* frame, WebURLRequest::RequestContext request_context, WebURLRequest::FrameType frame_type, + LoaderType loader_type, const Callback& callback) { DCHECK(!loader_); DCHECK(!request_.isNull()); DCHECK(callback_.is_null()); - DCHECK(!completed_); + DCHECK(!completed()); if (!request_.httpBody().isNull()) DCHECK_NE("GET", request_.httpMethod().utf8()) << "GETs can't have bodies."; @@ -95,7 +95,15 @@ void ResourceFetcherImpl::Start(WebFrame* frame, request_.setFrameType(frame_type); request_.setFirstPartyForCookies(frame->document().firstPartyForCookies()); frame->dispatchWillSendRequest(request_); - loader_.reset(blink::Platform::current()->createURLLoader()); + + switch (loader_type) { + case PLATFORM_LOADER: + loader_.reset(blink::Platform::current()->createURLLoader()); + break; + case FRAME_ASSOCIATED_LOADER: + loader_.reset(frame->createAssociatedURLLoader()); + break; + } loader_->loadAsynchronously(request_, this); // No need to hold on to the request. @@ -104,15 +112,12 @@ void ResourceFetcherImpl::Start(WebFrame* frame, void ResourceFetcherImpl::SetTimeout(const base::TimeDelta& timeout) { DCHECK(loader_); - DCHECK(!completed_); + DCHECK(!completed()); - timeout_timer_.Start(FROM_HERE, timeout, this, - &ResourceFetcherImpl::TimeoutFired); + timeout_timer_.Start(FROM_HERE, timeout, this, &ResourceFetcherImpl::Cancel); } -void ResourceFetcherImpl::RunCallback(const WebURLResponse& response, - const std::string& data) { - completed_ = true; +void ResourceFetcherImpl::OnLoadComplete() { timeout_timer_.Stop(); if (callback_.is_null()) return; @@ -120,65 +125,13 @@ void ResourceFetcherImpl::RunCallback(const WebURLResponse& response, // Take a reference to the callback as running the callback may lead to our // destruction. Callback callback = callback_; - callback.Run(response, data); + callback.Run(status() == LOAD_FAILED ? blink::WebURLResponse() : response(), + status() == LOAD_FAILED ? std::string() : data()); } -void ResourceFetcherImpl::TimeoutFired() { - DCHECK(!completed_); +void ResourceFetcherImpl::Cancel() { loader_->cancel(); - RunCallback(WebURLResponse(), std::string()); -} - -///////////////////////////////////////////////////////////////////////////// -// WebURLLoaderClient methods - -void ResourceFetcherImpl::willSendRequest( - WebURLLoader* loader, WebURLRequest& new_request, - const WebURLResponse& redirect_response) { -} - -void ResourceFetcherImpl::didSendData( - WebURLLoader* loader, unsigned long long bytes_sent, - unsigned long long total_bytes_to_be_sent) { -} - -void ResourceFetcherImpl::didReceiveResponse( - WebURLLoader* loader, const WebURLResponse& response) { - DCHECK(!completed_); - response_ = response; -} - -void ResourceFetcherImpl::didReceiveData( - WebURLLoader* loader, const char* data, int data_length, - int encoded_data_length) { - DCHECK(!completed_); - DCHECK(data_length > 0); - - data_.append(data, data_length); -} - -void ResourceFetcherImpl::didReceiveCachedMetadata( - WebURLLoader* loader, const char* data, int data_length) { - DCHECK(!completed_); - DCHECK(data_length > 0); - - metadata_.assign(data, data_length); -} - -void ResourceFetcherImpl::didFinishLoading( - WebURLLoader* loader, double finishTime, - int64_t total_encoded_data_length) { - DCHECK(!completed_); - - RunCallback(response_, data_); -} - -void ResourceFetcherImpl::didFail(WebURLLoader* loader, - const WebURLError& error) { - DCHECK(!completed_); - - // Go ahead and tell our delegate that we're done. - RunCallback(WebURLResponse(), std::string()); + WebURLLoaderClientImpl::Cancel(); } } // namespace content diff --git a/content/renderer/fetchers/resource_fetcher_impl.h b/content/renderer/fetchers/resource_fetcher_impl.h index 74c9919..5631ed9 100644 --- a/content/renderer/fetchers/resource_fetcher_impl.h +++ b/content/renderer/fetchers/resource_fetcher_impl.h @@ -13,7 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "base/timer/timer.h" #include "content/public/renderer/resource_fetcher.h" -#include "third_party/WebKit/public/platform/WebURLLoaderClient.h" +#include "content/renderer/fetchers/web_url_loader_client_impl.h" #include "third_party/WebKit/public/platform/WebURLRequest.h" #include "third_party/WebKit/public/platform/WebURLResponse.h" @@ -28,7 +28,7 @@ struct WebURLError; namespace content { class ResourceFetcherImpl : public ResourceFetcher, - public blink::WebURLLoaderClient { + public WebURLLoaderClientImpl { public: // ResourceFetcher implementation: virtual void SetMethod(const std::string& method) OVERRIDE; @@ -38,6 +38,7 @@ class ResourceFetcherImpl : public ResourceFetcher, virtual void Start(blink::WebFrame* frame, blink::WebURLRequest::RequestContext request_context, blink::WebURLRequest::FrameType frame_type, + LoaderType loader_type, const Callback& callback) OVERRIDE; virtual void SetTimeout(const base::TimeDelta& timeout) OVERRIDE; @@ -48,54 +49,22 @@ class ResourceFetcherImpl : public ResourceFetcher, virtual ~ResourceFetcherImpl(); - void RunCallback(const blink::WebURLResponse& response, - const std::string& data); - // Callback for timer that limits how long we wait for the server. If this // timer fires and the request hasn't completed, we kill the request. void TimeoutFired(); - // WebURLLoaderClient methods: - virtual void willSendRequest( - blink::WebURLLoader* loader, blink::WebURLRequest& new_request, - const blink::WebURLResponse& redirect_response); - virtual void didSendData( - blink::WebURLLoader* loader, unsigned long long bytes_sent, - unsigned long long total_bytes_to_be_sent); - virtual void didReceiveResponse( - blink::WebURLLoader* loader, const blink::WebURLResponse& response); - virtual void didReceiveCachedMetadata( - blink::WebURLLoader* loader, const char* data, int data_length); - - virtual void didReceiveData( - blink::WebURLLoader* loader, const char* data, int data_length, - int encoded_data_length); - virtual void didFinishLoading( - blink::WebURLLoader* loader, double finishTime, - int64_t total_encoded_data_length); - virtual void didFail( - blink::WebURLLoader* loader, const blink::WebURLError& error); + // WebURLLoaderClientImpl methods: + virtual void OnLoadComplete() OVERRIDE; + virtual void Cancel() OVERRIDE; scoped_ptr loader_; // Request to send. Released once Start() is called. blink::WebURLRequest request_; - // Set to true once the request is complete. - bool completed_; - - // Buffer to hold the content from the server. - std::string data_; - - // A copy of the original resource response. - blink::WebURLResponse response_; - // Callback when we're done. Callback callback_; - // Buffer to hold metadata from the cache. - std::string metadata_; - // Limit how long to wait for the server. base::OneShotTimer timeout_timer_; diff --git a/content/renderer/fetchers/web_url_loader_client_impl.cc b/content/renderer/fetchers/web_url_loader_client_impl.cc new file mode 100644 index 0000000..847a167 --- /dev/null +++ b/content/renderer/fetchers/web_url_loader_client_impl.cc @@ -0,0 +1,75 @@ +// 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 "content/renderer/fetchers/web_url_loader_client_impl.h" + +#include "base/logging.h" +#include "third_party/WebKit/public/platform/WebURLError.h" +#include "third_party/WebKit/public/platform/WebURLLoader.h" +#include "third_party/WebKit/public/platform/WebURLResponse.h" + +namespace content { + +WebURLLoaderClientImpl::WebURLLoaderClientImpl() + : completed_(false) + , status_(LOADING) { +} + +WebURLLoaderClientImpl::~WebURLLoaderClientImpl() { +} + +void WebURLLoaderClientImpl::didReceiveResponse( + blink::WebURLLoader* loader, const blink::WebURLResponse& response) { + DCHECK(!completed_); + response_ = response; +} + +void WebURLLoaderClientImpl::didReceiveData( + blink::WebURLLoader* loader, + const char* data, + int data_length, + int encoded_data_length) { + DCHECK(!completed_); + DCHECK(data_length > 0); + + data_.append(data, data_length); +} + +void WebURLLoaderClientImpl::didReceiveCachedMetadata( + blink::WebURLLoader* loader, + const char* data, + int data_length) { + DCHECK(!completed_); + DCHECK(data_length > 0); + + metadata_.assign(data, data_length); +} + +void WebURLLoaderClientImpl::didFinishLoading( + blink::WebURLLoader* loader, + double finishTime, + int64_t total_encoded_data_length) { + OnLoadCompleteInternal(LOAD_SUCCEEDED); +} + +void WebURLLoaderClientImpl::didFail(blink::WebURLLoader* loader, + const blink::WebURLError& error) { + OnLoadCompleteInternal(LOAD_FAILED); +} + +void WebURLLoaderClientImpl::Cancel() { + OnLoadCompleteInternal(LOAD_FAILED); +} + +void WebURLLoaderClientImpl::OnLoadCompleteInternal(LoadStatus status) { + DCHECK(!completed_); + DCHECK(status_ == LOADING); + + completed_ = true; + status_ = status; + + OnLoadComplete(); +} + +} // namespace content diff --git a/content/renderer/fetchers/web_url_loader_client_impl.h b/content/renderer/fetchers/web_url_loader_client_impl.h new file mode 100644 index 0000000..1113862 --- /dev/null +++ b/content/renderer/fetchers/web_url_loader_client_impl.h @@ -0,0 +1,82 @@ +// 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 CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_ +#define CONTENT_RENDERER_FETCHERS_WEB_URL_LOADER_CLIENT_IMPL_H_ + +#include + +#include "base/memory/scoped_ptr.h" +#include "third_party/WebKit/public/platform/WebURLLoaderClient.h" +#include "third_party/WebKit/public/platform/WebURLResponse.h" + +namespace blink { +class WebURLLoader; +struct WebURLError; +} + +namespace content { + +class WebURLLoaderClientImpl : public blink::WebURLLoaderClient { + protected: + enum LoadStatus { + LOADING, + LOAD_FAILED, + LOAD_SUCCEEDED, + }; + + WebURLLoaderClientImpl(); + virtual ~WebURLLoaderClientImpl(); + + virtual void Cancel(); + + bool completed() const { return completed_; } + const std::string& data() const { return data_; } + const blink::WebURLResponse& response() const { return response_; } + const std::string& metadata() const { return metadata_; } + LoadStatus status() const { return status_; } + + virtual void OnLoadComplete() = 0; + + private: + void OnLoadCompleteInternal(LoadStatus); + + // WebWebURLLoaderClientImpl methods: + virtual void didReceiveResponse( + blink::WebURLLoader* loader, const blink::WebURLResponse& response); + virtual void didReceiveCachedMetadata( + blink::WebURLLoader* loader, const char* data, int data_length); + virtual void didReceiveData( + blink::WebURLLoader* loader, + const char* data, + int data_length, + int encoded_data_length); + virtual void didFinishLoading( + blink::WebURLLoader* loader, + double finishTime, + int64_t total_encoded_data_length); + virtual void didFail( + blink::WebURLLoader* loader, const blink::WebURLError& error); + + private: + // Set to true once the request is complete. + bool completed_; + + // Buffer to hold the content from the server. + std::string data_; + + // A copy of the original resource response. + blink::WebURLResponse response_; + + // Buffer to hold metadata from the cache. + std::string metadata_; + + LoadStatus status_; + + DISALLOW_COPY_AND_ASSIGN(WebURLLoaderClientImpl); +}; + +} // namespace content + +#endif // CONTENT_RENDERER_FETCHERS_URL_LOADER_CLIENT_H_ diff --git a/content/renderer/resource_fetcher_browsertest.cc b/content/renderer/resource_fetcher_browsertest.cc index 70b3d31..d83e9f9 100644 --- a/content/renderer/resource_fetcher_browsertest.cc +++ b/content/renderer/resource_fetcher_browsertest.cc @@ -153,6 +153,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); delegate->WaitForResponse(); @@ -171,6 +172,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); delegate->WaitForResponse(); @@ -190,6 +192,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); delegate->WaitForResponse(); @@ -210,6 +213,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); fetcher->SetTimeout(base::TimeDelta()); @@ -231,6 +235,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); fetcher->SetTimeout(base::TimeDelta()); delegate->SetFetcher(fetcher.release()); @@ -251,6 +256,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); delegate->WaitForResponse(); @@ -270,6 +276,7 @@ class ResourceFetcherTests : public ContentBrowserTest { fetcher->Start(frame, WebURLRequest::RequestContextInternal, WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, delegate->NewCallback()); delegate->WaitForResponse(); diff --git a/content/renderer/web_ui_mojo_context_state.cc b/content/renderer/web_ui_mojo_context_state.cc index 3c99568..7757b26 100644 --- a/content/renderer/web_ui_mojo_context_state.cc +++ b/content/renderer/web_ui_mojo_context_state.cc @@ -100,6 +100,7 @@ void WebUIMojoContextState::FetchModule(const std::string& id) { fetcher->Start(frame_, blink::WebURLRequest::RequestContextScript, blink::WebURLRequest::FrameTypeNone, + ResourceFetcher::PLATFORM_LOADER, base::Bind(&WebUIMojoContextState::OnFetchModuleComplete, base::Unretained(this), fetcher)); -- cgit v1.1 From b6ffa66987678f2b7a3c3be79a5fb27d27cd521c Mon Sep 17 00:00:00 2001 From: chrome-tpm Date: Sat, 13 Sep 2014 06:05:13 -0700 Subject: Updating trunk VERSION from 2157.0 to 2158.0 Cr-Commit-Position: refs/heads/master@{#294745} --- chrome/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/VERSION b/chrome/VERSION index b868506..602629d 100644 --- a/chrome/VERSION +++ b/chrome/VERSION @@ -1,4 +1,4 @@ MAJOR=39 MINOR=0 -BUILD=2157 +BUILD=2158 PATCH=0 -- cgit v1.1 From 7f5d0b808652fe088a46631948d3deea164fd677 Mon Sep 17 00:00:00 2001 From: "ajith.v" Date: Sat, 13 Sep 2014 06:26:36 -0700 Subject: Removing ContentViewCore dependencies from few functions which acts as direct wrapper to WebContents It's a follow up patch to https://codereview.chromium.org/414423002/. We already restructured WebContents functionalities from ContentViewCore. In this patch we are removing unwanted ContentViewCore methods, so that ContentViewCore stake holders can directly call these methods. BUG=398263 Review URL: https://codereview.chromium.org/481803004 Cr-Commit-Position: refs/heads/master@{#294746} --- .../org/chromium/android_webview/AwContents.java | 59 ++++-- .../AwWebContentsDelegateAdapter.java | 6 +- .../AwContentsClientOnFormResubmissionTest.java | 2 +- .../android_webview/test/AwSettingsTest.java | 8 +- .../chromium/android_webview/test/AwTestBase.java | 4 +- .../android_webview/test/ClearHistoryTest.java | 17 +- .../test/LoadDataWithBaseUrlTest.java | 14 +- .../chromium/android_webview/test/LoadUrlTest.java | 2 +- .../test/NavigationHistoryTest.java | 12 +- .../android_webview/test/SaveRestoreStateTest.java | 10 +- .../android_webview/test/WebKitHitTestTest.java | 2 +- .../android_webview/shell/AwShellActivity.java | 20 +- .../java/src/org/chromium/chrome/browser/Tab.java | 53 +++-- .../chrome/browser/banners/AppBannerManager.java | 2 +- .../DomDistillerFeedbackReporter.java | 2 +- .../chrome/browser/test/ModalDialogTest.java | 6 +- .../org/chromium/chrome/shell/ChromeShellTab.java | 14 +- .../chromium/chrome/shell/ChromeShellToolbar.java | 8 +- .../chromium/chrome/shell/ChromeShellTestBase.java | 3 +- .../chromium/chrome/shell/ChromeShellUrlTest.java | 7 +- .../chromium/content/browser/ContentViewCore.java | 223 +-------------------- .../accessibility/AccessibilityInjector.java | 11 +- .../JellyBeanAccessibilityInjector.java | 2 +- .../content/browser/ContentDetectionTestBase.java | 3 +- .../content/browser/GestureDetectorResetTest.java | 5 +- .../content/browser/JavaBridgeBasicsTest.java | 16 +- .../content/browser/JavaBridgeTestBase.java | 4 +- .../chromium/content/browser/NavigationTest.java | 16 +- .../browser/WebContentsObserverAndroidTest.java | 3 +- .../content/browser/input/SelectPopupTest.java | 5 +- .../content/browser/test/util/HistoryUtils.java | 34 ++-- .../java/src/org/chromium/content_shell/Shell.java | 27 ++- .../ContentShellShellManagementTest.java | 6 +- .../content_shell_apk/ContentShellTestBase.java | 7 +- .../content_shell_apk/ContentShellUrlTest.java | 2 +- .../content_shell_apk/ContentShellActivity.java | 7 +- 36 files changed, 233 insertions(+), 389 deletions(-) diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index ffa0d5e..6c0e38f 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -54,8 +54,10 @@ import org.chromium.content_public.Referrer; import org.chromium.content_public.browser.GestureStateListener; import org.chromium.content_public.browser.JavaScriptCallback; import org.chromium.content_public.browser.LoadUrlParams; +import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationHistory; import org.chromium.content_public.browser.PageTransitionTypes; +import org.chromium.content_public.browser.WebContents; import org.chromium.ui.base.ActivityWindowAndroid; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.gfx.DeviceDisplayInfo; @@ -182,6 +184,8 @@ public class AwContents { private final Context mContext; private ContentViewCore mContentViewCore; private WindowAndroid mWindowAndroid; + private WebContents mWebContents; + private NavigationController mNavigationController; private final AwContentsClient mContentsClient; private final AwContentViewClient mContentViewClient; private WebContentsObserverAndroid mWebContentsObserver; @@ -745,6 +749,8 @@ public class AwContents { if (mNativeAwContents != 0) { destroy(); mContentViewCore = null; + mWebContents = null; + mNavigationController = null; } assert mNativeAwContents == 0 && mCleanupReference == null && mContentViewCore == null; @@ -768,6 +774,8 @@ public class AwContents { new AwGestureStateListener(), mContentViewClient, mZoomControls, mWindowAndroid); nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge, mIoThreadClient, mInterceptNavigationDelegate); + mWebContents = mContentViewCore.getWebContents(); + mNavigationController = mWebContents.getNavigationController(); installWebContentsObserver(); mSettings.setWebContents(nativeWebContents); nativeSetDipScale(mNativeAwContents, (float) mDIPScale); @@ -780,8 +788,7 @@ public class AwContents { if (mWebContentsObserver != null) { mWebContentsObserver.detachFromWebContents(); } - mWebContentsObserver = new AwWebContentsObserver(mContentViewCore.getWebContents(), - mContentsClient); + mWebContentsObserver = new AwWebContentsObserver(mWebContents, mContentsClient); } /** @@ -888,6 +895,16 @@ public class AwContents { return mContentViewCore; } + @VisibleForTesting + public WebContents getWebContents() { + return mWebContents; + } + + @VisibleForTesting + public NavigationController getNavigationController() { + return mNavigationController; + } + // Can be called from any thread. public AwSettings getSettings() { return mSettings; @@ -1074,7 +1091,7 @@ public class AwContents { // If we are reloading the same url, then set transition type as reload. if (params.getUrl() != null && - params.getUrl().equals(mContentViewCore.getUrl()) && + params.getUrl().equals(mWebContents.getUrl()) && params.getTransitionType() == PageTransitionTypes.PAGE_TRANSITION_LINK) { params.setTransitionType(PageTransitionTypes.PAGE_TRANSITION_RELOAD); } @@ -1108,7 +1125,7 @@ public class AwContents { } params.setExtraHeaders(new HashMap()); - mContentViewCore.loadUrl(params); + mNavigationController.loadUrl(params); // The behavior of WebViewClassic uses the populateVisitedLinks callback in WebKit. // Chromium does not use this use code path and the best emulation of this behavior to call @@ -1132,7 +1149,7 @@ public class AwContents { * @return The URL of the current page or null if it's empty. */ public String getUrl() { - String url = mContentViewCore.getUrl(); + String url = mWebContents.getUrl(); if (url == null || url.trim().isEmpty()) return null; return url; } @@ -1323,56 +1340,56 @@ public class AwContents { * @see android.webkit.WebView#stopLoading() */ public void stopLoading() { - mContentViewCore.stopLoading(); + mWebContents.stop(); } /** * @see android.webkit.WebView#reload() */ public void reload() { - mContentViewCore.reload(true); + mNavigationController.reload(true); } /** * @see android.webkit.WebView#canGoBack() */ public boolean canGoBack() { - return mContentViewCore.canGoBack(); + return mNavigationController.canGoBack(); } /** * @see android.webkit.WebView#goBack() */ public void goBack() { - mContentViewCore.goBack(); + mNavigationController.goBack(); } /** * @see android.webkit.WebView#canGoForward() */ public boolean canGoForward() { - return mContentViewCore.canGoForward(); + return mNavigationController.canGoForward(); } /** * @see android.webkit.WebView#goForward() */ public void goForward() { - mContentViewCore.goForward(); + mNavigationController.goForward(); } /** * @see android.webkit.WebView#canGoBackOrForward(int) */ public boolean canGoBackOrForward(int steps) { - return mContentViewCore.canGoToOffset(steps); + return mNavigationController.canGoToOffset(steps); } /** * @see android.webkit.WebView#goBackOrForward(int) */ public void goBackOrForward(int steps) { - mContentViewCore.goToOffset(steps); + mNavigationController.goToOffset(steps); } /** @@ -1473,7 +1490,7 @@ public class AwContents { } public String getOriginalUrl() { - NavigationHistory history = mContentViewCore.getNavigationHistory(); + NavigationHistory history = mNavigationController.getNavigationHistory(); int currentIndex = history.getCurrentEntryIndex(); if (currentIndex >= 0 && currentIndex < history.getEntryCount()) { return history.getEntryAtIndex(currentIndex).getOriginalUrl(); @@ -1485,21 +1502,21 @@ public class AwContents { * @see ContentViewCore#getNavigationHistory() */ public NavigationHistory getNavigationHistory() { - return mContentViewCore.getNavigationHistory(); + return mNavigationController.getNavigationHistory(); } /** * @see android.webkit.WebView#getTitle() */ public String getTitle() { - return mContentViewCore.getTitle(); + return mWebContents.getTitle(); } /** * @see android.webkit.WebView#clearHistory() */ public void clearHistory() { - mContentViewCore.clearHistory(); + mNavigationController.clearHistory(); } public String[] getHttpAuthUsernamePassword(String host, String realm) { @@ -1525,7 +1542,7 @@ public class AwContents { * @see android.webkit.WebView#clearSslPreferences() */ public void clearSslPreferences() { - mContentViewCore.clearSslPreferences(); + mNavigationController.clearSslPreferences(); } // TODO(sgurun) remove after this rolls in. To keep internal tree happy. @@ -1696,14 +1713,14 @@ public class AwContents { }; } - mContentViewCore.evaluateJavaScript(script, jsCallback); + mWebContents.evaluateJavaScript(script, jsCallback, false); } /** * @see ContentViewCore.evaluateJavaScriptEvenIfNotYetNavigated(String) */ public void evaluateJavaScriptEvenIfNotYetNavigated(String script) { - mContentViewCore.evaluateJavaScriptEvenIfNotYetNavigated(script); + mWebContents.evaluateJavaScript(script, null, true); } //-------------------------------------------------------------------------------------------- @@ -1853,7 +1870,7 @@ public class AwContents { // but is optimized out in the restoreState case because the title is // already restored. See WebContentsImpl::UpdateTitleForEntry. So we // call the callback explicitly here. - if (result) mContentsClient.onReceivedTitle(mContentViewCore.getTitle()); + if (result) mContentsClient.onReceivedTitle(mWebContents.getTitle()); return result; } diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java index 5aaa32f..e0a7a94 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java +++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java @@ -149,11 +149,13 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { public void handleMessage(Message msg) { switch(msg.what) { case msgContinuePendingReload: { - contentViewCore.continuePendingReload(); + contentViewCore.getWebContents().getNavigationController() + .continuePendingReload(); break; } case msgCancelPendingReload: { - contentViewCore.cancelPendingReload(); + contentViewCore.getWebContents().getNavigationController() + .cancelPendingReload(); break; } default: diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnFormResubmissionTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnFormResubmissionTest.java index 4ef59ee..b6535b3 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnFormResubmissionTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnFormResubmissionTest.java @@ -117,7 +117,7 @@ public class AwContentsClientOnFormResubmissionTest extends AwTestBase { getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { - mAwContents.getContentViewCore().reload(true); + mAwContents.getNavigationController().reload(true); } }); try { diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java index 9156196..9ecf971 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java @@ -33,9 +33,9 @@ import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.TestFileUtil; import org.chromium.base.test.util.UrlUtils; -import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.test.util.CallbackHelper; import org.chromium.content.browser.test.util.HistoryUtils; +import org.chromium.content_public.browser.WebContents; import org.chromium.net.test.util.TestWebServer; import org.chromium.ui.gfx.DeviceDisplayInfo; @@ -1675,7 +1675,7 @@ public class AwSettingsTest extends AwTestBase { final AwTestContainerView testContainerView = createAwTestContainerViewOnMainSync(contentClient); final AwContents awContents = testContainerView.getAwContents(); - final ContentViewCore contentView = testContainerView.getContentViewCore(); + final WebContents webContents = awContents.getWebContents(); CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper(); AwSettings settings = getAwSettingsOnUiThread(awContents); settings.setJavaScriptEnabled(true); @@ -1701,9 +1701,9 @@ public class AwSettingsTest extends AwTestBase { settings.setUserAgentString(null); // Must not cause any changes until the next page loading. assertEquals(page2Title + customUserAgentString, getTitleOnUiThread(awContents)); - HistoryUtils.goBackSync(getInstrumentation(), contentView, onPageFinishedHelper); + HistoryUtils.goBackSync(getInstrumentation(), webContents, onPageFinishedHelper); assertEquals(page1Title + defaultUserAgentString, getTitleOnUiThread(awContents)); - HistoryUtils.goForwardSync(getInstrumentation(), contentView, + HistoryUtils.goForwardSync(getInstrumentation(), webContents, onPageFinishedHelper); assertEquals(page2Title + defaultUserAgentString, getTitleOnUiThread(awContents)); } diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java index db3dcd8..d8dfe07 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java @@ -259,7 +259,7 @@ public class AwTestBase getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { - awContents.getContentViewCore().reload(true); + awContents.getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_MS, @@ -355,7 +355,7 @@ public class AwTestBase return runTestOnUiThreadAndGetResult(new Callable() { @Override public String call() throws Exception { - return awContents.getContentViewCore().getTitle(); + return awContents.getTitle(); } }); } diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/ClearHistoryTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/ClearHistoryTest.java index adc931c..086c2d2 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/ClearHistoryTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/ClearHistoryTest.java @@ -7,9 +7,9 @@ package org.chromium.android_webview.test; import org.chromium.android_webview.AwContents; import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.UrlUtils; -import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.test.util.HistoryUtils; import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper; +import org.chromium.content_public.browser.WebContents; /** * Tests for a wanted clearHistory method. @@ -36,23 +36,22 @@ public class ClearHistoryTest extends AwTestBase { final AwTestContainerView testContainerView = createAwTestContainerViewOnMainSync(contentsClient); final AwContents awContents = testContainerView.getAwContents(); - final ContentViewCore contentViewCore = testContainerView.getContentViewCore(); - + final WebContents webContents = awContents.getWebContents(); OnPageFinishedHelper onPageFinishedHelper = contentsClient.getOnPageFinishedHelper(); for (int i = 0; i < 3; i++) { loadUrlSync(awContents, onPageFinishedHelper, URLS[i]); } - HistoryUtils.goBackSync(getInstrumentation(), contentViewCore, onPageFinishedHelper); + HistoryUtils.goBackSync(getInstrumentation(), webContents, onPageFinishedHelper); assertTrue("Should be able to go back", - HistoryUtils.canGoBackOnUiThread(getInstrumentation(), contentViewCore)); + HistoryUtils.canGoBackOnUiThread(getInstrumentation(), webContents)); assertTrue("Should be able to go forward", - HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), contentViewCore)); + HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), webContents)); - HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), contentViewCore); + HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), webContents); assertFalse("Should not be able to go back", - HistoryUtils.canGoBackOnUiThread(getInstrumentation(), contentViewCore)); + HistoryUtils.canGoBackOnUiThread(getInstrumentation(), webContents)); assertFalse("Should not be able to go forward", - HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), contentViewCore)); + HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), webContents)); } } diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java index 04a176e..c9168c3 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java @@ -12,9 +12,9 @@ import org.chromium.android_webview.AwSettings; import org.chromium.android_webview.test.util.CommonResources; import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; -import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.test.util.HistoryUtils; import org.chromium.content.browser.test.util.TestCallbackHelperContainer; +import org.chromium.content_public.browser.WebContents; import org.chromium.net.test.util.TestWebServer; import java.io.File; @@ -29,7 +29,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase { private TestAwContentsClient mContentsClient; private AwContents mAwContents; - private ContentViewCore mContentViewCore; + private WebContents mWebContents; @Override public void setUp() throws Exception { @@ -38,7 +38,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase { final AwTestContainerView testContainerView = createAwTestContainerViewOnMainSync(mContentsClient); mAwContents = testContainerView.getAwContents(); - mContentViewCore = testContainerView.getContentViewCore(); + mWebContents = mAwContents.getWebContents(); } protected void loadDataWithBaseUrlSync( @@ -202,11 +202,11 @@ public class LoadDataWithBaseUrlTest extends AwTestBase { final String historyUrl = "http://history.com/"; loadDataWithBaseUrlSync(pageHtml, "text/html", false, baseUrl, historyUrl); assertEquals(historyUrl, HistoryUtils.getUrlOnUiThread( - getInstrumentation(), mContentViewCore)); + getInstrumentation(), mWebContents)); loadDataWithBaseUrlSync(pageHtml, "text/html", false, baseUrl, null); assertEquals("about:blank", HistoryUtils.getUrlOnUiThread( - getInstrumentation(), mContentViewCore)); + getInstrumentation(), mWebContents)); } @SmallTest @@ -228,7 +228,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase { final String historyUrl = "http://history.com/"; loadDataWithBaseUrlSync(pageHtml, "text/html", false, "data:foo", historyUrl); assertEquals("data:text/html," + pageHtml, HistoryUtils.getUrlOnUiThread( - getInstrumentation(), mContentViewCore)); + getInstrumentation(), mWebContents)); } /* @@ -260,7 +260,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase { loadDataSync(mAwContents, onPageFinishedHelper, page2Html, "text/html", false); assertEquals(page2Title, getTitleOnUiThread(mAwContents)); - HistoryUtils.goBackSync(getInstrumentation(), mContentViewCore, onPageFinishedHelper); + HistoryUtils.goBackSync(getInstrumentation(), mWebContents, onPageFinishedHelper); // The title of the 'about.html' specified via historyUrl. assertEquals(CommonResources.ABOUT_TITLE, getTitleOnUiThread(mAwContents)); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java index fa9707d..410b9d3bd 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java @@ -323,7 +323,7 @@ public class LoadUrlTest extends AwTestBase { validateNoRequestHeaders(extraHeaders, webServer.getLastRequest(nextPath)); HistoryUtils.goBackSync(getInstrumentation(), - awContents.getContentViewCore(), + awContents.getWebContents(), contentsClient.getOnPageFinishedHelper()); assertEquals(2, webServer.getRequestCount(path)); validateRequestHeaders(extraHeaders, webServer.getLastRequest(path)); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java index f123585..2f81905 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java @@ -60,7 +60,7 @@ public class NavigationHistoryTest extends AwTestBase { return ThreadUtils.runOnUiThreadBlocking(new Callable() { @Override public NavigationHistory call() { - return awContents.getContentViewCore().getNavigationHistory(); + return awContents.getNavigationController().getNavigationHistory(); } }); } @@ -171,7 +171,7 @@ public class NavigationHistoryTest extends AwTestBase { loadUrlSync(mAwContents, onPageFinishedHelper, page1Url); loadUrlSync(mAwContents, onPageFinishedHelper, page2Url); - HistoryUtils.goBackSync(getInstrumentation(), mAwContents.getContentViewCore(), + HistoryUtils.goBackSync(getInstrumentation(), mAwContents.getWebContents(), onPageFinishedHelper); list = getNavigationHistory(mAwContents); @@ -288,7 +288,7 @@ public class NavigationHistoryTest extends AwTestBase { pollOnUiThread(new Callable() { @Override public Boolean call() { - String title = mAwContents.getContentViewCore().getTitle(); + String title = mAwContents.getTitle(); return LOGIN_RESPONSE_PAGE_TITLE.equals(title); } }); @@ -299,18 +299,18 @@ public class NavigationHistoryTest extends AwTestBase { pollOnUiThread(new Callable() { @Override public Boolean call() { - String title = mAwContents.getContentViewCore().getTitle(); + String title = mAwContents.getTitle(); return PAGE_1_TITLE.equals(title); } }); // Verify that we can still go back to the login response page despite that // it is non-cacheable. - HistoryUtils.goBackSync(getInstrumentation(), mAwContents.getContentViewCore(), + HistoryUtils.goBackSync(getInstrumentation(), mAwContents.getWebContents(), onPageFinishedHelper); pollOnUiThread(new Callable() { @Override public Boolean call() { - String title = mAwContents.getContentViewCore().getTitle(); + String title = mAwContents.getTitle(); return LOGIN_RESPONSE_PAGE_TITLE.equals(title); } }); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/SaveRestoreStateTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/SaveRestoreStateTest.java index 0502611..ae8e135 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/SaveRestoreStateTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/SaveRestoreStateTest.java @@ -10,7 +10,7 @@ import android.test.suitebuilder.annotation.SmallTest; import org.chromium.android_webview.AwContents; import org.chromium.android_webview.test.util.CommonResources; import org.chromium.base.test.util.Feature; -import org.chromium.content.browser.ContentViewCore; +import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationHistory; import org.chromium.net.test.util.TestWebServer; @@ -25,14 +25,14 @@ public class SaveRestoreStateTest extends AwTestBase { public final TestAwContentsClient contentsClient; public final AwTestContainerView testView; public final AwContents awContents; - public final ContentViewCore contentViewCore; + public final NavigationController navigationController; public TestVars(TestAwContentsClient contentsClient, AwTestContainerView testView) { this.contentsClient = contentsClient; this.testView = testView; this.awContents = testView.getAwContents(); - this.contentViewCore = this.awContents.getContentViewCore(); + this.navigationController = this.awContents.getNavigationController(); } } @@ -93,7 +93,7 @@ public class SaveRestoreStateTest extends AwTestBase { return runTestOnUiThreadAndGetResult(new Callable() { @Override public NavigationHistory call() throws Exception { - return vars.contentViewCore.getNavigationHistory(); + return vars.navigationController.getNavigationHistory(); } }); } @@ -136,7 +136,7 @@ public class SaveRestoreStateTest extends AwTestBase { pollOnUiThread(new Callable() { @Override public Boolean call() throws Exception { - return TITLES[0].equals(restoredVars.contentViewCore.getTitle()) && + return TITLES[0].equals(restoredVars.awContents.getTitle()) && TITLES[0].equals(restoredVars.contentsClient.getUpdatedTitle()); } }); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/WebKitHitTestTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/WebKitHitTestTest.java index a7a1586..32ce543 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/WebKitHitTestTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/WebKitHitTestTest.java @@ -382,7 +382,7 @@ public class WebKitHitTestTest extends AwTestBase { pollOnUiThread(new Callable() { @Override public Boolean call() { - return mAwContents.getContentViewCore().getTitle().equals(title); + return mAwContents.getTitle().equals(title); } }); AwTestTouchUtils.simulateTouchCenterOfView(mTestView); diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java index af31b56..8ed513f 100644 --- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java +++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java @@ -37,6 +37,8 @@ import org.chromium.android_webview.AwSettings; import org.chromium.android_webview.test.AwTestContainerView; import org.chromium.android_webview.test.NullContentsClient; import org.chromium.content_public.browser.LoadUrlParams; +import org.chromium.content_public.browser.NavigationController; +import org.chromium.content_public.browser.WebContents; /** * This is a lightweight activity for tests that only require WebView functionality. @@ -47,6 +49,8 @@ public class AwShellActivity extends Activity { private AwBrowserContext mBrowserContext; private AwDevToolsServer mDevToolsServer; private AwTestContainerView mAwTestContainerView; + private WebContents mWebContents; + private NavigationController mNavigationController; private EditText mUrlTextView; private ImageButton mPrevButton; private ImageButton mNextButton; @@ -59,6 +63,8 @@ public class AwShellActivity extends Activity { mAwTestContainerView = createAwTestContainerView(); + mWebContents = mAwTestContainerView.getContentViewCore().getWebContents(); + mNavigationController = mWebContents.getNavigationController(); LinearLayout contentContainer = (LinearLayout) findViewById(R.id.content_container); mAwTestContainerView.setLayoutParams(new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); @@ -182,7 +188,7 @@ public class AwShellActivity extends Activity { mNextButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE); mPrevButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE); if (!hasFocus) { - mUrlTextView.setText(mAwTestContainerView.getContentViewCore().getUrl()); + mUrlTextView.setText(mWebContents.getUrl()); } } }); @@ -193,8 +199,8 @@ public class AwShellActivity extends Activity { mPrevButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - if (mAwTestContainerView.getContentViewCore().canGoBack()) { - mAwTestContainerView.getContentViewCore().goBack(); + if (mNavigationController.canGoBack()) { + mNavigationController.goBack(); } } }); @@ -203,8 +209,8 @@ public class AwShellActivity extends Activity { mNextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - if (mAwTestContainerView.getContentViewCore().canGoForward()) { - mAwTestContainerView.getContentViewCore().goForward(); + if (mNavigationController.canGoForward()) { + mNavigationController.goForward(); } } }); @@ -213,8 +219,8 @@ public class AwShellActivity extends Activity { @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { - if (mAwTestContainerView.getContentViewCore().canGoBack()) { - mAwTestContainerView.getContentViewCore().goBack(); + if (mNavigationController.canGoBack()) { + mNavigationController.goBack(); return true; } } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java index f37975a..a3ab6d9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java @@ -214,12 +214,12 @@ public class Tab implements NavigationClient { new Runnable() { @Override public void run() { - contentViewCore.cancelPendingReload(); + getWebContents().getNavigationController().cancelPendingReload(); } }, new Runnable() { @Override public void run() { - contentViewCore.continuePendingReload(); + getWebContents().getNavigationController().continuePendingReload(); } }); Activity activity = (Activity) mContext; @@ -363,34 +363,36 @@ public class Tab implements NavigationClient { * @return Whether or not this tab has a previous navigation entry. */ public boolean canGoBack() { - return mContentViewCore != null && mContentViewCore.canGoBack(); + return getWebContents() != null && getWebContents().getNavigationController().canGoBack(); } /** * @return Whether or not this tab has a navigation entry after the current one. */ public boolean canGoForward() { - return mContentViewCore != null && mContentViewCore.canGoForward(); + return getWebContents() != null && getWebContents().getNavigationController() + .canGoForward(); } /** * Goes to the navigation entry before the current one. */ public void goBack() { - if (mContentViewCore != null) mContentViewCore.goBack(); + if (getWebContents() != null) getWebContents().getNavigationController().goBack(); } /** * Goes to the navigation entry after the current one. */ public void goForward() { - if (mContentViewCore != null) mContentViewCore.goForward(); + if (getWebContents() != null) getWebContents().getNavigationController().goForward(); } @Override public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { - if (mContentViewCore != null) { - return mContentViewCore.getDirectedNavigationHistory(isForward, itemLimit); + if (getWebContents() != null) { + return getWebContents().getNavigationController() + .getDirectedNavigationHistory(isForward, itemLimit); } else { return new NavigationHistory(); } @@ -398,21 +400,25 @@ public class Tab implements NavigationClient { @Override public void goToNavigationIndex(int index) { - if (mContentViewCore != null) mContentViewCore.goToNavigationIndex(index); + if (getWebContents() != null) { + getWebContents().getNavigationController().goToNavigationIndex(index); + } } /** * Loads the current navigation if there is a pending lazy load (after tab restore). */ public void loadIfNecessary() { - if (mContentViewCore != null) mContentViewCore.loadIfNecessary(); + if (getWebContents() != null) getWebContents().getNavigationController().loadIfNecessary(); } /** * Requests the current navigation to be loaded upon the next call to loadIfNecessary(). */ protected void requestRestoreLoad() { - if (mContentViewCore != null) mContentViewCore.requestRestoreLoad(); + if (getWebContents() != null) { + getWebContents().getNavigationController().requestRestoreLoad(); + } } /** @@ -454,8 +460,7 @@ public class Tab implements NavigationClient { * a bad HTTPS page. */ public boolean isShowingInterstitialPage() { - ContentViewCore contentViewCore = getContentViewCore(); - return contentViewCore != null && contentViewCore.isShowingInterstitialPage(); + return getWebContents() != null && getWebContents().isShowingInterstitialPage(); } /** @@ -533,7 +538,7 @@ public class Tab implements NavigationClient { */ public void reload() { // TODO(dtrainor): Should we try to rebuild the ContentView if it's frozen? - if (mContentViewCore != null) mContentViewCore.reload(true); + if (getWebContents() != null) getWebContents().getNavigationController().reload(true); } /** @@ -541,12 +546,14 @@ public class Tab implements NavigationClient { * This version ignores the cache and reloads from the network. */ public void reloadIgnoringCache() { - if (mContentViewCore != null) mContentViewCore.reloadIgnoringCache(true); + if (getWebContents() != null) { + getWebContents().getNavigationController().reloadIgnoringCache(true); + } } /** Stop the current navigation. */ public void stopLoading() { - if (mContentViewCore != null) mContentViewCore.stopLoading(); + if (getWebContents() != null) getWebContents().stop(); } /** @@ -554,7 +561,7 @@ public class Tab implements NavigationClient { */ public int getBackgroundColor() { if (mNativePage != null) return mNativePage.getBackgroundColor(); - if (mContentViewCore != null) return mContentViewCore.getBackgroundColor(); + if (getWebContents() != null) return getWebContents().getBackgroundColor(); return Color.WHITE; } @@ -622,8 +629,9 @@ public class Tab implements NavigationClient { * @param reloadOnChange Reload the page if the user agent has changed. */ public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChange) { - if (mContentViewCore != null) { - mContentViewCore.setUseDesktopUserAgent(useDesktop, reloadOnChange); + if (getWebContents() != null) { + getWebContents().getNavigationController() + .setUseDesktopUserAgent(useDesktop, reloadOnChange); } } @@ -631,7 +639,8 @@ public class Tab implements NavigationClient { * @return Whether or not the {@link ContentViewCore} is using a desktop user agent. */ public boolean getUseDesktopUserAgent() { - return mContentViewCore != null && mContentViewCore.getUseDesktopUserAgent(); + return getWebContents() != null && getWebContents().getNavigationController() + .getUseDesktopUserAgent(); } /** @@ -880,7 +889,7 @@ public class Tab implements NavigationClient { */ @CalledByNative public String getUrl() { - return mContentViewCore != null ? mContentViewCore.getUrl() : ""; + return getWebContents() != null ? getWebContents().getUrl() : ""; } /** @@ -889,7 +898,7 @@ public class Tab implements NavigationClient { @CalledByNative public String getTitle() { if (mNativePage != null) return mNativePage.getTitle(); - if (mContentViewCore != null) return mContentViewCore.getTitle(); + if (getWebContents() != null) return getWebContents().getTitle(); return ""; } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java b/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java index c085655..9f371b8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java @@ -226,7 +226,7 @@ public class AppBannerManager implements AppBannerView.Observer, AppDetailsDeleg */ private boolean isBannerForCurrentPage(String bannerUrl) { return mContentViewCore != null && - TextUtils.equals(mContentViewCore.getUrl(), bannerUrl); + TextUtils.equals(mContentViewCore.getWebContents().getUrl(), bannerUrl); } private static native boolean nativeIsEnabled(); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReporter.java b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReporter.java index 96562d3..71ad6ec 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReporter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReporter.java @@ -85,7 +85,7 @@ public final class DomDistillerFeedbackReporter implements if (!good) { Activity activity = mTab.getWindowAndroid().getActivity().get(); String url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl( - mContentViewCore.getUrl()); + mContentViewCore.getWebContents().getUrl()); sExternalFeedbackReporter.reportFeedback(activity, url, good); } } diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/test/ModalDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/test/ModalDialogTest.java index 38181b5..e224230 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/test/ModalDialogTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/test/ModalDialogTest.java @@ -184,7 +184,8 @@ public class ModalDialogTest extends ChromeShellTestBase { "Stay on this page"); clickCancel(jsDialog); - assertEquals(BEFORE_UNLOAD_URL, getActivity().getActiveContentViewCore().getUrl()); + assertEquals(BEFORE_UNLOAD_URL, getActivity().getActiveContentViewCore() + .getWebContents().getUrl()); executeJavaScriptAndWaitForDialog("history.back();"); jsDialog = getCurrentDialog(); @@ -198,7 +199,8 @@ public class ModalDialogTest extends ChromeShellTestBase { int callCount = onPageLoaded.getCallCount(); clickOk(jsDialog); onPageLoaded.waitForCallback(callCount); - assertEquals(EMPTY_PAGE, getActivity().getActiveContentViewCore().getUrl()); + assertEquals(EMPTY_PAGE, getActivity().getActiveContentViewCore() + .getWebContents().getUrl()); } /** diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellTab.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellTab.java index 195d56a..f6ff41e 100644 --- a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellTab.java +++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellTab.java @@ -13,9 +13,10 @@ import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; import org.chromium.chrome.browser.infobar.AutoLoginProcessor; import org.chromium.content.browser.ContentViewClient; -import org.chromium.content.browser.ContentViewCore; import org.chromium.content_public.Referrer; import org.chromium.content_public.browser.LoadUrlParams; +import org.chromium.content_public.browser.NavigationController; +import org.chromium.content_public.browser.WebContents; import org.chromium.ui.base.WindowAndroid; /** @@ -62,14 +63,15 @@ public class ChromeShellTab extends Tab { // Invalid URLs will just return empty. if (TextUtils.isEmpty(url)) return; - ContentViewCore contentViewCore = getContentViewCore(); - if (TextUtils.equals(url, contentViewCore.getUrl())) { - contentViewCore.reload(true); + WebContents webContents = getWebContents(); + NavigationController navigationController = webContents.getNavigationController(); + if (TextUtils.equals(url, webContents.getUrl())) { + navigationController.reload(true); } else { if (postData == null) { - contentViewCore.loadUrl(new LoadUrlParams(url)); + navigationController.loadUrl(new LoadUrlParams(url)); } else { - contentViewCore.loadUrl(LoadUrlParams.createLoadHttpPostParams(url, postData)); + navigationController.loadUrl(LoadUrlParams.createLoadHttpPostParams(url, postData)); } } } diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellToolbar.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellToolbar.java index ed9e570..12c5e20 100644 --- a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellToolbar.java +++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellToolbar.java @@ -80,7 +80,7 @@ public class ChromeShellToolbar extends LinearLayout { if (mTab != null) mTab.removeObserver(mTabObserver); mTab = tab; mTab.addObserver(mTabObserver); - mUrlTextView.setText(mTab.getContentViewCore().getUrl()); + mUrlTextView.setText(mTab.getWebContents().getUrl()); } private void onUpdateUrl(String url) { @@ -145,7 +145,7 @@ public class ChromeShellToolbar extends LinearLayout { public void onFocusChange(View v, boolean hasFocus) { setKeyboardVisibilityForUrl(hasFocus); if (!hasFocus) { - mUrlTextView.setText(mTab.getContentViewCore().getUrl()); + mUrlTextView.setText(mTab.getWebContents().getUrl()); mSuggestionPopup.dismissPopup(); } } @@ -190,9 +190,9 @@ public class ChromeShellToolbar extends LinearLayout { @Override public void onClick(View v) { if (mLoading) { - mTab.getContentViewCore().stopLoading(); + mTab.getWebContents().stop(); } else { - mTab.getContentViewCore().reload(true); + mTab.getWebContents().getNavigationController().reload(true); } } }); diff --git a/chrome/android/shell/javatests/src/org/chromium/chrome/shell/ChromeShellTestBase.java b/chrome/android/shell/javatests/src/org/chromium/chrome/shell/ChromeShellTestBase.java index 01d160c..c11e001 100644 --- a/chrome/android/shell/javatests/src/org/chromium/chrome/shell/ChromeShellTestBase.java +++ b/chrome/android/shell/javatests/src/org/chromium/chrome/shell/ChromeShellTestBase.java @@ -95,7 +95,8 @@ public class ChromeShellTestBase extends ActivityInstrumentationTestCase2 params = URLEncodedUtils.parse(new URI(mContentViewCore.getUrl()), - null); + List params = URLEncodedUtils.parse( + new URI(mContentViewCore.getWebContents().getUrl()), null); for (NameValuePair param : params) { if ("axs".equals(param.getName())) { @@ -317,8 +319,11 @@ public class AccessibilityInjector extends WebContentsObserverAndroid { } } } catch (URISyntaxException ex) { + // Intentional no-op. } catch (NumberFormatException ex) { + // Intentional no-op. } catch (IllegalArgumentException ex) { + // Intentional no-op. } return ACCESSIBILITY_SCRIPT_INJECTION_UNDEFINED; diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanAccessibilityInjector.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanAccessibilityInjector.java index 059c5fb..363ebfe 100644 --- a/content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanAccessibilityInjector.java +++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanAccessibilityInjector.java @@ -77,7 +77,7 @@ class JellyBeanAccessibilityInjector extends AccessibilityInjector { boolean actionSuccessful = sendActionToAndroidVox(action, arguments); - if (actionSuccessful) mContentViewCore.showImeIfNeeded(); + if (actionSuccessful) mContentViewCore.getWebContents().showImeIfNeeded(); return actionSuccessful; } diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java index 6480854..870536f 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java @@ -52,7 +52,8 @@ public class ContentDetectionTestBase extends ContentShellTestBase { * @return true if the test url is the current one, false otherwise. */ protected boolean isCurrentTestUrl(String testUrl) { - return UrlUtils.getTestFileUrl(testUrl).equals(getContentViewCore().getUrl()); + return UrlUtils.getTestFileUrl(testUrl).equals(getContentViewCore() + .getWebContents().getUrl()); } /** diff --git a/content/public/android/javatests/src/org/chromium/content/browser/GestureDetectorResetTest.java b/content/public/android/javatests/src/org/chromium/content/browser/GestureDetectorResetTest.java index ed8ec23..71e1278 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/GestureDetectorResetTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/GestureDetectorResetTest.java @@ -125,8 +125,9 @@ public class GestureDetectorResetTest extends ContentShellTestBase { getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { - getActivity().getActiveShell().getContentViewCore().loadUrl( - new LoadUrlParams(CLICK_TEST_URL)); + getActivity().getActiveShell().getContentViewCore().getWebContents() + .getNavigationController().loadUrl( + new LoadUrlParams(CLICK_TEST_URL)); } }); onPageFinishedHelper.waitForCallback(currentCallCount, 1, diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java index fa42e6c..a2d5ad8 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeBasicsTest.java @@ -117,7 +117,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { public void run() { getContentViewCore().addPossiblyUnsafeJavascriptInterface(object, name, requiredAnnotation); - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount); @@ -130,7 +130,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { runTestOnUiThread(new Runnable() { @Override public void run() { - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount); @@ -195,7 +195,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { @Override public void run() { getContentViewCore().removeJavascriptInterface("foo"); - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount); @@ -357,7 +357,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { testObject, "testObject1", null); getContentViewCore().addPossiblyUnsafeJavascriptInterface( testObject, "testObject2", null); - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount); @@ -404,7 +404,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { object, "testObject", null); getContentViewCore().addPossiblyUnsafeJavascriptInterface( innerObject, "innerObject", null); - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount); @@ -545,7 +545,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { public void method() {} private void privateMethod() {} public int field; - private int privateField; + private int mPrivateField; }, "testObject"); executeJavaScript( "var result = \"\"; " + @@ -598,7 +598,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { public void testReflectPrivateFieldRaisesException() throws Throwable { injectObjectAndReload(new Object() { public Class myGetClass() { return getClass(); } - private int field; + private int mField; }, "testObject"); assertRaisesException("testObject.myGetClass().getField('field')"); // getDeclaredField() is able to access a private field, but getInt() @@ -774,7 +774,7 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { public void run() { getContentViewCore().addJavascriptInterface(new Test(), "testObject"); - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeTestBase.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeTestBase.java index bcf40c2..5a4bc7f 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeTestBase.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeTestBase.java @@ -43,8 +43,8 @@ public class JavaBridgeTestBase extends ContentViewTestBase { // converted to a string and used as the new document for the // frame. We don't want this behaviour, so wrap the script in // an anonymous function. - getContentViewCore().loadUrl(new LoadUrlParams( - "javascript:(function() { " + script + " })()")); + getContentViewCore().getWebContents().getNavigationController().loadUrl( + new LoadUrlParams("javascript:(function() { " + script + " })()")); } }); } diff --git a/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java b/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java index a2037b5..790e57d 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java @@ -35,7 +35,7 @@ public class NavigationTest extends ContentShellTestBase { new Runnable() { @Override public void run() { - contentViewCore.goBack(); + contentViewCore.getWebContents().getNavigationController().goBack(); } }); } @@ -47,7 +47,7 @@ public class NavigationTest extends ContentShellTestBase { new Runnable() { @Override public void run() { - contentViewCore.reload(true); + contentViewCore.getWebContents().getNavigationController().reload(true); } }); } @@ -68,26 +68,30 @@ public class NavigationTest extends ContentShellTestBase { loadUrl(contentViewCore, testCallbackHelperContainer, new LoadUrlParams(URL_6)); loadUrl(contentViewCore, testCallbackHelperContainer, new LoadUrlParams(URL_7)); - NavigationHistory history = contentViewCore.getDirectedNavigationHistory(false, 3); + NavigationHistory history = contentViewCore.getWebContents().getNavigationController() + .getDirectedNavigationHistory(false, 3); assertEquals(3, history.getEntryCount()); assertEquals(URL_6, history.getEntryAtIndex(0).getUrl()); assertEquals(URL_5, history.getEntryAtIndex(1).getUrl()); assertEquals(URL_4, history.getEntryAtIndex(2).getUrl()); - history = contentViewCore.getDirectedNavigationHistory(true, 3); + history = contentViewCore.getWebContents().getNavigationController() + .getDirectedNavigationHistory(true, 3); assertEquals(history.getEntryCount(), 0); goBack(contentViewCore, testCallbackHelperContainer); goBack(contentViewCore, testCallbackHelperContainer); goBack(contentViewCore, testCallbackHelperContainer); - history = contentViewCore.getDirectedNavigationHistory(false, 4); + history = contentViewCore.getWebContents().getNavigationController() + .getDirectedNavigationHistory(false, 4); assertEquals(3, history.getEntryCount()); assertEquals(URL_3, history.getEntryAtIndex(0).getUrl()); assertEquals(URL_2, history.getEntryAtIndex(1).getUrl()); assertEquals(URL_1, history.getEntryAtIndex(2).getUrl()); - history = contentViewCore.getDirectedNavigationHistory(true, 4); + history = contentViewCore.getWebContents().getNavigationController() + .getDirectedNavigationHistory(true, 4); assertEquals(3, history.getEntryCount()); assertEquals(URL_5, history.getEntryAtIndex(0).getUrl()); assertEquals(URL_6, history.getEntryAtIndex(1).getUrl()); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java b/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java index c6dab26..e5084a3 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java @@ -67,7 +67,8 @@ public class WebContentsObserverAndroidTest extends ContentShellTestBase { getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { - getContentViewCore().loadUrl(new LoadUrlParams(URL)); + getContentViewCore().getWebContents().getNavigationController() + .loadUrl(new LoadUrlParams(URL)); } }); observer.getDidFirstVisuallyNonEmptyPaintCallbackHelper().waitForCallback(callCount); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/SelectPopupTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/SelectPopupTest.java index 9fd40c40..f8d8b0f 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/input/SelectPopupTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/input/SelectPopupTest.java @@ -20,6 +20,9 @@ import org.chromium.content_shell_apk.ContentShellTestBase; import java.util.concurrent.TimeUnit; +/** + * Integration Tests for SelectPopup. + */ public class SelectPopupTest extends ContentShellTestBase { private static final long WAIT_TIMEOUT_SECONDS = scaleTimeout(2); private static final String SELECT_URL = UrlUtils.encodeHtmlDataUri( @@ -87,7 +90,7 @@ public class SelectPopupTest extends ContentShellTestBase { @Override public void run() { // Now reload the page while the popup is showing, it gets hidden. - getContentViewCore().reload(true); + getContentViewCore().getWebContents().getNavigationController().reload(true); } }); onPageFinishedHelper.waitForCallback(currentCallCount, 1, diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java index 7fe25689..36c7831 100644 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java @@ -9,7 +9,7 @@ import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; import android.app.Instrumentation; import org.chromium.base.test.util.InstrumentationUtils; -import org.chromium.content.browser.ContentViewCore; +import org.chromium.content_public.browser.WebContents; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -31,12 +31,12 @@ public class HistoryUtils { * @throws Throwable */ public static boolean canGoBackOnUiThread(Instrumentation instrumentation, - final ContentViewCore contentViewCore) throws Throwable { + final WebContents webContents) throws Throwable { return InstrumentationUtils.runOnMainSyncAndGetResult( instrumentation, new Callable() { @Override public Boolean call() { - return contentViewCore.canGoBack(); + return webContents.getNavigationController().canGoBack(); } }); } @@ -52,12 +52,12 @@ public class HistoryUtils { * @throws Throwable */ public static boolean canGoToOffsetOnUiThread(Instrumentation instrumentation, - final ContentViewCore contentViewCore, final int offset) throws Throwable { + final WebContents webContents, final int offset) throws Throwable { return InstrumentationUtils.runOnMainSyncAndGetResult( instrumentation, new Callable() { @Override public Boolean call() throws Exception { - return contentViewCore.canGoToOffset(offset); + return webContents.getNavigationController().canGoToOffset(offset); } }); } @@ -71,12 +71,12 @@ public class HistoryUtils { * @throws Throwable */ public static boolean canGoForwardOnUiThread(Instrumentation instrumentation, - final ContentViewCore contentViewCore) throws Throwable { + final WebContents webContents) throws Throwable { return InstrumentationUtils.runOnMainSyncAndGetResult( instrumentation, new Callable() { @Override public Boolean call() { - return contentViewCore.canGoForward(); + return webContents.getNavigationController().canGoForward(); } }); } @@ -89,11 +89,11 @@ public class HistoryUtils { * @throws Throwable */ public static void clearHistoryOnUiThread(Instrumentation instrumentation, - final ContentViewCore contentViewCore) throws Throwable { + final WebContents webContents) throws Throwable { instrumentation.runOnMainSync(new Runnable() { @Override public void run() { - contentViewCore.clearHistory(); + webContents.getNavigationController().clearHistory(); } }); } @@ -107,12 +107,12 @@ public class HistoryUtils { * @throws Throwable */ public static String getUrlOnUiThread(Instrumentation instrumentation, - final ContentViewCore contentViewCore) throws Throwable { + final WebContents webContents) throws Throwable { return InstrumentationUtils.runOnMainSyncAndGetResult( instrumentation, new Callable() { @Override public String call() throws Exception { - return contentViewCore.getUrl(); + return webContents.getUrl(); } }); } @@ -129,13 +129,13 @@ public class HistoryUtils { * @throws Throwable */ public static void goToOffsetSync(Instrumentation instrumentation, - final ContentViewCore contentViewCore, CallbackHelper onPageFinishedHelper, + final WebContents webContents, CallbackHelper onPageFinishedHelper, final int offset) throws Throwable { int currentCallCount = onPageFinishedHelper.getCallCount(); instrumentation.runOnMainSync(new Runnable() { @Override public void run() { - contentViewCore.goToOffset(offset); + webContents.getNavigationController().goToOffset(offset); } }); @@ -154,13 +154,13 @@ public class HistoryUtils { * @throws Throwable */ public static void goBackSync(Instrumentation instrumentation, - final ContentViewCore contentViewCore, + final WebContents webContents, CallbackHelper onPageFinishedHelper) throws Throwable { int currentCallCount = onPageFinishedHelper.getCallCount(); instrumentation.runOnMainSync(new Runnable() { @Override public void run() { - contentViewCore.goBack(); + webContents.getNavigationController().goBack(); } }); @@ -177,13 +177,13 @@ public class HistoryUtils { * @throws Throwable */ public static void goForwardSync(Instrumentation instrumentation, - final ContentViewCore contentViewCore, + final WebContents webContents, CallbackHelper onPageFinishedHelper) throws Throwable { int currentCallCount = onPageFinishedHelper.getCallCount(); instrumentation.runOnMainSync(new Runnable() { @Override public void run() { - contentViewCore.goForward(); + webContents.getNavigationController().goForward(); } }); diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java index 5940b5b..85190a3 100644 --- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java +++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java @@ -27,6 +27,8 @@ import org.chromium.content.browser.ContentViewClient; import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewRenderView; import org.chromium.content_public.browser.LoadUrlParams; +import org.chromium.content_public.browser.NavigationController; +import org.chromium.content_public.browser.WebContents; import org.chromium.ui.base.WindowAndroid; /** @@ -45,6 +47,8 @@ public class Shell extends LinearLayout { }; private ContentViewCore mContentViewCore; + private WebContents mWebContents; + private NavigationController mNavigationController; private ContentViewClient mContentViewClient; private EditText mUrlTextView; private ImageButton mPrevButton; @@ -162,7 +166,7 @@ public class Shell extends LinearLayout { mNextButton.setVisibility(hasFocus ? GONE : VISIBLE); mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE); if (!hasFocus) { - mUrlTextView.setText(mContentViewCore.getUrl()); + mUrlTextView.setText(mWebContents.getUrl()); } } }); @@ -187,10 +191,10 @@ public class Shell extends LinearLayout { public void loadUrl(String url) { if (url == null) return; - if (TextUtils.equals(url, mContentViewCore.getUrl())) { - mContentViewCore.reload(true); + if (TextUtils.equals(url, mWebContents.getUrl())) { + mNavigationController.reload(true); } else { - mContentViewCore.loadUrl(new LoadUrlParams(sanitizeUrl(url))); + mNavigationController.loadUrl(new LoadUrlParams(sanitizeUrl(url))); } mUrlTextView.clearFocus(); // TODO(aurimas): Remove this when crbug.com/174541 is fixed. @@ -214,7 +218,7 @@ public class Shell extends LinearLayout { mPrevButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - if (mContentViewCore.canGoBack()) mContentViewCore.goBack(); + if (mNavigationController.canGoBack()) mNavigationController.goBack(); } }); @@ -222,21 +226,21 @@ public class Shell extends LinearLayout { mNextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - if (mContentViewCore.canGoForward()) mContentViewCore.goForward(); + if (mNavigationController.canGoForward()) mNavigationController.goForward(); } }); mStopButton = (ImageButton)findViewById(R.id.stop); mStopButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - if (mLoading) mContentViewCore.stopLoading(); + if (mLoading) mWebContents.stop(); } }); mReloadButton = (ImageButton)findViewById(R.id.reload); mReloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - mContentViewCore.reload(true); + mNavigationController.reload(true); } }); } @@ -282,9 +286,12 @@ public class Shell extends LinearLayout { ContentView cv = ContentView.newInstance(context, mContentViewCore); mContentViewCore.initialize(cv, cv, nativeWebContents, mWindow); mContentViewCore.setContentViewClient(mContentViewClient); - + mWebContents = mContentViewCore.getWebContents(); + mNavigationController = mWebContents.getNavigationController(); if (getParent() != null) mContentViewCore.onShow(); - if (mContentViewCore.getUrl() != null) mUrlTextView.setText(mContentViewCore.getUrl()); + if (mWebContents.getUrl() != null) { + mUrlTextView.setText(mWebContents.getUrl()); + } ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, diff --git a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellShellManagementTest.java b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellShellManagementTest.java index ddeac73..a1ef292 100644 --- a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellShellManagementTest.java +++ b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellShellManagementTest.java @@ -25,7 +25,8 @@ public class ContentShellShellManagementTest extends ContentShellTestBase { @Feature({"Main"}) public void testMultipleShellsLaunched() throws InterruptedException { final ContentShellActivity activity = launchContentShellWithUrl(TEST_PAGE_1); - assertEquals(TEST_PAGE_1, activity.getActiveShell().getContentViewCore().getUrl()); + assertEquals(TEST_PAGE_1, activity.getActiveShell().getContentViewCore() + .getWebContents().getUrl()); Shell previousActiveShell = activity.getActiveShell(); assertFalse(previousActiveShell.isDestroyed()); @@ -37,7 +38,8 @@ public class ContentShellShellManagementTest extends ContentShellTestBase { } }); waitForActiveShellToBeDoneLoading(); - assertEquals(TEST_PAGE_2, activity.getActiveShell().getContentViewCore().getUrl()); + assertEquals(TEST_PAGE_2, activity.getActiveShell().getContentViewCore() + .getWebContents().getUrl()); assertNotSame(previousActiveShell, activity.getActiveShell()); assertTrue(previousActiveShell.isDestroyed()); diff --git a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java index 4ba3cc9..186f77a 100644 --- a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java +++ b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java @@ -86,7 +86,7 @@ public class ContentShellTestBase extends ActivityInstrumentationTestCase2 Date: Sat, 13 Sep 2014 07:53:57 -0700 Subject: Remove the use of ProvisionalChangeToMainFrameUrl from supervised user code. BUG=78512 TEST=no change Review URL: https://codereview.chromium.org/568163004 Cr-Commit-Position: refs/heads/master@{#294747} --- .../supervised_user_navigation_observer.cc | 18 ++++-------------- .../supervised_user_navigation_observer.h | 3 --- content/public/browser/web_contents_observer.h | 10 +++++++++- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/chrome/browser/supervised_user/supervised_user_navigation_observer.cc b/chrome/browser/supervised_user/supervised_user_navigation_observer.cc index 1e186b6..6a8c34f 100644 --- a/chrome/browser/supervised_user/supervised_user_navigation_observer.cc +++ b/chrome/browser/supervised_user/supervised_user_navigation_observer.cc @@ -178,20 +178,6 @@ void SupervisedUserNavigationObserver::WarnInfoBarDismissed() { warn_infobar_ = NULL; } -void SupervisedUserNavigationObserver::ProvisionalChangeToMainFrameUrl( - const GURL& url, - content::RenderFrameHost* render_frame_host) { - SupervisedUserURLFilter::FilteringBehavior behavior = - url_filter_->GetFilteringBehaviorForURL(url); - - if (behavior == SupervisedUserURLFilter::WARN || !warn_infobar_) - return; - - // If we shouldn't have a warn infobar remove it here. - InfoBarService::FromWebContents(web_contents())->RemoveInfoBar(warn_infobar_); - warn_infobar_ = NULL; -} - void SupervisedUserNavigationObserver::DidCommitProvisionalLoadForFrame( content::RenderFrameHost* render_frame_host, const GURL& url, @@ -206,6 +192,10 @@ void SupervisedUserNavigationObserver::DidCommitProvisionalLoadForFrame( if (behavior == SupervisedUserURLFilter::WARN && !warn_infobar_) { warn_infobar_ = SupervisedUserWarningInfoBarDelegate::Create( InfoBarService::FromWebContents(web_contents())); + } else if (behavior != SupervisedUserURLFilter::WARN && warn_infobar_) { + InfoBarService::FromWebContents(web_contents())-> + RemoveInfoBar(warn_infobar_); + warn_infobar_ = NULL; } } diff --git a/chrome/browser/supervised_user/supervised_user_navigation_observer.h b/chrome/browser/supervised_user/supervised_user_navigation_observer.h index 89307f0..a78c19c 100644 --- a/chrome/browser/supervised_user/supervised_user_navigation_observer.h +++ b/chrome/browser/supervised_user/supervised_user_navigation_observer.h @@ -51,9 +51,6 @@ class SupervisedUserNavigationObserver explicit SupervisedUserNavigationObserver(content::WebContents* web_contents); // content::WebContentsObserver implementation. - virtual void ProvisionalChangeToMainFrameUrl( - const GURL& url, - content::RenderFrameHost* render_frame_host) OVERRIDE; virtual void DidCommitProvisionalLoadForFrame( content::RenderFrameHost* render_frame_host, const GURL& url, diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h index 65bddd9..846bf94 100644 --- a/content/public/browser/web_contents_observer.h +++ b/content/public/browser/web_contents_observer.h @@ -131,8 +131,16 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, // This method is invoked right after the DidStartProvisionalLoadForFrame if // the provisional load affects the main frame, or if the provisional load - // was redirected. The latter use case is DEPRECATED. You should listen to + // was redirected. + // + // The latter use case is DEPRECATED. You should listen to // WebContentsObserver::DidGetRedirectForResourceRequest instead. + // + // The former use case is redundant; you should use + // DidStartProvisionalLoadForFrame instead, and do a check for the main frame. + // + // As a result, this whole callback is silly and DEPRECATED. Do not use it. + // http://crbug.com/78512 virtual void ProvisionalChangeToMainFrameUrl( const GURL& url, RenderFrameHost* render_frame_host) {} -- cgit v1.1 From 208d24bdad387f8496f05012a026bcc8d561de86 Mon Sep 17 00:00:00 2001 From: loislo Date: Sat, 13 Sep 2014 08:10:33 -0700 Subject: Manual blink roll to 181953 BUG= TBR= jianli@chromium.org Review URL: https://codereview.chromium.org/571553004 Cr-Commit-Position: refs/heads/master@{#294748} --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 6e38b3b..617d8cb6f 100644 --- a/DEPS +++ b/DEPS @@ -27,7 +27,7 @@ vars = { 'libcxx_revision': '48198f9110397fff47fe7c37cbfa296be7d44d3d', 'libcxxabi_revision': '4ad1009ab3a59fa7a6896d74d5e4de5885697f95', 'webkit_trunk': 'http://src.chromium.org/blink/trunk', - 'webkit_revision': 'a11635f657e0f1ce75179fd7336a309a604ff847', # from svn revision 181849 + 'webkit_revision': '9cb8a59cf2f63b817c4c4929dd0ba33b4c2ee7e1', # from svn revision 181953 'chromium_git': 'https://chromium.googlesource.com', 'chromiumos_git': 'https://chromium.googlesource.com/chromiumos', 'pdfium_git': 'https://pdfium.googlesource.com', -- cgit v1.1 From 66133e86b6d79534605539aa684a248e6b6205bf Mon Sep 17 00:00:00 2001 From: vollick Date: Sat, 13 Sep 2014 13:36:44 -0700 Subject: Fix RemoveFromScrollTree and RemoveFromClipTree These functions should set needs commit, but didn't. This lead to stale pointers in the impl tree. BUG=413743,403866 Review URL: https://codereview.chromium.org/572483002 Cr-Commit-Position: refs/heads/master@{#294749} --- cc/layers/layer.cc | 30 ++++++++++------------ cc/layers/layer.h | 16 ++++++------ cc/layers/layer_unittest.cc | 58 +++++++++++++++++++++++++++++++++++++++++++ cc/trees/tree_synchronizer.cc | 22 ++++++++++------ 4 files changed, 93 insertions(+), 33 deletions(-) diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 63b9990..1a22d92 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -91,6 +91,9 @@ Layer::~Layer() { layer_animation_controller_->RemoveValueObserver(this); layer_animation_controller_->remove_value_provider(this); + RemoveFromScrollTree(); + RemoveFromClipTree(); + // Remove the parent reference from all children and dependents. RemoveAllChildren(); if (mask_layer_.get()) { @@ -101,9 +104,6 @@ Layer::~Layer() { DCHECK_EQ(this, replica_layer_->parent()); replica_layer_->RemoveFromParent(); } - - RemoveFromScrollTree(); - RemoveFromClipTree(); } void Layer::SetLayerTreeHost(LayerTreeHost* host) { @@ -1200,28 +1200,24 @@ bool Layer::SupportsLCDText() const { void Layer::RemoveFromScrollTree() { if (scroll_children_.get()) { - for (std::set::iterator it = scroll_children_->begin(); - it != scroll_children_->end(); ++it) - (*it)->scroll_parent_ = NULL; + std::set copy = *scroll_children_; + for (std::set::iterator it = copy.begin(); it != copy.end(); ++it) + (*it)->SetScrollParent(NULL); } - if (scroll_parent_) - scroll_parent_->RemoveScrollChild(this); - - scroll_parent_ = NULL; + DCHECK(!scroll_children_); + SetScrollParent(NULL); } void Layer::RemoveFromClipTree() { if (clip_children_.get()) { - for (std::set::iterator it = clip_children_->begin(); - it != clip_children_->end(); ++it) - (*it)->clip_parent_ = NULL; + std::set copy = *clip_children_; + for (std::set::iterator it = copy.begin(); it != copy.end(); ++it) + (*it)->SetClipParent(NULL); } - if (clip_parent_) - clip_parent_->RemoveClipChild(this); - - clip_parent_ = NULL; + DCHECK(!clip_children_); + SetClipParent(NULL); } void Layer::AddDrawableDescendants(int num) { diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 61ef3f8..3452e8b 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -504,14 +504,6 @@ class CC_EXPORT Layer : public base::RefCounted, bool IsPropertyChangeAllowed() const; - // If this layer has a scroll parent, it removes |this| from its list of - // scroll children. - void RemoveFromScrollTree(); - - // If this layer has a clip parent, it removes |this| from its list of clip - // children. - void RemoveFromClipTree(); - void reset_raster_scale_to_unknown() { raster_scale_ = 0.f; } // This flag is set when the layer needs to push properties to the impl @@ -571,6 +563,14 @@ class CC_EXPORT Layer : public base::RefCounted, virtual void OnAnimationWaitingForDeletion() OVERRIDE; virtual bool IsActive() const OVERRIDE; + // If this layer has a scroll parent, it removes |this| from its list of + // scroll children. + void RemoveFromScrollTree(); + + // If this layer has a clip parent, it removes |this| from its list of clip + // children. + void RemoveFromClipTree(); + LayerList children_; Layer* parent_; diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index 7a1cb79..bab6d5c 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -336,6 +336,64 @@ TEST_F(LayerTest, ReplaceChildWithNewChildThatHasOtherParent) { EXPECT_FALSE(child2_->parent()); } +TEST_F(LayerTest, DeleteRemovedScrollParent) { + scoped_refptr parent = Layer::Create(); + scoped_refptr child1 = Layer::Create(); + scoped_refptr child2 = Layer::Create(); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); + + ASSERT_EQ(0U, parent->children().size()); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); + + ASSERT_EQ(2U, parent->children().size()); + EXPECT_EQ(child1, parent->children()[0]); + EXPECT_EQ(child2, parent->children()[1]); + + EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); + + child1->reset_needs_push_properties_for_testing(); + + EXPECT_SET_NEEDS_COMMIT(1, child2 = NULL); + + EXPECT_TRUE(child1->needs_push_properties()); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(NULL)); +} + +TEST_F(LayerTest, DeleteRemovedScrollChild) { + scoped_refptr parent = Layer::Create(); + scoped_refptr child1 = Layer::Create(); + scoped_refptr child2 = Layer::Create(); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); + + ASSERT_EQ(0U, parent->children().size()); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); + + ASSERT_EQ(2U, parent->children().size()); + EXPECT_EQ(child1, parent->children()[0]); + EXPECT_EQ(child2, parent->children()[1]); + + EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); + + child2->reset_needs_push_properties_for_testing(); + + EXPECT_SET_NEEDS_COMMIT(1, child1 = NULL); + + EXPECT_TRUE(child2->needs_push_properties()); + + EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(NULL)); +} + TEST_F(LayerTest, ReplaceChildWithSameChild) { CreateSimpleTestTree(); diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc index a54bd22..1faf0e0 100644 --- a/cc/trees/tree_synchronizer.cc +++ b/cc/trees/tree_synchronizer.cc @@ -242,16 +242,23 @@ static void CheckScrollAndClipPointersRecursive(Layer* layer, if (!layer) return; - DCHECK_EQ(!!layer->scroll_parent(), !!layer_impl->scroll_parent()); - if (layer->scroll_parent()) + // Having a scroll parent on the impl thread implies having one the main + // thread, too. The main thread may have a scroll parent that is not in the + // tree because it's been removed but not deleted. In this case, the layer + // impl will have no scroll parent. Same argument applies for clip parents and + // scroll/clip children. + DCHECK(!layer_impl->scroll_parent() || !!layer->scroll_parent()); + DCHECK(!layer_impl->clip_parent() || !!layer->clip_parent()); + DCHECK(!layer_impl->scroll_children() || !!layer->scroll_children()); + DCHECK(!layer_impl->clip_children() || !!layer->clip_children()); + + if (layer_impl->scroll_parent()) DCHECK_EQ(layer->scroll_parent()->id(), layer_impl->scroll_parent()->id()); - DCHECK_EQ(!!layer->clip_parent(), !!layer_impl->clip_parent()); - if (layer->clip_parent()) + if (layer_impl->clip_parent()) DCHECK_EQ(layer->clip_parent()->id(), layer_impl->clip_parent()->id()); - DCHECK_EQ(!!layer->scroll_children(), !!layer_impl->scroll_children()); - if (layer->scroll_children()) { + if (layer_impl->scroll_children()) { for (std::set::iterator it = layer->scroll_children()->begin(); it != layer->scroll_children()->end(); ++it) { @@ -265,8 +272,7 @@ static void CheckScrollAndClipPointersRecursive(Layer* layer, } } - DCHECK_EQ(!!layer->clip_children(), !!layer_impl->clip_children()); - if (layer->clip_children()) { + if (layer_impl->clip_children()) { for (std::set::iterator it = layer->clip_children()->begin(); it != layer->clip_children()->end(); ++it) { -- cgit v1.1 From 812c3481b5745d1169dcead897796fe13eead4ca Mon Sep 17 00:00:00 2001 From: noel Date: Sat, 13 Sep 2014 13:38:41 -0700 Subject: Roll libjpeg_turbo to r291962 (git 034e9a9747e0). [MIPS64] Add build support for MIPS64 in libjpeg_turbo https://chromium.googlesource.com/chromium/deps/libjpeg_turbo/+log/3963fbcd6c16..034e9a9747e0 TBR=rmcilroy@chromium.org BUG=400684 Review URL: https://codereview.chromium.org/559963004 Cr-Commit-Position: refs/heads/master@{#294750} --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 617d8cb6f..8a8e542 100644 --- a/DEPS +++ b/DEPS @@ -221,7 +221,7 @@ deps = { Var('chromium_git') + '/chromium/deps/yasm/patched-yasm.git' + '@' + 'c960eb11ccda80b10ed50be39df4f0663b371d1d', 'src/third_party/libjpeg_turbo': - Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + '3963fbcd6c16965948a9c081c6e9dce82a938dad', # from svn revision 291801 + Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + '034e9a9747e0983bc19808ea70e469bc8342081f', 'src/third_party/flac': Var('chromium_git') + '/chromium/deps/flac.git' + '@' + '0635a091379d9677f1ddde5f2eec85d0f096f219', -- cgit v1.1 From 3f43ba638732da04c922605827ad3e7e603d41e0 Mon Sep 17 00:00:00 2001 From: jln Date: Sat, 13 Sep 2014 13:39:49 -0700 Subject: Linux sandbox: restrict clock_gettime() and clock_getres() In the baseline policy, we restrict the |clk_id| parameter allowed in clock_gettime(). This applies to all sandboxed process types. In the renderer policy, we similarly restrict the |clk_id| parameter for clock_getres(). BUG=413469, 413855 Review URL: https://codereview.chromium.org/566083002 Cr-Commit-Position: refs/heads/master@{#294751} --- content/common/sandbox_linux/bpf_renderer_policy_linux.cc | 7 ++++--- sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc | 4 ++++ sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc | 9 +++++++++ sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/content/common/sandbox_linux/bpf_renderer_policy_linux.cc b/content/common/sandbox_linux/bpf_renderer_policy_linux.cc index 1e279e8..503a9b6 100644 --- a/content/common/sandbox_linux/bpf_renderer_policy_linux.cc +++ b/content/common/sandbox_linux/bpf_renderer_policy_linux.cc @@ -26,12 +26,13 @@ RendererProcessPolicy::~RendererProcessPolicy() {} ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { switch (sysno) { - case __NR_ioctl: - return sandbox::RestrictIoctl(); - // Allow the system calls below. // The baseline policy allows __NR_clock_gettime. Allow // clock_getres() for V8. crbug.com/329053. case __NR_clock_getres: + return sandbox::RestrictClockID(); + case __NR_ioctl: + return sandbox::RestrictIoctl(); + // Allow the system calls below. case __NR_fdatasync: case __NR_fsync: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) diff --git a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc index 45de129..eb2a307 100644 --- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc @@ -126,6 +126,10 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, return Allow(); #endif + if (sysno == __NR_clock_gettime) { + return RestrictClockID(); + } + if (sysno == __NR_clone) { return RestrictCloneToThreadsAndEPERMFork(); } diff --git a/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc b/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc index f55df03..98548568 100644 --- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc +++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "base/files/scoped_file.h" @@ -336,6 +337,14 @@ BPF_DEATH_TEST_C(BaselinePolicy, _exit(1); } +BPF_DEATH_TEST_C(BaselinePolicy, + ClockGettimeWithDisallowedClockCrashes, + DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), + BaselinePolicy) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); +} + } // namespace } // namespace sandbox diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc index c0a720a3..de6ba24 100644 --- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc @@ -27,7 +27,6 @@ bool SyscallSets::IsKill(int sysno) { bool SyscallSets::IsAllowedGettime(int sysno) { switch (sysno) { - case __NR_clock_gettime: case __NR_gettimeofday: #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) case __NR_time: @@ -36,6 +35,7 @@ bool SyscallSets::IsAllowedGettime(int sysno) { case __NR_adjtimex: // Privileged. case __NR_clock_adjtime: // Privileged. case __NR_clock_getres: // Could be allowed. + case __NR_clock_gettime: case __NR_clock_nanosleep: // Could be allowed. case __NR_clock_settime: // Privileged. #if defined(__i386__) || defined(__mips__) -- cgit v1.1 From f69b019f961526cbef468814597c9d10d8237bab Mon Sep 17 00:00:00 2001 From: sergeyu Date: Sat, 13 Sep 2014 13:41:02 -0700 Subject: Remove legacy version of the control channel protocol. All current versions of host and client support capabilities, we no longer need to keep support for older versions. Review URL: https://codereview.chromium.org/565263006 Cr-Commit-Position: refs/heads/master@{#294752} --- remoting/client/chromoting_client.cc | 18 ++++-------------- remoting/host/client_session.cc | 31 ++++++++----------------------- remoting/protocol/session_config.cc | 11 ----------- remoting/protocol/session_config.h | 3 --- 4 files changed, 12 insertions(+), 51 deletions(-) diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 590902a..2270796 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -151,27 +151,17 @@ void ChromotingClient::OnAuthenticated() { if (connection_.config().is_audio_enabled()) audio_decode_scheduler_->Initialize(connection_.config()); - // Do not negotiate capabilities with the host if the host does not support - // them. - if (!connection_.config().SupportsCapabilities()) { - VLOG(1) << "The host does not support any capabilities."; - - host_capabilities_received_ = true; - user_interface_->SetCapabilities(host_capabilities_); - } } void ChromotingClient::OnChannelsConnected() { DCHECK(task_runner_->BelongsToCurrentThread()); // Negotiate capabilities with the host. - if (connection_.config().SupportsCapabilities()) { - VLOG(1) << "Client capabilities: " << local_capabilities_; + VLOG(1) << "Client capabilities: " << local_capabilities_; - protocol::Capabilities capabilities; - capabilities.set_capabilities(local_capabilities_); - connection_.host_stub()->SetCapabilities(capabilities); - } + protocol::Capabilities capabilities; + capabilities.set_capabilities(local_capabilities_); + connection_.host_stub()->SetCapabilities(capabilities); } } // namespace remoting diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index e594b10..3fcfeb3 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -176,13 +176,6 @@ void ClientSession::SetCapabilities( const protocol::Capabilities& capabilities) { DCHECK(CalledOnValidThread()); - // The client should not send protocol::Capabilities if it is not supported by - // the config channel. - if (!connection_->session()->config().SupportsCapabilities()) { - LOG(ERROR) << "Unexpected protocol::Capabilities has been received."; - return; - } - // Ignore all the messages but the 1st one. if (client_capabilities_) { LOG(WARNING) << "protocol::Capabilities has been received already."; @@ -288,16 +281,10 @@ void ClientSession::OnConnectionAuthenticated( } // Collate the set of capabilities to offer the client, if it supports them. - if (connection_->session()->config().SupportsCapabilities()) { - host_capabilities_ = desktop_environment_->GetCapabilities(); - if (!host_capabilities_.empty()) { - host_capabilities_.append(" "); - } - host_capabilities_.append(extension_manager_->GetCapabilities()); - } else { - VLOG(1) << "The client does not support any capabilities."; - desktop_environment_->SetCapabilities(std::string()); - } + host_capabilities_ = desktop_environment_->GetCapabilities(); + if (!host_capabilities_.empty()) + host_capabilities_.append(" "); + host_capabilities_.append(extension_manager_->GetCapabilities()); // Create the object that controls the screen resolution. screen_controls_ = desktop_environment_->CreateScreenControls(); @@ -332,13 +319,11 @@ void ClientSession::OnConnectionChannelsConnected( DCHECK_EQ(connection_.get(), connection); // Negotiate capabilities with the client. - if (connection_->session()->config().SupportsCapabilities()) { - VLOG(1) << "Host capabilities: " << host_capabilities_; + VLOG(1) << "Host capabilities: " << host_capabilities_; - protocol::Capabilities capabilities; - capabilities.set_capabilities(host_capabilities_); - connection_->client_stub()->SetCapabilities(capabilities); - } + protocol::Capabilities capabilities; + capabilities.set_capabilities(host_capabilities_); + connection_->client_stub()->SetCapabilities(capabilities); // Start the event executor. input_injector_->Start(CreateClipboardProxy()); diff --git a/remoting/protocol/session_config.cc b/remoting/protocol/session_config.cc index 3f2c911..0693627 100644 --- a/remoting/protocol/session_config.cc +++ b/remoting/protocol/session_config.cc @@ -10,10 +10,7 @@ namespace remoting { namespace protocol { const int kDefaultStreamVersion = 2; - -// The control channel version that supports the "capabilities" message. const int kControlStreamVersion = 3; -const int kControlStreamVersionNoCapabilities = kDefaultStreamVersion; ChannelConfig ChannelConfig::None() { return ChannelConfig(); @@ -41,10 +38,6 @@ bool ChannelConfig::operator==(const ChannelConfig& b) const { SessionConfig::SessionConfig() { } -bool SessionConfig::SupportsCapabilities() const { - return control_config_.version >= kControlStreamVersion; -} - // static SessionConfig SessionConfig::ForTest() { SessionConfig result; @@ -180,10 +173,6 @@ scoped_ptr CandidateSessionConfig::CreateDefault() { ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, kControlStreamVersion, ChannelConfig::CODEC_UNDEFINED)); - result->mutable_control_configs()->push_back( - ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, - kControlStreamVersionNoCapabilities, - ChannelConfig::CODEC_UNDEFINED)); // Event channel. result->mutable_event_configs()->push_back( diff --git a/remoting/protocol/session_config.h b/remoting/protocol/session_config.h index ae1ab5e..4246228 100644 --- a/remoting/protocol/session_config.h +++ b/remoting/protocol/session_config.h @@ -83,9 +83,6 @@ class SessionConfig { return audio_config_.transport != ChannelConfig::TRANSPORT_NONE; } - // Returns true if the control channel supports capabilities. - bool SupportsCapabilities() const; - // Returns a suitable session configuration for use in tests. static SessionConfig ForTest(); -- cgit v1.1 From a541363f90b8e9f0732db9f7e6f4d842cdc53c13 Mon Sep 17 00:00:00 2001 From: blink-deps-roller Date: Sat, 13 Sep 2014 13:43:21 -0700 Subject: Blink roll 9cb8a59:1c10331 (svn 181953:181956) https://chromium.googlesource.com/chromium/blink/+log/9cb8a59cf2f63b817c4c4929dd0ba33b4c2ee7e1..1c10331d9ed2cb8073d44563b1c6e243971b7557 TBR= Review URL: https://codereview.chromium.org/573533002 Cr-Commit-Position: refs/heads/master@{#294753} --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 8a8e542..0ec28bb 100644 --- a/DEPS +++ b/DEPS @@ -27,7 +27,7 @@ vars = { 'libcxx_revision': '48198f9110397fff47fe7c37cbfa296be7d44d3d', 'libcxxabi_revision': '4ad1009ab3a59fa7a6896d74d5e4de5885697f95', 'webkit_trunk': 'http://src.chromium.org/blink/trunk', - 'webkit_revision': '9cb8a59cf2f63b817c4c4929dd0ba33b4c2ee7e1', # from svn revision 181953 + 'webkit_revision': '1c10331d9ed2cb8073d44563b1c6e243971b7557', # from svn revision 181956 'chromium_git': 'https://chromium.googlesource.com', 'chromiumos_git': 'https://chromium.googlesource.com/chromiumos', 'pdfium_git': 'https://pdfium.googlesource.com', -- cgit v1.1 From 6967652cefa1e306d21e70d4a12dcc0ac572c28b Mon Sep 17 00:00:00 2001 From: jianli Date: Sat, 13 Sep 2014 13:45:41 -0700 Subject: Clear GCM data when the user clears cookies and other site data This is needed for the work to drop GCM sign-in enforcement. Since we no longer wipe out the GCM data when the user signs out, we need to give user a chance to clear the data if he or she wants. BUG=384041 TEST=Manual test by selecting "Cookies and other site and plugin data" Review URL: https://codereview.chromium.org/562423002 Cr-Commit-Position: refs/heads/master@{#294754} --- .../browser/browsing_data/browsing_data_remover.cc | 12 ++++++++++++ chrome/browser/browsing_data/browsing_data_remover.h | 6 ++++++ .../api/browsing_data/browsing_data_test.cc | 20 +++++++++++--------- chrome/browser/services/gcm/gcm_profile_service.cc | 8 +++++--- components/gcm_driver/fake_gcm_driver.cc | 3 +++ components/gcm_driver/fake_gcm_driver.h | 1 + components/gcm_driver/gcm_driver.h | 4 ++-- components/gcm_driver/gcm_driver_android.cc | 3 +++ components/gcm_driver/gcm_driver_android.h | 1 + components/gcm_driver/gcm_driver_desktop.cc | 14 +++++++++----- components/gcm_driver/gcm_driver_desktop.h | 1 + components/gcm_driver/gcm_driver_desktop_unittest.cc | 15 ++++++++++++++- 12 files changed, 68 insertions(+), 20 deletions(-) diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc index 401a6334..a38415b 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.cc +++ b/chrome/browser/browsing_data/browsing_data_remover.cc @@ -35,6 +35,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" +#include "chrome/browser/services/gcm/gcm_profile_service.h" +#include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/tab_restore_service.h" @@ -45,6 +47,7 @@ #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/domain_reliability/service.h" +#include "components/gcm_driver/gcm_driver.h" #include "components/nacl/browser/nacl_browser.h" #include "components/nacl/browser/pnacl_host.h" #include "components/password_manager/core/browser/password_store.h" @@ -532,6 +535,15 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask, } #endif +#if !defined(OS_ANDROID) + if (remove_mask & REMOVE_GCM) { + gcm::GCMProfileService* gcm_profile_service = + gcm::GCMProfileServiceFactory::GetForProfile(profile_); + if (gcm_profile_service) + gcm_profile_service->driver()->Purge(); + } +#endif + if (remove_mask & REMOVE_PASSWORDS) { content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); password_manager::PasswordStore* password_store = diff --git a/chrome/browser/browsing_data/browsing_data_remover.h b/chrome/browser/browsing_data/browsing_data_remover.h index 7a2b063..3871455 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.h +++ b/chrome/browser/browsing_data/browsing_data_remover.h @@ -93,6 +93,9 @@ class BrowsingDataRemover #if defined(OS_ANDROID) REMOVE_APP_BANNER_DATA = 1 << 15, #endif +#if !defined(OS_ANDROID) + REMOVE_GCM = 1 << 16, +#endif // The following flag is used only in tests. In normal usage, hosted app // data is controlled by the REMOVE_COOKIES flag, applied to the // protected-web origin. @@ -109,6 +112,9 @@ class BrowsingDataRemover #if defined(OS_ANDROID) REMOVE_APP_BANNER_DATA | #endif +#if !defined(OS_ANDROID) + REMOVE_GCM | +#endif REMOVE_CHANNEL_IDS, // Includes all the available remove options. Meant to be used by clients diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc index 5d017ea..43e0e1f 100644 --- a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc @@ -496,39 +496,41 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSimple) { // Test cookie and app data settings. IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSiteData) { - int site_data_no_plugins = BrowsingDataRemover::REMOVE_SITE_DATA & - ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; + int site_data_no_plugins_and_gcm = BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_PLUGIN_DATA & + ~BrowsingDataRemover::REMOVE_GCM; SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES, UNPROTECTED_WEB, - site_data_no_plugins); + site_data_no_plugins_and_gcm); SetPrefsAndVerifySettings( BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY, PROTECTED_WEB, - site_data_no_plugins); + site_data_no_plugins_and_gcm); SetPrefsAndVerifySettings( BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY, PROTECTED_WEB | UNPROTECTED_WEB, - site_data_no_plugins); + site_data_no_plugins_and_gcm); SetPrefsAndVerifySettings( BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_PLUGIN_DATA, UNPROTECTED_WEB, - BrowsingDataRemover::REMOVE_SITE_DATA); + site_data_no_plugins_and_gcm | BrowsingDataRemover::REMOVE_PLUGIN_DATA); } // Test an arbitrary assortment of settings. IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionAssorted) { - int site_data_no_plugins = BrowsingDataRemover::REMOVE_SITE_DATA & - ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; + int site_data_no_plugins_and_gcm = BrowsingDataRemover::REMOVE_SITE_DATA & + ~BrowsingDataRemover::REMOVE_PLUGIN_DATA & + ~BrowsingDataRemover::REMOVE_GCM; SetPrefsAndVerifySettings( BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_DOWNLOADS, UNPROTECTED_WEB, - site_data_no_plugins | + site_data_no_plugins_and_gcm | BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_DOWNLOADS); } diff --git a/chrome/browser/services/gcm/gcm_profile_service.cc b/chrome/browser/services/gcm/gcm_profile_service.cc index 0539acc..069862d 100644 --- a/chrome/browser/services/gcm/gcm_profile_service.cc +++ b/chrome/browser/services/gcm/gcm_profile_service.cc @@ -116,9 +116,11 @@ void GCMProfileService::IdentityObserver::OnActiveAccountLogout() { // Check is necessary to not crash browser_tests. if (gcm_account_tracker_) gcm_account_tracker_->Stop(); - // TODO(fgorski): If we purge here, what should happen when we get - // OnActiveAccountLogin() right after that? - driver_->Purge(); + // When sign-in enforcement is not dropped, OnSignedOut will also clear all + // the GCM data and a new GCM ID will be retrieved after the user signs in + // again. Otherwise, the user sign-out will not affect the existing GCM + // data. + driver_->OnSignedOut(); } std::string GCMProfileService::IdentityObserver::SignedInUserName() const { diff --git a/components/gcm_driver/fake_gcm_driver.cc b/components/gcm_driver/fake_gcm_driver.cc index 85cc920..7ee53c5 100644 --- a/components/gcm_driver/fake_gcm_driver.cc +++ b/components/gcm_driver/fake_gcm_driver.cc @@ -25,6 +25,9 @@ void FakeGCMDriver::RemoveAppHandler(const std::string& app_id) { void FakeGCMDriver::OnSignedIn() { } +void FakeGCMDriver::OnSignedOut() { +} + void FakeGCMDriver::Purge() { } diff --git a/components/gcm_driver/fake_gcm_driver.h b/components/gcm_driver/fake_gcm_driver.h index a549e1f..30a2117 100644 --- a/components/gcm_driver/fake_gcm_driver.h +++ b/components/gcm_driver/fake_gcm_driver.h @@ -22,6 +22,7 @@ class FakeGCMDriver : public GCMDriver { GCMAppHandler* handler) OVERRIDE; virtual void RemoveAppHandler(const std::string& app_id) OVERRIDE; virtual void OnSignedIn() OVERRIDE; + virtual void OnSignedOut() OVERRIDE; virtual void Purge() OVERRIDE; virtual void AddConnectionObserver(GCMConnectionObserver* observer) OVERRIDE; virtual void RemoveConnectionObserver( diff --git a/components/gcm_driver/gcm_driver.h b/components/gcm_driver/gcm_driver.h index c10d9f1..9878068 100644 --- a/components/gcm_driver/gcm_driver.h +++ b/components/gcm_driver/gcm_driver.h @@ -72,9 +72,9 @@ class GCMDriver { // been called, no other GCMDriver methods may be used. virtual void Shutdown(); - // Call this method when the user signs in to a GAIA account. - // TODO(jianli): To be removed when sign-in enforcement is dropped. + // Called when the user signs in to or out of a GAIA account. virtual void OnSignedIn() = 0; + virtual void OnSignedOut() = 0; // Removes all the cached and persisted GCM data. If the GCM service is // restarted after the purge, a new Android ID will be obtained. diff --git a/components/gcm_driver/gcm_driver_android.cc b/components/gcm_driver/gcm_driver_android.cc index d855363..69da4c5 100644 --- a/components/gcm_driver/gcm_driver_android.cc +++ b/components/gcm_driver/gcm_driver_android.cc @@ -95,6 +95,9 @@ bool GCMDriverAndroid::RegisterBindings(JNIEnv* env) { void GCMDriverAndroid::OnSignedIn() { } +void GCMDriverAndroid::OnSignedOut() { +} + void GCMDriverAndroid::Purge() { } diff --git a/components/gcm_driver/gcm_driver_android.h b/components/gcm_driver/gcm_driver_android.h index e862c60..5cc97f6 100644 --- a/components/gcm_driver/gcm_driver_android.h +++ b/components/gcm_driver/gcm_driver_android.h @@ -45,6 +45,7 @@ class GCMDriverAndroid : public GCMDriver { // GCMDriver implementation: virtual void OnSignedIn() OVERRIDE; + virtual void OnSignedOut() OVERRIDE; virtual void Purge() OVERRIDE; virtual void Enable() OVERRIDE; virtual void AddConnectionObserver(GCMConnectionObserver* observer) OVERRIDE; diff --git a/components/gcm_driver/gcm_driver_desktop.cc b/components/gcm_driver/gcm_driver_desktop.cc index 6722966..8d35c2c 100644 --- a/components/gcm_driver/gcm_driver_desktop.cc +++ b/components/gcm_driver/gcm_driver_desktop.cc @@ -369,13 +369,18 @@ void GCMDriverDesktop::OnSignedIn() { EnsureStarted(); } +void GCMDriverDesktop::OnSignedOut() { + signed_in_ = false; + + // When sign-in enforcement is dropped, we will no longer wipe out the GCM + // data when the user signs out. + if (!GCMDriver::IsAllowedForAllUsers()) + Purge(); +} + void GCMDriverDesktop::Purge() { DCHECK(ui_thread_->RunsTasksOnCurrentThread()); - // We still proceed with the check-out logic even if the check-in is not - // initiated in the current session. This will make sure that all the - // persisted data written previously will get purged. - signed_in_ = false; RemoveCachedData(); io_thread_->PostTask(FROM_HERE, @@ -616,7 +621,6 @@ GCMClient::Result GCMDriverDesktop::EnsureStarted() { if (app_handlers().empty()) return GCMClient::UNKNOWN_ERROR; - // TODO(jianli): To be removed when sign-in enforcement is dropped. if (!signed_in_ && !GCMDriver::IsAllowedForAllUsers()) return GCMClient::NOT_SIGNED_IN; diff --git a/components/gcm_driver/gcm_driver_desktop.h b/components/gcm_driver/gcm_driver_desktop.h index 3199a48..51a9845 100644 --- a/components/gcm_driver/gcm_driver_desktop.h +++ b/components/gcm_driver/gcm_driver_desktop.h @@ -54,6 +54,7 @@ class GCMDriverDesktop : public GCMDriver { // GCMDriver overrides: virtual void Shutdown() OVERRIDE; virtual void OnSignedIn() OVERRIDE; + virtual void OnSignedOut() OVERRIDE; virtual void Purge() OVERRIDE; virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler) OVERRIDE; diff --git a/components/gcm_driver/gcm_driver_desktop_unittest.cc b/components/gcm_driver/gcm_driver_desktop_unittest.cc index cec87ef..ad95f86 100644 --- a/components/gcm_driver/gcm_driver_desktop_unittest.cc +++ b/components/gcm_driver/gcm_driver_desktop_unittest.cc @@ -258,7 +258,7 @@ void GCMDriverTest::SignIn(const std::string& account_id) { } void GCMDriverTest::SignOut() { - driver_->Purge(); + driver_->OnSignedOut(); PumpIOLoop(); PumpUILoop(); } @@ -350,6 +350,7 @@ TEST_F(GCMDriverTest, Create) { } TEST_F(GCMDriverTest, CreateByFieldTrial) { + // Turn on the signal to drop sign-in enforcement. ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("GCM", "Enabled")); // Create GCMDriver first. GCM is not started. @@ -364,6 +365,18 @@ TEST_F(GCMDriverTest, CreateByFieldTrial) { PumpIOLoop(); EXPECT_TRUE(driver()->IsConnected()); EXPECT_TRUE(gcm_connection_observer()->connected()); + + // Sign-in will not affect GCM state. + SignIn(kTestAccountID1); + PumpIOLoop(); + EXPECT_TRUE(driver()->IsStarted()); + EXPECT_TRUE(driver()->IsConnected()); + + // Sign-out will not affect GCM state. + SignOut(); + PumpIOLoop(); + EXPECT_TRUE(driver()->IsStarted()); + EXPECT_TRUE(driver()->IsConnected()); } TEST_F(GCMDriverTest, Shutdown) { -- cgit v1.1 From cdf83e8f7ec3d723c058260a492c2d9f83ec4a25 Mon Sep 17 00:00:00 2001 From: thestig Date: Sat, 13 Sep 2014 14:00:01 -0700 Subject: Revert of Cleanup: Remove base/file_util.h. Convert remaining references. (patchset #1 id:1 of https://codereview.chromium.org/568873004/) Reason for revert: Broke some internal builds. Need to give them a chance to fix their builds. Original issue's description: > Cleanup: Remove base/file_util.h. Convert remaining references. > > TBR=brettw@chromium.org > > Committed: https://crrev.com/6d63c4898c2da5a286d01f80229baeb914f99f18 > Cr-Commit-Position: refs/heads/master@{#294729} TBR=brettw@chromium.org NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/565803006 Cr-Commit-Position: refs/heads/master@{#294755} --- android_webview/browser/renderer_host/print_manager.cc | 2 +- android_webview/native/cookie_manager.cc | 4 ++-- base/file_util.h | 6 ++++++ third_party/leveldatabase/env_chromium.cc | 2 +- third_party/leveldatabase/env_chromium_unittest.cc | 2 +- third_party/libjingle/overrides/init_webrtc.cc | 2 +- third_party/zlib/google/zip_internal.cc | 2 +- third_party/zlib/google/zip_reader.h | 2 +- third_party/zlib/google/zip_reader_unittest.cc | 2 +- third_party/zlib/google/zip_unittest.cc | 2 +- 10 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 base/file_util.h diff --git a/android_webview/browser/renderer_host/print_manager.cc b/android_webview/browser/renderer_host/print_manager.cc index 24fa3b4..53c3ba4 100644 --- a/android_webview/browser/renderer_host/print_manager.cc +++ b/android_webview/browser/renderer_host/print_manager.cc @@ -9,7 +9,7 @@ #include "android_webview/common/render_view_messages.h" #include "base/android/scoped_java_ref.h" #include "base/callback.h" -#include "base/files/file_util.h" +#include "base/file_util.h" #include "base/logging.h" #include "content/public/browser/browser_thread.h" #include "printing/print_settings.h" diff --git a/android_webview/native/cookie_manager.cc b/android_webview/native/cookie_manager.cc index 13fcb35..5d74418 100644 --- a/android_webview/native/cookie_manager.cc +++ b/android_webview/native/cookie_manager.cc @@ -13,8 +13,8 @@ #include "base/android/path_utils.h" #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/file_util.h" #include "base/files/file_path.h" -#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" @@ -609,4 +609,4 @@ bool RegisterCookieManager(JNIEnv* env) { return RegisterNativesImpl(env); } -} // namespace android_webview +} // android_webview namespace diff --git a/base/file_util.h b/base/file_util.h new file mode 100644 index 0000000..9760a34 --- /dev/null +++ b/base/file_util.h @@ -0,0 +1,6 @@ +// 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. + +// TODO(brettw) update callers to use the new location and remove this file. +#include "base/files/file_util.h" diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index 7f0d45d..4c3375c 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -9,7 +9,7 @@ #endif #include "base/debug/trace_event.h" -#include "base/files/file_util.h" +#include "base/file_util.h" #include "base/lazy_instance.h" #include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" diff --git a/third_party/leveldatabase/env_chromium_unittest.cc b/third_party/leveldatabase/env_chromium_unittest.cc index 35e4f90..caac7a6 100644 --- a/third_party/leveldatabase/env_chromium_unittest.cc +++ b/third_party/leveldatabase/env_chromium_unittest.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" -#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/test/test_suite.h" #include "third_party/leveldatabase/env_chromium_stdio.h" diff --git a/third_party/libjingle/overrides/init_webrtc.cc b/third_party/libjingle/overrides/init_webrtc.cc index 0775ce8..e11f78d 100644 --- a/third_party/libjingle/overrides/init_webrtc.cc +++ b/third_party/libjingle/overrides/init_webrtc.cc @@ -6,8 +6,8 @@ #include "base/command_line.h" #include "base/debug/trace_event.h" +#include "base/file_util.h" #include "base/files/file_path.h" -#include "base/files/file_util.h" #include "base/metrics/field_trial.h" #include "base/native_library.h" #include "base/path_service.h" diff --git a/third_party/zlib/google/zip_internal.cc b/third_party/zlib/google/zip_internal.cc index d62e0bb..5ed2024 100644 --- a/third_party/zlib/google/zip_internal.cc +++ b/third_party/zlib/google/zip_internal.cc @@ -6,7 +6,7 @@ #include -#include "base/files/file_util.h" +#include "base/file_util.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" diff --git a/third_party/zlib/google/zip_reader.h b/third_party/zlib/google/zip_reader.h index cda9cf7..fa4186b 100644 --- a/third_party/zlib/google/zip_reader.h +++ b/third_party/zlib/google/zip_reader.h @@ -8,9 +8,9 @@ #include "base/basictypes.h" #include "base/callback.h" +#include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_path.h" -#include "base/files/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" diff --git a/third_party/zlib/google/zip_reader_unittest.cc b/third_party/zlib/google/zip_reader_unittest.cc index 09fc241..a137d9d 100644 --- a/third_party/zlib/google/zip_reader_unittest.cc +++ b/third_party/zlib/google/zip_reader_unittest.cc @@ -8,8 +8,8 @@ #include #include "base/bind.h" +#include "base/file_util.h" #include "base/files/file.h" -#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/md5.h" diff --git a/third_party/zlib/google/zip_unittest.cc b/third_party/zlib/google/zip_unittest.cc index eda9a68..c606434 100644 --- a/third_party/zlib/google/zip_unittest.cc +++ b/third_party/zlib/google/zip_unittest.cc @@ -6,10 +6,10 @@ #include #include +#include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" -#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" #include "base/strings/string_util.h" -- cgit v1.1 From 917b312e36bdebde4d92bf8bcc1e070b5d064f54 Mon Sep 17 00:00:00 2001 From: tfarina Date: Sat, 13 Sep 2014 14:03:35 -0700 Subject: ui/gfx: Remove duplicated win condition. We already have the same msvs_disabled_warnings declared at line 172. No need to have it twice. BUG=331829 TEST=gfx_unittests TBR=sky@chromium.org Review URL: https://codereview.chromium.org/555543003 Cr-Commit-Position: refs/heads/master@{#294756} --- ui/gfx/gfx_tests.gyp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ui/gfx/gfx_tests.gyp b/ui/gfx/gfx_tests.gyp index 710a3d5..c272472 100644 --- a/ui/gfx/gfx_tests.gyp +++ b/ui/gfx/gfx_tests.gyp @@ -90,10 +90,6 @@ }, { # OS != "ios" 'sources': ['<@(_all_sources)'], }], - ['OS == "win"', { - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], - }], ['OS != "mac" and OS != "ios"', { 'sources': [ 'transform_unittest.cc', -- cgit v1.1 From 566ed9f6e71cea313c88e8f259eca76581b72d67 Mon Sep 17 00:00:00 2001 From: jbroman Date: Sat, 13 Sep 2014 14:15:54 -0700 Subject: Telemetry: Fix exact_matches in telemetry.test_runner. Previously, if exact_matches was True but there were no exact matches, it would return fuzzy matches instead. This is not what the caller asked for. GPU test names are changed to match the buildbot config, since they were previously relying on fuzzy matching. SHERIFFS: May cause errors like: No test named "some_test_name". Available tests are: ... If so, this CL can be safely reverted. BUG=413334,413442 Review URL: https://codereview.chromium.org/560153004 Cr-Commit-Position: refs/heads/master@{#294757} --- content/test/gpu/gpu_tests/gpu_process.py | 3 +- content/test/gpu/gpu_tests/gpu_rasterization.py | 3 +- content/test/gpu/gpu_tests/memory.py | 114 --------------------- content/test/gpu/gpu_tests/memory_expectations.py | 35 ------- content/test/gpu/gpu_tests/memory_test.py | 113 ++++++++++++++++++++ .../test/gpu/gpu_tests/memory_test_expectations.py | 35 +++++++ content/test/gpu/gpu_tests/pixel.py | 3 +- tools/telemetry/telemetry/test_runner.py | 1 + 8 files changed, 152 insertions(+), 155 deletions(-) delete mode 100644 content/test/gpu/gpu_tests/memory.py delete mode 100644 content/test/gpu/gpu_tests/memory_expectations.py create mode 100644 content/test/gpu/gpu_tests/memory_test.py create mode 100644 content/test/gpu/gpu_tests/memory_test_expectations.py diff --git a/content/test/gpu/gpu_tests/gpu_process.py b/content/test/gpu/gpu_tests/gpu_process.py index 531319c..11104fc 100644 --- a/content/test/gpu/gpu_tests/gpu_process.py +++ b/content/test/gpu/gpu_tests/gpu_process.py @@ -36,13 +36,12 @@ class _GpuProcessValidator(page_test.PageTest): class GpuProcess(benchmark.Benchmark): """Tests that accelerated content triggers the creation of a GPU process""" test = _GpuProcessValidator - page_set = page_sets.GpuProcessTestsPageSet def CreateExpectations(self, page_set): return expectations.GpuProcessExpectations() def CreatePageSet(self, options): - page_set = super(GpuProcess, self).CreatePageSet(options) + page_set = page_sets.GpuProcessTestsPageSet() for page in page_set.pages: page.script_to_evaluate_on_commit = test_harness_script return page_set diff --git a/content/test/gpu/gpu_tests/gpu_rasterization.py b/content/test/gpu/gpu_tests/gpu_rasterization.py index 0e4fd06..1a12407 100644 --- a/content/test/gpu/gpu_tests/gpu_rasterization.py +++ b/content/test/gpu/gpu_tests/gpu_rasterization.py @@ -65,10 +65,9 @@ class _GpuRasterizationValidator(cloud_storage_test_base.ValidatorBase): class GpuRasterization(cloud_storage_test_base.TestBase): """Tests that GPU rasterization produces valid content""" test = _GpuRasterizationValidator - page_set = page_sets.GpuRasterizationTestsPageSet def CreatePageSet(self, options): - page_set = super(GpuRasterization, self).CreatePageSet(options) + page_set = page_sets.GpuRasterizationTestsPageSet() for page in page_set.pages: page.script_to_evaluate_on_commit = test_harness_script return page_set diff --git a/content/test/gpu/gpu_tests/memory.py b/content/test/gpu/gpu_tests/memory.py deleted file mode 100644 index c8eadc4..0000000 --- a/content/test/gpu/gpu_tests/memory.py +++ /dev/null @@ -1,114 +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. -import memory_expectations -import page_sets - -from telemetry import benchmark -from telemetry.page import page_test -from telemetry.core.platform import tracing_category_filter -from telemetry.core.platform import tracing_options -from telemetry.timeline import counter -from telemetry.timeline import model - -MEMORY_LIMIT_MB = 192 -SINGLE_TAB_LIMIT_MB = 192 -WIGGLE_ROOM_MB = 12 - -test_harness_script = r""" - var domAutomationController = {}; - domAutomationController._finished = false; - - domAutomationController.send = function(msg) { - // This should wait until all effects of memory management complete. - // We will need to wait until all - // 1. pending commits from the main thread to the impl thread in the - // compositor complete (for visible compositors). - // 2. allocations that the renderer's impl thread will make due to the - // compositor and WebGL are completed. - // 3. pending GpuMemoryManager::Manage() calls to manage are made. - // 4. renderers' OnMemoryAllocationChanged callbacks in response to - // manager are made. - // Each step in this sequence can cause trigger the next (as a 1-2-3-4-1 - // cycle), so we will need to pump this cycle until it stabilizes. - - // Pump the cycle 8 times (in principle it could take an infinite number - // of iterations to settle). - - var rafCount = 0; - - // Impl-side painting has changed the behavior of this test. - // Currently the background of the page shows up checkerboarded - // initially, causing the test to fail because the memory - // allocation is too low (no root layer). Temporarily increase the - // rAF count to 32 in order to make the test work reliably again. - // crbug.com/373098 - // TODO(kbr): revert this change and put it back to 8 iterations. - var totalRafCount = 32; - - function pumpRAF() { - if (rafCount == totalRafCount) { - domAutomationController._finished = true; - return; - } - ++rafCount; - window.requestAnimationFrame(pumpRAF); - } - pumpRAF(); - } - - window.domAutomationController = domAutomationController; - - window.addEventListener("load", function() { - useGpuMemory(%d); - }, false); -""" % MEMORY_LIMIT_MB - -class _MemoryValidator(page_test.PageTest): - def ValidateAndMeasurePage(self, page, tab, results): - timeline_data = tab.browser.platform.tracing_controller.Stop() - timeline_model = model.TimelineModel(timeline_data) - for process in timeline_model.GetAllProcesses(): - if 'gpu.GpuMemoryUsage' in process.counters: - counter = process.GetCounter('gpu', 'GpuMemoryUsage') - mb_used = counter.samples[-1] / 1048576 - - if mb_used + WIGGLE_ROOM_MB < SINGLE_TAB_LIMIT_MB: - raise page_test.Failure(self._FormatException('low', mb_used)) - - if mb_used - WIGGLE_ROOM_MB > MEMORY_LIMIT_MB: - raise page_test.Failure(self._FormatException('high', mb_used)) - - def CustomizeBrowserOptions(self, options): - options.AppendExtraBrowserArgs('--enable-logging') - options.AppendExtraBrowserArgs( - '--force-gpu-mem-available-mb=%s' % MEMORY_LIMIT_MB) - - def WillNavigateToPage(self, page, tab): - # FIXME: Remove webkit.console when blink.console lands in chromium and the - # ref builds are updated. crbug.com/386847 - custom_categories = ['webkit.console', 'blink.console', 'gpu'] - category_filter = tracing_category_filter.TracingCategoryFilter() - for c in custom_categories: - category_filter.AddIncludedCategory(c) - options = tracing_options.TracingOptions() - options.enable_chrome_trace = True - tab.browser.platform.tracing_controller.Start(options, category_filter, 60) - - def _FormatException(self, low_or_high, mb_used): - return 'Memory allocation too %s (was %d MB, should be %d MB +/- %d MB)' % ( - low_or_high, mb_used, SINGLE_TAB_LIMIT_MB, WIGGLE_ROOM_MB) - -class Memory(benchmark.Benchmark): - """Tests GPU memory limits""" - test = _MemoryValidator - page_set = page_sets.MemoryTestsPageSet - - def CreateExpectations(self, page_set): - return memory_expectations.MemoryExpectations() - - def CreatePageSet(self, options): - page_set = super(Memory, self).CreatePageSet(options) - for page in page_set.pages: - page.script_to_evaluate_on_commit = test_harness_script - return page_set diff --git a/content/test/gpu/gpu_tests/memory_expectations.py b/content/test/gpu/gpu_tests/memory_expectations.py deleted file mode 100644 index 0b2cce0..0000000 --- a/content/test/gpu/gpu_tests/memory_expectations.py +++ /dev/null @@ -1,35 +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. - -from telemetry.page import test_expectations - -# Valid expectation conditions are: -# -# Operating systems: -# win, xp, vista, win7, mac, leopard, snowleopard, lion, mountainlion, -# linux, chromeos, android -# -# GPU vendors: -# amd, arm, broadcom, hisilicon, intel, imagination, nvidia, qualcomm, -# vivante -# -# Specific GPUs can be listed as a tuple with vendor name and device ID. -# Examples: ('nvidia', 0x1234), ('arm', 'Mali-T604') -# Device IDs must be paired with a GPU vendor. - -class MemoryExpectations(test_expectations.TestExpectations): - def SetExpectations(self): - # Sample Usage: - # self.Fail('Memory.CSS3D', - # ['mac', 'amd', ('nvidia', 0x1234)], bug=123) - - self.Fail('Memory.CSS3D', ['mac', ('nvidia', 0x0fd5)], bug=368037) - - # TODO(vmpstr): Memory drops and increases again, and this - # particular bot happens to catch it when its low. Remove - # once the bug is fixed. - self.Fail('Memory.CSS3D', ['win'], bug=373098) - - # Test has turned flaky on Linux also. Remove once the bug is fixed. - self.Fail('Memory.CSS3D', ['linux'], bug=373098) diff --git a/content/test/gpu/gpu_tests/memory_test.py b/content/test/gpu/gpu_tests/memory_test.py new file mode 100644 index 0000000..95b8375 --- /dev/null +++ b/content/test/gpu/gpu_tests/memory_test.py @@ -0,0 +1,113 @@ +# 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. +import memory_test_expectations +import page_sets + +from telemetry import benchmark +from telemetry.page import page_test +from telemetry.core.platform import tracing_category_filter +from telemetry.core.platform import tracing_options +from telemetry.timeline import counter +from telemetry.timeline import model + +MEMORY_LIMIT_MB = 192 +SINGLE_TAB_LIMIT_MB = 192 +WIGGLE_ROOM_MB = 12 + +test_harness_script = r""" + var domAutomationController = {}; + domAutomationController._finished = false; + + domAutomationController.send = function(msg) { + // This should wait until all effects of memory management complete. + // We will need to wait until all + // 1. pending commits from the main thread to the impl thread in the + // compositor complete (for visible compositors). + // 2. allocations that the renderer's impl thread will make due to the + // compositor and WebGL are completed. + // 3. pending GpuMemoryManager::Manage() calls to manage are made. + // 4. renderers' OnMemoryAllocationChanged callbacks in response to + // manager are made. + // Each step in this sequence can cause trigger the next (as a 1-2-3-4-1 + // cycle), so we will need to pump this cycle until it stabilizes. + + // Pump the cycle 8 times (in principle it could take an infinite number + // of iterations to settle). + + var rafCount = 0; + + // Impl-side painting has changed the behavior of this test. + // Currently the background of the page shows up checkerboarded + // initially, causing the test to fail because the memory + // allocation is too low (no root layer). Temporarily increase the + // rAF count to 32 in order to make the test work reliably again. + // crbug.com/373098 + // TODO(kbr): revert this change and put it back to 8 iterations. + var totalRafCount = 32; + + function pumpRAF() { + if (rafCount == totalRafCount) { + domAutomationController._finished = true; + return; + } + ++rafCount; + window.requestAnimationFrame(pumpRAF); + } + pumpRAF(); + } + + window.domAutomationController = domAutomationController; + + window.addEventListener("load", function() { + useGpuMemory(%d); + }, false); +""" % MEMORY_LIMIT_MB + +class _MemoryValidator(page_test.PageTest): + def ValidateAndMeasurePage(self, page, tab, results): + timeline_data = tab.browser.platform.tracing_controller.Stop() + timeline_model = model.TimelineModel(timeline_data) + for process in timeline_model.GetAllProcesses(): + if 'gpu.GpuMemoryUsage' in process.counters: + counter = process.GetCounter('gpu', 'GpuMemoryUsage') + mb_used = counter.samples[-1] / 1048576 + + if mb_used + WIGGLE_ROOM_MB < SINGLE_TAB_LIMIT_MB: + raise page_test.Failure(self._FormatException('low', mb_used)) + + if mb_used - WIGGLE_ROOM_MB > MEMORY_LIMIT_MB: + raise page_test.Failure(self._FormatException('high', mb_used)) + + def CustomizeBrowserOptions(self, options): + options.AppendExtraBrowserArgs('--enable-logging') + options.AppendExtraBrowserArgs( + '--force-gpu-mem-available-mb=%s' % MEMORY_LIMIT_MB) + + def WillNavigateToPage(self, page, tab): + # FIXME: Remove webkit.console when blink.console lands in chromium and the + # ref builds are updated. crbug.com/386847 + custom_categories = ['webkit.console', 'blink.console', 'gpu'] + category_filter = tracing_category_filter.TracingCategoryFilter() + for c in custom_categories: + category_filter.AddIncludedCategory(c) + options = tracing_options.TracingOptions() + options.enable_chrome_trace = True + tab.browser.platform.tracing_controller.Start(options, category_filter, 60) + + def _FormatException(self, low_or_high, mb_used): + return 'Memory allocation too %s (was %d MB, should be %d MB +/- %d MB)' % ( + low_or_high, mb_used, SINGLE_TAB_LIMIT_MB, WIGGLE_ROOM_MB) + +class MemoryTest(benchmark.Benchmark): + """Tests GPU memory limits""" + test = _MemoryValidator + + def CreateExpectations(self, page_set): + return memory_test_expectations.MemoryTestExpectations() + + def CreatePageSet(self, options): + page_set = page_sets.MemoryTestsPageSet() + for page in page_set.pages: + page.script_to_evaluate_on_commit = test_harness_script + return page_set diff --git a/content/test/gpu/gpu_tests/memory_test_expectations.py b/content/test/gpu/gpu_tests/memory_test_expectations.py new file mode 100644 index 0000000..b5eba5c --- /dev/null +++ b/content/test/gpu/gpu_tests/memory_test_expectations.py @@ -0,0 +1,35 @@ +# 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. + +from telemetry.page import test_expectations + +# Valid expectation conditions are: +# +# Operating systems: +# win, xp, vista, win7, mac, leopard, snowleopard, lion, mountainlion, +# linux, chromeos, android +# +# GPU vendors: +# amd, arm, broadcom, hisilicon, intel, imagination, nvidia, qualcomm, +# vivante +# +# Specific GPUs can be listed as a tuple with vendor name and device ID. +# Examples: ('nvidia', 0x1234), ('arm', 'Mali-T604') +# Device IDs must be paired with a GPU vendor. + +class MemoryTestExpectations(test_expectations.TestExpectations): + def SetExpectations(self): + # Sample Usage: + # self.Fail('Memory.CSS3D', + # ['mac', 'amd', ('nvidia', 0x1234)], bug=123) + + self.Fail('Memory.CSS3D', ['mac', ('nvidia', 0x0fd5)], bug=368037) + + # TODO(vmpstr): Memory drops and increases again, and this + # particular bot happens to catch it when its low. Remove + # once the bug is fixed. + self.Fail('Memory.CSS3D', ['win'], bug=373098) + + # Test has turned flaky on Linux also. Remove once the bug is fixed. + self.Fail('Memory.CSS3D', ['linux'], bug=373098) diff --git a/content/test/gpu/gpu_tests/pixel.py b/content/test/gpu/gpu_tests/pixel.py index 90fcaa6..d1dbc2a 100644 --- a/content/test/gpu/gpu_tests/pixel.py +++ b/content/test/gpu/gpu_tests/pixel.py @@ -148,7 +148,6 @@ class _PixelValidator(cloud_storage_test_base.ValidatorBase): class Pixel(cloud_storage_test_base.TestBase): test = _PixelValidator - page_set = page_sets.PixelTestsPageSet @classmethod def AddTestCommandLineArgs(cls, group): @@ -159,7 +158,7 @@ class Pixel(cloud_storage_test_base.TestBase): default=default_reference_image_dir) def CreatePageSet(self, options): - page_set = super(Pixel, self).CreatePageSet(options) + page_set = page_sets.PixelTestsPageSet() for page in page_set.pages: page.script_to_evaluate_on_commit = test_harness_script return page_set diff --git a/tools/telemetry/telemetry/test_runner.py b/tools/telemetry/telemetry/test_runner.py index 7fbbd8f..d549a38 100644 --- a/tools/telemetry/telemetry/test_runner.py +++ b/tools/telemetry/telemetry/test_runner.py @@ -246,6 +246,7 @@ def _MatchTestName(input_test_name, exact_matches=True): for test_class in _Tests(): if exact_match == test_class.Name(): return [test_class] + return [] # Fuzzy matching. return [test_class for test_class in _Tests() -- cgit v1.1 From 79146d0b0d917eb6482cf2c22ec76db09eaa5a37 Mon Sep 17 00:00:00 2001 From: reillyg Date: Sat, 13 Sep 2014 22:19:25 -0700 Subject: Add chrome.usb.getConfiguration and expose extra descriptors. Adds a new API function, chrome.usb.getConfiguration, that returns all the data from the device's configuration descriptor instead of just the interfaces as chrome.usb.listInterfaces does. Each level of the descriptor hierarchy also gets an "extra_data" field which contains all of the miscellaneous descriptors assocated with a configuration, interface or endpoint. BUG=382908 Review URL: https://codereview.chromium.org/558373002 Cr-Commit-Position: refs/heads/master@{#294758} --- extensions/browser/api/usb/usb_api.cc | 354 ++++++++++----------- extensions/browser/api/usb/usb_api.h | 27 +- .../browser/extension_function_histogram_value.h | 1 + extensions/common/api/usb.idl | 28 ++ tools/metrics/histograms/histograms.xml | 1 + 5 files changed, 209 insertions(+), 202 deletions(-) diff --git a/extensions/browser/api/usb/usb_api.cc b/extensions/browser/api/usb/usb_api.cc index 22e19c4..2c2b490 100644 --- a/extensions/browser/api/usb/usb_api.cc +++ b/extensions/browser/api/usb/usb_api.cc @@ -27,6 +27,7 @@ namespace FindDevices = usb::FindDevices; namespace GetDevices = usb::GetDevices; namespace InterruptTransfer = usb::InterruptTransfer; namespace IsochronousTransfer = usb::IsochronousTransfer; +namespace GetConfiguration = usb::GetConfiguration; namespace ListInterfaces = usb::ListInterfaces; namespace OpenDevice = usb::OpenDevice; namespace ReleaseInterface = usb::ReleaseInterface; @@ -35,8 +36,7 @@ namespace ResetDevice = usb::ResetDevice; namespace SetInterfaceAlternateSetting = usb::SetInterfaceAlternateSetting; using content::BrowserThread; -using std::string; -using std::vector; +using usb::ConfigDescriptor; using usb::ControlTransferInfo; using usb::ConnectionHandle; using usb::Device; @@ -84,8 +84,6 @@ const char kErrorOverflow[] = "Inbound transfer overflow."; const char kErrorStalled[] = "Transfer stalled."; const char kErrorTimeout[] = "Transfer timed out."; const char kErrorTransferLength[] = "Transfer length is insufficient."; - -const char kErrorCannotListInterfaces[] = "Error listing interfaces."; const char kErrorCannotClaimInterface[] = "Error claiming interface."; const char kErrorCannotReleaseInterface[] = "Error releasing interface."; const char kErrorCannotSetInterfaceAlternateSetting[] = @@ -93,9 +91,6 @@ const char kErrorCannotSetInterfaceAlternateSetting[] = const char kErrorConvertDirection[] = "Invalid transfer direction."; const char kErrorConvertRecipient[] = "Invalid transfer recipient."; const char kErrorConvertRequestType[] = "Invalid request type."; -const char kErrorConvertSynchronizationType[] = "Invalid synchronization type"; -const char kErrorConvertTransferType[] = "Invalid endpoint type."; -const char kErrorConvertUsageType[] = "Invalid usage type."; const char kErrorMalformedParameters[] = "Error parsing parameters."; const char kErrorNoDevice[] = "No such device."; const char kErrorPermissionDenied[] = "Permission to access device was denied"; @@ -112,81 +107,8 @@ const size_t kMaxTransferLength = 100 * 1024 * 1024; const int kMaxPackets = 4 * 1024 * 1024; const int kMaxPacketLength = 64 * 1024; -bool ConvertDirectionToApi(const UsbEndpointDirection& input, - Direction* output) { - switch (input) { - case device::USB_DIRECTION_INBOUND: - *output = usb::DIRECTION_IN; - return true; - case device::USB_DIRECTION_OUTBOUND: - *output = usb::DIRECTION_OUT; - return true; - default: - NOTREACHED(); - return false; - } -} - -bool ConvertSynchronizationTypeToApi(const UsbSynchronizationType& input, - usb::SynchronizationType* output) { - switch (input) { - case device::USB_SYNCHRONIZATION_NONE: - *output = usb::SYNCHRONIZATION_TYPE_NONE; - return true; - case device::USB_SYNCHRONIZATION_ASYNCHRONOUS: - *output = usb::SYNCHRONIZATION_TYPE_ASYNCHRONOUS; - return true; - case device::USB_SYNCHRONIZATION_ADAPTIVE: - *output = usb::SYNCHRONIZATION_TYPE_ADAPTIVE; - return true; - case device::USB_SYNCHRONIZATION_SYNCHRONOUS: - *output = usb::SYNCHRONIZATION_TYPE_SYNCHRONOUS; - return true; - default: - NOTREACHED(); - return false; - } -} - -bool ConvertTransferTypeToApi(const UsbTransferType& input, - usb::TransferType* output) { - switch (input) { - case device::USB_TRANSFER_CONTROL: - *output = usb::TRANSFER_TYPE_CONTROL; - return true; - case device::USB_TRANSFER_INTERRUPT: - *output = usb::TRANSFER_TYPE_INTERRUPT; - return true; - case device::USB_TRANSFER_ISOCHRONOUS: - *output = usb::TRANSFER_TYPE_ISOCHRONOUS; - return true; - case device::USB_TRANSFER_BULK: - *output = usb::TRANSFER_TYPE_BULK; - return true; - default: - NOTREACHED(); - return false; - } -} - -bool ConvertUsageTypeToApi(const UsbUsageType& input, usb::UsageType* output) { - switch (input) { - case device::USB_USAGE_DATA: - *output = usb::USAGE_TYPE_DATA; - return true; - case device::USB_USAGE_FEEDBACK: - *output = usb::USAGE_TYPE_FEEDBACK; - return true; - case device::USB_USAGE_EXPLICIT_FEEDBACK: - *output = usb::USAGE_TYPE_EXPLICITFEEDBACK; - return true; - default: - NOTREACHED(); - return false; - } -} - -bool ConvertDirection(const Direction& input, UsbEndpointDirection* output) { +bool ConvertDirectionFromApi(const Direction& input, + UsbEndpointDirection* output) { switch (input) { case usb::DIRECTION_IN: *output = device::USB_DIRECTION_INBOUND; @@ -200,8 +122,8 @@ bool ConvertDirection(const Direction& input, UsbEndpointDirection* output) { } } -bool ConvertRequestType(const RequestType& input, - UsbDeviceHandle::TransferRequestType* output) { +bool ConvertRequestTypeFromApi(const RequestType& input, + UsbDeviceHandle::TransferRequestType* output) { switch (input) { case usb::REQUEST_TYPE_STANDARD: *output = UsbDeviceHandle::STANDARD; @@ -221,8 +143,8 @@ bool ConvertRequestType(const RequestType& input, } } -bool ConvertRecipient(const Recipient& input, - UsbDeviceHandle::TransferRecipient* output) { +bool ConvertRecipientFromApi(const Recipient& input, + UsbDeviceHandle::TransferRecipient* output) { switch (input) { case usb::RECIPIENT_DEVICE: *output = UsbDeviceHandle::DEVICE; @@ -286,7 +208,7 @@ scoped_refptr CreateBufferForTransfer( return NULL; } -const char* ConvertTransferStatusToErrorString(const UsbTransferStatus status) { +const char* ConvertTransferStatusToApi(const UsbTransferStatus status) { switch (status) { case device::USB_TRANSFER_COMPLETED: return ""; @@ -380,21 +302,121 @@ base::Value* PopulateDevice(UsbDevice* device) { return result.ToValue().release(); } -base::Value* PopulateInterfaceDescriptor( - int interface_number, - int alternate_setting, - int interface_class, - int interface_subclass, - int interface_protocol, - std::vector >* endpoints) { - InterfaceDescriptor descriptor; - descriptor.interface_number = interface_number; - descriptor.alternate_setting = alternate_setting; - descriptor.interface_class = interface_class; - descriptor.interface_subclass = interface_subclass; - descriptor.interface_protocol = interface_protocol; - descriptor.endpoints = *endpoints; - return descriptor.ToValue().release(); +TransferType ConvertTransferTypeToApi(const UsbTransferType& input) { + switch (input) { + case device::USB_TRANSFER_CONTROL: + return usb::TRANSFER_TYPE_CONTROL; + case device::USB_TRANSFER_INTERRUPT: + return usb::TRANSFER_TYPE_INTERRUPT; + case device::USB_TRANSFER_ISOCHRONOUS: + return usb::TRANSFER_TYPE_ISOCHRONOUS; + case device::USB_TRANSFER_BULK: + return usb::TRANSFER_TYPE_BULK; + default: + NOTREACHED(); + return usb::TRANSFER_TYPE_NONE; + } +} + +Direction ConvertDirectionToApi(const UsbEndpointDirection& input) { + switch (input) { + case device::USB_DIRECTION_INBOUND: + return usb::DIRECTION_IN; + case device::USB_DIRECTION_OUTBOUND: + return usb::DIRECTION_OUT; + default: + NOTREACHED(); + return usb::DIRECTION_NONE; + } +} + +SynchronizationType ConvertSynchronizationTypeToApi( + const UsbSynchronizationType& input) { + switch (input) { + case device::USB_SYNCHRONIZATION_NONE: + return usb::SYNCHRONIZATION_TYPE_NONE; + case device::USB_SYNCHRONIZATION_ASYNCHRONOUS: + return usb::SYNCHRONIZATION_TYPE_ASYNCHRONOUS; + case device::USB_SYNCHRONIZATION_ADAPTIVE: + return usb::SYNCHRONIZATION_TYPE_ADAPTIVE; + case device::USB_SYNCHRONIZATION_SYNCHRONOUS: + return usb::SYNCHRONIZATION_TYPE_SYNCHRONOUS; + default: + NOTREACHED(); + return usb::SYNCHRONIZATION_TYPE_NONE; + } +} + +UsageType ConvertUsageTypeToApi(const UsbUsageType& input) { + switch (input) { + case device::USB_USAGE_DATA: + return usb::USAGE_TYPE_DATA; + case device::USB_USAGE_FEEDBACK: + return usb::USAGE_TYPE_FEEDBACK; + case device::USB_USAGE_EXPLICIT_FEEDBACK: + return usb::USAGE_TYPE_EXPLICITFEEDBACK; + default: + NOTREACHED(); + return usb::USAGE_TYPE_NONE; + } +} + +void ConvertEndpointDescriptor(const UsbEndpointDescriptor& input, + EndpointDescriptor* output) { + output->address = input.address; + output->type = ConvertTransferTypeToApi(input.transfer_type); + output->direction = ConvertDirectionToApi(input.direction); + output->maximum_packet_size = input.maximum_packet_size; + output->synchronization = + ConvertSynchronizationTypeToApi(input.synchronization_type); + output->usage = ConvertUsageTypeToApi(input.usage_type); + output->polling_interval.reset(new int(input.polling_interval)); + if (input.extra_data.size() > 0) { + output->extra_data = + std::string(reinterpret_cast(&input.extra_data[0]), + input.extra_data.size()); + } +} + +void ConvertInterfaceDescriptor(const UsbInterfaceDescriptor& input, + InterfaceDescriptor* output) { + output->interface_number = input.interface_number; + output->alternate_setting = input.alternate_setting; + output->interface_class = input.interface_class; + output->interface_subclass = input.interface_subclass; + output->interface_protocol = input.interface_protocol; + for (UsbEndpointDescriptor::Iterator endpointIt = input.endpoints.begin(); + endpointIt != input.endpoints.end(); + ++endpointIt) { + linked_ptr endpoint(new EndpointDescriptor); + ConvertEndpointDescriptor(*endpointIt, endpoint.get()); + output->endpoints.push_back(endpoint); + } + if (input.extra_data.size() > 0) { + output->extra_data = + std::string(reinterpret_cast(&input.extra_data[0]), + input.extra_data.size()); + } +} + +void ConvertConfigDescriptor(const UsbConfigDescriptor& input, + ConfigDescriptor* output) { + output->configuration_value = input.configuration_value; + output->self_powered = input.self_powered; + output->remote_wakeup = input.remote_wakeup; + output->max_power = input.maximum_power; + for (UsbInterfaceDescriptor::Iterator interfaceIt = input.interfaces.begin(); + interfaceIt != input.interfaces.end(); + ++interfaceIt) { + linked_ptr interface(new InterfaceDescriptor); + ConvertInterfaceDescriptor(*interfaceIt, interface.get()); + output->interfaces.push_back(interface); + } + if (input.extra_data.size() > 0) { + output->extra_data = + std::string(reinterpret_cast(&input.extra_data[0]), + input.extra_data.size()); + } } } // namespace @@ -516,7 +538,7 @@ void UsbAsyncApiTransferFunction::OnCompleted(UsbTransferStatus status, scoped_refptr data, size_t length) { if (status != device::USB_TRANSFER_COMPLETED) - SetError(ConvertTransferStatusToErrorString(status)); + SetError(ConvertTransferStatusToApi(status)); SetResult(CreateTransferInfo(status, data, length)); AsyncWorkCompleted(); @@ -525,7 +547,7 @@ void UsbAsyncApiTransferFunction::OnCompleted(UsbTransferStatus status, bool UsbAsyncApiTransferFunction::ConvertDirectionSafely( const Direction& input, UsbEndpointDirection* output) { - const bool converted = ConvertDirection(input, output); + const bool converted = ConvertDirectionFromApi(input, output); if (!converted) SetError(kErrorConvertDirection); return converted; @@ -534,7 +556,7 @@ bool UsbAsyncApiTransferFunction::ConvertDirectionSafely( bool UsbAsyncApiTransferFunction::ConvertRequestTypeSafely( const RequestType& input, UsbDeviceHandle::TransferRequestType* output) { - const bool converted = ConvertRequestType(input, output); + const bool converted = ConvertRequestTypeFromApi(input, output); if (!converted) SetError(kErrorConvertRequestType); return converted; @@ -543,7 +565,7 @@ bool UsbAsyncApiTransferFunction::ConvertRequestTypeSafely( bool UsbAsyncApiTransferFunction::ConvertRecipientSafely( const Recipient& input, UsbDeviceHandle::TransferRecipient* output) { - const bool converted = ConvertRecipient(input, output); + const bool converted = ConvertRecipientFromApi(input, output); if (!converted) SetError(kErrorConvertRecipient); return converted; @@ -742,113 +764,63 @@ void UsbOpenDeviceFunction::AsyncWorkStart() { AsyncWorkCompleted(); } -UsbListInterfacesFunction::UsbListInterfacesFunction() { +UsbGetConfigurationFunction::UsbGetConfigurationFunction() { } -UsbListInterfacesFunction::~UsbListInterfacesFunction() { +UsbGetConfigurationFunction::~UsbGetConfigurationFunction() { } -bool UsbListInterfacesFunction::Prepare() { - parameters_ = ListInterfaces::Params::Create(*args_); +bool UsbGetConfigurationFunction::Prepare() { + parameters_ = GetConfiguration::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(parameters_.get()); return true; } -void UsbListInterfacesFunction::AsyncWorkStart() { +void UsbGetConfigurationFunction::AsyncWorkStart() { scoped_refptr device_handle = GetDeviceHandleOrCompleteWithError(parameters_->handle); - if (!device_handle.get()) + if (!device_handle.get()) { return; - - const UsbConfigDescriptor& config = - device_handle->GetDevice()->GetConfiguration(); - - scoped_ptr result(new base::ListValue()); - - for (UsbInterfaceDescriptor::Iterator interfaceIt = config.interfaces.begin(); - interfaceIt != config.interfaces.end(); - ++interfaceIt) { - std::vector > endpoints; - - for (UsbEndpointDescriptor::Iterator endpointIt = - interfaceIt->endpoints.begin(); - endpointIt != interfaceIt->endpoints.end(); - ++endpointIt) { - linked_ptr endpoint_desc(new EndpointDescriptor()); - - TransferType type; - Direction direction; - SynchronizationType synchronization; - UsageType usage; - - if (!ConvertTransferTypeSafely(endpointIt->transfer_type, &type) || - !ConvertDirectionSafely(endpointIt->direction, &direction) || - !ConvertSynchronizationTypeSafely(endpointIt->synchronization_type, - &synchronization) || - !ConvertUsageTypeSafely(endpointIt->usage_type, &usage)) { - SetError(kErrorCannotListInterfaces); - AsyncWorkCompleted(); - return; - } - - endpoint_desc->address = endpointIt->address; - endpoint_desc->type = type; - endpoint_desc->direction = direction; - endpoint_desc->maximum_packet_size = endpointIt->maximum_packet_size; - endpoint_desc->synchronization = synchronization; - endpoint_desc->usage = usage; - endpoint_desc->polling_interval.reset( - new int(endpointIt->polling_interval)); - - endpoints.push_back(endpoint_desc); - } - - result->Append(PopulateInterfaceDescriptor(interfaceIt->interface_number, - interfaceIt->alternate_setting, - interfaceIt->interface_class, - interfaceIt->interface_subclass, - interfaceIt->interface_protocol, - &endpoints)); } - SetResult(result.release()); + ConfigDescriptor config; + ConvertConfigDescriptor(device_handle->GetDevice()->GetConfiguration(), + &config); + + SetResult(config.ToValue().release()); AsyncWorkCompleted(); } -bool UsbListInterfacesFunction::ConvertDirectionSafely( - const UsbEndpointDirection& input, - usb::Direction* output) { - const bool converted = ConvertDirectionToApi(input, output); - if (!converted) - SetError(kErrorConvertDirection); - return converted; +UsbListInterfacesFunction::UsbListInterfacesFunction() { } -bool UsbListInterfacesFunction::ConvertSynchronizationTypeSafely( - const UsbSynchronizationType& input, - usb::SynchronizationType* output) { - const bool converted = ConvertSynchronizationTypeToApi(input, output); - if (!converted) - SetError(kErrorConvertSynchronizationType); - return converted; +UsbListInterfacesFunction::~UsbListInterfacesFunction() { } -bool UsbListInterfacesFunction::ConvertTransferTypeSafely( - const UsbTransferType& input, - usb::TransferType* output) { - const bool converted = ConvertTransferTypeToApi(input, output); - if (!converted) - SetError(kErrorConvertTransferType); - return converted; +bool UsbListInterfacesFunction::Prepare() { + parameters_ = ListInterfaces::Params::Create(*args_); + EXTENSION_FUNCTION_VALIDATE(parameters_.get()); + return true; } -bool UsbListInterfacesFunction::ConvertUsageTypeSafely( - const UsbUsageType& input, - usb::UsageType* output) { - const bool converted = ConvertUsageTypeToApi(input, output); - if (!converted) - SetError(kErrorConvertUsageType); - return converted; +void UsbListInterfacesFunction::AsyncWorkStart() { + scoped_refptr device_handle = + GetDeviceHandleOrCompleteWithError(parameters_->handle); + if (!device_handle.get()) { + return; + } + + ConfigDescriptor config; + ConvertConfigDescriptor(device_handle->GetDevice()->GetConfiguration(), + &config); + + scoped_ptr result(new base::ListValue); + for (size_t i = 0; i < config.interfaces.size(); ++i) { + result->Append(config.interfaces[i]->ToValue().release()); + } + + SetResult(result.release()); + AsyncWorkCompleted(); } UsbCloseDeviceFunction::UsbCloseDeviceFunction() { diff --git a/extensions/browser/api/usb/usb_api.h b/extensions/browser/api/usb/usb_api.h index 2a0a6ef..8bd673f 100644 --- a/extensions/browser/api/usb/usb_api.h +++ b/extensions/browser/api/usb/usb_api.h @@ -144,6 +144,22 @@ class UsbOpenDeviceFunction : public UsbAsyncApiFunction { scoped_ptr parameters_; }; +class UsbGetConfigurationFunction : public UsbAsyncApiFunction { + public: + DECLARE_EXTENSION_FUNCTION("usb.getConfiguration", USB_GETCONFIGURATION) + + UsbGetConfigurationFunction(); + + protected: + virtual ~UsbGetConfigurationFunction(); + + virtual bool Prepare() OVERRIDE; + virtual void AsyncWorkStart() OVERRIDE; + + private: + scoped_ptr parameters_; +}; + class UsbListInterfacesFunction : public UsbAsyncApiFunction { public: DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES) @@ -157,17 +173,6 @@ class UsbListInterfacesFunction : public UsbAsyncApiFunction { virtual void AsyncWorkStart() OVERRIDE; private: - bool ConvertDirectionSafely(const device::UsbEndpointDirection& input, - extensions::core_api::usb::Direction* output); - bool ConvertSynchronizationTypeSafely( - const device::UsbSynchronizationType& input, - extensions::core_api::usb::SynchronizationType* output); - bool ConvertTransferTypeSafely( - const device::UsbTransferType& input, - extensions::core_api::usb::TransferType* output); - bool ConvertUsageTypeSafely(const device::UsbUsageType& input, - extensions::core_api::usb::UsageType* output); - scoped_ptr parameters_; }; diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 61db879..fc1ba2b7 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -952,6 +952,7 @@ enum HistogramValue { EASYUNLOCKPRIVATE_GETSIGNINCHALLENGE, EASYUNLOCKPRIVATE_TRYSIGNINSECRET, ACCESSIBILITY_PRIVATE_SETFOCUSRING, + USB_GETCONFIGURATION, // Last entry: Add new entries above and ensure to update // tools/metrics/histograms/histograms.xml. ENUM_BOUNDARY diff --git a/extensions/common/api/usb.idl b/extensions/common/api/usb.idl index 18dd1f3..af6d550 100644 --- a/extensions/common/api/usb.idl +++ b/extensions/common/api/usb.idl @@ -60,6 +60,8 @@ namespace usb { UsageType? usage; // Polling interval (interrupt and isochronous only). long? pollingInterval; + // Extra descriptor data associated with this endpoint. + ArrayBuffer extra_data; }; [noinline_doc] dictionary InterfaceDescriptor { @@ -77,6 +79,25 @@ namespace usb { DOMString? description; // Available endpoints. EndpointDescriptor[] endpoints; + // Extra descriptor data associated with this interface. + ArrayBuffer extra_data; + }; + + [noinline_doc] dictionary ConfigDescriptor { + // The configuration number. + long configurationValue; + // Description of the configuration. + DOMString? description; + // The device is self-powered. + boolean selfPowered; + // The device supports remote wakeup. + boolean remoteWakeup; + // The maximum power needed by this device in milliamps (mA). + long maxPower; + // Available interfaces. + InterfaceDescriptor[] interfaces; + // Extra descriptor data associated with this configuration. + ArrayBuffer extra_data; }; dictionary ControlTransferInfo { @@ -181,6 +202,7 @@ namespace usb { callback RequestAccessCallback = void (boolean success); callback OpenDeviceCallback = void (ConnectionHandle handle); callback FindDevicesCallback = void (ConnectionHandle[] handles); + callback GetConfigurationCallback = void (ConfigDescriptor config); callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); callback CloseDeviceCallback = void (); callback TransferCallback = void (TransferResultInfo info); @@ -232,6 +254,12 @@ namespace usb { static void closeDevice(ConnectionHandle handle, optional CloseDeviceCallback callback); + // Gets the configuration descriptor for the currently selected + // configuration. + // |handle|: An open connection to the device. + static void getConfiguration(ConnectionHandle handle, + GetConfigurationCallback callback); + // Lists all interfaces on a USB device. // |handle|: An open connection to the device. static void listInterfaces(ConnectionHandle handle, diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 759fb73..fea147b 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -41549,6 +41549,7 @@ Therefore, the affected-histogram name has to have at least one dot in it. + -- cgit v1.1 From 8dc42c4dbf738d543362385bb0e2e2170a0b5edc Mon Sep 17 00:00:00 2001 From: bradnelson Date: Sat, 13 Sep 2014 22:22:03 -0700 Subject: Default to returning success in utime. Restoring the previous behavior of nacl_io regarding utime, such that it pretends to succeed when a mount doesn't implement utime. BUG=https://code.google.com/p/chromium/issues/detail?id=414058 TEST=trybots TBR=binji@chromium.org Review URL: https://codereview.chromium.org/571773002 Cr-Commit-Position: refs/heads/master@{#294759} --- native_client_sdk/src/libraries/nacl_io/node.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native_client_sdk/src/libraries/nacl_io/node.cc b/native_client_sdk/src/libraries/nacl_io/node.cc index 76d3734..6702dc8 100644 --- a/native_client_sdk/src/libraries/nacl_io/node.cc +++ b/native_client_sdk/src/libraries/nacl_io/node.cc @@ -177,7 +177,7 @@ Error Node::Tcsetattr(int optional_actions, const struct termios* termios_p) { } Error Node::Futimens(const struct timespec times[2]) { - return EINVAL; + return 0; } int Node::GetLinks() { -- cgit v1.1 From b5e408e7bffd3d1e6b60612f65c0538a90329c59 Mon Sep 17 00:00:00 2001 From: lanwei Date: Sat, 13 Sep 2014 22:24:07 -0700 Subject: Clean up GestureEventDetails' constructors. In one of the GestureEventDetails' constructors, the arguments delta_x, delta_y sometime are not used, so we should make a new constructor which only takes one argument EventType. BUG=350942 Review URL: https://codereview.chromium.org/565583005 Cr-Commit-Position: refs/heads/master@{#294760} --- ash/drag_drop/drag_drop_controller.cc | 11 ++-- ash/drag_drop/drag_drop_controller_unittest.cc | 2 +- ash/shelf/shelf_tooltip_manager_unittest.cc | 6 ++- .../rotation/tray_rotation_lock_unittest.cc | 4 +- .../overview/overview_button_tray_unittest.cc | 4 +- .../autofill_popup_base_view_browsertest.cc | 2 +- .../views/desktop_media_picker_views_unittest.cc | 10 ++-- .../tabs/tab_drag_controller_interactive_uitest.cc | 13 +++-- .../input/gesture_text_selector_unittest.cc | 2 +- .../touch_editable_impl_aura_browsertest.cc | 17 +++---- ui/aura/remote_window_tree_host_win.cc | 2 +- ui/aura/window_event_dispatcher_unittest.cc | 2 +- ui/events/gesture_detection/gesture_event_data.cc | 2 +- .../gesture_event_data_packet_unittest.cc | 2 +- ui/events/gesture_detection/gesture_provider.cc | 19 ++++--- .../touch_disposition_gesture_filter.cc | 2 +- .../touch_disposition_gesture_filter_unittest.cc | 2 +- ui/events/gesture_event_details.cc | 26 +++------- ui/events/gesture_event_details.h | 7 +++ ui/events/test/event_generator.cc | 6 +-- ui/views/controls/button/custom_button_unittest.cc | 2 +- ui/views/controls/table/table_view_unittest.cc | 7 ++- ui/views/controls/textfield/textfield_unittest.cc | 46 +++++++++-------- .../corewm/desktop_capture_controller_unittest.cc | 11 ++-- .../touch_selection_controller_impl_unittest.cc | 40 ++++++--------- ui/views/view_targeter_unittest.cc | 16 +++--- ui/views/widget/root_view_unittest.cc | 54 +++++++------------- ui/views/widget/widget_interactive_uitest.cc | 6 +-- ui/views/widget/widget_unittest.cc | 58 ++++++++++------------ ui/wm/core/user_activity_detector_unittest.cc | 6 ++- 30 files changed, 171 insertions(+), 216 deletions(-) diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index 004298c..21510e7 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -64,12 +64,11 @@ gfx::Rect AdjustDragImageBoundsForScaleAndOffset( void DispatchGestureEndToWindow(aura::Window* window) { if (window && window->delegate()) { - ui::GestureEvent gesture_end( - 0, - 0, - 0, - ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent gesture_end(0, + 0, + 0, + ui::EventTimeForNow(), + ui::GestureEventDetails(ui::ET_GESTURE_END)); window->delegate()->OnGestureEvent(&gesture_end); } } diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index 48ff847..252b567 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -273,7 +273,7 @@ void AddViewToWidgetAndResize(views::Widget* widget, views::View* view) { } void DispatchGesture(ui::EventType gesture_type, gfx::Point location) { - ui::GestureEventDetails event_details(gesture_type, 0, 0); + ui::GestureEventDetails event_details(gesture_type); event_details.set_oldest_touch_id(1); ui::GestureEvent gesture_event( location.x(), location.y(), 0, ui::EventTimeForNow(), event_details); diff --git a/ash/shelf/shelf_tooltip_manager_unittest.cc b/ash/shelf/shelf_tooltip_manager_unittest.cc index 295c7e9..bafe29c 100644 --- a/ash/shelf/shelf_tooltip_manager_unittest.cc +++ b/ash/shelf/shelf_tooltip_manager_unittest.cc @@ -207,9 +207,11 @@ TEST_F(ShelfTooltipManagerTest, ShouldHideForEvents) { // Should hide for gesture events. ui::GestureEvent gesture_event( - 0, 0, ui::EF_NONE, + 0, + 0, + ui::EF_NONE, base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), - ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0.0f, 0.0f)); + ui::GestureEventDetails(ui::ET_GESTURE_BEGIN)); SetEventTarget(tooltip_widget->GetNativeWindow(), &gesture_event); event_handler->OnGestureEvent(&gesture_event); EXPECT_FALSE(gesture_event.handled()); diff --git a/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc b/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc index dd6eb40..7a53f9d 100644 --- a/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc +++ b/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc @@ -209,8 +209,8 @@ TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { EnableMaximizeModeWindowManager(true); ASSERT_FALSE(tray_view()->visible()); - ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f)); + ui::GestureEvent tap( + 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); default_view()->OnGestureEvent(&tap); EXPECT_TRUE(maximize_mode_controller->rotation_locked()); EXPECT_TRUE(tray_view()->visible()); diff --git a/ash/system/overview/overview_button_tray_unittest.cc b/ash/system/overview/overview_button_tray_unittest.cc index 2471533..27ff367 100644 --- a/ash/system/overview/overview_button_tray_unittest.cc +++ b/ash/system/overview/overview_button_tray_unittest.cc @@ -78,8 +78,8 @@ TEST_F(OverviewButtonTrayTest, PerformAction) { // Overview Mode only works when there is a window scoped_ptr window( CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); - ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f)); + ui::GestureEvent tap( + 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); GetTray()->PerformAction(tap); EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()-> IsSelecting()); diff --git a/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc b/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc index b767efe..01f5288 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc @@ -63,7 +63,7 @@ class AutofillPopupBaseViewTest : public InProcessBrowserTest { point.y(), 0, ui::EventTimeForNow(), - ui::GestureEventDetails(type, 0, 0)); + ui::GestureEventDetails(type)); } void SimulateGesture(ui::GestureEvent* event) { diff --git a/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc b/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc index 511493d..4fb7576 100644 --- a/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc +++ b/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc @@ -126,13 +126,9 @@ TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleTap) { content::DesktopMediaID::TYPE_WINDOW, kFakeId))); media_list_->AddSource(kFakeId); - - ui::GestureEvent double_tap( - 10, - 10, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 2, 0)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(2); + ui::GestureEvent double_tap(10, 10, 0, base::TimeDelta(), details); GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnGestureEvent( &double_tap); diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc index 4b6b5e8..9ac23b4 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc @@ -335,17 +335,16 @@ IN_PROC_BROWSER_TEST_F(TabDragControllerTest, GestureEndShouldEndDragTest) { tab_1_center.x(), 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, 0.0f, 0.0f)); + ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); tab_strip->MaybeStartDrag(tab1, gesture_tap_down, tab_strip->GetSelectionModel()); EXPECT_TRUE(TabDragController::IsActive()); - ui::GestureEvent gesture_end( - tab_1_center.x(), - tab_1_center.x(), - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0.0f, 0.0f)); + ui::GestureEvent gesture_end(tab_1_center.x(), + tab_1_center.x(), + 0, + base::TimeDelta(), + ui::GestureEventDetails(ui::ET_GESTURE_END)); tab_strip->OnGestureEvent(&gesture_end); EXPECT_FALSE(TabDragController::IsActive()); EXPECT_FALSE(tab_strip->IsDragSessionActive()); diff --git a/content/browser/renderer_host/input/gesture_text_selector_unittest.cc b/content/browser/renderer_host/input/gesture_text_selector_unittest.cc index 762ef62..5304244 100644 --- a/content/browser/renderer_host/input/gesture_text_selector_unittest.cc +++ b/content/browser/renderer_host/input/gesture_text_selector_unittest.cc @@ -61,7 +61,7 @@ class GestureTextSelectorTest : public testing::Test, base::TimeTicks event_time, float x, float y) { - return GestureEventData(GestureEventDetails(type, 0, 0), + return GestureEventData(GestureEventDetails(type), 0, MotionEvent::TOOL_TYPE_FINGER, event_time, diff --git a/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc b/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc index 421f4ba..72c6cec 100644 --- a/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc +++ b/content/browser/web_contents/touch_editable_impl_aura_browsertest.cc @@ -207,7 +207,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 10, 0, ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); touch_editable->Reset(); rwhva->OnGestureEvent(&long_press); touch_editable->WaitForSelectionChangeCallback(); @@ -227,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 10, 0, ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); rwhva->OnGestureEvent(&scroll_begin); EXPECT_FALSE(GetTouchSelectionController(touch_editable)); @@ -237,7 +237,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 10, 0, ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); rwhva->OnGestureEvent(&scroll_end); EXPECT_TRUE(GetTouchSelectionController(touch_editable)); } @@ -262,7 +262,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 10, 0, ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); touch_editable->Reset(); rwhva->OnGestureEvent(&long_press); touch_editable->WaitForSelectionChangeCallback(); @@ -292,12 +292,9 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); // Double-tap to select word. - ui::GestureEvent double_tap( - 10, - 10, - 0, - ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 2, 0)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(2); + ui::GestureEvent double_tap(10, 10, 0, ui::EventTimeForNow(), details); touch_editable->Reset(); rwhva->OnGestureEvent(&double_tap); touch_editable->WaitForSelectionChangeCallback(); diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc index f939ccb..80ffc99 100644 --- a/ui/aura/remote_window_tree_host_win.cc +++ b/ui/aura/remote_window_tree_host_win.cc @@ -389,7 +389,7 @@ void RemoteWindowTreeHostWin::OnEdgeGesture() { 0, 0, ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE)); SendEventToProcessor(&event); } diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc index d00c4e2..6d84645 100644 --- a/ui/aura/window_event_dispatcher_unittest.cc +++ b/ui/aura/window_event_dispatcher_unittest.cc @@ -1322,7 +1322,7 @@ TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { scoped_ptr window(CreateTestWindowWithDelegate( &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); - ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN, 0.0f, 0.0f); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN); gfx::Point point(10, 10); ui::GestureEvent event(point.x(), point.y(), diff --git a/ui/events/gesture_detection/gesture_event_data.cc b/ui/events/gesture_detection/gesture_event_data.cc index 41824e8..2102f23 100644 --- a/ui/events/gesture_detection/gesture_event_data.cc +++ b/ui/events/gesture_detection/gesture_event_data.cc @@ -36,7 +36,7 @@ GestureEventData::GestureEventData(const GestureEventDetails& details, GestureEventData::GestureEventData(EventType type, const GestureEventData& other) - : details(type, 0, 0), + : details(type), motion_event_id(other.motion_event_id), primary_tool_type(other.primary_tool_type), time(other.time), diff --git a/ui/events/gesture_detection/gesture_event_data_packet_unittest.cc b/ui/events/gesture_detection/gesture_event_data_packet_unittest.cc index 01330b3..f8af11e 100644 --- a/ui/events/gesture_detection/gesture_event_data_packet_unittest.cc +++ b/ui/events/gesture_detection/gesture_event_data_packet_unittest.cc @@ -16,7 +16,7 @@ const float kTouchX = 13.7f; const float kTouchY = 14.2f; GestureEventData CreateGesture(EventType type) { - return GestureEventData(GestureEventDetails(type, 0, 0), + return GestureEventData(GestureEventDetails(type), 0, MotionEvent::TOOL_TYPE_FINGER, base::TimeTicks(), diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc index b31ec59..981eb0a 100644 --- a/ui/events/gesture_detection/gesture_provider.cc +++ b/ui/events/gesture_detection/gesture_provider.cc @@ -246,7 +246,8 @@ class GestureProvider::GestureListenerImpl : 1.0f - kDoubleTapDragZoomSpeed, std::abs(dy)); } - GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0); + GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE); + pinch_details.set_scale(scale); Send(CreateGesture(pinch_details, e.GetId(), e.GetToolType(), @@ -263,7 +264,7 @@ class GestureProvider::GestureListenerImpl // GestureDetector::GestureListener implementation. virtual bool OnDown(const MotionEvent& e) OVERRIDE { - GestureEventDetails tap_details(ET_GESTURE_TAP_DOWN, 0, 0); + GestureEventDetails tap_details(ET_GESTURE_TAP_DOWN); Send(CreateGesture(tap_details, e)); // Return true to indicate that we want to handle touch. @@ -403,7 +404,7 @@ class GestureProvider::GestureListenerImpl } virtual void OnShowPress(const MotionEvent& e) OVERRIDE { - GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); + GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS); show_press_event_sent_ = true; Send(CreateGesture(show_press_details, e)); } @@ -433,7 +434,7 @@ class GestureProvider::GestureListenerImpl if (e.GetAction() == MotionEvent::ACTION_UP && !current_longpress_time_.is_null() && !IsScaleGestureDetectionInProgress()) { - GestureEventDetails long_tap_details(ET_GESTURE_LONG_TAP, 0, 0); + GestureEventDetails long_tap_details(ET_GESTURE_LONG_TAP); Send(CreateGesture(long_tap_details, e)); return true; } @@ -482,7 +483,7 @@ class GestureProvider::GestureListenerImpl virtual void OnLongPress(const MotionEvent& e) OVERRIDE { DCHECK(!IsDoubleTapInProgress()); SetIgnoreSingleTap(true); - GestureEventDetails long_press_details(ET_GESTURE_LONG_PRESS, 0, 0); + GestureEventDetails long_press_details(ET_GESTURE_LONG_PRESS); Send(CreateGesture(long_press_details, e)); } @@ -521,7 +522,7 @@ class GestureProvider::GestureListenerImpl size_t touch_point_count, const gfx::RectF& bounding_box, int flags) { - return GestureEventData(GestureEventDetails(type, 0, 0), + return GestureEventData(GestureEventDetails(type), motion_event_id, primary_tool_type, time, @@ -550,14 +551,16 @@ class GestureProvider::GestureListenerImpl } GestureEventData CreateGesture(EventType type, const MotionEvent& event) { - return CreateGesture(GestureEventDetails(type, 0, 0), event); + return CreateGesture(GestureEventDetails(type), event); } GestureEventData CreateTapGesture(EventType type, const MotionEvent& event) { // Set the tap count to 1 even for ET_GESTURE_DOUBLE_TAP, in order to be // consistent with double tap behavior on a mobile viewport. See // crbug.com/234986 for context. - return CreateGesture(GestureEventDetails(type, 1, 0), event); + GestureEventDetails details(type); + details.set_tap_count(1); + return CreateGesture(details, event); } gfx::RectF GetBoundingBox(const MotionEvent& event, EventType type) { diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter.cc b/ui/events/gesture_detection/touch_disposition_gesture_filter.cc index a72390c..fcb92d4 100644 --- a/ui/events/gesture_detection/touch_disposition_gesture_filter.cc +++ b/ui/events/gesture_detection/touch_disposition_gesture_filter.cc @@ -21,7 +21,7 @@ GestureEventData CreateGesture(EventType type, const GestureEventDataPacket& packet) { // As the event is purely synthetic, we needn't be strict with event flags. int flags = EF_NONE; - return GestureEventData(GestureEventDetails(type, 0, 0), + return GestureEventData(GestureEventDetails(type), motion_event_id, primary_tool_type, packet.timestamp(), diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc index 2e37efb..7e99c94 100644 --- a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc +++ b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc @@ -230,7 +230,7 @@ class TouchDispositionGestureFilterTest float y, float diameter) { return GestureEventData( - GestureEventDetails(type, 0, 0), + GestureEventDetails(type), 0, MotionEvent::TOOL_TYPE_FINGER, base::TimeTicks(), diff --git a/ui/events/gesture_event_details.cc b/ui/events/gesture_event_details.cc index 3f478e5..7807131 100644 --- a/ui/events/gesture_event_details.cc +++ b/ui/events/gesture_event_details.cc @@ -10,10 +10,16 @@ GestureEventDetails::GestureEventDetails() : type_(ET_UNKNOWN), touch_points_(0), oldest_touch_id_(-1) { } +GestureEventDetails::GestureEventDetails(ui::EventType type) + : type_(type), touch_points_(1), oldest_touch_id_(-1) { + DCHECK_GE(type, ET_GESTURE_TYPE_START); + DCHECK_LE(type, ET_GESTURE_TYPE_END); +} + GestureEventDetails::GestureEventDetails(ui::EventType type, float delta_x, float delta_y) - : type_(type), touch_points_(1), oldest_touch_id_(0) { + : type_(type), touch_points_(1), oldest_touch_id_(-1) { DCHECK_GE(type, ET_GESTURE_TYPE_START); DCHECK_LE(type, ET_GESTURE_TYPE_END); switch (type_) { @@ -37,11 +43,6 @@ GestureEventDetails::GestureEventDetails(ui::EventType type, data.first_finger_enclosing_rectangle.height = delta_y; break; - case ui::ET_GESTURE_PINCH_UPDATE: - data.scale = delta_x; - CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch"; - break; - case ui::ET_GESTURE_SWIPE: data.swipe.left = delta_x < 0; data.swipe.right = delta_x > 0; @@ -49,19 +50,8 @@ GestureEventDetails::GestureEventDetails(ui::EventType type, data.swipe.down = delta_y > 0; break; - case ui::ET_GESTURE_TAP: - case ui::ET_GESTURE_DOUBLE_TAP: - case ui::ET_GESTURE_TAP_UNCONFIRMED: - data.tap_count = static_cast(delta_x); - CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for tap."; - break; - default: - if (delta_x != 0.f || delta_y != 0.f) { - DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: (" - << delta_x << "," << delta_y; - } - break; + NOTREACHED() << "Invalid event type for constructor: " << type; } } diff --git a/ui/events/gesture_event_details.h b/ui/events/gesture_event_details.h index 58d28fa..da7a60b 100644 --- a/ui/events/gesture_event_details.h +++ b/ui/events/gesture_event_details.h @@ -16,6 +16,7 @@ namespace ui { struct EVENTS_BASE_EXPORT GestureEventDetails { public: GestureEventDetails(); + explicit GestureEventDetails(EventType type); GestureEventDetails(EventType type, float delta_x, float delta_y); EventType type() const { return type_; } @@ -123,6 +124,12 @@ struct EVENTS_BASE_EXPORT GestureEventDetails { data.tap_count = tap_count; } + void set_scale(float scale) { + DCHECK_GE(scale, 0.0f); + DCHECK_EQ(type_, ET_GESTURE_PINCH_UPDATE); + data.scale = scale; + } + private: EventType type_; union Details { diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc index 05dd286..ad9d597 100644 --- a/ui/events/test/event_generator.cc +++ b/ui/events/test/event_generator.cc @@ -248,11 +248,7 @@ void EventGenerator::PressMoveAndReleaseTouchToCenterOf(EventTarget* window) { void EventGenerator::GestureEdgeSwipe() { ui::GestureEvent gesture( - 0, - 0, - 0, - Now(), - ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0)); + 0, 0, 0, Now(), ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE)); Dispatch(&gesture); } diff --git a/ui/views/controls/button/custom_button_unittest.cc b/ui/views/controls/button/custom_button_unittest.cc index 49d9987..a5d97c9 100644 --- a/ui/views/controls/button/custom_button_unittest.cc +++ b/ui/views/controls/button/custom_button_unittest.cc @@ -36,7 +36,7 @@ class TestCustomButton : public CustomButton { }; void PerformGesture(CustomButton* button, ui::EventType event_type) { - ui::GestureEventDetails gesture_details(event_type, 0, 0); + ui::GestureEventDetails gesture_details(event_type); base::TimeDelta time_stamp = base::TimeDelta::FromMicroseconds(0); ui::GestureEvent gesture_event(0, 0, 0, time_stamp, gesture_details); button->OnGestureEvent(&gesture_event); diff --git a/ui/views/controls/table/table_view_unittest.cc b/ui/views/controls/table/table_view_unittest.cc index e592f2e..6ce06c8 100644 --- a/ui/views/controls/table/table_view_unittest.cc +++ b/ui/views/controls/table/table_view_unittest.cc @@ -198,8 +198,7 @@ class TableViewTest : public testing::Test { void TapOnRow(int row) { const int y = row * table_->row_height(); - const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP, - .0f, .0f); + const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP); ui::GestureEvent tap(0, y, 0, base::TimeDelta(), event_details); table_->OnGestureEvent(&tap); } @@ -312,14 +311,14 @@ TEST_F(TableViewTest, ResizeViaGesture) { 0, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, .0f, .0f)); + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); helper_->header()->OnGestureEvent(&scroll_begin); ui::GestureEvent scroll_update( x - 1, 0, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, .0f, .0f)); + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE)); helper_->header()->OnGestureEvent(&scroll_update); // This should shrink the first column and pull the second column in. diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc index 2cd92c0..b7a6117 100644 --- a/ui/views/controls/textfield/textfield_unittest.cc +++ b/ui/views/controls/textfield/textfield_unittest.cc @@ -103,16 +103,8 @@ class TestTextfield : public views::Textfield { // Convenience to make constructing a GestureEvent simpler. class GestureEventForTest : public ui::GestureEvent { public: - GestureEventForTest(ui::EventType type, - int x, - int y, - float delta_x, - float delta_y) - : GestureEvent(x, - y, - 0, - base::TimeDelta(), - ui::GestureEventDetails(type, delta_x, delta_y)) {} + GestureEventForTest(int x, int y, ui::GestureEventDetails details) + : GestureEvent(x, y, 0, base::TimeDelta(), details) {} private: DISALLOW_COPY_AND_ASSIGN(GestureEventForTest); @@ -330,23 +322,26 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController { // Simulates a complete tap. void Tap(const gfx::Point& point) { GestureEventForTest begin( - ui::ET_GESTURE_BEGIN, point.x(), point.y(), 0.0f, 0.0f); + point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_BEGIN)); textfield_->OnGestureEvent(&begin); GestureEventForTest tap_down( - ui::ET_GESTURE_TAP_DOWN, point.x(), point.y(), 0.0f, 0.0f); + point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); textfield_->OnGestureEvent(&tap_down); GestureEventForTest show_press( - ui::ET_GESTURE_SHOW_PRESS, point.x(), point.y(), 0.0f, 0.0f); + point.x(), + point.y(), + ui::GestureEventDetails(ui::ET_GESTURE_SHOW_PRESS)); textfield_->OnGestureEvent(&show_press); - GestureEventForTest tap( - ui::ET_GESTURE_TAP, point.x(), point.y(), 1.0f, 0.0f); + ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP); + tap_details.set_tap_count(1); + GestureEventForTest tap(point.x(), point.y(), tap_details); textfield_->OnGestureEvent(&tap); GestureEventForTest end( - ui::ET_GESTURE_END, point.x(), point.y(), 0.0f, 0.0f); + point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_END)); textfield_->OnGestureEvent(&end); } @@ -1957,7 +1952,9 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) { CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing); // Tapping on the textfield should turn on the TouchSelectionController. - GestureEventForTest tap(ui::ET_GESTURE_TAP, x, 0, 1.0f, 0.0f); + ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP); + tap_details.set_tap_count(1); + GestureEventForTest tap(x, 0, tap_details); textfield_->OnGestureEvent(&tap); EXPECT_TRUE(test_api_->touch_selection_controller()); @@ -1968,7 +1965,8 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) { // With touch editing enabled, long press should not show context menu. // Instead, select word and invoke TouchSelectionController. - GestureEventForTest long_press_1(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f); + GestureEventForTest long_press_1( + x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); textfield_->OnGestureEvent(&long_press_1); EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); EXPECT_TRUE(test_api_->touch_selection_controller()); @@ -1977,7 +1975,8 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) { // With touch drag drop enabled, long pressing in the selected region should // start a drag and remove TouchSelectionController. ASSERT_TRUE(switches::IsTouchDragDropEnabled()); - GestureEventForTest long_press_2(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f); + GestureEventForTest long_press_2( + x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); textfield_->OnGestureEvent(&long_press_2); EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); EXPECT_FALSE(test_api_->touch_selection_controller()); @@ -1988,7 +1987,8 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kDisableTouchDragDrop); ASSERT_FALSE(switches::IsTouchDragDropEnabled()); - GestureEventForTest long_press_3(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f); + GestureEventForTest long_press_3( + x, 0, ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); textfield_->OnGestureEvent(&long_press_3); EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); EXPECT_FALSE(test_api_->touch_selection_controller()); @@ -2033,8 +2033,10 @@ TEST_F(TextfieldTest, TestLongPressInitiatesDragDrop) { switches::kEnableTouchDragDrop); // Create a long press event in the selected region should start a drag. - GestureEventForTest long_press(ui::ET_GESTURE_LONG_PRESS, kStringPoint.x(), - kStringPoint.y(), 0.0f, 0.0f); + GestureEventForTest long_press( + kStringPoint.x(), + kStringPoint.y(), + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); textfield_->OnGestureEvent(&long_press); EXPECT_TRUE(textfield_->CanStartDragForView(NULL, kStringPoint, kStringPoint)); diff --git a/ui/views/corewm/desktop_capture_controller_unittest.cc b/ui/views/corewm/desktop_capture_controller_unittest.cc index a7628a6..3baf0f4 100644 --- a/ui/views/corewm/desktop_capture_controller_unittest.cc +++ b/ui/views/corewm/desktop_capture_controller_unittest.cc @@ -167,12 +167,11 @@ TEST_F(DesktopCaptureControllerTest, CaptureWindowInputEventTest) { EXPECT_FALSE(widget2->GetNativeView()->HasCapture()); EXPECT_EQ(capture_client->GetCaptureWindow(), widget1->GetNativeView()); - ui::GestureEvent g1( - 80, - 80, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0.0f, 0.0f)); + ui::GestureEvent g1(80, + 80, + 0, + base::TimeDelta(), + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); details = root1->OnEventFromSource(&g1); EXPECT_FALSE(details.dispatcher_destroyed); EXPECT_FALSE(details.target_destroyed); diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc index acd62ff..b268d2c 100644 --- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc +++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc @@ -252,11 +252,9 @@ TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { CreateTextfield(); textfield_->SetText(ASCIIToUTF16("some text")); // Tap the textfield to invoke touch selection. - ui::GestureEvent tap(0, - 0, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(1); + ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), details); textfield_->OnGestureEvent(&tap); // Test selecting a range. @@ -287,11 +285,9 @@ TEST_F(TouchSelectionControllerImplTest, SelectionInBidiTextfieldTest) { CreateTextfield(); textfield_->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2")); // Tap the textfield to invoke touch selection. - ui::GestureEvent tap(0, - 0, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(1); + ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), details); textfield_->OnGestureEvent(&tap); // Test cursor at run boundary and with empty selection. @@ -338,11 +334,9 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) { CreateTextfield(); textfield_->SetText(ASCIIToUTF16("textfield with selected text")); // Tap the textfield to invoke touch selection. - ui::GestureEvent tap(0, - 0, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(1); + ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), details); textfield_->OnGestureEvent(&tap); textfield_->SelectRange(gfx::Range(3, 7)); @@ -379,11 +373,9 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) { CreateTextfield(); textfield_->SetText(WideToUTF16(L"abc\x05e1\x05e2\x05e3" L"def")); // Tap the textfield to invoke touch selection. - ui::GestureEvent tap(0, - 0, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(1); + ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), details); textfield_->OnGestureEvent(&tap); // Select [c] from left to right. @@ -511,11 +503,9 @@ TEST_F(TouchSelectionControllerImplTest, textfield_->SetText(ASCIIToUTF16(textfield_text)); // Tap the textfield to invoke selection. - ui::GestureEvent tap(0, - 0, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f)); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); + details.set_tap_count(1); + ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), details); textfield_->OnGestureEvent(&tap); // Select some text such that one handle is hidden. diff --git a/ui/views/view_targeter_unittest.cc b/ui/views/view_targeter_unittest.cc index 92d0fd6..b855161 100644 --- a/ui/views/view_targeter_unittest.cc +++ b/ui/views/view_targeter_unittest.cc @@ -231,7 +231,7 @@ class GestureEventForTest : public ui::GestureEvent { y, 0, base::TimeDelta(), - ui::GestureEventDetails(type, 0.0f, 0.0f)) {} + ui::GestureEventDetails(type)) {} GestureEventForTest(ui::GestureEventDetails details, int x, int y) : GestureEvent(x, y, 0, base::TimeDelta(), details) {} @@ -266,13 +266,13 @@ TEST_F(ViewTargeterTest, ViewTargeterForGestureEvents) { // Define some gesture events for testing. gfx::Rect bounding_box(gfx::Point(46, 46), gfx::Size(8, 8)); gfx::Point center_point(bounding_box.CenterPoint()); - ui::GestureEventDetails details(ui::ET_GESTURE_TAP, 0.0f, 0.0f); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); details.set_bounding_box(bounding_box); GestureEventForTest tap(details, center_point.x(), center_point.y()); - details = ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0.0f, 0.0f); + details = ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN); details.set_bounding_box(bounding_box); GestureEventForTest scroll_begin(details, center_point.x(), center_point.y()); - details = ui::GestureEventDetails(ui::ET_GESTURE_END, 0.0f, 0.0f); + details = ui::GestureEventDetails(ui::ET_GESTURE_END); details.set_bounding_box(bounding_box); GestureEventForTest end(details, center_point.x(), center_point.y()); @@ -324,14 +324,14 @@ TEST_F(ViewTargeterTest, ViewTargeterForGestureEvents) { // again (calls to FindTargetForEvent() and FindNextBestTarget() // mutate the location of the gesture events to be in the coordinate // space of the returned view). - details = ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f); + details = ui::GestureEventDetails(ui::ET_GESTURE_TAP); details.set_bounding_box(bounding_box); tap = GestureEventForTest(details, center_point.x(), center_point.y()); - details = ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0.0f, 0.0f); + details = ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN); details.set_bounding_box(bounding_box); scroll_begin = GestureEventForTest(details, center_point.x(), center_point.y()); - details = ui::GestureEventDetails(ui::ET_GESTURE_END, 0.0f, 0.0f); + details = ui::GestureEventDetails(ui::ET_GESTURE_END); details.set_bounding_box(bounding_box); end = GestureEventForTest(details, center_point.x(), center_point.y()); @@ -381,7 +381,7 @@ TEST_F(ViewTargeterTest, GestureEventCoordinateConversion) { // in root view coordinates with width and height of 4. gfx::Rect bounding_box(gfx::Point(58, 58), gfx::Size(4, 4)); gfx::Point center_point(bounding_box.CenterPoint()); - ui::GestureEventDetails details(ui::ET_GESTURE_TAP, 0.0f, 0.0f); + ui::GestureEventDetails details(ui::ET_GESTURE_TAP); details.set_bounding_box(bounding_box); GestureEventForTest tap(details, center_point.x(), center_point.y()); diff --git a/ui/views/widget/root_view_unittest.cc b/ui/views/widget/root_view_unittest.cc index d13e6c99..f4836cd 100644 --- a/ui/views/widget/root_view_unittest.cc +++ b/ui/views/widget/root_view_unittest.cc @@ -206,14 +206,11 @@ TEST_F(RootViewTest, ContextMenuFromLongPress) { 5, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); - ui::GestureEvent end1(5, - 5, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent end1( + 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); details = root_view->OnEventFromSource(&end1); EXPECT_FALSE(details.target_destroyed); @@ -228,14 +225,11 @@ TEST_F(RootViewTest, ContextMenuFromLongPress) { 5, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); details = root_view->OnEventFromSource(&long_press2); - ui::GestureEvent end2(25, - 5, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent end2( + 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); details = root_view->OnEventFromSource(&end2); EXPECT_FALSE(details.target_destroyed); @@ -250,14 +244,11 @@ TEST_F(RootViewTest, ContextMenuFromLongPress) { 50, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); details = root_view->OnEventFromSource(&long_press3); - ui::GestureEvent end3(25, - 5, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent end3( + 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); details = root_view->OnEventFromSource(&end3); EXPECT_FALSE(details.target_destroyed); @@ -300,14 +291,11 @@ TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) { 5, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); - ui::GestureEvent end1(5, - 5, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent end1( + 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); details = root_view->OnEventFromSource(&end1); EXPECT_FALSE(details.target_destroyed); @@ -322,14 +310,11 @@ TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) { 5, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); details = root_view->OnEventFromSource(&long_press2); - ui::GestureEvent end2(25, - 5, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent end2( + 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); details = root_view->OnEventFromSource(&end2); EXPECT_FALSE(details.target_destroyed); @@ -344,14 +329,11 @@ TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) { 50, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); details = root_view->OnEventFromSource(&long_press3); - ui::GestureEvent end3(25, - 5, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEvent end3( + 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); details = root_view->OnEventFromSource(&end3); EXPECT_FALSE(details.target_destroyed); diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc index d3827df..68d646c 100644 --- a/ui/views/widget/widget_interactive_uitest.cc +++ b/ui/views/widget/widget_interactive_uitest.cc @@ -301,14 +301,12 @@ TEST_F(WidgetTestInteractive, ResetCaptureOnGestureEnd) { 15, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, - 0, - 0)); + ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); ui::GestureEvent end(15, 15, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_END)); toplevel->OnGestureEvent(&tap_down); // Now try to click on |mouse|. Since |gesture| will have capture, |mouse| diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index 2dc6b24..e006e06 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -1339,7 +1339,7 @@ TEST_F(WidgetTest, GestureScrollEventDispatching) { 5, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); widget->OnGestureEvent(&begin); ui::GestureEvent update( 25, @@ -1348,12 +1348,11 @@ TEST_F(WidgetTest, GestureScrollEventDispatching) { base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); widget->OnGestureEvent(&update); - ui::GestureEvent end( - 25, - 15, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0)); + ui::GestureEvent end(25, + 15, + 0, + base::TimeDelta(), + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); widget->OnGestureEvent(&end); EXPECT_EQ(1, noscroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); @@ -1367,7 +1366,7 @@ TEST_F(WidgetTest, GestureScrollEventDispatching) { 5, 0, base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); widget->OnGestureEvent(&begin); ui::GestureEvent update( 85, @@ -1376,12 +1375,11 @@ TEST_F(WidgetTest, GestureScrollEventDispatching) { base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 20, 10)); widget->OnGestureEvent(&update); - ui::GestureEvent end( - 85, - 15, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0)); + ui::GestureEvent end(85, + 15, + 0, + base::TimeDelta(), + ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); widget->OnGestureEvent(&end); EXPECT_EQ(1, scroll_view->GetEventCount(ui::ET_GESTURE_SCROLL_BEGIN)); @@ -1470,21 +1468,18 @@ TEST_F(WidgetTest, EventHandlersOnRootView) { 5, 0, ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, - 0, - 0)); + ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); widget->OnGestureEvent(&tap_down); EXPECT_EQ(1, h1.GetEventCount(ui::ET_GESTURE_TAP_DOWN)); EXPECT_EQ(1, view->GetEventCount(ui::ET_GESTURE_TAP_DOWN)); EXPECT_EQ(0, h2.GetEventCount(ui::ET_GESTURE_TAP_DOWN)); - ui::GestureEvent tap_cancel(5, - 5, - 0, - ui::EventTimeForNow(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL, - 0, - 0)); + ui::GestureEvent tap_cancel( + 5, + 5, + 0, + ui::EventTimeForNow(), + ui::GestureEventDetails(ui::ET_GESTURE_TAP_CANCEL)); widget->OnGestureEvent(&tap_cancel); EXPECT_EQ(1, h1.GetEventCount(ui::ET_GESTURE_TAP_CANCEL)); EXPECT_EQ(1, view->GetEventCount(ui::ET_GESTURE_TAP_CANCEL)); @@ -1954,12 +1949,11 @@ TEST_F(WidgetTest, MAYBE_DisableTestRootViewHandlersWhenHidden) { // Check RootView::gesture_handler_. widget->Show(); EXPECT_EQ(NULL, GetGestureHandler(root_view)); - ui::GestureEvent tap_down( - 15, - 15, - 0, - base::TimeDelta(), - ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN, 0, 0)); + ui::GestureEvent tap_down(15, + 15, + 0, + base::TimeDelta(), + ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN)); widget->OnGestureEvent(&tap_down); EXPECT_EQ(view, GetGestureHandler(root_view)); widget->Hide(); @@ -1976,7 +1970,7 @@ class GestureEventForTest : public ui::GestureEvent { y, 0, base::TimeDelta(), - ui::GestureEventDetails(type, 0.0f, 0.0f)) {} + ui::GestureEventDetails(type)) {} GestureEventForTest(ui::GestureEventDetails details, int x, int y) : GestureEvent(x, y, 0, base::TimeDelta(), details) {} @@ -2029,7 +2023,7 @@ TEST_F(WidgetTest, GestureBeginAndEndEvents) { // If no gesture handler is set, dispatching only a ui::ET_GESTURE_BEGIN // corresponding to a second touch point should not set the gesture handler // and should not be marked as handled because it is never dispatched. - ui::GestureEventDetails details(ui::ET_GESTURE_END, 15, 15); + ui::GestureEventDetails details(ui::ET_GESTURE_END); details.set_touch_points(2); GestureEventForTest end_second_touch_point(details, 15, 15); widget->OnGestureEvent(&end_second_touch_point); diff --git a/ui/wm/core/user_activity_detector_unittest.cc b/ui/wm/core/user_activity_detector_unittest.cc index df669c7..620ab0c 100644 --- a/ui/wm/core/user_activity_detector_unittest.cc +++ b/ui/wm/core/user_activity_detector_unittest.cc @@ -139,9 +139,11 @@ TEST_F(UserActivityDetectorTest, Basic) { AdvanceTime(advance_delta); ui::GestureEvent gesture_event( - 0, 0, ui::EF_NONE, + 0, + 0, + ui::EF_NONE, base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), - ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0)); + ui::GestureEventDetails(ui::ET_GESTURE_TAP)); detector_->OnGestureEvent(&gesture_event); EXPECT_FALSE(gesture_event.handled()); EXPECT_EQ(now_.ToInternalValue(), -- cgit v1.1 From b27b2bd22bf6ee984f3d9adf47369527298ae158 Mon Sep 17 00:00:00 2001 From: yoshiki Date: Sat, 13 Sep 2014 22:26:24 -0700 Subject: Support 'loop' atribute on fake video element for casting BUG=413006 TEST=manually tested Review URL: https://codereview.chromium.org/563253002 Cr-Commit-Position: refs/heads/master@{#294761} --- .../video_player/js/cast/cast_video_element.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ui/file_manager/video_player/js/cast/cast_video_element.js b/ui/file_manager/video_player/js/cast/cast_video_element.js index d613964..ccbc342f 100644 --- a/ui/file_manager/video_player/js/cast/cast_video_element.js +++ b/ui/file_manager/video_player/js/cast/cast_video_element.js @@ -36,6 +36,7 @@ function CastVideoElement(media, session) { this.currentTime_ = null; this.src_ = ''; this.volume_ = 100; + this.loop_ = false; this.currentMediaPlayerState_ = null; this.currentMediaCurrentTime_ = null; this.currentMediaDuration_ = null; @@ -193,6 +194,17 @@ CastVideoElement.prototype = { }, /** + * Returns the flag if the video loops at end or not. + * @type {boolean} + */ + get loop() { + return this.loop_; + }, + set loop(value) { + this.loop_ = !!value; + }, + + /** * Returns the error object if available. * @type {?Object} */ @@ -408,6 +420,21 @@ CastVideoElement.prototype = { return; var media = this.castMedia_; + if (this.loop_ && + media.idleReason === chrome.cast.media.IdleReason.FINISHED && + !alive) { + // Resets the previous media silently. + this.castMedia_ = null; + + // Replay the current media. + this.currentMediaPlayerState_ = chrome.cast.media.PlayerState.BUFFERING; + this.currentMediaCurrentTime_ = 0; + this.dispatchEvent(new Event('play')); + this.dispatchEvent(new Event('timeupdate')); + this.play(); + return; + } + if (this.currentMediaPlayerState_ !== media.playerState) { var oldPlayState = false; var oldState = this.currentMediaPlayerState_; -- cgit v1.1 From 32faa2e971b85b9e131880f13084988a9567dce3 Mon Sep 17 00:00:00 2001 From: yoshiki Date: Sat, 13 Sep 2014 22:27:36 -0700 Subject: Detach video when the another video is loaded BUG=none TEST=none TBR=fukino@chromium.org Review URL: https://codereview.chromium.org/569663002 Cr-Commit-Position: refs/heads/master@{#294762} --- ui/file_manager/video_player/js/video_player.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/file_manager/video_player/js/video_player.js b/ui/file_manager/video_player/js/video_player.js index dba0d6a..b941805 100644 --- a/ui/file_manager/video_player/js/video_player.js +++ b/ui/file_manager/video_player/js/video_player.js @@ -307,6 +307,7 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { // Re-enables ui and hides error message if already displayed. document.querySelector('#video-player').removeAttribute('disabled'); document.querySelector('#error').removeAttribute('visible'); + this.controls.detachMedia(); this.controls.inactivityWatcher.disabled = true; this.controls.decodeErrorOccured = false; this.controls.casting = !!this.currentCast_; -- cgit v1.1 From 983e6aaf1a9014b199c348a21f198b3e2d52c6c9 Mon Sep 17 00:00:00 2001 From: John Abd-El-Malek Date: Sat, 13 Sep 2014 22:39:01 -0700 Subject: Disable WebViewInteractiveTest.PointerLock which is flaky. BUG=412086 TBR=lfg@chromium.org Review URL: https://codereview.chromium.org/569083003 Cr-Commit-Position: refs/heads/master@{#294763} --- chrome/browser/apps/web_view_interactive_browsertest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/browser/apps/web_view_interactive_browsertest.cc b/chrome/browser/apps/web_view_interactive_browsertest.cc index 7dbd1db..281d32a3 100644 --- a/chrome/browser/apps/web_view_interactive_browsertest.cc +++ b/chrome/browser/apps/web_view_interactive_browsertest.cc @@ -550,8 +550,8 @@ class WebViewInteractiveTest // crbug.com/341876 #if defined(OS_LINUX) - -IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PointerLock) { +// flaky http://crbug.com/412086 +IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_PointerLock) { SetupTest("web_view/pointer_lock", "/extensions/platform_apps/web_view/pointer_lock/guest.html"); -- cgit v1.1 From af71ddc669b073844cbc10d6e0f8fd9f3cf36e98 Mon Sep 17 00:00:00 2001 From: John Abd-El-Malek Date: Sat, 13 Sep 2014 23:07:31 -0700 Subject: Revert "Adding DumpAccessibilityTree Tests (8 of 20)" This reverts commit 711d923e3b9dd778e482f991f280e6dd937d1abf. flaky a bunch of times. as an example, see http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%282%29/builds/22538/steps/content_browsertests/logs/AccessibilityFrameset DumpAccessibilityTreeTest.AccessibilityFrameset (run #1): [ RUN ] DumpAccessibilityTreeTest.AccessibilityFrameset Testing: E:\b\build\slave\Win7_Tests__dbg__2_\build\src\content\test\data\accessibility\frameset.html c:\b\build\slave\win_builder__dbg_\build\src\content\browser\accessibility\dump_accessibility_tree_browsertest.cc(252): error: Value of: is_different Actual: true Expected: false [3080:2208:0913/171203:4867433:WARNING:channel.cc(211)] WriteMessage() while shutting down * Line Expected - ---- -------- 1 ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE 2 ROLE_SYSTEM_CLIENT FOCUSABLE 3 IA2_ROLE_SCROLL_PANE 4 ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE 5 IA2_ROLE_PARAGRAPH 6 ROLE_SYSTEM_STATICTEXT name='My favorite browser is ' 7 ROLE_SYSTEM_STATICTEXT name='ABC' 8 ROLE_SYSTEM_STATICTEXT name='Chrome' 9 ROLE_SYSTEM_STATICTEXT name='!' 10 ROLE_SYSTEM_CLIENT FOCUSABLE 11 IA2_ROLE_SCROLL_PANE 12 ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE * 13 IA2_ROLE_PARAGRAPH 14 ROLE_SYSTEM_STATICTEXT name='This test is to check ' 15 ROLE_SYSTEM_STATICTEXT name='mark tag' 16 ROLE_SYSTEM_STATICTEXT name='.' 17 \u003C-- End-of-file --> Actual ------ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ROLE_SYSTEM_CLIENT FOCUSABLE IA2_ROLE_SCROLL_PANE ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE IA2_ROLE_PARAGRAPH ROLE_SYSTEM_STATICTEXT name='My favorite browser is ' ROLE_SYSTEM_STATICTEXT name='ABC' ROLE_SYSTEM_STATICTEXT name='Chrome' ROLE_SYSTEM_STATICTEXT name='!' ROLE_SYSTEM_CLIENT FOCUSABLE IA2_ROLE_SCROLL_PANE ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE [ FAILED ] DumpAccessibilityTreeTest.AccessibilityFrameset, where TypeParam = and GetParam() = (1903 ms) BUG= Review URL: https://codereview.chromium.org/567223002 Cr-Commit-Position: refs/heads/master@{#294764} --- .../dump_accessibility_tree_browsertest.cc | 40 ---------------------- .../accessibility/aria-atomic-expected-android.txt | 3 -- .../accessibility/aria-atomic-expected-mac.txt | 5 --- .../accessibility/aria-atomic-expected-win.txt | 5 --- content/test/data/accessibility/aria-atomic.html | 12 ------- .../accessibility/aria-row-expected-android.txt | 14 -------- .../data/accessibility/aria-row-expected-mac.txt | 20 ----------- .../data/accessibility/aria-row-expected-win.txt | 20 ----------- content/test/data/accessibility/aria-row.html | 19 ---------- .../data/accessibility/body-expected-android.txt | 2 -- .../test/data/accessibility/body-expected-mac.txt | 3 -- .../test/data/accessibility/body-expected-win.txt | 3 -- content/test/data/accessibility/body.html | 6 ---- .../accessibility/caption-expected-android.txt | 14 -------- .../data/accessibility/caption-expected-mac.txt | 20 ----------- .../data/accessibility/caption-expected-win.txt | 20 ----------- content/test/data/accessibility/caption.html | 22 ------------ .../accessibility/frameset-expected-android.txt | 1 - .../data/accessibility/frameset-expected-mac.txt | 16 --------- .../data/accessibility/frameset-expected-win.txt | 16 --------- content/test/data/accessibility/frameset.html | 9 ----- .../test/data/accessibility/i-expected-android.txt | 2 -- content/test/data/accessibility/i-expected-mac.txt | 5 --- content/test/data/accessibility/i-expected-win.txt | 5 --- content/test/data/accessibility/i.html | 8 ----- .../data/accessibility/ins-expected-android.txt | 3 -- .../test/data/accessibility/ins-expected-mac.txt | 6 ---- .../test/data/accessibility/ins-expected-win.txt | 6 ---- content/test/data/accessibility/ins.html | 8 ----- .../data/accessibility/legend-expected-android.txt | 8 ----- .../data/accessibility/legend-expected-mac.txt | 9 ----- .../data/accessibility/legend-expected-win.txt | 9 ----- content/test/data/accessibility/legend.html | 17 --------- .../data/accessibility/mark-expected-android.txt | 3 -- .../test/data/accessibility/mark-expected-mac.txt | 5 --- .../test/data/accessibility/mark-expected-win.txt | 5 --- content/test/data/accessibility/mark.html | 8 ----- .../data/accessibility/object-expected-android.txt | 3 -- .../data/accessibility/object-expected-mac.txt | 3 -- .../data/accessibility/object-expected-win.txt | 3 -- content/test/data/accessibility/object.html | 9 ----- .../table-simple-expected-android.txt | 14 ++++---- .../accessibility/table-simple-expected-mac.txt | 18 +++++----- content/test/data/accessibility/table-simple.html | 12 +++---- 44 files changed, 21 insertions(+), 418 deletions(-) delete mode 100644 content/test/data/accessibility/aria-atomic-expected-android.txt delete mode 100644 content/test/data/accessibility/aria-atomic-expected-mac.txt delete mode 100644 content/test/data/accessibility/aria-atomic-expected-win.txt delete mode 100644 content/test/data/accessibility/aria-atomic.html delete mode 100644 content/test/data/accessibility/aria-row-expected-android.txt delete mode 100644 content/test/data/accessibility/aria-row-expected-mac.txt delete mode 100644 content/test/data/accessibility/aria-row-expected-win.txt delete mode 100644 content/test/data/accessibility/aria-row.html delete mode 100644 content/test/data/accessibility/body-expected-android.txt delete mode 100644 content/test/data/accessibility/body-expected-mac.txt delete mode 100644 content/test/data/accessibility/body-expected-win.txt delete mode 100644 content/test/data/accessibility/body.html delete mode 100644 content/test/data/accessibility/caption-expected-android.txt delete mode 100644 content/test/data/accessibility/caption-expected-mac.txt delete mode 100644 content/test/data/accessibility/caption-expected-win.txt delete mode 100644 content/test/data/accessibility/caption.html delete mode 100644 content/test/data/accessibility/frameset-expected-android.txt delete mode 100644 content/test/data/accessibility/frameset-expected-mac.txt delete mode 100644 content/test/data/accessibility/frameset-expected-win.txt delete mode 100644 content/test/data/accessibility/frameset.html delete mode 100644 content/test/data/accessibility/i-expected-android.txt delete mode 100644 content/test/data/accessibility/i-expected-mac.txt delete mode 100644 content/test/data/accessibility/i-expected-win.txt delete mode 100644 content/test/data/accessibility/i.html delete mode 100644 content/test/data/accessibility/ins-expected-android.txt delete mode 100644 content/test/data/accessibility/ins-expected-mac.txt delete mode 100644 content/test/data/accessibility/ins-expected-win.txt delete mode 100644 content/test/data/accessibility/ins.html delete mode 100644 content/test/data/accessibility/legend-expected-android.txt delete mode 100644 content/test/data/accessibility/legend-expected-mac.txt delete mode 100644 content/test/data/accessibility/legend-expected-win.txt delete mode 100644 content/test/data/accessibility/legend.html delete mode 100644 content/test/data/accessibility/mark-expected-android.txt delete mode 100644 content/test/data/accessibility/mark-expected-mac.txt delete mode 100644 content/test/data/accessibility/mark-expected-win.txt delete mode 100644 content/test/data/accessibility/mark.html delete mode 100644 content/test/data/accessibility/object-expected-android.txt delete mode 100644 content/test/data/accessibility/object-expected-mac.txt delete mode 100644 content/test/data/accessibility/object-expected-win.txt delete mode 100644 content/test/data/accessibility/object.html diff --git a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc index f73c624..9c628a4 100644 --- a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc @@ -319,10 +319,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("aria-application.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaAtomic) { - RunTest(FILE_PATH_LITERAL("aria-atomic.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaAutocomplete) { RunTest(FILE_PATH_LITERAL("aria-autocomplete.html")); @@ -399,10 +395,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("aria-progressbar.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaRow) { - RunTest(FILE_PATH_LITERAL("aria-row.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAriaReadonly) { RunTest(FILE_PATH_LITERAL("aria-readonly.html")); @@ -449,10 +441,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityBdo) { RunTest(FILE_PATH_LITERAL("bdo.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityBody) { - RunTest(FILE_PATH_LITERAL("body.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityBR) { RunTest(FILE_PATH_LITERAL("br.html")); } @@ -465,10 +453,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCanvas) { RunTest(FILE_PATH_LITERAL("canvas.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCaption) { - RunTest(FILE_PATH_LITERAL("caption.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityCheckboxNameCalc) { RunTest(FILE_PATH_LITERAL("checkbox-name-calc.html")); @@ -511,10 +495,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityForm) { RunTest(FILE_PATH_LITERAL("form.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityFrameset) { - RunTest(FILE_PATH_LITERAL("frameset.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityHeading) { RunTest(FILE_PATH_LITERAL("heading.html")); } @@ -523,10 +503,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityHR) { RunTest(FILE_PATH_LITERAL("hr.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityI) { - RunTest(FILE_PATH_LITERAL("i.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityIframeCoordinates) { RunTest(FILE_PATH_LITERAL("iframe-coordinates.html")); @@ -566,10 +542,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("input-types.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityIns) { - RunTest(FILE_PATH_LITERAL("ins.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityLabel) { RunTest(FILE_PATH_LITERAL("label.html")); } @@ -578,18 +550,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityLandmark) { RunTest(FILE_PATH_LITERAL("landmark.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityLegend) { - RunTest(FILE_PATH_LITERAL("legend.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityListMarkers) { RunTest(FILE_PATH_LITERAL("list-markers.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityMark) { - RunTest(FILE_PATH_LITERAL("mark.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityMenutypecontext) { RunTest(FILE_PATH_LITERAL("menu-type-context.html")); @@ -624,10 +588,6 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityOl) { RunTest(FILE_PATH_LITERAL("ol.html")); } -IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityObject) { - RunTest(FILE_PATH_LITERAL("object.html")); -} - IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityOptionindatalist) { RunTest(FILE_PATH_LITERAL("option-in-datalist.html")); diff --git a/content/test/data/accessibility/aria-atomic-expected-android.txt b/content/test/data/accessibility/aria-atomic-expected-android.txt deleted file mode 100644 index 07e2fed..0000000 --- a/content/test/data/accessibility/aria-atomic-expected-android.txt +++ /dev/null @@ -1,3 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.view.View clickable focusable name='This test is for aria-atomic="false"' live_region_type=1 - android.view.View clickable focusable name='This test is for aria-atomic="true"' live_region_type=1 diff --git a/content/test/data/accessibility/aria-atomic-expected-mac.txt b/content/test/data/accessibility/aria-atomic-expected-mac.txt deleted file mode 100644 index b65645f..0000000 --- a/content/test/data/accessibility/aria-atomic-expected-mac.txt +++ /dev/null @@ -1,5 +0,0 @@ -AXWebArea - AXGroup AXARIAAtomic='0' - AXStaticText AXValue='This test is for aria-atomic="false"' AXARIAAtomic='0' - AXGroup AXARIAAtomic='1' - AXStaticText AXValue='This test is for aria-atomic="true"' AXARIAAtomic='0' diff --git a/content/test/data/accessibility/aria-atomic-expected-win.txt b/content/test/data/accessibility/aria-atomic-expected-win.txt deleted file mode 100644 index 818e893..0000000 --- a/content/test/data/accessibility/aria-atomic-expected-win.txt +++ /dev/null @@ -1,5 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - ROLE_SYSTEM_CLIENT FOCUSABLE atomic:false container-atomic:false - ROLE_SYSTEM_STATICTEXT name='This test is for aria-atomic="false"' container-atomic:false - ROLE_SYSTEM_CLIENT FOCUSABLE atomic:true container-atomic:true - ROLE_SYSTEM_STATICTEXT name='This test is for aria-atomic="true"' container-atomic:true diff --git a/content/test/data/accessibility/aria-atomic.html b/content/test/data/accessibility/aria-atomic.html deleted file mode 100644 index 3529969..0000000 --- a/content/test/data/accessibility/aria-atomic.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - -

This test is for aria-atomic="false"

-

This test is for aria-atomic="true"

- - diff --git a/content/test/data/accessibility/aria-row-expected-android.txt b/content/test/data/accessibility/aria-row-expected-android.txt deleted file mode 100644 index 2880436..0000000 --- a/content/test/data/accessibility/aria-row-expected-android.txt +++ /dev/null @@ -1,14 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.widget.GridView collection row_count=3 column_count=2 - android.view.View - android.view.View clickable collection_item name='Browser' row_span=1 column_span=1 - android.view.View clickable collection_item name='Rendering Engine' row_span=1 column_index=1 column_span=1 - android.view.View - android.view.View clickable collection_item name='Chrome' row_index=1 row_span=1 column_span=1 - android.view.View clickable collection_item name='Blink' row_index=1 row_span=1 column_index=1 column_span=1 - android.view.View - android.view.View clickable collection_item name='Safari' row_index=2 row_span=1 column_span=1 - android.view.View clickable collection_item name='WebKit' row_index=2 row_span=1 column_index=1 column_span=1 - android.view.View - android.view.View - android.view.View diff --git a/content/test/data/accessibility/aria-row-expected-mac.txt b/content/test/data/accessibility/aria-row-expected-mac.txt deleted file mode 100644 index 21e989d..0000000 --- a/content/test/data/accessibility/aria-row-expected-mac.txt +++ /dev/null @@ -1,20 +0,0 @@ -AXWebArea - AXTable - AXRow - AXCell - AXStaticText AXValue='Browser' - AXCell - AXStaticText AXValue='Rendering Engine' - AXRow - AXCell - AXStaticText AXValue='Chrome' - AXCell - AXStaticText AXValue='Blink' - AXRow - AXCell - AXStaticText AXValue='Safari' - AXCell - AXStaticText AXValue='WebKit' - AXColumn - AXColumn - AXGroup diff --git a/content/test/data/accessibility/aria-row-expected-win.txt b/content/test/data/accessibility/aria-row-expected-win.txt deleted file mode 100644 index c74d2db..0000000 --- a/content/test/data/accessibility/aria-row-expected-win.txt +++ /dev/null @@ -1,20 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - ROLE_SYSTEM_TABLE READONLY - ROLE_SYSTEM_ROW READONLY - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Browser' - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Rendering Engine' - ROLE_SYSTEM_ROW READONLY - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Chrome' - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Blink' - ROLE_SYSTEM_ROW READONLY - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Safari' - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='WebKit' - ROLE_SYSTEM_COLUMN - ROLE_SYSTEM_COLUMN - IA2_ROLE_SECTION diff --git a/content/test/data/accessibility/aria-row.html b/content/test/data/accessibility/aria-row.html deleted file mode 100644 index e19da13..0000000 --- a/content/test/data/accessibility/aria-row.html +++ /dev/null @@ -1,19 +0,0 @@ - - - -
-
- Browser - Rendering Engine -
-
- Chrome - Blink -
-
- Safari - WebKit -
-
- - diff --git a/content/test/data/accessibility/body-expected-android.txt b/content/test/data/accessibility/body-expected-android.txt deleted file mode 100644 index 89003eb..0000000 --- a/content/test/data/accessibility/body-expected-android.txt +++ /dev/null @@ -1,2 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.view.View clickable name='This test is for body tag' diff --git a/content/test/data/accessibility/body-expected-mac.txt b/content/test/data/accessibility/body-expected-mac.txt deleted file mode 100644 index 888b49e..0000000 --- a/content/test/data/accessibility/body-expected-mac.txt +++ /dev/null @@ -1,3 +0,0 @@ -AXWebArea - AXGroup - AXStaticText AXValue='This test is for body tag' diff --git a/content/test/data/accessibility/body-expected-win.txt b/content/test/data/accessibility/body-expected-win.txt deleted file mode 100644 index 8beeb8f..0000000 --- a/content/test/data/accessibility/body-expected-win.txt +++ /dev/null @@ -1,3 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_PARAGRAPH - ROLE_SYSTEM_STATICTEXT name='This test is for body tag' diff --git a/content/test/data/accessibility/body.html b/content/test/data/accessibility/body.html deleted file mode 100644 index ec450a05..0000000 --- a/content/test/data/accessibility/body.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -

This test is for body tag

- - diff --git a/content/test/data/accessibility/caption-expected-android.txt b/content/test/data/accessibility/caption-expected-android.txt deleted file mode 100644 index 47c7263..0000000 --- a/content/test/data/accessibility/caption-expected-android.txt +++ /dev/null @@ -1,14 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.widget.GridView collection name='Browser and Engine' row_count=3 column_count=2 - android.view.View - android.view.View clickable collection_item name='Browser' row_span=1 column_span=1 - android.view.View clickable collection_item name='Engine' row_span=1 column_index=1 column_span=1 - android.view.View - android.view.View clickable collection_item name='Chrome' row_index=1 row_span=1 column_span=1 - android.view.View clickable collection_item name='Blink' row_index=1 row_span=1 column_index=1 column_span=1 - android.view.View - android.view.View clickable collection_item name='Safari' row_index=2 row_span=1 column_span=1 - android.view.View clickable collection_item name='WebKit' row_index=2 row_span=1 column_index=1 column_span=1 - android.view.View - android.view.View - android.view.View diff --git a/content/test/data/accessibility/caption-expected-mac.txt b/content/test/data/accessibility/caption-expected-mac.txt deleted file mode 100644 index e8cbaec..0000000 --- a/content/test/data/accessibility/caption-expected-mac.txt +++ /dev/null @@ -1,20 +0,0 @@ -AXWebArea - AXTable AXTitle='Browser and Engine' - AXRow - AXCell - AXStaticText AXValue='Browser' - AXCell - AXStaticText AXValue='Engine' - AXRow - AXCell - AXStaticText AXValue='Chrome' - AXCell - AXStaticText AXValue='Blink' - AXRow - AXCell - AXStaticText AXValue='Safari' - AXCell - AXStaticText AXValue='WebKit' - AXColumn - AXColumn - AXGroup diff --git a/content/test/data/accessibility/caption-expected-win.txt b/content/test/data/accessibility/caption-expected-win.txt deleted file mode 100644 index 196e549..0000000 --- a/content/test/data/accessibility/caption-expected-win.txt +++ /dev/null @@ -1,20 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - ROLE_SYSTEM_TABLE name='Browser and Engine' READONLY - ROLE_SYSTEM_ROW READONLY - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Browser' - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Engine' - ROLE_SYSTEM_ROW READONLY - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Chrome' - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Blink' - ROLE_SYSTEM_ROW READONLY - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='Safari' - ROLE_SYSTEM_CELL - ROLE_SYSTEM_STATICTEXT name='WebKit' - ROLE_SYSTEM_COLUMN - ROLE_SYSTEM_COLUMN - IA2_ROLE_SECTION diff --git a/content/test/data/accessibility/caption.html b/content/test/data/accessibility/caption.html deleted file mode 100644 index 69141eb..0000000 --- a/content/test/data/accessibility/caption.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - -
Browser and Engine
BrowserEngine
ChromeBlink
SafariWebKit
- - - diff --git a/content/test/data/accessibility/frameset-expected-android.txt b/content/test/data/accessibility/frameset-expected-android.txt deleted file mode 100644 index 81e1652..0000000 --- a/content/test/data/accessibility/frameset-expected-android.txt +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/content/test/data/accessibility/frameset-expected-mac.txt b/content/test/data/accessibility/frameset-expected-mac.txt deleted file mode 100644 index 4740f61..0000000 --- a/content/test/data/accessibility/frameset-expected-mac.txt +++ /dev/null @@ -1,16 +0,0 @@ -AXWebArea - AXUnknown - AXUnknown - AXWebArea - AXGroup - AXStaticText AXValue='My favorite browser is' - AXStaticText AXValue='ABC' - AXStaticText AXValue='Chrome' - AXStaticText AXValue='!' - AXUnknown - AXUnknown - AXWebArea - AXGroup - AXStaticText AXValue='This test is to check ' - AXStaticText AXValue='mark tag' - AXStaticText AXValue='.' diff --git a/content/test/data/accessibility/frameset-expected-win.txt b/content/test/data/accessibility/frameset-expected-win.txt deleted file mode 100644 index 45de7f8..0000000 --- a/content/test/data/accessibility/frameset-expected-win.txt +++ /dev/null @@ -1,16 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - ROLE_SYSTEM_CLIENT FOCUSABLE - IA2_ROLE_SCROLL_PANE - ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_PARAGRAPH - ROLE_SYSTEM_STATICTEXT name='My favorite browser is ' - ROLE_SYSTEM_STATICTEXT name='ABC' - ROLE_SYSTEM_STATICTEXT name='Chrome' - ROLE_SYSTEM_STATICTEXT name='!' - ROLE_SYSTEM_CLIENT FOCUSABLE - IA2_ROLE_SCROLL_PANE - ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_PARAGRAPH - ROLE_SYSTEM_STATICTEXT name='This test is to check ' - ROLE_SYSTEM_STATICTEXT name='mark tag' - ROLE_SYSTEM_STATICTEXT name='.' diff --git a/content/test/data/accessibility/frameset.html b/content/test/data/accessibility/frameset.html deleted file mode 100644 index 3240bf1..0000000 --- a/content/test/data/accessibility/frameset.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/content/test/data/accessibility/i-expected-android.txt b/content/test/data/accessibility/i-expected-android.txt deleted file mode 100644 index 00578de..0000000 --- a/content/test/data/accessibility/i-expected-android.txt +++ /dev/null @@ -1,2 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.view.View clickable name='This is to checkitalic propertyusing i tag.' diff --git a/content/test/data/accessibility/i-expected-mac.txt b/content/test/data/accessibility/i-expected-mac.txt deleted file mode 100644 index f3ae8837..0000000 --- a/content/test/data/accessibility/i-expected-mac.txt +++ /dev/null @@ -1,5 +0,0 @@ -AXWebArea - AXGroup - AXStaticText AXValue='This is to check ' - AXStaticText AXValue='italic property' - AXStaticText AXValue=' using i tag.' diff --git a/content/test/data/accessibility/i-expected-win.txt b/content/test/data/accessibility/i-expected-win.txt deleted file mode 100644 index aabbfaa..0000000 --- a/content/test/data/accessibility/i-expected-win.txt +++ /dev/null @@ -1,5 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_PARAGRAPH - ROLE_SYSTEM_STATICTEXT name='This is to check ' - ROLE_SYSTEM_STATICTEXT name='italic property' - ROLE_SYSTEM_STATICTEXT name=' using i tag.' diff --git a/content/test/data/accessibility/i.html b/content/test/data/accessibility/i.html deleted file mode 100644 index 192cd73..0000000 --- a/content/test/data/accessibility/i.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - -

This is to check italic property using i tag.

- - - diff --git a/content/test/data/accessibility/ins-expected-android.txt b/content/test/data/accessibility/ins-expected-android.txt deleted file mode 100644 index b1bf07a..0000000 --- a/content/test/data/accessibility/ins-expected-android.txt +++ /dev/null @@ -1,3 +0,0 @@ -# -android.webkit.WebView focusable focused scrollable - android.view.View clickable name='My favorite browser isABCChrome!' diff --git a/content/test/data/accessibility/ins-expected-mac.txt b/content/test/data/accessibility/ins-expected-mac.txt deleted file mode 100644 index 17ce68f..0000000 --- a/content/test/data/accessibility/ins-expected-mac.txt +++ /dev/null @@ -1,6 +0,0 @@ -AXWebArea - AXGroup - AXStaticText AXValue='My favorite browser is ' - AXStaticText AXValue='ABC' - AXStaticText AXValue='Chrome' - AXStaticText AXValue='!' diff --git a/content/test/data/accessibility/ins-expected-win.txt b/content/test/data/accessibility/ins-expected-win.txt deleted file mode 100644 index 4817f9b..0000000 --- a/content/test/data/accessibility/ins-expected-win.txt +++ /dev/null @@ -1,6 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_PARAGRAPH - ROLE_SYSTEM_STATICTEXT name='My favorite browser is ' - ROLE_SYSTEM_STATICTEXT name='ABC' - ROLE_SYSTEM_STATICTEXT name='Chrome' - ROLE_SYSTEM_STATICTEXT name='!' diff --git a/content/test/data/accessibility/ins.html b/content/test/data/accessibility/ins.html deleted file mode 100644 index 6f6da3c..0000000 --- a/content/test/data/accessibility/ins.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - -

My favorite browser is ABC Chrome!

- - - diff --git a/content/test/data/accessibility/legend-expected-android.txt b/content/test/data/accessibility/legend-expected-android.txt deleted file mode 100644 index 89efde9..0000000 --- a/content/test/data/accessibility/legend-expected-android.txt +++ /dev/null @@ -1,8 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.view.View - android.view.View clickable name='Browser Engine's:' - android.view.View - android.view.View clickable name='Browser: ' - android.widget.EditText editable_text focusable input_type=1 - android.view.View clickable name='Rendering Engine: ' - android.widget.EditText editable_text focusable input_type=1 diff --git a/content/test/data/accessibility/legend-expected-mac.txt b/content/test/data/accessibility/legend-expected-mac.txt deleted file mode 100644 index 7c170da..0000000 --- a/content/test/data/accessibility/legend-expected-mac.txt +++ /dev/null @@ -1,9 +0,0 @@ -AXWebArea - AXGroup AXTitleUIElement='AXUnknown' - AXUnknown - AXStaticText AXValue='Browser Engine's:' - AXGroup - AXStaticText AXValue='Browser: ' - AXTextField - AXStaticText AXValue='Rendering Engine: ' - AXTextField diff --git a/content/test/data/accessibility/legend-expected-win.txt b/content/test/data/accessibility/legend-expected-win.txt deleted file mode 100644 index d0a3fc9..0000000 --- a/content/test/data/accessibility/legend-expected-win.txt +++ /dev/null @@ -1,9 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - ROLE_SYSTEM_GROUPING name='Browser Engine's:' READONLY - ROLE_SYSTEM_CLIENT - ROLE_SYSTEM_STATICTEXT name='Browser Engine's:' - IA2_ROLE_SECTION READONLY - ROLE_SYSTEM_STATICTEXT name='Browser: ' - ROLE_SYSTEM_TEXT FOCUSABLE - ROLE_SYSTEM_STATICTEXT name='Rendering Engine: ' - ROLE_SYSTEM_TEXT FOCUSABLE diff --git a/content/test/data/accessibility/legend.html b/content/test/data/accessibility/legend.html deleted file mode 100644 index 8118b2f..0000000 --- a/content/test/data/accessibility/legend.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -
-
- Browser Engine's: - Browser:
- Rendering Engine:
-
-
- - - diff --git a/content/test/data/accessibility/mark-expected-android.txt b/content/test/data/accessibility/mark-expected-android.txt deleted file mode 100644 index c81d844..0000000 --- a/content/test/data/accessibility/mark-expected-android.txt +++ /dev/null @@ -1,3 +0,0 @@ -# -android.webkit.WebView focusable focused scrollable - android.view.View clickable name='This test is to checkmark tag.' diff --git a/content/test/data/accessibility/mark-expected-mac.txt b/content/test/data/accessibility/mark-expected-mac.txt deleted file mode 100644 index b6158ac..0000000 --- a/content/test/data/accessibility/mark-expected-mac.txt +++ /dev/null @@ -1,5 +0,0 @@ -AXWebArea - AXGroup - AXStaticText AXValue='This test is to check ' - AXStaticText AXValue='mark tag' - AXStaticText AXValue='.' diff --git a/content/test/data/accessibility/mark-expected-win.txt b/content/test/data/accessibility/mark-expected-win.txt deleted file mode 100644 index 69f8308d..0000000 --- a/content/test/data/accessibility/mark-expected-win.txt +++ /dev/null @@ -1,5 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_PARAGRAPH - ROLE_SYSTEM_STATICTEXT name='This test is to check ' - ROLE_SYSTEM_STATICTEXT name='mark tag' - ROLE_SYSTEM_STATICTEXT name='.' diff --git a/content/test/data/accessibility/mark.html b/content/test/data/accessibility/mark.html deleted file mode 100644 index 5afffec..0000000 --- a/content/test/data/accessibility/mark.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - -

This test is to check mark tag.

- - - diff --git a/content/test/data/accessibility/object-expected-android.txt b/content/test/data/accessibility/object-expected-android.txt deleted file mode 100644 index 947af64..0000000 --- a/content/test/data/accessibility/object-expected-android.txt +++ /dev/null @@ -1,3 +0,0 @@ -android.webkit.WebView focusable focused scrollable - android.view.View - android.view.View focusable diff --git a/content/test/data/accessibility/object-expected-mac.txt b/content/test/data/accessibility/object-expected-mac.txt deleted file mode 100644 index 9ef0230..0000000 --- a/content/test/data/accessibility/object-expected-mac.txt +++ /dev/null @@ -1,3 +0,0 @@ -AXWebArea - AXGroup - AXUnknown diff --git a/content/test/data/accessibility/object-expected-win.txt b/content/test/data/accessibility/object-expected-win.txt deleted file mode 100644 index 342c9c5..0000000 --- a/content/test/data/accessibility/object-expected-win.txt +++ /dev/null @@ -1,3 +0,0 @@ -ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE - IA2_ROLE_SECTION READONLY - ROLE_SYSTEM_CLIENT FOCUSABLE diff --git a/content/test/data/accessibility/object.html b/content/test/data/accessibility/object.html deleted file mode 100644 index 00dd004..0000000 --- a/content/test/data/accessibility/object.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/content/test/data/accessibility/table-simple-expected-android.txt b/content/test/data/accessibility/table-simple-expected-android.txt index 139b3a0..831377b 100644 --- a/content/test/data/accessibility/table-simple-expected-android.txt +++ b/content/test/data/accessibility/table-simple-expected-android.txt @@ -1,14 +1,14 @@ android.webkit.WebView focusable focused scrollable name='Table example' - android.widget.GridView collection row_count=3 column_count=2 + android.widget.GridView collection row_count=2 column_count=3 android.view.View - android.view.View clickable collection_item name='Pair' row_span=1 column_span=1 - android.view.View clickable collection_item name='Single' row_span=1 column_index=1 column_span=1 + android.view.View clickable collection_item name='A' row_span=1 column_span=1 + android.view.View clickable collection_item name='B' row_span=1 column_index=1 column_span=1 + android.view.View clickable collection_item name='C' row_span=1 column_index=2 column_span=1 android.view.View - android.view.View clickable collection_item name='AB' row_index=1 row_span=1 column_span=1 - android.view.View clickable collection_item name='B' row_index=1 row_span=1 column_index=1 column_span=1 + android.view.View clickable collection_item name='D' row_index=1 row_span=1 column_span=1 + android.view.View clickable collection_item name='E' row_index=1 row_span=1 column_index=1 column_span=1 + android.view.View clickable collection_item name='F' row_index=1 row_span=1 column_index=2 column_span=1 android.view.View - android.view.View clickable collection_item name='CD' row_index=2 row_span=1 column_span=1 - android.view.View clickable collection_item name='D' row_index=2 row_span=1 column_index=1 column_span=1 android.view.View android.view.View android.view.View diff --git a/content/test/data/accessibility/table-simple-expected-mac.txt b/content/test/data/accessibility/table-simple-expected-mac.txt index 214a4c0..798e4c7 100644 --- a/content/test/data/accessibility/table-simple-expected-mac.txt +++ b/content/test/data/accessibility/table-simple-expected-mac.txt @@ -2,19 +2,19 @@ AXWebArea AXTitle='Table example' AXTable AXRow AXIndex='0' AXCell AXColumnIndexRange={"len":1,"loc":0} AXRowIndexRange={"len":1,"loc":0} - AXStaticText AXValue='Pair' + AXStaticText AXValue='A' AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":0} - AXStaticText AXValue='Single' + AXStaticText AXValue='B' + AXCell AXColumnIndexRange={"len":1,"loc":2} AXRowIndexRange={"len":1,"loc":0} + AXStaticText AXValue='C' AXRow AXIndex='1' AXCell AXColumnIndexRange={"len":1,"loc":0} AXRowIndexRange={"len":1,"loc":1} - AXStaticText AXValue='AB' - AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":1} - AXStaticText AXValue='B' - AXRow AXIndex='2' - AXCell AXColumnIndexRange={"len":1,"loc":0} AXRowIndexRange={"len":1,"loc":2} - AXStaticText AXValue='CD' - AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":2} AXStaticText AXValue='D' + AXCell AXColumnIndexRange={"len":1,"loc":1} AXRowIndexRange={"len":1,"loc":1} + AXStaticText AXValue='E' + AXCell AXColumnIndexRange={"len":1,"loc":2} AXRowIndexRange={"len":1,"loc":1} + AXStaticText AXValue='F' AXColumn AXIndex='0' AXColumn AXIndex='1' + AXColumn AXIndex='2' AXGroup diff --git a/content/test/data/accessibility/table-simple.html b/content/test/data/accessibility/table-simple.html index 72e2b4d..9bfbbf8 100644 --- a/content/test/data/accessibility/table-simple.html +++ b/content/test/data/accessibility/table-simple.html @@ -12,16 +12,14 @@ - - + + + - - - - - + +
PairSingleABC
ABB
CD DEF
-- cgit v1.1 From 5a4ccee21258b2a6266375d194149ba27e80b3f7 Mon Sep 17 00:00:00 2001 From: jam Date: Sat, 13 Sep 2014 23:14:00 -0700 Subject: Revert of Fix some more for= usage. (patchset #7 id:120001 of https://codereview.chromium.org/539383003/) Reason for revert: breaks linux_chromeos on try runs here and on buildbot Original issue's description: > Fix some more for= usage. > > Also fix some controlled settings indicators. > > BUG=409938 > R=dbeam@chromium.org > > Committed: https://crrev.com/ce80b519af00bb6259e8c63f91fee5263d818124 > Cr-Commit-Position: refs/heads/master@{#294681} TBR=dbeam@chromium.org,estade@chromium.org NOTREECHECKS=true NOTRY=true BUG=409938 Review URL: https://codereview.chromium.org/562023003 Cr-Commit-Position: refs/heads/master@{#294765} --- .../browser/resources/options/browser_options.html | 242 +++++++++------------ .../resources/options/content_settings.html | 203 +++++++---------- .../resources/options/controlled_setting.css | 14 +- .../resources/options/home_page_overlay.html | 42 ++-- .../resources/options/hotword_confirm_overlay.html | 12 +- .../resources/options/import_data_overlay.html | 40 ++-- .../options/language_add_language_overlay.html | 5 +- .../resources/options/manage_profile_overlay.html | 10 +- .../options/reset_profile_settings_overlay.css | 6 +- .../options/reset_profile_settings_overlay.html | 12 +- .../options/reset_profile_settings_overlay.js | 7 +- .../browser/resources/options/startup_section.html | 24 +- chrome/browser/resources/options/sync_section.html | 10 +- 13 files changed, 272 insertions(+), 355 deletions(-) diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html index 387ccee..6c5e16e 100644 --- a/chrome/browser/resources/options/browser_options.html +++ b/chrome/browser/resources/options/browser_options.html @@ -60,12 +60,10 @@ - - - - + + @@ -468,10 +452,8 @@ @@ -625,12 +604,10 @@ - - - - + +
- - - - - + + +
@@ -729,12 +700,10 @@ - - - - + +
@@ -743,12 +712,11 @@ - - - - + + +
@@ -757,12 +725,11 @@ - - - - + + +
@@ -771,12 +738,11 @@ - - - - + + +
- +
@@ -812,14 +775,12 @@ +
-
+
- - - - + + +
@@ -878,12 +838,10 @@ +
diff --git a/chrome/browser/resources/options/content_settings.html b/chrome/browser/resources/options/content_settings.html index 07e409e..4454594 100644 --- a/chrome/browser/resources/options/content_settings.html +++ b/chrome/browser/resources/options/content_settings.html @@ -9,41 +9,35 @@
+
+
+
+ +
@@ -73,19 +67,18 @@ +
+ +
+
+
+
+
+
+
- - - - + +
@@ -284,32 +255,26 @@
+
+
+
+
+
+ +

-
-
- + + + +
diff --git a/chrome/browser/resources/options/import_data_overlay.html b/chrome/browser/resources/options/import_data_overlay.html index 7a2aa02..ce7bdb6 100644 --- a/chrome/browser/resources/options/import_data_overlay.html +++ b/chrome/browser/resources/options/import_data_overlay.html @@ -15,48 +15,40 @@ id="import-history-with-label"> + +
+
+
+
@@ -84,12 +76,10 @@ - - - - + +
diff --git a/chrome/browser/resources/options/language_add_language_overlay.html b/chrome/browser/resources/options/language_add_language_overlay.html index 0cbf1b6..ca8947a 100644 --- a/chrome/browser/resources/options/language_add_language_overlay.html +++ b/chrome/browser/resources/options/language_add_language_overlay.html @@ -2,10 +2,9 @@

- - +
-
-