diff options
Diffstat (limited to 'chromium')
64 files changed, 894 insertions, 311 deletions
diff --git a/chromium/DEPS b/chromium/DEPS index 09bba9fdf3d..6e8b41a3ce6 100644 --- a/chromium/DEPS +++ b/chromium/DEPS @@ -6,7 +6,7 @@ vars = { 'boringssl_revision': '0e4a448ab8aa66a38593f68d19fa0a2e340833e4', 'buildspec_platforms': - 'all', + 'win, win64, mac64, linux64, ios, android, chromeos', 'buildtools_revision': 'd511e4d53d6fc8037badbdf4b225c137e94b52fb', 'catapult_revision': @@ -184,7 +184,7 @@ deps = { 'src/tools/swarming_client': (Var("chromium_git")) + '/external/swarming.client.git@a56c2b39ca23bdf41458421a7f825ddbf3f43f28', 'src/v8': - (Var("chromium_git")) + '/v8/v8.git@5b43e2caac786baa9d3805fda9a0dafe3728c60a' + (Var("chromium_git")) + '/v8/v8.git@fe8c059defe75f3fe91ddba933245759db03198b' } deps_os = { diff --git a/chromium/build/util/LASTCHANGE b/chromium/build/util/LASTCHANGE index 221a9b9d8e8..316fa8f1240 100644 --- a/chromium/build/util/LASTCHANGE +++ b/chromium/build/util/LASTCHANGE @@ -1 +1 @@ -LASTCHANGE=4a304aaec98384eea3cb69cd2abc7ff422720cf4- +LASTCHANGE=da5c81391af28ed5c4b58cca638ef5fd5205e8c3- diff --git a/chromium/build/util/LASTCHANGE.blink b/chromium/build/util/LASTCHANGE.blink index 221a9b9d8e8..316fa8f1240 100644 --- a/chromium/build/util/LASTCHANGE.blink +++ b/chromium/build/util/LASTCHANGE.blink @@ -1 +1 @@ -LASTCHANGE=4a304aaec98384eea3cb69cd2abc7ff422720cf4- +LASTCHANGE=da5c81391af28ed5c4b58cca638ef5fd5205e8c3- diff --git a/chromium/chrome/VERSION b/chromium/chrome/VERSION index 9f74d3e72ef..d593ba0b27c 100644 --- a/chromium/chrome/VERSION +++ b/chromium/chrome/VERSION @@ -1,4 +1,4 @@ MAJOR=61 MINOR=0 BUILD=3163 -PATCH=99 +PATCH=140 diff --git a/chromium/chrome/app/chromeos_strings.grdp b/chromium/chrome/app/chromeos_strings.grdp index eac9cc916a7..d30edf17993 100644 --- a/chromium/chrome/app/chromeos_strings.grdp +++ b/chromium/chrome/app/chromeos_strings.grdp @@ -5962,7 +5962,7 @@ All users must sign out to continue. Google Play Store (beta) </message> <message name="IDS_ARC_PLAYSTORE_ICON_TITLE_BETA" desc="The Play Store icon title with the beta label in the launcher."> - Play Store (beta) + Play Store </message> <message name="IDS_OPTIONS_ARC_ENABLE" desc="Label for the checkbox that enables Google Play Store apps."> Enable Google Play Store on your Chromebook. @@ -6118,7 +6118,7 @@ All users must sign out to continue. Free up disk space to launch Android apps. </message> <message name="IDS_ARC_MANAGED_PROVISION_NOTIFICATION_TITLE" desc="Title of the notification shown to user during ARC provision when the ARC opt-in flow happens silently due to enterprise policies"> - Google Play Store (beta) + Google Play Store </message> <message name="IDS_ARC_MANAGED_PROVISION_NOTIFICATION_MESSAGE" desc="Notification shown to user during ARC provision when the ARC opt-in flow happens silently due to enterprise policies."> Installing the Google Play Store on your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph>. This could take a few minutes. diff --git a/chromium/chrome/app/settings_strings.grdp b/chromium/chrome/app/settings_strings.grdp index b7f34098d82..dc010c651bf 100644 --- a/chromium/chrome/app/settings_strings.grdp +++ b/chromium/chrome/app/settings_strings.grdp @@ -223,7 +223,7 @@ <if expr="chromeos"> <!-- Android Apps Page --> <message name="IDS_SETTINGS_ANDROID_APPS_TITLE" desc="The title of Google Play Store (Arc++ / Android Apps) section."> - Google Play Store (beta) + Google Play Store </message> <message name="IDS_SETTINGS_ANDROID_SETTINGS_TITLE" desc="The title of Android settings section in case Play Store app is not available."> Android settings diff --git a/chromium/chrome/browser/chromeos/BUILD.gn b/chromium/chrome/browser/chromeos/BUILD.gn index ea37c4e6d1c..1dbe39bbcc0 100644 --- a/chromium/chrome/browser/chromeos/BUILD.gn +++ b/chromium/chrome/browser/chromeos/BUILD.gn @@ -1485,6 +1485,8 @@ source_set("chromeos") { "tether/tether_service.h", "tether/tether_service_factory.cc", "tether/tether_service_factory.h", + "tpm_firmware_update.cc", + "tpm_firmware_update.h", "ui/accessibility_cursor_ring_layer.cc", "ui/accessibility_cursor_ring_layer.h", "ui/accessibility_focus_ring.cc", diff --git a/chromium/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc b/chromium/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc index 6b8b17d5341..1ce23f227bd 100644 --- a/chromium/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc +++ b/chromium/chrome/browser/extensions/api/feedback_private/feedback_private_api.cc @@ -29,6 +29,7 @@ #include "components/feedback/tracing_manager.h" #include "components/signin/core/browser/signin_manager.h" #include "components/strings/grit/components_strings.h" +#include "content/public/common/browser_side_navigation_policy.h" #include "extensions/browser/event_router.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/webui/web_ui_util.h" @@ -174,12 +175,22 @@ void FeedbackPrivateAPI::RequestFeedbackForFlow( feedback_private::OnFeedbackRequested::kEventName, std::move(args), browser_context_); - // TODO(weidongg/754329): Using DispatchEventWithLazyListener() is a - // temporary fix to the bug. Investigate a better solution that apply to all - // scenarios. - EventRouter::Get(browser_context_) - ->DispatchEventWithLazyListener(extension_misc::kFeedbackExtensionId, - std::move(event)); + if (content::IsBrowserSideNavigationEnabled()) { + // LoginFeedbackTest.Basic times out when this flag is enabled if we are + // using DispatchEventWithLazyListener(). It is a temporary solution to + // fix the test failure. Please track crbug.com/765289 for further + // investigation. + EventRouter::Get(browser_context_) + ->DispatchEventToExtension(extension_misc::kFeedbackExtensionId, + std::move(event)); + } else { + // TODO(weidongg/754329): Using DispatchEventWithLazyListener() is a + // temporary fix to the bug. Investigate a better solution that applies to + // all scenarios. + EventRouter::Get(browser_context_) + ->DispatchEventWithLazyListener(extension_misc::kFeedbackExtensionId, + std::move(event)); + } } } diff --git a/chromium/chrome/browser/resources/settings/device_page/night_light_slider.html b/chromium/chrome/browser/resources/settings/device_page/night_light_slider.html index bd0db71050e..247f30fa4f7 100644 --- a/chromium/chrome/browser/resources/settings/device_page/night_light_slider.html +++ b/chromium/chrome/browser/resources/settings/device_page/night_light_slider.html @@ -1,15 +1,13 @@ -<html><head> <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-behaviors/paper-inky-focus-behavior.html"> <link rel="import" href="../prefs/prefs_behavior.html"> -<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> -</head><body><dom-module id="night-light-slider"> + +<dom-module id="night-light-slider"> <template> <style> :host { cursor: default; - font-family: 'Roboto', sans-serif; text-align: center; user-select: none; } @@ -191,5 +189,5 @@ </div> </template> + <script src="night_light_slider.js"></script> </dom-module> -<script src="night_light_slider.js"></script></body></html>
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js b/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js index d948ecbf936..84210288d1f 100644 --- a/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js +++ b/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js @@ -86,12 +86,6 @@ Polymer({ markersContainer.appendChild(marker); marker.style.left = (i * 100 / HOURS_PER_DAY) + '%'; } - - this.async(function() { - // Refresh the hour format as well as read the initial pref values and - // refresh the slider. - this.hourFormatChanged_(); - }); }, /** @@ -579,4 +573,4 @@ Polymer({ } }); -})();
\ No newline at end of file +})(); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc index 028151d5c7b..bb29a3bb45a 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc @@ -15,6 +15,7 @@ #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/magnification_manager.h" #include "chrome/browser/chromeos/events/keyboard_driven_event_rewriter.h" +#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" #include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/chromeos/login/lock/screen_locker.h" #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" @@ -23,6 +24,7 @@ #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/system/input_device_settings.h" +#include "chrome/browser/chromeos/tpm_firmware_update.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" @@ -46,6 +48,8 @@ #include "ui/gfx/geometry/size.h" #include "ui/keyboard/keyboard_controller.h" +namespace chromeos { + namespace { const char kJsScreenPath[] = "cr.ui.Oobe"; @@ -58,9 +62,20 @@ bool IsRemoraRequisition() { return policy_manager && policy_manager->IsRemoraRequisition(); } -} // namespace +void LaunchResetScreen() { + // Don't recreate WizardController if it already exists. + WizardController* const wizard_controller = + WizardController::default_controller(); + if (wizard_controller && !wizard_controller->login_screen_started()) { + wizard_controller->AdvanceToScreen(OobeScreen::SCREEN_OOBE_RESET); + } else { + DCHECK(LoginDisplayHost::default_host()); + LoginDisplayHost::default_host()->StartWizard( + OobeScreen::SCREEN_OOBE_RESET); + } +} -namespace chromeos { +} // namespace // Note that show_oobe_ui_ defaults to false because WizardController assumes // OOBE UI is not visible by default. @@ -186,19 +201,33 @@ void CoreOobeHandler::ShowTpmError() { } void CoreOobeHandler::ShowDeviceResetScreen() { - policy::BrowserPolicyConnectorChromeOS* connector = - g_browser_process->platform_part()->browser_policy_connector_chromeos(); - if (!connector->IsEnterpriseManaged()) { - // Don't recreate WizardController if it already exists. - WizardController* wizard_controller = - WizardController::default_controller(); - if (wizard_controller && !wizard_controller->login_screen_started()) { - wizard_controller->AdvanceToScreen(OobeScreen::SCREEN_OOBE_RESET); - } else { - DCHECK(LoginDisplayHost::default_host()); - LoginDisplayHost::default_host()->StartWizard( - OobeScreen::SCREEN_OOBE_RESET); - } + // Powerwash is generally not available on enterprise devices. First, check + // the common case of a correctly enrolled device. + if (g_browser_process->platform_part() + ->browser_policy_connector_chromeos() + ->IsEnterpriseManaged()) { + // Powerwash not allowed, except if allowed by the admin specifically for + // the purpose of installing a TPM firmware update. + tpm_firmware_update::ShouldOfferUpdateViaPowerwash( + base::Bind([](bool offer_update) { + if (offer_update) { + // Force the TPM firmware update option to be enabled. + g_browser_process->local_state()->SetBoolean( + prefs::kFactoryResetTPMFirmwareUpdateRequested, true); + LaunchResetScreen(); + } + })); + return; + } + + // Devices that are still in OOBE may be subject to forced re-enrollment (FRE) + // and thus pending for enterprise management. These should not be allowed to + // powerwash either. Note that taking consumer device ownership has the side + // effect of dropping the FRE requirement if it was previously in effect. + const AutoEnrollmentController::FRERequirement requirement = + AutoEnrollmentController::GetFRERequirement(); + if (requirement != AutoEnrollmentController::EXPLICITLY_REQUIRED) { + LaunchResetScreen(); } } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc index ae698ed9293..8608f084f9a 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc @@ -11,12 +11,10 @@ #include "chrome/browser/chromeos/login/help_app_launcher.h" #include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/screens/reset_screen.h" -#include "chrome/common/pref_names.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "chromeos/dbus/session_manager_client.h" #include "components/login/localized_values_builder.h" -#include "components/prefs/pref_registry_simple.h" #include "components/strings/grit/components_strings.h" namespace { @@ -95,11 +93,6 @@ void ResetScreenHandler::DeclareLocalizedValues( builder->Add("confirmResetButton", IDS_RESET_SCREEN_POPUP_CONFIRM_BUTTON); } -// static -void ResetScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { - registry->RegisterBooleanPref(prefs::kFactoryResetRequested, false); -} - void ResetScreenHandler::Initialize() { if (!page_is_ready()) return; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h index ff9544394ac..f6dc3f235c9 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h @@ -11,8 +11,6 @@ #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" #include "content/public/browser/web_ui.h" -class PrefRegistrySimple; - namespace chromeos { // WebUI implementation of ResetScreenActor. @@ -33,9 +31,6 @@ class ResetScreenHandler : public ResetView, ::login::LocalizedValuesBuilder* builder) override; void Initialize() override; - // Registers Local State preferences. - static void RegisterPrefs(PrefRegistrySimple* registry); - private: ResetScreen* screen_ = nullptr; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index 6c8ee2725d9..cb9873a4b9f 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc @@ -908,9 +908,9 @@ void SigninScreenHandler::UpdateAccountPickerColors() { dark_muted_color); SkColor scroll_color = SkColorSetA(base_color, ash::login_constants::kScrollTranslucentAlpha); - CallJS("login.AccountPickerScreen.setOverlayColors", - color_utils::SkColorToRgbaString(dark_muted_color), - color_utils::SkColorToRgbaString(scroll_color)); + CallJSOrDefer("login.AccountPickerScreen.setOverlayColors", + color_utils::SkColorToRgbaString(dark_muted_color), + color_utils::SkColorToRgbaString(scroll_color)); } void SigninScreenHandler::Initialize() { diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc index 9ec43165c6a..a75305fab98 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc @@ -48,6 +48,9 @@ namespace settings { namespace { +// usb:// is 6 characters long. +constexpr int kUsbSchemeLength = 6; + constexpr char kIppScheme[] = "ipp"; constexpr char kIppsScheme[] = "ipps"; @@ -60,6 +63,15 @@ constexpr int kIppsPort = 443; // enums must never be renumbered or deleted and reused. enum PpdSourceForHistogram { kUser = 0, kScs = 1, kPpdSourceMax }; +// A parsed representation of a printer uri. +struct PrinterUri { + bool encrypted = false; + std::string scheme; + std::string host; + int port = url::SpecialPort::PORT_INVALID; + std::string path; +}; + void RecordPpdSource(const PpdSourceForHistogram& source) { UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PpdSource", source, kPpdSourceMax); } @@ -69,6 +81,76 @@ void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) { Printer::PrinterProtocol::kProtocolMax); } +// Log if the IPP attributes request was succesful. +void RecordIppQuerySuccess(bool success) { + UMA_HISTOGRAM_BOOLEAN("Printing.CUPS.IppAttributesSuccess", success); +} + +// Parsees |printer_uri| into its components and written into |uri|. Returns +// true if the uri was parsed successfully, returns false otherwise. No changes +// are made to |uri| if this function returns false. +bool ParseUri(const std::string& printer_uri, PrinterUri* uri) { + DCHECK(uri); + const char* uri_ptr = printer_uri.c_str(); + url::Parsed parsed; + url::ParseStandardURL(uri_ptr, printer_uri.length(), &parsed); + if (!parsed.scheme.is_valid() || !parsed.host.is_valid() || + !parsed.path.is_valid()) { + return false; + } + base::StringPiece scheme(&uri_ptr[parsed.scheme.begin], parsed.scheme.len); + base::StringPiece host(&uri_ptr[parsed.host.begin], parsed.host.len); + base::StringPiece path(&uri_ptr[parsed.path.begin], parsed.path.len); + + bool encrypted = scheme != kIppScheme; + int port = ParsePort(uri_ptr, parsed.port); + // Port not specified. + if (port == url::SpecialPort::PORT_UNSPECIFIED || + port == url::SpecialPort::PORT_INVALID) { + if (scheme == kIppScheme) { + port = kIppPort; + } else if (scheme == kIppsScheme) { + port = kIppsPort; + } + } + + uri->encrypted = encrypted; + uri->scheme = scheme.as_string(); + uri->host = host.as_string(); + uri->port = port; + uri->path = path.as_string(); + + return true; +} + +// Returns true if |printer_uri| is an IPP uri. +bool IsIppUri(base::StringPiece printer_uri) { + base::StringPiece::size_type separator_location = + printer_uri.find(url::kStandardSchemeSeparator); + if (separator_location == base::StringPiece::npos) { + return false; + } + + base::StringPiece scheme_part = printer_uri.substr(0, separator_location); + return scheme_part == kIppScheme || scheme_part == kIppsScheme; +} + +// Query an IPP printer to check for autoconf support where the printer is +// located at |printer_uri|. Results are reported through |callback|. It is an +// error to attempt this with a non-IPP printer. +void QueryAutoconf(const std::string& printer_uri, + const PrinterInfoCallback& callback) { + PrinterUri uri; + // Behavior for querying a non-IPP uri is undefined and disallowed. + if (!IsIppUri(printer_uri) || !ParseUri(printer_uri, &uri)) { + LOG(WARNING) << "Printer uri is invalid: " << printer_uri; + callback.Run(false, "", "", "", false); + return; + } + + QueryIppPrinter(uri.host, uri.port, uri.path, uri.encrypted, callback); +} + // Create an empty CupsPrinterInfo dictionary value. It should be consistent // with the fields in js side. See cups_printers_browser_proxy.js for the // definition of CupsPrinterInfo. @@ -92,6 +174,16 @@ std::unique_ptr<base::DictionaryValue> CreateEmptyPrinterInfo() { return printer_info; } +// Formats a host and port string. The |port| portion is omitted if +// it is unspecified or invalid. +std::string PrinterAddress(const std::string& host, int port) { + if (port != url::PORT_UNSPECIFIED && port != url::PORT_INVALID) { + return base::StringPrintf("%s:%d", host.c_str(), port); + } + + return host; +} + // Returns a JSON representation of |printer| as a CupsPrinterInfo. std::unique_ptr<base::DictionaryValue> GetPrinterInfo(const Printer& printer) { std::unique_ptr<base::DictionaryValue> printer_info = @@ -102,34 +194,27 @@ std::unique_ptr<base::DictionaryValue> GetPrinterInfo(const Printer& printer) { printer_info->SetString("printerManufacturer", printer.manufacturer()); printer_info->SetString("printerModel", printer.model()); printer_info->SetString("printerMakeAndModel", printer.make_and_model()); - // Get protocol, ip address and queue from the printer's URI. - const std::string printer_uri = printer.uri(); - url::Parsed parsed; - url::ParseStandardURL(printer_uri.c_str(), printer_uri.length(), &parsed); - std::string scheme; - std::string host; - std::string path; - if (parsed.scheme.len > 0) - scheme = std::string(printer_uri, parsed.scheme.begin, parsed.scheme.len); - if (parsed.host.len > 0) - host = std::string(printer_uri, parsed.host.begin, parsed.host.len); - if (parsed.path.len > 0) - path = std::string(printer_uri, parsed.path.begin, parsed.path.len); - if (base::ToLowerASCII(scheme) == "usb") { + PrinterUri uri; + if (!ParseUri(printer.uri(), &uri)) { + return nullptr; + } + + if (base::ToLowerASCII(uri.scheme) == "usb") { // USB has URI path (and, maybe, query) components that aren't really // associated with a queue -- the mapping between printing semantics and URI // semantics breaks down a bit here. From the user's point of view, the // entire host/path/query block is the printer address for USB. printer_info->SetString("printerAddress", - printer_uri.substr(parsed.host.begin)); + printer.uri().substr(kUsbSchemeLength)); } else { - printer_info->SetString("printerAddress", host); - if (!path.empty()) { - printer_info->SetString("printerQueue", path.substr(1)); + printer_info->SetString("printerAddress", + PrinterAddress(uri.host, uri.port)); + if (!uri.path.empty()) { + printer_info->SetString("printerQueue", uri.path.substr(1)); } } - printer_info->SetString("printerProtocol", base::ToLowerASCII(scheme)); + printer_info->SetString("printerProtocol", base::ToLowerASCII(uri.scheme)); return printer_info; } @@ -294,7 +379,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) { if (printer_address.empty()) { // Run the failure callback. - OnPrinterInfo(callback_id, false, "", "", "", false); + OnAutoconfQueried(callback_id, false, "", "", "", false); return; } @@ -306,43 +391,62 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) { return; } - // Parse url to separate address and port. ParseStandardURL expects a scheme, - // so add the printer_protocol. + DCHECK(printer_protocol == kIppScheme || printer_protocol == kIppsScheme) + << "Printer info requests only supported for IPP and IPPS printers"; std::string printer_uri = - printer_protocol + url::kStandardSchemeSeparator + printer_address; - const char* uri_ptr = printer_uri.c_str(); - url::Parsed parsed; - url::ParseStandardURL(uri_ptr, printer_uri.length(), &parsed); - base::StringPiece host(&printer_uri[parsed.host.begin], parsed.host.len); + base::StringPrintf("%s://%s/%s", printer_protocol.c_str(), + printer_address.c_str(), printer_queue.c_str()); + QueryAutoconf(printer_uri, + base::Bind(&CupsPrintersHandler::OnAutoconfQueried, + weak_factory_.GetWeakPtr(), callback_id)); +} - bool encrypted = printer_protocol != kIppScheme; - int port = ParsePort(uri_ptr, parsed.port); - // Port not specified. - if (port == url::SpecialPort::PORT_UNSPECIFIED || - port == url::SpecialPort::PORT_INVALID) { - if (printer_protocol == kIppScheme) { - port = kIppPort; - } else if (printer_protocol == kIppsScheme) { - port = kIppsPort; - } else { - // Port was not defined explicitly and scheme is not recognized. Cannot - // infer a port number. - NOTREACHED() << "Unrecognized protocol. Port was not set."; +void CupsPrintersHandler::OnAutoconfQueriedDiscovered( + std::unique_ptr<Printer> printer, + bool success, + const std::string& make, + const std::string& model, + const std::string& make_and_model, + bool ipp_everywhere) { + RecordIppQuerySuccess(success); + + if (success) { + // If we queried a valid make and model, use it. The mDNS record isn't + // guaranteed to have it. However, don't overwrite it if the printer + // advertises an empty value through printer-make-and-model. + if (!make_and_model.empty()) { + // manufacturer and model are set with make_and_model because they are + // derived from make_and_model for compatability and are slated for + // removal. + printer->set_manufacturer(make); + printer->set_model(model); + printer->set_make_and_model(make_and_model); + } + + // Autoconfig available, use it. + if (ipp_everywhere) { + printer->mutable_ppd_reference()->autoconf = true; + printer_configurer_->SetUpPrinter( + *printer, base::Bind(&CupsPrintersHandler::OnAddedDiscoveredPrinter, + weak_factory_.GetWeakPtr(), *printer)); + return; } } - QueryIppPrinter(host.as_string(), port, printer_queue, encrypted, - base::Bind(&CupsPrintersHandler::OnPrinterInfo, - weak_factory_.GetWeakPtr(), callback_id)); + // We don't have enough from discovery to configure the printer. Fill in as + // much information as we can about the printer, and ask the user to supply + // the rest. + FireWebUIListener("on-manually-add-discovered-printer", + *GetPrinterInfo(*printer)); } -void CupsPrintersHandler::OnPrinterInfo(const std::string& callback_id, - bool success, - const std::string& make, - const std::string& model, - const std::string& make_and_model, - bool ipp_everywhere) { - UMA_HISTOGRAM_BOOLEAN("Printing.CUPS.IppAttributesSuccess", success); +void CupsPrintersHandler::OnAutoconfQueried(const std::string& callback_id, + bool success, + const std::string& make, + const std::string& model, + const std::string& make_and_model, + bool ipp_everywhere) { + RecordIppQuerySuccess(success); if (!success) { base::DictionaryValue reject; @@ -684,24 +788,36 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter( std::string printer_id; CHECK(args->GetString(0, &printer_id)); - auto printer = printers_manager_->GetPrinter(printer_id); + std::unique_ptr<Printer> printer = printers_manager_->GetPrinter(printer_id); if (printer == nullptr) { // Printer disappeared, so we don't have information about it anymore and // can't really do much. Fail the add. FireWebUIListener("on-add-cups-printer", base::Value(false), base::Value(printer_id)); - } else if (printer->ppd_reference().autoconf || - !printer->ppd_reference().effective_make_and_model.empty() || - !printer->ppd_reference().user_supplied_ppd_url.empty()) { + return; + } + + if (printer->ppd_reference().autoconf || + !printer->ppd_reference().effective_make_and_model.empty() || + !printer->ppd_reference().user_supplied_ppd_url.empty()) { // If we have something that looks like a ppd reference for this printer, // try to configure it. printer_configurer_->SetUpPrinter( *printer, base::Bind(&CupsPrintersHandler::OnAddedDiscoveredPrinter, weak_factory_.GetWeakPtr(), *printer)); + return; + } + + // The mDNS record doesn't guarantee we can setup the printer. Query it to + // see if we want to try IPP. + const std::string printer_uri = printer->effective_uri(); + if (IsIppUri(printer_uri)) { + QueryAutoconf( + printer_uri, + base::Bind(&CupsPrintersHandler::OnAutoconfQueriedDiscovered, + weak_factory_.GetWeakPtr(), base::Passed(&printer))); } else { - // We don't have enough from discovery to configure the printer. Fill in as - // much information as we can about the printer, and ask the user to supply - // the rest. + // If it's not an IPP printer, the user must choose a PPD. FireWebUIListener("on-manually-add-discovered-printer", *GetPrinterInfo(*printer)); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h index 8a92dd25f51..f1106406c3a 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h @@ -62,12 +62,20 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, // string. |ipp_everywhere| indicates if configuration using the CUPS IPP // Everywhere driver should be attempted. If |success| is false, the values of // |make|, |model|, |make_and_model|, and |ipp_everywhere| are not specified. - void OnPrinterInfo(const std::string& callback_id, - bool success, - const std::string& make, - const std::string& model, - const std::string& make_and_model, - bool ipp_everywhere); + void OnAutoconfQueried(const std::string& callback_id, + bool success, + const std::string& make, + const std::string& model, + const std::string& make_and_model, + bool ipp_everywhere); + + // Handles the callback for HandleGetPrinterInfo for a discovered printer. + void OnAutoconfQueriedDiscovered(std::unique_ptr<Printer> printer, + bool success, + const std::string& make, + const std::string& model, + const std::string& make_and_model, + bool ipp_everywhere); void HandleAddCupsPrinter(const base::ListValue* args); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc index 0d356464b37..ea381abb6c4 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc @@ -28,15 +28,9 @@ constexpr char kAppLockScreenSupportKey[] = "lockScreenSupport"; } // namespace -StylusHandler::StylusHandler() { - NoteTakingHelper::Get()->AddObserver(this); - ui::InputDeviceManager::GetInstance()->AddObserver(this); -} +StylusHandler::StylusHandler() : note_observer_(this), input_observer_(this) {} -StylusHandler::~StylusHandler() { - ui::InputDeviceManager::GetInstance()->RemoveObserver(this); - NoteTakingHelper::Get()->RemoveObserver(this); -} +StylusHandler::~StylusHandler() = default; void StylusHandler::RegisterMessages() { DCHECK(web_ui()); @@ -60,6 +54,16 @@ void StylusHandler::RegisterMessages() { base::Bind(&StylusHandler::ShowPlayStoreApps, base::Unretained(this))); } +void StylusHandler::OnJavascriptAllowed() { + note_observer_.Add(NoteTakingHelper::Get()); + input_observer_.Add(ui::InputDeviceManager::GetInstance()); +} + +void StylusHandler::OnJavascriptDisallowed() { + note_observer_.RemoveAll(); + input_observer_.RemoveAll(); +} + void StylusHandler::OnAvailableNoteTakingAppsUpdated() { UpdateNoteTakingApps(); } @@ -99,12 +103,12 @@ void StylusHandler::UpdateNoteTakingApps() { } } - AllowJavascript(); FireWebUIListener("onNoteTakingAppsUpdated", apps_list, base::Value(waiting_for_android)); } void StylusHandler::RequestApps(const base::ListValue* unused_args) { + AllowJavascript(); UpdateNoteTakingApps(); } @@ -133,13 +137,13 @@ void StylusHandler::SetPreferredNoteTakingAppEnabledOnLockScreen( } void StylusHandler::HandleInitialize(const base::ListValue* args) { + AllowJavascript(); if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) SendHasStylus(); } void StylusHandler::SendHasStylus() { DCHECK(ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()); - AllowJavascript(); FireWebUIListener("has-stylus-changed", base::Value(ash::palette_utils::HasStylusInput())); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h index ac52790f5ad..8f2800d4d86 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h @@ -9,6 +9,7 @@ #include <string> #include "base/macros.h" +#include "base/scoped_observer.h" #include "chrome/browser/chromeos/note_taking_helper.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "ui/events/devices/input_device_event_observer.h" @@ -17,12 +18,16 @@ namespace base { class ListValue; } +namespace ui { +class InputDeviceManager; +} + namespace chromeos { namespace settings { // Chrome OS stylus settings handler. class StylusHandler : public ::settings::SettingsPageUIHandler, - public chromeos::NoteTakingHelper::Observer, + public NoteTakingHelper::Observer, public ui::InputDeviceEventObserver { public: StylusHandler(); @@ -30,8 +35,8 @@ class StylusHandler : public ::settings::SettingsPageUIHandler, // SettingsPageUIHandler implementation. void RegisterMessages() override; - void OnJavascriptAllowed() override {} - void OnJavascriptDisallowed() override {} + void OnJavascriptAllowed() override; + void OnJavascriptDisallowed() override; // chromeos::NoteTakingHelper::Observer implementation. void OnAvailableNoteTakingAppsUpdated() override; @@ -58,6 +63,11 @@ class StylusHandler : public ::settings::SettingsPageUIHandler, // IDs of available note-taking apps. std::set<std::string> note_taking_app_ids_; + // Observer registration. + ScopedObserver<NoteTakingHelper, NoteTakingHelper::Observer> note_observer_; + ScopedObserver<ui::InputDeviceManager, ui::InputDeviceEventObserver> + input_observer_; + DISALLOW_COPY_AND_ASSIGN(StylusHandler); }; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc index d046f21e27d..69b4aef7ff2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc @@ -48,7 +48,7 @@ void GoogleAssistantHandler::HandleSetGoogleAssistantEnabled( auto* service = arc::ArcVoiceInteractionFrameworkService::GetForBrowserContext(profile_); if (service) - service->SetVoiceInteractionEnabled(enabled); + service->SetVoiceInteractionEnabled(enabled, base::BindOnce([](bool) {})); } void GoogleAssistantHandler::HandleSetGoogleAssistantContextEnabled( diff --git a/chromium/chromeos/components/tether/BUILD.gn b/chromium/chromeos/components/tether/BUILD.gn index 065a6cb64d3..953f12a16b8 100644 --- a/chromium/chromeos/components/tether/BUILD.gn +++ b/chromium/chromeos/components/tether/BUILD.gn @@ -16,10 +16,11 @@ static_library("tether") { "ble_advertiser.h", "ble_connection_manager.cc", "ble_connection_manager.h", - "ble_constants.cc", "ble_constants.h", "ble_scanner.cc", "ble_scanner.h", + "ble_synchronizer.cc", + "ble_synchronizer.h", "connect_tethering_operation.cc", "connect_tethering_operation.h", "crash_recovery_manager.cc", @@ -34,6 +35,10 @@ static_library("tether") { "disconnect_tethering_request_sender.h", "disconnect_tethering_request_sender_impl.cc", "disconnect_tethering_request_sender_impl.h", + "error_tolerant_ble_advertisement.cc", + "error_tolerant_ble_advertisement.h", + "error_tolerant_ble_advertisement_impl.cc", + "error_tolerant_ble_advertisement_impl.h", "host_connection_metrics_logger.cc", "host_connection_metrics_logger.h", "host_scan_cache.cc", @@ -127,8 +132,12 @@ static_library("test_support") { "fake_active_host.h", "fake_ble_connection_manager.cc", "fake_ble_connection_manager.h", + "fake_ble_synchronizer.cc", + "fake_ble_synchronizer.h", "fake_disconnect_tethering_request_sender.cc", "fake_disconnect_tethering_request_sender.h", + "fake_error_tolerant_ble_advertisement.cc", + "fake_error_tolerant_ble_advertisement.h", "fake_host_scan_cache.cc", "fake_host_scan_cache.h", "fake_initializer.cc", @@ -166,6 +175,7 @@ static_library("test_support") { "//chromeos", "//chromeos/components/tether/proto", "//components/cryptauth", + "//device/bluetooth", "//testing/gmock", "//testing/gtest", "//ui/message_center:test_support", @@ -182,11 +192,13 @@ source_set("unit_tests") { "ble_advertiser_unittest.cc", "ble_connection_manager_unittest.cc", "ble_scanner_unittest.cc", + "ble_synchronizer_unittest.cc", "connect_tethering_operation_unittest.cc", "crash_recovery_manager_unittest.cc", "device_status_util_unittest.cc", "disconnect_tethering_operation_unittest.cc", "disconnect_tethering_request_sender_impl_unittest.cc", + "error_tolerant_ble_advertisement_impl_unittest.cc", "host_connection_metrics_logger_unittest.cc", "host_scan_cache_unittest.cc", "host_scan_device_prioritizer_impl_unittest.cc", diff --git a/chromium/components/arc/common/voice_interaction_framework.mojom b/chromium/components/arc/common/voice_interaction_framework.mojom index aaa0a4791de..7cfd385126c 100644 --- a/chromium/components/arc/common/voice_interaction_framework.mojom +++ b/chromium/components/arc/common/voice_interaction_framework.mojom @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Next MinVersion: 11 +// Next MinVersion: 13 module arc.mojom; @@ -53,7 +53,8 @@ struct VoiceInteractionStatus { }; // Connects with Android system server. -// Next method ID: 10 +// Next method ID: 11 +// Deprecated method ID: 4 interface VoiceInteractionFrameworkInstance { Init@0(VoiceInteractionFrameworkHost host_ptr); @@ -70,8 +71,8 @@ interface VoiceInteractionFrameworkInstance { // Shows/hides the metalayer in the container. [MinVersion=1] SetMetalayerVisibility@3([MinVersion=2] bool visible); - // Turns on / off voice interaction in container. - [MinVersion=4] SetVoiceInteractionEnabled@4(bool enable); + // Turns on / off voice interaction and ack the setting. + [MinVersion=12] SetVoiceInteractionEnabled@10(bool enable) => (); // Turns on / off context for voice interaction in container. This function // controls whether screenshot and view hierarchy information should be sent diff --git a/chromium/components/arc/net/arc_net_host_impl.cc b/chromium/components/arc/net/arc_net_host_impl.cc index 705cb90673f..38dd9a21c0b 100644 --- a/chromium/components/arc/net/arc_net_host_impl.cc +++ b/chromium/components/arc/net/arc_net_host_impl.cc @@ -223,6 +223,24 @@ arc::mojom::NetworkConfigurationPtr TranslateONCConfiguration( return mojo; } +const chromeos::NetworkState* GetShillBackedNetwork( + const chromeos::NetworkState* network) { + if (!network) + return nullptr; + + // Non-Tether networks are already backed by Shill. + if (!chromeos::NetworkTypePattern::Tether().MatchesType(network->type())) + return network; + + // Tether networks which are not connected are also not backed by Shill. + if (!network->IsConnectedState()) + return nullptr; + + // Connected Tether networks delegate to an underlying Wi-Fi network. + DCHECK(!network->tether_guid().empty()); + return GetStateHandler()->GetNetworkStateFromGuid(network->tether_guid()); +} + void ForgetNetworkSuccessCallback( const arc::mojom::NetHost::ForgetNetworkCallback& mojo_callback) { mojo_callback.Run(arc::mojom::NetworkResult::SUCCESS); @@ -538,7 +556,7 @@ void ArcNetHostImpl::CreateNetwork(mojom::WifiConfigurationPtr cfg, bool ArcNetHostImpl::GetNetworkPathFromGuid(const std::string& guid, std::string* path) { const chromeos::NetworkState* network = - GetStateHandler()->GetNetworkStateFromGuid(guid); + GetShillBackedNetwork(GetStateHandler()->GetNetworkStateFromGuid(guid)); if (network) { *path = network->path(); return true; @@ -641,7 +659,8 @@ void ArcNetHostImpl::ScanCompleted(const chromeos::DeviceState* /*unused*/) { void ArcNetHostImpl::GetDefaultNetwork( const GetDefaultNetworkCallback& callback) { const chromeos::NetworkState* default_network = - GetStateHandler()->DefaultNetwork(); + GetShillBackedNetwork(GetStateHandler()->DefaultNetwork()); + if (!default_network) { VLOG(1) << "GetDefaultNetwork: no default network"; callback.Run(nullptr, nullptr); @@ -670,7 +689,10 @@ void ArcNetHostImpl::DefaultNetworkSuccessCallback( void ArcNetHostImpl::DefaultNetworkChanged( const chromeos::NetworkState* network) { - if (!network) { + const chromeos::NetworkState* shill_backed_network = + GetShillBackedNetwork(network); + + if (!shill_backed_network) { VLOG(1) << "No default network"; auto* net_instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->net(), DefaultNetworkChanged); @@ -679,10 +701,10 @@ void ArcNetHostImpl::DefaultNetworkChanged( return; } - VLOG(1) << "New default network: " << network->path(); + VLOG(1) << "New default network: " << shill_backed_network->path(); std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash(); GetManagedConfigurationHandler()->GetProperties( - user_id_hash, network->path(), + user_id_hash, shill_backed_network->path(), base::Bind(&ArcNetHostImpl::DefaultNetworkSuccessCallback, weak_factory_.GetWeakPtr()), base::Bind(&DefaultNetworkFailureCallback)); diff --git a/chromium/components/cronet/android/BUILD.gn b/chromium/components/cronet/android/BUILD.gn index 4474e321496..9e1a3ee9400 100644 --- a/chromium/components/cronet/android/BUILD.gn +++ b/chromium/components/cronet/android/BUILD.gn @@ -365,6 +365,7 @@ android_library("cronet_impl_native_java") { "java/src/org/chromium/net/impl/CronetUrlRequest.java", "java/src/org/chromium/net/impl/CronetUrlRequestContext.java", "java/src/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java", + "java/src/org/chromium/net/impl/NativeCronetEngineBuilderWithLibraryLoaderImpl.java", "java/src/org/chromium/net/impl/NativeCronetProvider.java", "java/src/org/chromium/net/urlconnection/CronetBufferedOutputStream.java", "java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java", diff --git a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc index d0f0466642a..c3da0c48fbe 100644 --- a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc +++ b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.cc @@ -55,14 +55,16 @@ BluetoothLowEnergyWeaveClientConnection::Factory* std::unique_ptr<Connection> BluetoothLowEnergyWeaveClientConnection::Factory::NewInstance( const RemoteDevice& remote_device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid) { + const device::BluetoothUUID remote_service_uuid, + device::BluetoothDevice* bluetooth_device, + bool should_set_low_connection_latency) { if (!factory_instance_) { factory_instance_ = new Factory(); } - return factory_instance_->BuildInstance(remote_device, device_address, - adapter, remote_service_uuid); + return factory_instance_->BuildInstance(remote_device, adapter, + remote_service_uuid, bluetooth_device, + should_set_low_connection_latency); } // static @@ -74,11 +76,13 @@ void BluetoothLowEnergyWeaveClientConnection::Factory::SetInstanceForTesting( std::unique_ptr<Connection> BluetoothLowEnergyWeaveClientConnection::Factory::BuildInstance( const RemoteDevice& remote_device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid) { + const device::BluetoothUUID remote_service_uuid, + device::BluetoothDevice* bluetooth_device, + bool should_set_low_connection_latency) { return base::MakeUnique<BluetoothLowEnergyWeaveClientConnection>( - remote_device, device_address, adapter, remote_service_uuid); + remote_device, adapter, remote_service_uuid, bluetooth_device, + should_set_low_connection_latency); } // static @@ -131,11 +135,13 @@ std::string BluetoothLowEnergyWeaveClientConnection::SubStatusToString( BluetoothLowEnergyWeaveClientConnection:: BluetoothLowEnergyWeaveClientConnection( const RemoteDevice& device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid) + const device::BluetoothUUID remote_service_uuid, + device::BluetoothDevice* bluetooth_device, + bool should_set_low_connection_latency) : Connection(device), - device_address_(device_address), + bluetooth_device_(bluetooth_device), + should_set_low_connection_latency_(should_set_low_connection_latency), adapter_(adapter), remote_service_({remote_service_uuid, std::string()}), packet_generator_( @@ -160,6 +166,15 @@ BluetoothLowEnergyWeaveClientConnection:: void BluetoothLowEnergyWeaveClientConnection::Connect() { DCHECK(sub_status() == SubStatus::DISCONNECTED); + + if (should_set_low_connection_latency_) + SetConnectionLatency(); + else + CreateGattConnection(); +} + +void BluetoothLowEnergyWeaveClientConnection::SetConnectionLatency() { + DCHECK(sub_status() == SubStatus::DISCONNECTED); SetSubStatus(SubStatus::WAITING_CONNECTION_LATENCY); device::BluetoothDevice* bluetooth_device = GetBluetoothDevice(); @@ -182,7 +197,8 @@ void BluetoothLowEnergyWeaveClientConnection::Connect() { } void BluetoothLowEnergyWeaveClientConnection::CreateGattConnection() { - DCHECK(sub_status() == SubStatus::WAITING_CONNECTION_LATENCY); + DCHECK(sub_status() == SubStatus::DISCONNECTED || + sub_status() == SubStatus::WAITING_CONNECTION_LATENCY); SetSubStatus(SubStatus::WAITING_GATT_CONNECTION); device::BluetoothDevice* bluetooth_device = GetBluetoothDevice(); @@ -717,12 +733,12 @@ std::string BluetoothLowEnergyWeaveClientConnection::GetDeviceAddress() { // |gatt_connection_|. Unpaired BLE device addresses are ephemeral and are // expected to change periodically. return gatt_connection_ ? gatt_connection_->GetDeviceAddress() - : device_address_; + : bluetooth_device_->GetAddress(); } device::BluetoothDevice* BluetoothLowEnergyWeaveClientConnection::GetBluetoothDevice() { - return adapter_->GetDevice(GetDeviceAddress()); + return bluetooth_device_; } device::BluetoothRemoteGattService* diff --git a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h index 1a74e45c6a9..2ae20e4e015 100644 --- a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h +++ b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.h @@ -57,17 +57,19 @@ class BluetoothLowEnergyWeaveClientConnection public: static std::unique_ptr<Connection> NewInstance( const RemoteDevice& remote_device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid); + const device::BluetoothUUID remote_service_uuid, + device::BluetoothDevice* bluetooth_device, + bool should_set_low_connection_latency); static void SetInstanceForTesting(Factory* factory); protected: virtual std::unique_ptr<Connection> BuildInstance( const RemoteDevice& remote_device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid); + const device::BluetoothUUID remote_service_uuid, + device::BluetoothDevice* bluetooth_device, + bool should_set_low_connection_latency); private: static Factory* factory_instance_; @@ -89,9 +91,10 @@ class BluetoothLowEnergyWeaveClientConnection // necessary to initiate the BLE connection. BluetoothLowEnergyWeaveClientConnection( const RemoteDevice& remote_device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid); + const device::BluetoothUUID remote_service_uuid, + device::BluetoothDevice* bluetooth_device, + bool should_set_low_connection_latency); ~BluetoothLowEnergyWeaveClientConnection() override; @@ -134,6 +137,10 @@ class BluetoothLowEnergyWeaveClientConnection device::BluetoothRemoteGattCharacteristic* characteristic, const Packet& value) override; + bool should_set_low_connection_latency() { + return should_set_low_connection_latency_; + } + private: enum WriteRequestType { REGULAR, @@ -217,10 +224,10 @@ class BluetoothLowEnergyWeaveClientConnection // connection. std::string GetReasonForClose(); - // The device to which to connect. This is the starting value, but the device - // address may change during the connection because BLE addresses are - // ephemeral. Use GetDeviceAddress() to get the most up-to-date address. - const std::string device_address_; + // The device to which to connect. + device::BluetoothDevice* bluetooth_device_; + + bool should_set_low_connection_latency_; scoped_refptr<device::BluetoothAdapter> adapter_; RemoteAttribute remote_service_; diff --git a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc index 87333d3ddb7..c8a00920387 100644 --- a/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc +++ b/chromium/components/cryptauth/ble/bluetooth_low_energy_weave_client_connection_unittest.cc @@ -210,16 +210,24 @@ class TestBluetoothLowEnergyWeaveClientConnection public: TestBluetoothLowEnergyWeaveClientConnection( const RemoteDevice& remote_device, - const std::string& device_address, scoped_refptr<device::BluetoothAdapter> adapter, - const device::BluetoothUUID remote_service_uuid) - : BluetoothLowEnergyWeaveClientConnection(remote_device, - device_address, - adapter, - remote_service_uuid) {} + const device::BluetoothUUID remote_service_uuid, + device::MockBluetoothDevice* mock_bluetooth_device, + bool should_set_low_connection_latency) + : BluetoothLowEnergyWeaveClientConnection( + remote_device, + adapter, + remote_service_uuid, + mock_bluetooth_device, + should_set_low_connection_latency) {} ~TestBluetoothLowEnergyWeaveClientConnection() override {} + bool should_set_low_connection_latency() { + return BluetoothLowEnergyWeaveClientConnection:: + should_set_low_connection_latency(); + } + MOCK_METHOD2( CreateCharacteristicsFinder, BluetoothLowEnergyCharacteristicsFinder*( @@ -364,15 +372,15 @@ class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest // Creates a BluetoothLowEnergyWeaveClientConnection and verifies it's in // DISCONNECTED state. - std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> - CreateConnection() { + std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> CreateConnection( + bool should_set_low_connection_latency) { EXPECT_CALL(*adapter_, AddObserver(_)); EXPECT_CALL(*adapter_, RemoveObserver(_)); std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( new TestBluetoothLowEnergyWeaveClientConnection( - remote_device_, kTestRemoteDeviceBluetoothAddress, adapter_, - service_uuid_)); + remote_device_, adapter_, service_uuid_, + mock_bluetooth_device_.get(), should_set_low_connection_latency)); EXPECT_EQ(connection->sub_status(), SubStatus::DISCONNECTED); EXPECT_EQ(connection->status(), Connection::DISCONNECTED); @@ -396,11 +404,13 @@ class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest // Transitions |connection| from DISCONNECTED to WAITING_CHARACTERISTICS // state, without an existing GATT connection. void ConnectGatt(TestBluetoothLowEnergyWeaveClientConnection* connection) { - EXPECT_CALL(*mock_bluetooth_device_, - SetConnectionLatency( - device::BluetoothDevice::CONNECTION_LATENCY_LOW, _, _)) - .WillOnce(DoAll(SaveArg<1>(&connection_latency_callback_), - SaveArg<2>(&connection_latency_error_callback_))); + if (connection->should_set_low_connection_latency()) { + EXPECT_CALL(*mock_bluetooth_device_, + SetConnectionLatency( + device::BluetoothDevice::CONNECTION_LATENCY_LOW, _, _)) + .WillOnce(DoAll(SaveArg<1>(&connection_latency_callback_), + SaveArg<2>(&connection_latency_error_callback_))); + } // Preparing |connection| for a CreateGattConnection call. EXPECT_CALL(*mock_bluetooth_device_, CreateGattConnection(_, _)) @@ -409,12 +419,15 @@ class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest connection->Connect(); - // Handle setting the connection latency. - EXPECT_EQ(connection->sub_status(), SubStatus::WAITING_CONNECTION_LATENCY); - EXPECT_EQ(connection->status(), Connection::IN_PROGRESS); - ASSERT_FALSE(connection_latency_callback_.is_null()); - ASSERT_FALSE(connection_latency_error_callback_.is_null()); - connection_latency_callback_.Run(); + if (connection->should_set_low_connection_latency()) { + // Handle setting the connection latency. + EXPECT_EQ(connection->sub_status(), + SubStatus::WAITING_CONNECTION_LATENCY); + EXPECT_EQ(connection->status(), Connection::IN_PROGRESS); + ASSERT_FALSE(connection_latency_callback_.is_null()); + ASSERT_FALSE(connection_latency_error_callback_.is_null()); + connection_latency_callback_.Run(); + } EXPECT_EQ(connection->sub_status(), SubStatus::WAITING_GATT_CONNECTION); EXPECT_EQ(connection->status(), Connection::IN_PROGRESS); @@ -605,21 +618,21 @@ class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, CreateAndDestroyWithoutConnectCallDoesntCrash) { BluetoothLowEnergyWeaveClientConnection connection( - remote_device_, kTestRemoteDeviceBluetoothAddress, adapter_, - service_uuid_); + remote_device_, adapter_, service_uuid_, mock_bluetooth_device_.get(), + true /* should_set_low_connection_latency */); } TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, DisconnectWithoutConnectDoesntCrash) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); Disconnect(connection.get()); } TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectSuccess) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); NotifySessionStarted(connection.get()); @@ -629,7 +642,16 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectSuccessDisconnect) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); + InitializeConnection(connection.get(), kDefaultMaxPacketSize); + EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED); + Disconnect(connection.get()); +} + +TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, + ConnectSuccessDisconnect_DoNotSetLowLatency) { + std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( + CreateConnection(false /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED); Disconnect(connection.get()); @@ -638,7 +660,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectIncompleteDisconnectFromWaitingCharacteristicsState) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); Disconnect(connection.get()); } @@ -646,7 +668,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectIncompleteDisconnectFromWaitingNotifySessionState) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); Disconnect(connection.get()); @@ -655,7 +677,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectIncompleteDisconnectFromWaitingConnectionResponseState) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); NotifySessionStarted(connection.get()); @@ -665,7 +687,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectFailsCharacteristicsNotFound) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); EXPECT_CALL(*rx_characteristic_, StartNotifySession(_, _)).Times(0); @@ -683,7 +705,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectFailsCharacteristicsFoundThenUnavailable) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); // Simulate the inability to fetch the characteristic after it was received. @@ -705,7 +727,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectFailsNotifySessionError) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); @@ -723,7 +745,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectFailsErrorSendingConnectionRequest) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); NotifySessionStarted(connection.get()); @@ -756,7 +778,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ReceiveMessageSmallerThanCharacteristicSize) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); std::string received_bytes; @@ -772,7 +794,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ReceiveMessageLargerThanCharacteristicSize) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kLargeMaxPacketSize); @@ -792,7 +814,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, SendMessageSmallerThanCharacteristicSize) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); // Expecting a first call of WriteRemoteCharacteristic, after SendMessage is @@ -818,7 +840,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, SendMessageLargerThanCharacteristicSize) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kLargeMaxPacketSize); @@ -862,7 +884,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, SendMessageKeepsFailing) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); EXPECT_CALL(*tx_characteristic_, WriteRemoteCharacteristic(_, _, _)) @@ -899,7 +921,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ReceiveCloseConnectionTest) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); connection->GattCharacteristicValueChanged( @@ -913,7 +935,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ReceiverErrorTest) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); @@ -938,7 +960,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ReceiverErrorWithPendingWritesTest) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kLargeMaxPacketSize); @@ -977,7 +999,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ObserverDeletesConnectionOnDisconnect) { TestBluetoothLowEnergyWeaveClientConnection* connection = - CreateConnection().release(); + CreateConnection(true /* should_set_low_connection_latency */).release(); connection_observer_->set_delete_on_disconnect(true); InitializeConnection(connection, kDefaultMaxPacketSize); @@ -1005,7 +1027,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ObserverDeletesConnectionOnMessageSent) { TestBluetoothLowEnergyWeaveClientConnection* connection = - CreateConnection().release(); + CreateConnection(true /* should_set_low_connection_latency */).release(); connection_observer_->set_delete_on_message_sent(true); InitializeConnection(connection, kDefaultMaxPacketSize); @@ -1033,7 +1055,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, WriteConnectionCloseMaxNumberOfTimes) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); InitializeConnection(connection.get(), kDefaultMaxPacketSize); EXPECT_EQ(connection->sub_status(), SubStatus::CONNECTED); @@ -1072,7 +1094,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, ConnectAfterADelayWhenThrottled) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); EXPECT_CALL(*mock_bluetooth_device_, SetConnectionLatency( @@ -1118,7 +1140,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, SetConnectionLatencyError) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); EXPECT_CALL(*mock_bluetooth_device_, SetConnectionLatency( @@ -1156,7 +1178,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, Timeout_ConnectionLatency) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); EXPECT_CALL(*mock_bluetooth_device_, SetConnectionLatency( @@ -1181,7 +1203,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, Timeout_GattConnection) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); EXPECT_CALL(*mock_bluetooth_device_, SetConnectionLatency( @@ -1216,7 +1238,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, Timeout_GattCharacteristics) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); EXPECT_EQ(connection->sub_status(), SubStatus::WAITING_CHARACTERISTICS); EXPECT_EQ(connection->status(), Connection::IN_PROGRESS); @@ -1231,7 +1253,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, Timeout_NotifySession) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); EXPECT_EQ(connection->sub_status(), SubStatus::WAITING_NOTIFY_SESSION); @@ -1247,7 +1269,7 @@ TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest, Timeout_ConnectionResponse) { std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection( - CreateConnection()); + CreateConnection(true /* should_set_low_connection_latency */)); ConnectGatt(connection.get()); CharacteristicsFound(connection.get()); NotifySessionStarted(connection.get()); diff --git a/chromium/components/cryptauth/cryptauth_test_util.cc b/chromium/components/cryptauth/cryptauth_test_util.cc index 60b31f8ecff..4d0be8586e9 100644 --- a/chromium/components/cryptauth/cryptauth_test_util.cc +++ b/chromium/components/cryptauth/cryptauth_test_util.cc @@ -12,6 +12,8 @@ const char kTestRemoteDeviceName[] = "remote device"; const char kTestRemoteDevicePublicKey[] = "public key"; const char kTestRemoteDeviceBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; const char kTestRemoteDevicePSK[] = "remote device psk"; -const char kTestRemoteDeviceSignInChallenge[] = "sign-in challenge"; +const bool kTestRemoteDeviceUnlockKey = true; +const bool kTestRemoteDeviceSupportsMobileHotspot = true; +const int64_t kTestRemoteDeviceLastUpdateTimeMillis = 0L; } // namespace cryptauth diff --git a/chromium/components/cryptauth/cryptauth_test_util.h b/chromium/components/cryptauth/cryptauth_test_util.h index 4c43b810e62..3ef00122a7f 100644 --- a/chromium/components/cryptauth/cryptauth_test_util.h +++ b/chromium/components/cryptauth/cryptauth_test_util.h @@ -15,14 +15,18 @@ extern const char kTestRemoteDeviceName[]; extern const char kTestRemoteDevicePublicKey[]; extern const char kTestRemoteDeviceBluetoothAddress[]; extern const char kTestRemoteDevicePSK[]; -extern const char kTestRemoteDeviceSignInChallenge[]; +extern const bool kTestRemoteDeviceUnlockKey; +extern const bool kTestRemoteDeviceSupportsMobileHotspot; +extern const int64_t kTestRemoteDeviceLastUpdateTimeMillis; // Returns a BLE RemoteDevice used for tests. inline RemoteDevice CreateLERemoteDeviceForTest() { return RemoteDevice(kTestRemoteDeviceUserId, kTestRemoteDeviceName, kTestRemoteDevicePublicKey, kTestRemoteDeviceBluetoothAddress, kTestRemoteDevicePSK, - kTestRemoteDeviceSignInChallenge); + kTestRemoteDeviceUnlockKey, + kTestRemoteDeviceSupportsMobileHotspot, + kTestRemoteDeviceLastUpdateTimeMillis); } // Returns a classic Bluetooth RemoteDevice used for tests. @@ -30,7 +34,9 @@ inline RemoteDevice CreateClassicRemoteDeviceForTest() { return RemoteDevice(kTestRemoteDeviceUserId, kTestRemoteDeviceName, kTestRemoteDevicePublicKey, kTestRemoteDeviceBluetoothAddress, kTestRemoteDevicePSK, - kTestRemoteDeviceSignInChallenge); + kTestRemoteDeviceUnlockKey, + kTestRemoteDeviceSupportsMobileHotspot, + kTestRemoteDeviceLastUpdateTimeMillis); } } // namespace cryptauth diff --git a/chromium/components/cryptauth/mock_foreground_eid_generator.h b/chromium/components/cryptauth/mock_foreground_eid_generator.h index c9b328d041e..ef7232c898d 100644 --- a/chromium/components/cryptauth/mock_foreground_eid_generator.h +++ b/chromium/components/cryptauth/mock_foreground_eid_generator.h @@ -39,7 +39,7 @@ class MockForegroundEidGenerator : public ForegroundEidGenerator { possible_advertisements_ = std::move(possible_advertisements); } - void set_identified_device(RemoteDevice* identified_device) { + void set_identified_device(const RemoteDevice* identified_device) { identified_device_ = identified_device; } diff --git a/chromium/components/cryptauth/remote_device.cc b/chromium/components/cryptauth/remote_device.cc index b9556956e57..7a176026d24 100644 --- a/chromium/components/cryptauth/remote_device.cc +++ b/chromium/components/cryptauth/remote_device.cc @@ -32,20 +32,27 @@ bool AreBeaconSeedsEqual(const std::vector<BeaconSeed> beacon_seeds1, } // namespace -RemoteDevice::RemoteDevice() {} +RemoteDevice::RemoteDevice() + : unlock_key(false), + supports_mobile_hotspot(false), + last_update_time_millis(0L) {} RemoteDevice::RemoteDevice(const std::string& user_id, const std::string& name, const std::string& public_key, const std::string& bluetooth_address, const std::string& persistent_symmetric_key, - std::string sign_in_challenge) + bool unlock_key, + bool supports_mobile_hotspot, + int64_t last_update_time_millis) : user_id(user_id), name(name), public_key(public_key), bluetooth_address(bluetooth_address), persistent_symmetric_key(persistent_symmetric_key), - sign_in_challenge(sign_in_challenge) {} + unlock_key(unlock_key), + supports_mobile_hotspot(supports_mobile_hotspot), + last_update_time_millis(last_update_time_millis) {} RemoteDevice::RemoteDevice(const RemoteDevice& other) = default; @@ -82,7 +89,10 @@ bool RemoteDevice::operator==(const RemoteDevice& other) const { public_key == other.public_key && bluetooth_address == other.bluetooth_address && persistent_symmetric_key == other.persistent_symmetric_key && - sign_in_challenge == other.sign_in_challenge && are_beacon_seeds_equal; + unlock_key == other.unlock_key && + supports_mobile_hotspot == other.supports_mobile_hotspot && + last_update_time_millis == other.last_update_time_millis && + are_beacon_seeds_equal; } bool RemoteDevice::operator<(const RemoteDevice& other) const { diff --git a/chromium/components/cryptauth/remote_device.h b/chromium/components/cryptauth/remote_device.h index 7662b1a38c7..abdd4db15cb 100644 --- a/chromium/components/cryptauth/remote_device.h +++ b/chromium/components/cryptauth/remote_device.h @@ -19,7 +19,9 @@ struct RemoteDevice { std::string public_key; std::string bluetooth_address; std::string persistent_symmetric_key; - std::string sign_in_challenge; + bool unlock_key; + bool supports_mobile_hotspot; + int64_t last_update_time_millis; // Note: To save space, the BeaconSeeds may not necessarily be included in // this object. @@ -32,7 +34,9 @@ struct RemoteDevice { const std::string& public_key, const std::string& bluetooth_address, const std::string& persistent_symmetric_key, - std::string sign_in_challenge); + bool unlock_key, + bool supports_mobile_hotspot, + int64_t last_update_time_millis); RemoteDevice(const RemoteDevice& other); ~RemoteDevice(); diff --git a/chromium/components/cryptauth/remote_device_loader.cc b/chromium/components/cryptauth/remote_device_loader.cc index 705a1262d84..a9fc03543a7 100644 --- a/chromium/components/cryptauth/remote_device_loader.cc +++ b/chromium/components/cryptauth/remote_device_loader.cc @@ -106,7 +106,8 @@ void RemoteDeviceLoader::OnPSKDerived( cryptauth::RemoteDevice remote_device( user_id_, device.friendly_device_name(), device.public_key(), - device.bluetooth_address(), psk, std::string()); + device.bluetooth_address(), psk, device.unlock_key(), + device.mobile_hotspot_supported(), device.last_update_time_millis()); if (should_load_beacon_seeds_) { std::vector<BeaconSeed> beacon_seeds; diff --git a/chromium/components/cryptauth/remote_device_loader_unittest.cc b/chromium/components/cryptauth/remote_device_loader_unittest.cc index 3f538d383aa..3aa71fb89c4 100644 --- a/chromium/components/cryptauth/remote_device_loader_unittest.cc +++ b/chromium/components/cryptauth/remote_device_loader_unittest.cc @@ -153,6 +153,62 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadDevicesWithAndWithoutBeaconSeeds) { remote_device_without_beacon_seed); } +TEST_F(CryptAuthRemoteDeviceLoaderTest, BooleanAttributes) { + cryptauth::ExternalDeviceInfo first = CreateDeviceInfo("0"); + first.set_unlock_key(true); + first.set_mobile_hotspot_supported(true); + + cryptauth::ExternalDeviceInfo second = CreateDeviceInfo("1"); + second.set_unlock_key(false); + second.set_mobile_hotspot_supported(false); + + std::vector<cryptauth::ExternalDeviceInfo> device_infos{first, second}; + + RemoteDeviceLoader loader(device_infos, user_private_key_, kUserId, + std::move(secure_message_delegate_)); + + std::vector<cryptauth::RemoteDevice> result; + EXPECT_CALL(*this, LoadCompleted()); + loader.Load( + false, base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded, + base::Unretained(this))); + + EXPECT_EQ(2u, remote_devices_.size()); + + EXPECT_FALSE(remote_devices_[0].persistent_symmetric_key.empty()); + EXPECT_TRUE(remote_devices_[0].unlock_key); + EXPECT_TRUE(remote_devices_[0].supports_mobile_hotspot); + + EXPECT_FALSE(remote_devices_[1].persistent_symmetric_key.empty()); + EXPECT_FALSE(remote_devices_[1].unlock_key); + EXPECT_FALSE(remote_devices_[1].supports_mobile_hotspot); +} + +TEST_F(CryptAuthRemoteDeviceLoaderTest, LastUpdateTimeMillis) { + cryptauth::ExternalDeviceInfo first = CreateDeviceInfo("0"); + first.set_last_update_time_millis(1000); + + cryptauth::ExternalDeviceInfo second = CreateDeviceInfo("1"); + second.set_last_update_time_millis(2000); + + std::vector<cryptauth::ExternalDeviceInfo> device_infos{first, second}; + + RemoteDeviceLoader loader(device_infos, user_private_key_, kUserId, + std::move(secure_message_delegate_)); + + std::vector<cryptauth::RemoteDevice> result; + EXPECT_CALL(*this, LoadCompleted()); + loader.Load( + false, base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded, + base::Unretained(this))); + + EXPECT_EQ(2u, remote_devices_.size()); + + EXPECT_EQ(1000, remote_devices_[0].last_update_time_millis); + + EXPECT_EQ(2000, remote_devices_[1].last_update_time_millis); +} + TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithAddress) { std::vector<cryptauth::ExternalDeviceInfo> device_infos(1, CreateDeviceInfo("0")); diff --git a/chromium/components/exo/shell_surface.cc b/chromium/components/exo/shell_surface.cc index 6b48c787ef2..395cb87d848 100644 --- a/chromium/components/exo/shell_surface.cc +++ b/chromium/components/exo/shell_surface.cc @@ -72,7 +72,8 @@ const Accelerator kCloseWindowAccelerators[] = { const Accelerator kReservedAccelerators[] = { {ui::VKEY_SPACE, ui::EF_CONTROL_DOWN}, {ui::VKEY_SPACE, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, - {ui::VKEY_F13, ui::EF_NONE}}; + {ui::VKEY_F13, ui::EF_NONE}, + {ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN}}; class CustomFrameView : public views::NonClientFrameView { public: diff --git a/chromium/components/exo/shell_surface_unittest.cc b/chromium/components/exo/shell_surface_unittest.cc index 888744cf1f1..a8c08164200 100644 --- a/chromium/components/exo/shell_surface_unittest.cc +++ b/chromium/components/exo/shell_surface_unittest.cc @@ -1046,8 +1046,8 @@ TEST_F(ShellSurfaceTest, CompositorLockInRotation) { EXPECT_FALSE(compositor->IsLocked()); } -// System tray should be activated if user presses tab key while shell surface -// is active. +// If system tray is shown by click. It should be activated if user presses tab +// key while shell surface is active. TEST_F(ShellSurfaceTest, KeyboardNavigationWithSystemTray) { const gfx::Size buffer_size(800, 600); std::unique_ptr<Buffer> buffer( @@ -1062,9 +1062,11 @@ TEST_F(ShellSurfaceTest, KeyboardNavigationWithSystemTray) { EXPECT_TRUE(shell_surface->GetWidget()->IsActive()); - // Show system tray. + // Show system tray by perfoming a gesture tap at tray. ash::SystemTray* system_tray = GetPrimarySystemTray(); - system_tray->ShowDefaultView(ash::BUBBLE_CREATE_NEW); + ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), + ui::GestureEventDetails(ui::ET_GESTURE_TAP)); + system_tray->PerformAction(tap); ASSERT_TRUE(system_tray->GetWidget()); // Confirm that system tray is not active at this time. diff --git a/chromium/components/viz/service/display_embedder/buffer_queue.cc b/chromium/components/viz/service/display_embedder/buffer_queue.cc index 8c59cf2f5e9..11cbf2d515a 100644 --- a/chromium/components/viz/service/display_embedder/buffer_queue.cc +++ b/chromium/components/viz/service/display_embedder/buffer_queue.cc @@ -89,7 +89,7 @@ void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { void BufferQueue::SwapBuffers(const gfx::Rect& damage) { if (damage.IsEmpty()) { - in_flight_surfaces_.push_back(nullptr); + in_flight_surfaces_.push_back(std::move(current_surface_)); return; } diff --git a/chromium/components/viz/service/display_embedder/buffer_queue_unittest.cc b/chromium/components/viz/service/display_embedder/buffer_queue_unittest.cc index 5f2179029fb..e3bb2e77ed8 100644 --- a/chromium/components/viz/service/display_embedder/buffer_queue_unittest.cc +++ b/chromium/components/viz/service/display_embedder/buffer_queue_unittest.cc @@ -477,18 +477,35 @@ TEST_F(BufferQueueTest, CheckTripleBuffering) { } TEST_F(BufferQueueTest, CheckEmptySwap) { - // Check empty swap flow, in which the damage is empty. + // Check empty swap flow, in which the damage is empty and BindFramebuffer + // might not be called. EXPECT_EQ(0, CountBuffers()); output_surface_->BindFramebuffer(); EXPECT_EQ(1, CountBuffers()); EXPECT_NE(0U, current_surface()); EXPECT_FALSE(displayed_frame()); + + // This is the texture to scanout. + uint32_t texture_id = output_surface_->GetCurrentTextureId(); SwapBuffers(); + // Make sure we won't be drawing to the texture we just sent for scanout. + output_surface_->BindFramebuffer(); + EXPECT_NE(texture_id, output_surface_->GetCurrentTextureId()); + EXPECT_EQ(1U, in_flight_surfaces().size()); - EXPECT_EQ(nullptr, in_flight_surfaces().front()); + output_surface_->PageFlipComplete(); + + // Test swapbuffers without calling BindFramebuffer. DirectRenderer skips + // BindFramebuffer if not necessary. + SwapBuffers(); + SwapBuffers(); + EXPECT_EQ(2U, in_flight_surfaces().size()); + + output_surface_->PageFlipComplete(); + EXPECT_EQ(1U, in_flight_surfaces().size()); + output_surface_->PageFlipComplete(); EXPECT_EQ(0U, in_flight_surfaces().size()); - EXPECT_EQ(nullptr, displayed_frame()); } TEST_F(BufferQueueTest, CheckCorrectBufferOrdering) { diff --git a/chromium/content/renderer/media/gpu/rtc_video_encoder.cc b/chromium/content/renderer/media/gpu/rtc_video_encoder.cc index dc153db4599..5f86834ce2e 100644 --- a/chromium/content/renderer/media/gpu/rtc_video_encoder.cc +++ b/chromium/content/renderer/media/gpu/rtc_video_encoder.cc @@ -31,6 +31,7 @@ #include "media/renderers/gpu_video_accelerator_factories.h" #include "media/video/video_encode_accelerator.h" #include "third_party/libyuv/include/libyuv.h" +#include "third_party/webrtc/modules/video_coding/codecs/h264/include/h264.h" #include "third_party/webrtc/rtc_base/timeutils.h" namespace content { @@ -568,15 +569,22 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(int32_t bitstream_buffer_id, void RTCVideoEncoder::Impl::NotifyError( media::VideoEncodeAccelerator::Error error) { DCHECK(thread_checker_.CalledOnValidThread()); - int32_t retval; + int32_t retval = WEBRTC_VIDEO_CODEC_ERROR; switch (error) { case media::VideoEncodeAccelerator::kInvalidArgumentError: retval = WEBRTC_VIDEO_CODEC_ERR_PARAMETER; break; - default: + case media::VideoEncodeAccelerator::kIllegalStateError: retval = WEBRTC_VIDEO_CODEC_ERROR; + break; + case media::VideoEncodeAccelerator::kPlatformFailureError: + // Some platforms(i.e. Android) do not have SW H264 implementation so + // check if it is available before asking for fallback. + retval = video_codec_type_ != webrtc::kVideoCodecH264 || + webrtc::H264Encoder::IsSupported() + ? WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE + : WEBRTC_VIDEO_CODEC_ERROR; } - video_encoder_.reset(); SetStatus(retval); diff --git a/chromium/content/renderer/media/gpu/rtc_video_encoder_unittest.cc b/chromium/content/renderer/media/gpu/rtc_video_encoder_unittest.cc index 3fd7a91b3ac..7824c10475c 100644 --- a/chromium/content/renderer/media/gpu/rtc_video_encoder_unittest.cc +++ b/chromium/content/renderer/media/gpu/rtc_video_encoder_unittest.cc @@ -64,9 +64,9 @@ class RTCVideoEncoderTest : public ::testing::TestWithParam<webrtc::VideoCodecType> { public: RTCVideoEncoderTest() - : mock_gpu_factories_( + : encoder_thread_("vea_thread"), + mock_gpu_factories_( new media::MockGpuVideoAcceleratorFactories(nullptr)), - encoder_thread_("vea_thread"), idle_waiter_(base::WaitableEvent::ResetPolicy::AUTOMATIC, base::WaitableEvent::InitialState::NOT_SIGNALED) {} @@ -183,12 +183,12 @@ class RTCVideoEncoderTest protected: media::MockVideoEncodeAccelerator* mock_vea_; std::unique_ptr<RTCVideoEncoder> rtc_encoder_; + media::VideoEncodeAccelerator::Client* client_; + base::Thread encoder_thread_; private: std::unique_ptr<media::MockGpuVideoAcceleratorFactories> mock_gpu_factories_; - media::VideoEncodeAccelerator::Client* client_; std::unique_ptr<EncodedImageCallbackWrapper> callback_wrapper_; - base::Thread encoder_thread_; base::WaitableEvent idle_waiter_; }; @@ -211,6 +211,46 @@ TEST_P(RTCVideoEncoderTest, RepeatedInitSucceeds) { EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, rtc_encoder_->InitEncode(&codec, 1, 12345)); } +INSTANTIATE_TEST_CASE_P(CodecProfiles, + RTCVideoEncoderTest, + Values(webrtc::kVideoCodecVP8, + webrtc::kVideoCodecH264)); + +// Checks that WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE is returned when there is +// platform error. +TEST_F(RTCVideoEncoderTest, SoftwareFallbackAfterError) { + const webrtc::VideoCodecType codec_type = webrtc::kVideoCodecVP8; + CreateEncoder(codec_type); + webrtc::VideoCodec codec = GetDefaultCodec(); + codec.codecType = codec_type; + EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, rtc_encoder_->InitEncode(&codec, 1, 12345)); + + EXPECT_CALL(*mock_vea_, Encode(_, _)) + .WillOnce(Invoke([this](const scoped_refptr<media::VideoFrame>&, bool) { + encoder_thread_.task_runner()->PostTask( + FROM_HERE, + base::Bind(&media::VideoEncodeAccelerator::Client::NotifyError, + base::Unretained(client_), + media::VideoEncodeAccelerator::kPlatformFailureError)); + })); + + const rtc::scoped_refptr<webrtc::I420Buffer> buffer = + webrtc::I420Buffer::Create(kInputFrameWidth, kInputFrameHeight); + FillFrameBuffer(buffer); + std::vector<webrtc::FrameType> frame_types; + EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, + rtc_encoder_->Encode( + webrtc::VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0), + nullptr, &frame_types)); + RunUntilIdle(); + + // Expect the next frame to return SW fallback. + EXPECT_EQ(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE, + rtc_encoder_->Encode( + webrtc::VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0), + nullptr, &frame_types)); +} + TEST_F(RTCVideoEncoderTest, EncodeScaledFrame) { const webrtc::VideoCodecType codec_type = webrtc::kVideoCodecVP8; CreateEncoder(codec_type); @@ -273,8 +313,4 @@ TEST_F(RTCVideoEncoderTest, MAYBE_PreserveTimestamps) { rtc_encoder_->Encode(rtc_frame, nullptr, &frame_types)); } -INSTANTIATE_TEST_CASE_P(CodecProfiles, - RTCVideoEncoderTest, - Values(webrtc::kVideoCodecVP8, - webrtc::kVideoCodecH264)); } // namespace content diff --git a/chromium/device/bluetooth/bluez/bluetooth_adapter_bluez.cc b/chromium/device/bluetooth/bluez/bluetooth_adapter_bluez.cc index 552f4f03e01..a84aaf4c75b 100644 --- a/chromium/device/bluetooth/bluez/bluetooth_adapter_bluez.cc +++ b/chromium/device/bluetooth/bluez/bluetooth_adapter_bluez.cc @@ -1565,18 +1565,7 @@ void BluetoothAdapterBlueZ::OnStartDiscoveryError( DCHECK(discovery_request_pending_); discovery_request_pending_ = false; - // Discovery request may fail if discovery was previously initiated by Chrome, - // but the session were invalidated due to the discovery state unexpectedly - // changing to false and then back to true. In this case, report success. - if (IsPresent() && error_name == bluetooth_device::kErrorInProgress && - IsDiscovering()) { - BLUETOOTH_LOG(DEBUG) - << "Discovery previously initiated. Reporting success."; - num_discovery_sessions_++; - callback.Run(); - } else { - error_callback.Run(TranslateDiscoveryErrorToUMA(error_name)); - } + error_callback.Run(TranslateDiscoveryErrorToUMA(error_name)); // Try to add a new discovery session for each queued request. ProcessQueuedDiscoveryRequests(); diff --git a/chromium/net/quic/core/quic_client_promised_info.cc b/chromium/net/quic/core/quic_client_promised_info.cc index ebc6d185057..ca8334be778 100644 --- a/chromium/net/quic/core/quic_client_promised_info.cc +++ b/chromium/net/quic/core/quic_client_promised_info.cc @@ -39,7 +39,11 @@ void QuicClientPromisedInfo::OnPromiseHeaders(const SpdyHeaderBlock& headers) { // RFC7540, Section 8.2, requests MUST be safe [RFC7231], Section // 4.2.1. GET and HEAD are the methods that are safe and required. SpdyHeaderBlock::const_iterator it = headers.find(":method"); - DCHECK(it != headers.end()); + if (it == headers.end()) { + QUIC_DVLOG(1) << "Promise for stream " << id_ << " has no method"; + Reset(QUIC_INVALID_PROMISE_METHOD); + return; + } if (!(it->second == "GET" || it->second == "HEAD")) { QUIC_DVLOG(1) << "Promise for stream " << id_ << " has invalid method " << it->second; diff --git a/chromium/net/quic/core/quic_client_promised_info_test.cc b/chromium/net/quic/core/quic_client_promised_info_test.cc index 954f21b4425..59e87c9882d 100644 --- a/chromium/net/quic/core/quic_client_promised_info_test.cc +++ b/chromium/net/quic/core/quic_client_promised_info_test.cc @@ -153,6 +153,19 @@ TEST_F(QuicClientPromisedInfoTest, PushPromiseInvalidMethod) { EXPECT_EQ(session_.GetPromisedByUrl(promise_url_), nullptr); } +TEST_F(QuicClientPromisedInfoTest, PushPromiseMissingMethod) { + // Promise with a missing method + push_promise_.erase(":method"); + + EXPECT_CALL(*connection_, + SendRstStream(promise_id_, QUIC_INVALID_PROMISE_METHOD, 0)); + ReceivePromise(promise_id_); + + // Verify that the promise headers were ignored + EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr); + EXPECT_EQ(session_.GetPromisedByUrl(promise_url_), nullptr); +} + TEST_F(QuicClientPromisedInfoTest, PushPromiseInvalidUrl) { // Remove required header field to make URL invalid push_promise_.erase(":authority"); diff --git a/chromium/skia/ext/skia_commit_hash.h b/chromium/skia/ext/skia_commit_hash.h index b25885a432d..a1e3ee91248 100644 --- a/chromium/skia/ext/skia_commit_hash.h +++ b/chromium/skia/ext/skia_commit_hash.h @@ -3,6 +3,6 @@ #ifndef SKIA_EXT_SKIA_COMMIT_HASH_H_ #define SKIA_EXT_SKIA_COMMIT_HASH_H_ -#define SKIA_COMMIT_HASH "bbb09c42d396da2d7abf4e1521f89968ae5afbae-" +#define SKIA_COMMIT_HASH "9b2caa32d28d80789df32838c8da1dd3164b1036-" #endif // SKIA_EXT_SKIA_COMMIT_HASH_H_ diff --git a/chromium/third_party/WebKit/Source/core/dom/Document.cpp b/chromium/third_party/WebKit/Source/core/dom/Document.cpp index 58ab5143efd..a39067db8c5 100644 --- a/chromium/third_party/WebKit/Source/core/dom/Document.cpp +++ b/chromium/third_party/WebKit/Source/core/dom/Document.cpp @@ -1998,24 +1998,6 @@ void Document::InheritHtmlAndBodyElementStyles(StyleRecalcChange change) { GetLayoutViewItem().SetStyle(new_style); SetupFontBuilder(*new_style); } - - if (body) { - if (const ComputedStyle* style = body->GetComputedStyle()) { - if (style->Direction() != root_direction || - style->GetWritingMode() != root_writing_mode) - body->SetNeedsStyleRecalc(kSubtreeStyleChange, - StyleChangeReasonForTracing::Create( - StyleChangeReason::kWritingModeChange)); - } - } - - if (const ComputedStyle* style = documentElement()->GetComputedStyle()) { - if (style->Direction() != root_direction || - style->GetWritingMode() != root_writing_mode) - documentElement()->SetNeedsStyleRecalc( - kSubtreeStyleChange, StyleChangeReasonForTracing::Create( - StyleChangeReason::kWritingModeChange)); - } } #if DCHECK_IS_ON() diff --git a/chromium/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/chromium/third_party/WebKit/Source/core/dom/DocumentTest.cpp index 1937e46252a..aadc52838ab 100644 --- a/chromium/third_party/WebKit/Source/core/dom/DocumentTest.cpp +++ b/chromium/third_party/WebKit/Source/core/dom/DocumentTest.cpp @@ -916,4 +916,24 @@ TEST_F(DocumentTest, GetDocument().Lifecycle().GetState()); } +// Tests that the difference in computed style of direction on the html and body +// elements does not trigger a style recalc for viewport style propagation when +// the computed style for another element in the document is recalculated. +TEST_F(DocumentTest, ViewportPropagationNoRecalc) { + SetHtmlInnerHTML( + "<body style='direction:rtl'>" + " <div id=recalc></div>" + "</body>"); + + int old_element_count = GetDocument().GetStyleEngine().StyleForElementCount(); + + Element* div = GetDocument().getElementById("recalc"); + div->setAttribute("style", "color:green"); + GetDocument().UpdateStyleAndLayoutTree(); + + int new_element_count = GetDocument().GetStyleEngine().StyleForElementCount(); + + EXPECT_EQ(1, new_element_count - old_element_count); +} + } // namespace blink diff --git a/chromium/ui/events/ozone/evdev/event_device_test_util.cc b/chromium/ui/events/ozone/evdev/event_device_test_util.cc index 5f032d9d38a..c84115eb8a4 100644 --- a/chromium/ui/events/ozone/evdev/event_device_test_util.cc +++ b/chromium/ui/events/ozone/evdev/event_device_test_util.cc @@ -230,6 +230,45 @@ const DeviceCapabilities kLinkTouchscreen = { arraysize(kLinkTouchscreenAbsAxes), }; +// Fake Atmel touchscreen based on real device from Chromebook Pixel, +// with the addition of ABS_MT_TOOL_TYPE capability. +const DeviceAbsoluteAxis kLinkWithToolTypeTouchscreenAbsAxes[] = { + {ABS_X, {0, 0, 2559, 0, 0, 20}}, + {ABS_Y, {0, 0, 1699, 0, 0, 20}}, + {ABS_PRESSURE, {0, 0, 255, 0, 0, 0}}, + {ABS_MT_SLOT, {0, 0, 15, 0, 0, 0}}, + {ABS_MT_TOUCH_MAJOR, {0, 0, 938, 0, 0, 0}}, + {ABS_MT_ORIENTATION, {0, -3, 4, 0, 0, 0}}, + {ABS_MT_POSITION_X, {0, 0, 2559, 0, 0, 20}}, + {ABS_MT_POSITION_Y, {0, 0, 1699, 0, 0, 20}}, + {ABS_MT_TOOL_TYPE, {0, 0, 0, 0, 0, 0}}, + {ABS_MT_TRACKING_ID, {0, 0, 65535, 0, 0, 0}}, + {ABS_MT_PRESSURE, {0, 0, 255, 0, 0, 0}}, +}; +const DeviceCapabilities kLinkWithToolTypeTouchscreen = { + /* path */ + "/sys/devices/pci0000:00/0000:00:02.0/i2c-2/2-004a/" + "input/input7/event7", + /* name */ "Atmel maXTouch Touchscreen", + /* phys */ "i2c-2-004a/input0", + /* uniq */ "", + /* bustype */ "0018", + /* vendor */ "0000", + /* product */ "0000", + /* version */ "0000", + /* prop */ "0", + /* ev */ "b", + /* key */ "400 0 0 0 0 0", + /* rel */ "0", + /* abs */ "673800001000003", + /* msc */ "0", + /* sw */ "0", + /* led */ "0", + /* ff */ "0", + kLinkWithToolTypeTouchscreenAbsAxes, + arraysize(kLinkWithToolTypeTouchscreenAbsAxes), +}; + // Captured from Chromebook Pixel. const DeviceAbsoluteAxis kLinkTouchpadAbsAxes[] = { {ABS_X, {0, 0, 2040, 0, 0, 20}}, diff --git a/chromium/ui/events/ozone/evdev/event_device_test_util.h b/chromium/ui/events/ozone/evdev/event_device_test_util.h index 145ca4b9568..bd77560ccce 100644 --- a/chromium/ui/events/ozone/evdev/event_device_test_util.h +++ b/chromium/ui/events/ozone/evdev/event_device_test_util.h @@ -64,6 +64,7 @@ extern const DeviceCapabilities kHJCGamepad; extern const DeviceCapabilities kiBuffaloGamepad; extern const DeviceCapabilities kLinkKeyboard; extern const DeviceCapabilities kLinkTouchscreen; +extern const DeviceCapabilities kLinkWithToolTypeTouchscreen; extern const DeviceCapabilities kLinkTouchpad; extern const DeviceCapabilities kHpUsbKeyboard; extern const DeviceCapabilities kHpUsbKeyboard_Extra; diff --git a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc index ca5a9a05654..7cdda3a0827 100644 --- a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc +++ b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc @@ -196,7 +196,10 @@ void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MINOR, i, 0) / 2.0f; events_[i].pressure = ScalePressure( info.GetAbsMtSlotValueWithDefault(ABS_MT_PRESSURE, i, 0)); - events_[i].cancelled = major_max_ > 0 && touch_major == major_max_; + int tool_type = info.GetAbsMtSlotValueWithDefault(ABS_MT_TOOL_TYPE, i, + MT_TOOL_FINGER); + events_[i].cancelled = (tool_type == MT_TOOL_PALM) || + (major_max_ > 0 && touch_major == major_max_); if (events_[i].cancelled) cancelled_state = true; } @@ -391,8 +394,9 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { // neither minor nor orientation, so this is all we can do. events_[current_slot_].radius_x = input.value / 2.0f; - // The MT protocol cannot communicate cancelled touches, so some kernel - // drivers will identify palms by setting touch major to max. + // The MT protocol communicates that there is palm on the surface + // by either sending ABS_MT_TOOL_TYPE/MT_TOOL_PALM, or by setting + // touch major to max. if (major_max_ > 0 && input.value == major_max_) events_[current_slot_].cancelled = true; break; @@ -405,6 +409,10 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { case ABS_MT_POSITION_Y: events_[current_slot_].y = input.value; break; + case ABS_MT_TOOL_TYPE: + if (input.value == MT_TOOL_PALM) + events_[current_slot_].cancelled = true; + break; case ABS_MT_TRACKING_ID: UpdateTrackingId(current_slot_, input.value); break; diff --git a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h index 3ad2a364902..c3ef9d2e485 100644 --- a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h +++ b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h @@ -11,6 +11,13 @@ #include <bitset> #include <memory> +#include <linux/input.h> +// See if we compile against new enough headers and add missing definition +// if the headers are too old. +#ifndef MT_TOOL_PALM +#define MT_TOOL_PALM 2 +#endif + #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/macros.h" diff --git a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc index e52c540d06e..7b4e229e785 100644 --- a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc +++ b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc @@ -679,6 +679,128 @@ TEST_F(TouchEventConverterEvdevTest, ShouldRemoveContactsWhenDisabled) { EXPECT_EQ(2u, size()); } +TEST_F(TouchEventConverterEvdevTest, PalmShouldCancelTouch) { + ui::MockTouchEventConverterEvdev* dev = device(); + + EventDeviceInfo devinfo; + EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkWithToolTypeTouchscreen, &devinfo)); + + timeval time; + time = {1429651083, 686882}; + int major_max = devinfo.GetAbsMaximum(ABS_MT_TOUCH_MAJOR); + struct input_event mock_kernel_queue_max_major[] = { + {time, EV_ABS, ABS_MT_SLOT, 0}, + {time, EV_ABS, ABS_MT_TRACKING_ID, 0}, + {time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER}, + {time, EV_ABS, ABS_MT_POSITION_X, 1003}, + {time, EV_ABS, ABS_MT_POSITION_Y, 749}, + {time, EV_ABS, ABS_MT_PRESSURE, 50}, + {time, EV_ABS, ABS_MT_TOUCH_MAJOR, 116}, + {time, EV_ABS, ABS_MT_SLOT, 1}, + {time, EV_ABS, ABS_MT_TRACKING_ID, 1}, + {time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER}, + {time, EV_ABS, ABS_MT_POSITION_X, 1103}, + {time, EV_ABS, ABS_MT_POSITION_Y, 649}, + {time, EV_ABS, ABS_MT_PRESSURE, 50}, + {time, EV_ABS, ABS_MT_TOUCH_MAJOR, 116}, + {time, EV_KEY, BTN_TOUCH, 1}, + {time, EV_ABS, ABS_X, 1003}, + {time, EV_ABS, ABS_Y, 749}, + {time, EV_ABS, ABS_PRESSURE, 50}, + {time, EV_SYN, SYN_REPORT, 0}, + {time, EV_ABS, ABS_MT_SLOT, 0}, + {time, EV_ABS, ABS_MT_TOUCH_MAJOR, major_max}, + {time, EV_SYN, SYN_REPORT, 0}, + {time, EV_ABS, ABS_MT_TRACKING_ID, -1}, + {time, EV_ABS, ABS_MT_SLOT, 1}, + {time, EV_ABS, ABS_MT_TRACKING_ID, -1}, + {time, EV_SYN, SYN_REPORT, 0}, + }; + struct input_event mock_kernel_queue_tool_palm[] = { + {time, EV_ABS, ABS_MT_SLOT, 0}, + {time, EV_ABS, ABS_MT_TRACKING_ID, 2}, + {time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER}, + {time, EV_ABS, ABS_MT_POSITION_X, 1003}, + {time, EV_ABS, ABS_MT_POSITION_Y, 749}, + {time, EV_ABS, ABS_MT_PRESSURE, 50}, + {time, EV_ABS, ABS_MT_TOUCH_MAJOR, 116}, + {time, EV_ABS, ABS_MT_SLOT, 1}, + {time, EV_ABS, ABS_MT_TRACKING_ID, 3}, + {time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER}, + {time, EV_ABS, ABS_MT_POSITION_X, 1103}, + {time, EV_ABS, ABS_MT_POSITION_Y, 649}, + {time, EV_ABS, ABS_MT_PRESSURE, 50}, + {time, EV_ABS, ABS_MT_TOUCH_MAJOR, 116}, + {time, EV_KEY, BTN_TOUCH, 1}, + {time, EV_ABS, ABS_X, 1003}, + {time, EV_ABS, ABS_Y, 749}, + {time, EV_ABS, ABS_PRESSURE, 50}, + {time, EV_SYN, SYN_REPORT, 0}, + {time, EV_ABS, ABS_MT_SLOT, 0}, + {time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM}, + {time, EV_SYN, SYN_REPORT, 0}, + {time, EV_ABS, ABS_MT_TRACKING_ID, -1}, + {time, EV_SYN, SYN_REPORT, 0}, + }; + + // Initialize the device. + dev->Initialize(devinfo); + + dev->ConfigureReadMock(mock_kernel_queue_max_major, + arraysize(mock_kernel_queue_max_major), 0); + dev->ReadNow(); + EXPECT_EQ(4u, size()); + + ui::TouchEventParams ev1_1 = dispatched_touch_event(0); + EXPECT_EQ(ET_TOUCH_PRESSED, ev1_1.type); + EXPECT_EQ(0, ev1_1.slot); + EXPECT_EQ(1003, ev1_1.location.x()); + EXPECT_EQ(749, ev1_1.location.y()); + + ui::TouchEventParams ev1_2 = dispatched_touch_event(1); + EXPECT_EQ(ET_TOUCH_PRESSED, ev1_2.type); + EXPECT_EQ(1, ev1_2.slot); + EXPECT_EQ(1103, ev1_2.location.x()); + EXPECT_EQ(649, ev1_2.location.y()); + + ui::TouchEventParams ev1_3 = dispatched_touch_event(2); + EXPECT_EQ(ET_TOUCH_CANCELLED, ev1_3.type); + EXPECT_EQ(0, ev1_3.slot); + + // We expect both touches to be cancelled even though + // just one reported major at max value. + ui::TouchEventParams ev1_4 = dispatched_touch_event(3); + EXPECT_EQ(ET_TOUCH_CANCELLED, ev1_4.type); + EXPECT_EQ(1, ev1_4.slot); + + dev->ConfigureReadMock(mock_kernel_queue_tool_palm, + arraysize(mock_kernel_queue_tool_palm), 0); + dev->ReadNow(); + EXPECT_EQ(8u, size()); + + ui::TouchEventParams ev2_1 = dispatched_touch_event(4); + EXPECT_EQ(ET_TOUCH_PRESSED, ev2_1.type); + EXPECT_EQ(0, ev2_1.slot); + EXPECT_EQ(1003, ev2_1.location.x()); + EXPECT_EQ(749, ev2_1.location.y()); + + ui::TouchEventParams ev2_2 = dispatched_touch_event(5); + EXPECT_EQ(ET_TOUCH_PRESSED, ev2_2.type); + EXPECT_EQ(1, ev2_2.slot); + EXPECT_EQ(1103, ev2_2.location.x()); + EXPECT_EQ(649, ev2_2.location.y()); + + ui::TouchEventParams ev2_3 = dispatched_touch_event(6); + EXPECT_EQ(ET_TOUCH_CANCELLED, ev2_3.type); + EXPECT_EQ(0, ev2_3.slot); + + // We expect both touches to be cancelled even though + // just one reported MT_TOOL_PALM. + ui::TouchEventParams ev2_4 = dispatched_touch_event(7); + EXPECT_EQ(ET_TOUCH_CANCELLED, ev2_4.type); + EXPECT_EQ(1, ev2_4.slot); +} + // crbug.com/477695 TEST_F(TouchEventConverterEvdevTest, ShouldUseLeftButtonIfNoTouchButton) { ui::MockTouchEventConverterEvdev* dev = device(); diff --git a/chromium/ui/message_center/fake_message_center_tray_delegate.cc b/chromium/ui/message_center/fake_message_center_tray_delegate.cc index ae4903484bb..ebeb752c015 100644 --- a/chromium/ui/message_center/fake_message_center_tray_delegate.cc +++ b/chromium/ui/message_center/fake_message_center_tray_delegate.cc @@ -26,7 +26,7 @@ bool FakeMessageCenterTrayDelegate::ShowPopups() { void FakeMessageCenterTrayDelegate::HidePopups() { } -bool FakeMessageCenterTrayDelegate::ShowMessageCenter() { +bool FakeMessageCenterTrayDelegate::ShowMessageCenter(bool show_by_click) { return false; } diff --git a/chromium/ui/message_center/fake_message_center_tray_delegate.h b/chromium/ui/message_center/fake_message_center_tray_delegate.h index 2e52daa8898..fd0e7daab1b 100644 --- a/chromium/ui/message_center/fake_message_center_tray_delegate.h +++ b/chromium/ui/message_center/fake_message_center_tray_delegate.h @@ -26,7 +26,7 @@ class FakeMessageCenterTrayDelegate : public MessageCenterTrayDelegate { void OnMessageCenterTrayChanged() override; bool ShowPopups() override; void HidePopups() override; - bool ShowMessageCenter() override; + bool ShowMessageCenter(bool show_by_click) override; void HideMessageCenter() override; bool ShowNotifierSettings() override; bool IsContextMenuEnabled() const override; diff --git a/chromium/ui/message_center/message_center_tray.cc b/chromium/ui/message_center/message_center_tray.cc index 9d368b0d430..302c24306a9 100644 --- a/chromium/ui/message_center/message_center_tray.cc +++ b/chromium/ui/message_center/message_center_tray.cc @@ -110,13 +110,13 @@ MessageCenterTray::~MessageCenterTray() { message_center_->RemoveObserver(this); } -bool MessageCenterTray::ShowMessageCenterBubble() { +bool MessageCenterTray::ShowMessageCenterBubble(bool show_by_click) { if (message_center_visible_) return true; HidePopupBubbleInternal(); - message_center_visible_ = delegate_->ShowMessageCenter(); + message_center_visible_ = delegate_->ShowMessageCenter(show_by_click); if (message_center_visible_) { message_center_->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); NotifyMessageCenterTrayChanged(); diff --git a/chromium/ui/message_center/message_center_tray.h b/chromium/ui/message_center/message_center_tray.h index 86d35f745be..339654d5d90 100644 --- a/chromium/ui/message_center/message_center_tray.h +++ b/chromium/ui/message_center/message_center_tray.h @@ -34,10 +34,11 @@ class MESSAGE_CENTER_EXPORT MessageCenterTray : public MessageCenterObserver { message_center::MessageCenter* message_center); ~MessageCenterTray() override; - // Shows or updates the message center bubble and hides the popup bubble. + // Shows or updates the message center bubble and hides the popup bubble. Set + // |show_by_click| to true if bubble is shown by mouse or gesture click. // Returns whether the message center is visible after the call, whether or // not it was visible before. - bool ShowMessageCenterBubble(); + bool ShowMessageCenterBubble(bool show_by_click); // Hides the message center if visible and returns whether the message center // was visible before. diff --git a/chromium/ui/message_center/message_center_tray_delegate.h b/chromium/ui/message_center/message_center_tray_delegate.h index d1d31ac23f0..7084b46820c 100644 --- a/chromium/ui/message_center/message_center_tray_delegate.h +++ b/chromium/ui/message_center/message_center_tray_delegate.h @@ -28,8 +28,10 @@ class MESSAGE_CENTER_EXPORT MessageCenterTrayDelegate { virtual void HidePopups() = 0; // Display the message center containing all undismissed notifications to the - // user. Returns true if the center was actually displayed to the user. - virtual bool ShowMessageCenter() = 0; + // user. Set |show_by_click| to true if message center is shown by mouse or + // gesture click. Returns true if the center was actually displayed to the + // user. + virtual bool ShowMessageCenter(bool show_by_click) = 0; // Remove the message center from the UI. virtual void HideMessageCenter() = 0; diff --git a/chromium/ui/message_center/message_center_tray_unittest.cc b/chromium/ui/message_center/message_center_tray_unittest.cc index 6c4212d81cc..0af1d19e541 100644 --- a/chromium/ui/message_center/message_center_tray_unittest.cc +++ b/chromium/ui/message_center/message_center_tray_unittest.cc @@ -29,7 +29,9 @@ class MockDelegate : public MessageCenterTrayDelegate { void OnMessageCenterTrayChanged() override {} bool ShowPopups() override { return show_message_center_success_; } void HidePopups() override {} - bool ShowMessageCenter() override { return show_popups_success_; } + bool ShowMessageCenter(bool show_by_click) override { + return show_popups_success_; + } void HideMessageCenter() override {} bool ShowNotifierSettings() override { return true; } bool IsContextMenuEnabled() const override { return enable_context_menu_; } @@ -100,7 +102,8 @@ TEST_F(MessageCenterTrayTest, BasicMessageCenter) { ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - bool shown = message_center_tray_->ShowMessageCenterBubble(); + bool shown = + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); EXPECT_TRUE(shown); ASSERT_FALSE(message_center_tray_->popups_visible()); @@ -111,7 +114,7 @@ TEST_F(MessageCenterTrayTest, BasicMessageCenter) { ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - message_center_tray_->ShowMessageCenterBubble(); + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_TRUE(message_center_tray_->message_center_visible()); @@ -153,7 +156,8 @@ TEST_F(MessageCenterTrayTest, MessageCenterClosesPopups) { ASSERT_TRUE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - bool shown = message_center_tray_->ShowMessageCenterBubble(); + bool shown = + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); EXPECT_TRUE(shown); ASSERT_FALSE(message_center_tray_->popups_visible()); @@ -173,7 +177,7 @@ TEST_F(MessageCenterTrayTest, MessageCenterClosesPopups) { ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - message_center_tray_->ShowMessageCenterBubble(); + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); message_center_tray_->HideMessageCenterBubble(); ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); @@ -234,7 +238,8 @@ TEST_F(MessageCenterTrayTest, MessageCenterReopenPopupsForSystemPriority) { ASSERT_TRUE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - bool shown = message_center_tray_->ShowMessageCenterBubble(); + bool shown = + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); EXPECT_TRUE(shown); ASSERT_FALSE(message_center_tray_->popups_visible()); @@ -261,7 +266,8 @@ TEST_F(MessageCenterTrayTest, ShowBubbleFails) { ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - bool shown = message_center_tray_->ShowMessageCenterBubble(); + bool shown = + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); EXPECT_FALSE(shown); ASSERT_FALSE(message_center_tray_->popups_visible()); @@ -272,7 +278,7 @@ TEST_F(MessageCenterTrayTest, ShowBubbleFails) { ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); - message_center_tray_->ShowMessageCenterBubble(); + message_center_tray_->ShowMessageCenterBubble(false /* show_by_click */); ASSERT_FALSE(message_center_tray_->popups_visible()); ASSERT_FALSE(message_center_tray_->message_center_visible()); diff --git a/chromium/ui/views/bubble/tray_bubble_view.cc b/chromium/ui/views/bubble/tray_bubble_view.cc index 7b4c4f3872b..165a07eb45d 100644 --- a/chromium/ui/views/bubble/tray_bubble_view.cc +++ b/chromium/ui/views/bubble/tray_bubble_view.cc @@ -297,9 +297,10 @@ void TrayBubbleView::InitializeAndShowBubble() { ++g_current_tray_bubble_showing_count_; - // If TrayBubbleView cannot be activated, register pre target event handler to - // reroute key events to the widget for activating the view or closing it. - if (!CanActivate()) { + // If TrayBubbleView cannot be activated and is shown by clicking on the + // corresponding tray view, register pre target event handler to reroute key + // events to the widget for activating the view or closing it. + if (!CanActivate() && params_.show_by_click) { reroute_event_handler_ = base::MakeUnique<RerouteEventHandler>(this); } } diff --git a/chromium/ui/views/bubble/tray_bubble_view.h b/chromium/ui/views/bubble/tray_bubble_view.h index c308f57a9c6..51928ad75ce 100644 --- a/chromium/ui/views/bubble/tray_bubble_view.h +++ b/chromium/ui/views/bubble/tray_bubble_view.h @@ -91,6 +91,8 @@ class VIEWS_EXPORT TrayBubbleView : public BubbleDialogDelegateView, int max_width = 0; int max_height = 0; bool close_on_deactivate = true; + // Indicates whether tray bubble view is shown by click on the tray view. + bool show_by_click = false; // If not provided, the bg color will be derived from the NativeTheme. base::Optional<SkColor> bg_color; }; diff --git a/chromium/v8/AUTHORS b/chromium/v8/AUTHORS index 048702701c4..293e6fd22cb 100644 --- a/chromium/v8/AUTHORS +++ b/chromium/v8/AUTHORS @@ -100,6 +100,7 @@ Mike Pennisi <mike@mikepennisi.com> Milton Chiang <milton.chiang@mediatek.com> Myeong-bo Shim <m0609.shim@samsung.com> Nicolas Antonius Ernst Leopold Maria Kaiser <nikai@nikai.net> +Niklas Hambüchen <mail@nh2.me> Noj Vek <nojvek@gmail.com> Oleksandr Chekhovskyi <oleksandr.chekhovskyi@gmail.com> Paolo Giarrusso <p.giarrusso@gmail.com> diff --git a/chromium/v8/include/v8-version.h b/chromium/v8/include/v8-version.h index 6e42708504c..461af5e347d 100644 --- a/chromium/v8/include/v8-version.h +++ b/chromium/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 6 #define V8_MINOR_VERSION 1 #define V8_BUILD_NUMBER 534 -#define V8_PATCH_LEVEL 39 +#define V8_PATCH_LEVEL 44 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/chromium/v8/src/asmjs/asm-parser.cc b/chromium/v8/src/asmjs/asm-parser.cc index 1e5f7d5dc4b..3107e764064 100644 --- a/chromium/v8/src/asmjs/asm-parser.cc +++ b/chromium/v8/src/asmjs/asm-parser.cc @@ -2449,7 +2449,8 @@ void AsmJsParser::GatherCases(ZoneVector<int32_t>* cases) { value = static_cast<int32_t>(uvalue); } cases->push_back(value); - } else if (Peek(AsmJsScanner::kEndOfInput)) { + } else if (Peek(AsmJsScanner::kEndOfInput) || + Peek(AsmJsScanner::kParseError)) { break; } scanner_.Next(); diff --git a/chromium/v8/src/assembler.cc b/chromium/v8/src/assembler.cc index c561050ed62..c24dc28fedd 100644 --- a/chromium/v8/src/assembler.cc +++ b/chromium/v8/src/assembler.cc @@ -340,11 +340,7 @@ void RelocInfo::update_wasm_function_table_size_reference( Isolate* isolate, uint32_t old_size, uint32_t new_size, ICacheFlushMode icache_flush_mode) { DCHECK(IsWasmFunctionTableSizeReference(rmode_)); - uint32_t current_size_reference = wasm_function_table_size_reference(); - uint32_t updated_size_reference = - new_size + (current_size_reference - old_size); - unchecked_update_wasm_size(isolate, updated_size_reference, - icache_flush_mode); + unchecked_update_wasm_size(isolate, new_size, icache_flush_mode); } void RelocInfo::set_target_address(Isolate* isolate, Address target, diff --git a/chromium/v8/src/compiler/typer.cc b/chromium/v8/src/compiler/typer.cc index 94b6e5a9223..64a028015c2 100644 --- a/chromium/v8/src/compiler/typer.cc +++ b/chromium/v8/src/compiler/typer.cc @@ -1450,7 +1450,7 @@ Type* Typer::Visitor::JSCallTyper(Type* fun, Typer* t) { return Type::String(); case kStringIndexOf: case kStringLastIndexOf: - return Type::Range(-1.0, String::kMaxLength - 1.0, t->zone()); + return Type::Range(-1.0, String::kMaxLength, t->zone()); case kStringEndsWith: case kStringIncludes: return Type::Boolean(); diff --git a/chromium/v8/src/inspector/v8-inspector-impl.cc b/chromium/v8/src/inspector/v8-inspector-impl.cc index 6b8e7324f56..2edfa521032 100644 --- a/chromium/v8/src/inspector/v8-inspector-impl.cc +++ b/chromium/v8/src/inspector/v8-inspector-impl.cc @@ -282,18 +282,22 @@ std::unique_ptr<V8StackTrace> V8InspectorImpl::captureStackTrace( void V8InspectorImpl::asyncTaskScheduled(const StringView& taskName, void* task, bool recurring) { + if (!task) return; m_debugger->asyncTaskScheduled(taskName, task, recurring); } void V8InspectorImpl::asyncTaskCanceled(void* task) { + if (!task) return; m_debugger->asyncTaskCanceled(task); } void V8InspectorImpl::asyncTaskStarted(void* task) { + if (!task) return; m_debugger->asyncTaskStarted(task); } void V8InspectorImpl::asyncTaskFinished(void* task) { + if (!task) return; m_debugger->asyncTaskFinished(task); } |