diff -Nru chromium-browser-58.0.3029.96/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java chromium-browser-58.0.3029.110/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java --- chromium-browser-58.0.3029.96/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java 2017-05-02 19:02:45.000000000 +0000 +++ chromium-browser-58.0.3029.110/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java 2017-05-09 19:02:40.000000000 +0000 @@ -16,6 +16,7 @@ import android.os.Build; import android.os.Looper; import android.os.Process; +import android.os.StrictMode; import android.os.UserManager; import android.provider.Settings; import android.util.Log; @@ -248,8 +249,15 @@ System.loadLibrary("webviewchromium_plat_support"); // Use shared preference to check for package downgrade. - mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences( - CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); + // Since N, getSharedPreferences creates the preference dir if it doesn't exist, + // causing a disk write. + StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); + try { + mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences( + CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); + } finally { + StrictMode.setThreadPolicy(oldPolicy); + } int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); int currentVersion = packageInfo.versionCode; if (!versionCodeGE(currentVersion, lastVersion)) { diff -Nru chromium-browser-58.0.3029.96/ash/system/chromeos/power/tablet_power_button_controller.cc chromium-browser-58.0.3029.110/ash/system/chromeos/power/tablet_power_button_controller.cc --- chromium-browser-58.0.3029.96/ash/system/chromeos/power/tablet_power_button_controller.cc 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/ash/system/chromeos/power/tablet_power_button_controller.cc 2017-05-09 19:02:40.000000000 +0000 @@ -215,11 +215,7 @@ ->GetPowerManagerClient() ->SetBacklightsForcedOff(forced_off); backlights_forced_off_ = forced_off; - - ShellDelegate* delegate = WmShell::Get()->delegate(); - delegate->SetTouchscreenEnabledInPrefs(!forced_off, - true /* use_local_state */); - delegate->UpdateTouchscreenStatusFromPrefs(); + UpdateTouchscreenStatus(); // Send an a11y alert. WmShell::Get()->accessibility_delegate()->TriggerAccessibilityAlert( @@ -237,6 +233,14 @@ void TabletPowerButtonController::OnGotInitialBacklightsForcedOff( bool is_forced_off) { backlights_forced_off_ = is_forced_off; + UpdateTouchscreenStatus(); +} + +void TabletPowerButtonController::UpdateTouchscreenStatus() { + ShellDelegate* delegate = WmShell::Get()->delegate(); + delegate->SetTouchscreenEnabledInPrefs(!backlights_forced_off_, + true /* use_local_state */); + delegate->UpdateTouchscreenStatusFromPrefs(); } void TabletPowerButtonController::StartShutdownTimer() { diff -Nru chromium-browser-58.0.3029.96/ash/system/chromeos/power/tablet_power_button_controller.h chromium-browser-58.0.3029.110/ash/system/chromeos/power/tablet_power_button_controller.h --- chromium-browser-58.0.3029.96/ash/system/chromeos/power/tablet_power_button_controller.h 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/ash/system/chromeos/power/tablet_power_button_controller.h 2017-05-09 19:02:40.000000000 +0000 @@ -90,6 +90,10 @@ // Initializes |backlights_forced_off_|. void OnGotInitialBacklightsForcedOff(bool is_forced_off); + // Enables or disables the touchscreen, also writing its state to a pref in + // local state. The touchscreen is disabled when backlights are forced off. + void UpdateTouchscreenStatus(); + // Starts |shutdown_timer_| when the power button is pressed while in // tablet mode. void StartShutdownTimer(); diff -Nru chromium-browser-58.0.3029.96/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc chromium-browser-58.0.3029.110/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc --- chromium-browser-58.0.3029.96/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc 2017-05-09 19:02:40.000000000 +0000 @@ -477,5 +477,25 @@ EXPECT_TRUE(GetBacklightsForcedOff()); } +// Tests that with system reboot, the local state of touchscreen enabled state +// should be synced with new backlights forced off state from powerd. +TEST_F(TabletPowerButtonControllerTest, SyncTouchscreenStatus) { + shell_delegate_->SetTouchscreenEnabledInPrefs(false, + true /* use_local_state */); + ASSERT_FALSE(shell_delegate_->IsTouchscreenEnabledInPrefs(true)); + + // Simulate system reboot by resetting backlights forced off state in powerd + // and TabletPowerButtonController. + power_manager_client_->SetBacklightsForcedOff(false); + Shell::GetInstance() + ->power_button_controller() + ->ResetTabletPowerButtonControllerForTest(); + + // Check that the local state of touchscreen enabled state is in line with + // backlights forced off state. + EXPECT_FALSE(GetBacklightsForcedOff()); + EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true)); +} + } // namespace test } // namespace ash diff -Nru chromium-browser-58.0.3029.96/ash/wm/power_button_controller.cc chromium-browser-58.0.3029.110/ash/wm/power_button_controller.cc --- chromium-browser-58.0.3029.96/ash/wm/power_button_controller.cc 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/ash/wm/power_button_controller.cc 2017-05-09 19:02:40.000000000 +0000 @@ -197,4 +197,9 @@ OnPowerButtonEvent(down, timestamp); } +void PowerButtonController::ResetTabletPowerButtonControllerForTest() { + tablet_controller_.reset( + new TabletPowerButtonController(lock_state_controller_)); +} + } // namespace ash diff -Nru chromium-browser-58.0.3029.96/ash/wm/power_button_controller.h chromium-browser-58.0.3029.110/ash/wm/power_button_controller.h --- chromium-browser-58.0.3029.96/ash/wm/power_button_controller.h 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/ash/wm/power_button_controller.h 2017-05-09 19:02:40.000000000 +0000 @@ -52,6 +52,10 @@ void PowerButtonEventReceived(bool down, const base::TimeTicks& timestamp) override; + // Resets |tablet_controller_| to hold a new object to simulate Chrome + // starting. + void ResetTabletPowerButtonControllerForTest(); + TabletPowerButtonController* tablet_power_button_controller_for_test() { return tablet_controller_.get(); } diff -Nru chromium-browser-58.0.3029.96/base/android/java/src/org/chromium/base/BuildInfo.java chromium-browser-58.0.3029.110/base/android/java/src/org/chromium/base/BuildInfo.java --- chromium-browser-58.0.3029.96/base/android/java/src/org/chromium/base/BuildInfo.java 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/base/android/java/src/org/chromium/base/BuildInfo.java 2017-05-09 19:02:40.000000000 +0000 @@ -159,7 +159,24 @@ * @return Whether the current device is running Android O release or newer. */ public static boolean isAtLeastO() { - return !"REL".equals(Build.VERSION.CODENAME) - && ("O".equals(Build.VERSION.CODENAME) || Build.VERSION.CODENAME.startsWith("OMR")); + if ("REL".equals(Build.VERSION.CODENAME)) return Build.VERSION.SDK_INT >= 26; + + // The following allows pre-releases of Android O to be identified as Android O. + // TODO(crbug/685808): Remove this and simplify check above once Android O is available. + return "O".equals(Build.VERSION.CODENAME) || Build.VERSION.CODENAME.startsWith("OMR"); + } + + /** + * @return Whether the current app targets the SDK for at least O + */ + public static boolean targetsAtLeastO(Context appContext) { + if (appContext.getApplicationInfo().targetSdkVersion >= 26) return true; + + // The following accepts target SDK version to be |CUR_DEVELOPMENT| when the platform Chrome + // is running on is a pre-release of Android O. + // TODO(crbug/685808): Remove this and simplify the check above once Android O is available. + return ("O".equals(Build.VERSION.CODENAME) || Build.VERSION.CODENAME.startsWith("OMR")) + && appContext.getApplicationInfo().targetSdkVersion + == Build.VERSION_CODES.CUR_DEVELOPMENT; } } diff -Nru chromium-browser-58.0.3029.96/base/files/file_util_mac.mm chromium-browser-58.0.3029.110/base/files/file_util_mac.mm --- chromium-browser-58.0.3029.96/base/files/file_util_mac.mm 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/base/files/file_util_mac.mm 2017-05-09 19:02:40.000000000 +0000 @@ -7,8 +7,10 @@ #import #include #include +#include #include "base/files/file_path.h" +#include "base/logging.h" #include "base/mac/foundation_util.h" #include "base/strings/string_util.h" #include "base/threading/thread_restrictions.h" @@ -24,10 +26,14 @@ } bool GetTempDir(base::FilePath* path) { - // In order to facilitate hermetic runs on macOS, first check $TMPDIR. - // NOTE: $TMPDIR is ALMOST ALWAYS set on macOS (unless the user un-set it). - const char* env_tmpdir = getenv("TMPDIR"); + // In order to facilitate hermetic runs on macOS, first check + // $MAC_CHROMIUM_TMPDIR. We check this instead of $TMPDIR because external + // programs currently set $TMPDIR with no effect, but when we respect it + // directly it can cause crashes (like crbug.com/698759). + const char* env_tmpdir = getenv("MAC_CHROMIUM_TMPDIR"); if (env_tmpdir) { + DCHECK_LT(strlen(env_tmpdir), 50u) + << "too-long TMPDIR causes socket name length issues."; *path = base::FilePath(env_tmpdir); return true; } diff -Nru chromium-browser-58.0.3029.96/build/util/LASTCHANGE chromium-browser-58.0.3029.110/build/util/LASTCHANGE --- chromium-browser-58.0.3029.96/build/util/LASTCHANGE 2017-05-02 19:04:15.000000000 +0000 +++ chromium-browser-58.0.3029.110/build/util/LASTCHANGE 2017-05-09 19:04:08.000000000 +0000 @@ -1 +1 @@ -LASTCHANGE=ab55a2296aa9c73271e0967ea8c78476e675bd74 +LASTCHANGE=5cab18a2bc5f84621b7ed002eb43e9e72413f001 diff -Nru chromium-browser-58.0.3029.96/build/util/LASTCHANGE.blink chromium-browser-58.0.3029.110/build/util/LASTCHANGE.blink --- chromium-browser-58.0.3029.96/build/util/LASTCHANGE.blink 2017-05-02 19:04:15.000000000 +0000 +++ chromium-browser-58.0.3029.110/build/util/LASTCHANGE.blink 2017-05-09 19:04:08.000000000 +0000 @@ -1 +1 @@ -LASTCHANGE=ab55a2296aa9c73271e0967ea8c78476e675bd74 +LASTCHANGE=5cab18a2bc5f84621b7ed002eb43e9e72413f001 diff -Nru chromium-browser-58.0.3029.96/chrome/android/BUILD.gn chromium-browser-58.0.3029.110/chrome/android/BUILD.gn --- chromium-browser-58.0.3029.96/chrome/android/BUILD.gn 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/android/BUILD.gn 2017-05-09 19:02:40.000000000 +0000 @@ -394,6 +394,15 @@ # From java_sources.gni. java_files = chrome_test_java_sources + # TODO(crbug/716236): Remove this exclusion and update these two test files, + # after the O SDK is rolled. + if (android_sdk_version == "O") { + java_files -= [ + "javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionRunnableTest.java", + "javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadServiceTest.java", + ] + } + deps = [ "//base:base_java", "//base:base_java_test_support", diff -Nru chromium-browser-58.0.3029.96/chrome/android/java/AndroidManifest.xml chromium-browser-58.0.3029.110/chrome/android/java/AndroidManifest.xml --- chromium-browser-58.0.3029.96/chrome/android/java/AndroidManifest.xml 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/android/java/AndroidManifest.xml 2017-05-09 19:02:40.000000000 +0000 @@ -110,7 +110,8 @@ + + + + @mipmap/app_icon + diff -Nru chromium-browser-58.0.3029.96/chrome/android/java/res/values/ic_launcher_round_alias.xml chromium-browser-58.0.3029.110/chrome/android/java/res/values/ic_launcher_round_alias.xml --- chromium-browser-58.0.3029.96/chrome/android/java/res/values/ic_launcher_round_alias.xml 1970-01-01 00:00:00.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/android/java/res/values/ic_launcher_round_alias.xml 2017-05-09 19:02:40.000000000 +0000 @@ -0,0 +1,8 @@ + + + + + @mipmap/app_icon + diff -Nru chromium-browser-58.0.3029.96/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java chromium-browser-58.0.3029.110/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java --- chromium-browser-58.0.3029.96/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java 2017-05-09 19:02:40.000000000 +0000 @@ -32,6 +32,7 @@ import android.util.SparseArray; import android.view.KeyEvent; +import org.chromium.base.BuildInfo; import org.chromium.base.SysUtils; import org.chromium.base.VisibleForTesting; import org.chromium.blink.mojom.MediaSessionAction; @@ -134,6 +135,20 @@ } }; + // On O, if startForegroundService() was called, the app MUST call startForeground on the + // created service no matter what or it will crash. Show the minimal notification. The caller is + // responsible for hiding it afterwards. + private static void finishStartingForegroundService(ListenerService s) { + if (!BuildInfo.isAtLeastO()) return; + + ChromeNotificationBuilder builder = AppHooks.get().createChromeNotificationBuilder( + true /* preferCompat */, NotificationConstants.CATEGORY_ID_BROWSER, + s.getString(org.chromium.chrome.R.string.notification_category_browser), + NotificationConstants.CATEGORY_GROUP_ID_GENERAL, + s.getString(org.chromium.chrome.R.string.notification_category_group_general)); + s.startForeground(s.getNotificationId(), builder.build()); + } + /** * Service used to transform intent requests triggered from the notification into * {@code MediaNotificationListener} callbacks. We have to create a separate derived class for @@ -181,18 +196,29 @@ return START_NOT_STICKY; } + protected abstract int getNotificationId(); + @Nullable - protected abstract MediaNotificationManager getManager(); + private MediaNotificationManager getManager() { + return MediaNotificationManager.getManager(getNotificationId()); + } private boolean processIntent(Intent intent) { if (intent == null) return false; MediaNotificationManager manager = getManager(); - if (manager == null || manager.mMediaNotificationInfo == null) return false; + if (manager == null || manager.mMediaNotificationInfo == null) { + if (intent.getAction() == null) { + // The service has been started with startForegroundService() but the + // notification hasn't been shown. On O it will lead to the app crash. + // So show an empty notification before stopping the service. + finishStartingForegroundService(this); + } + return false; + } if (intent.getAction() == null) { - // The intent comes from {@link startService()} or - // {@link startForegroundService}. + // The intent comes from {@link AppHooks#startForegroundService}. manager.onServiceStarted(this); } else { // The intent comes from the notification. In this case, {@link onServiceStarted()} @@ -291,9 +317,8 @@ } @Override - @Nullable - protected MediaNotificationManager getManager() { - return MediaNotificationManager.getManager(NOTIFICATION_ID); + protected int getNotificationId() { + return NOTIFICATION_ID; } private BroadcastReceiver mAudioBecomingNoisyReceiver = new BroadcastReceiver() { @@ -317,9 +342,8 @@ private static final int NOTIFICATION_ID = R.id.presentation_notification; @Override - @Nullable - protected MediaNotificationManager getManager() { - return MediaNotificationManager.getManager(NOTIFICATION_ID); + protected int getNotificationId() { + return NOTIFICATION_ID; } } @@ -330,9 +354,8 @@ private static final int NOTIFICATION_ID = R.id.remote_notification; @Override - @Nullable - protected MediaNotificationManager getManager() { - return MediaNotificationManager.getManager(NOTIFICATION_ID); + protected int getNotificationId() { + return NOTIFICATION_ID; } } @@ -625,7 +648,7 @@ if (mService == service) return; mService = service; - updateNotification(); + updateNotification(true /*serviceStarting*/); } /** @@ -676,7 +699,7 @@ } else { mService.startService(createIntent(mContext)); } - updateNotification(); + updateNotification(false); } private void clearNotification() { @@ -730,16 +753,30 @@ return metadataBuilder.build(); } - private void updateNotification() { + private void updateNotification(boolean serviceStarting) { if (mService == null) return; - if (mMediaNotificationInfo == null) return; + if (mMediaNotificationInfo == null) { + if (serviceStarting) { + finishStartingForegroundService(mService); + mService.stopForeground(true /* removeNotification */); + } + return; + } updateMediaSession(); updateNotificationBuilder(); Notification notification = mNotificationBuilder.build(); + // On O, finish starting the foreground service nevertheless, or Android will + // crash Chrome. + boolean foregroundedService = false; + if (BuildInfo.isAtLeastO() && serviceStarting) { + mService.startForeground(mMediaNotificationInfo.id, notification); + foregroundedService = true; + } + // We keep the service as a foreground service while the media is playing. When it is not, // the service isn't stopped but is no longer in foreground, thus at a lower priority. // While the service is in foreground, the associated notification can't be swipped away. @@ -749,7 +786,7 @@ NotificationManagerCompat manager = NotificationManagerCompat.from(mContext); manager.notify(mMediaNotificationInfo.id, notification); - } else { + } else if (!foregroundedService) { mService.startForeground(mMediaNotificationInfo.id, notification); } } diff -Nru chromium-browser-58.0.3029.96/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionRunnableTest.java chromium-browser-58.0.3029.110/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionRunnableTest.java --- chromium-browser-58.0.3029.96/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionRunnableTest.java 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionRunnableTest.java 2017-05-09 19:02:41.000000000 +0000 @@ -52,6 +52,7 @@ } }; + // TODO(crbug/716236): Refer to this crbug for compilation error after the O SDK is rolled. @TargetApi(Build.VERSION_CODES.M) private static class TestJobScheduler extends JobScheduler { TestJobScheduler() {} diff -Nru chromium-browser-58.0.3029.96/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadServiceTest.java chromium-browser-58.0.3029.110/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadServiceTest.java --- chromium-browser-58.0.3029.96/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadServiceTest.java 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/android/javatests/src/org/chromium/chrome/browser/crash/MinidumpUploadServiceTest.java 2017-05-09 19:02:41.000000000 +0000 @@ -586,6 +586,7 @@ } } + // TODO(crbug/716236): Refer to this crbug for compilation error after the O SDK is rolled. /** * A JobScheduler wrapper that verifies that the expected properties are set correctly. */ diff -Nru chromium-browser-58.0.3029.96/chrome/browser/android/chrome_feature_list.cc chromium-browser-58.0.3029.110/chrome/browser/android/chrome_feature_list.cc --- chromium-browser-58.0.3029.96/chrome/browser/android/chrome_feature_list.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/android/chrome_feature_list.cc 2017-05-09 19:02:41.000000000 +0000 @@ -177,7 +177,7 @@ "UserMediaScreenCapturing", base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kVideoPersistence{"VideoPersistence", - base::FEATURE_ENABLED_BY_DEFAULT}; + base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kWebPaymentsModifiers{"WebPaymentsModifiers", base::FEATURE_DISABLED_BY_DEFAULT}; diff -Nru chromium-browser-58.0.3029.96/chrome/browser/background/background_contents_service_unittest.cc chromium-browser-58.0.3029.110/chrome/browser/background/background_contents_service_unittest.cc --- chromium-browser-58.0.3029.96/chrome/browser/background/background_contents_service_unittest.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/background/background_contents_service_unittest.cc 2017-05-09 19:02:41.000000000 +0000 @@ -193,7 +193,7 @@ } void TearDown() override { - g_browser_process->notification_ui_manager()->CancelAll(); + g_browser_process->notification_ui_manager()->StartShutdown(); profile_manager_.reset(); #if !defined(OS_CHROMEOS) message_center::MessageCenter::Shutdown(); diff -Nru chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc --- chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc 1970-01-01 00:00:00.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_migration_guide_notification.cc 2017-05-09 19:02:41.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" + +#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/ui/ash/multi_user/multi_user_util.h" +#include "chrome/common/pref_names.h" +#include "components/signin/core/account_id/account_id.h" +#include "components/user_manager/known_user.h" + +namespace arc { + +void ShowArcMigrationSuccessNotificationIfNeeded(Profile* profile) { + const AccountId account_id = + multi_user_util::GetAccountIdFromProfile(profile); + + int pref_value = kFileSystemIncompatible; + user_manager::known_user::GetIntegerPref( + account_id, prefs::kArcCompatibleFilesystemChosen, &pref_value); + + // Show notification only when the pref value indicates the file system is + // compatible, but not yet notified. + if (pref_value != kFileSystemCompatible) + return; + + // TODO(kinaba): The acutual notificaiton is added here in M59. + // For M58, this function is deployed just for maintaining the pref value. + + // Mark as notified. + user_manager::known_user::SetIntegerPref( + account_id, prefs::kArcCompatibleFilesystemChosen, + arc::kFileSystemCompatibleAndNotified); +} + +} // namespace arc diff -Nru chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_migration_guide_notification.h chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_migration_guide_notification.h --- chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_migration_guide_notification.h 1970-01-01 00:00:00.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_migration_guide_notification.h 2017-05-09 19:02:41.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_MIGRATION_GUIDE_NOTIFICATION_H_ +#define CHROME_BROWSER_CHROMEOS_ARC_ARC_MIGRATION_GUIDE_NOTIFICATION_H_ + +class Profile; + +namespace arc { + +// TODO(kinaba): Will show a one-time notification for successful migration. +// On M58 it just updates the pref value regarding this behavior, so that +// the update to M59 is not confused by the unset pref. +void ShowArcMigrationSuccessNotificationIfNeeded(Profile* profile); + +} // namespace arc + +#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_MIGRATION_GUIDE_NOTIFICATION_H_ diff -Nru chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_util.cc chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_util.cc --- chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_util.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_util.cc 2017-05-09 19:02:41.000000000 +0000 @@ -4,7 +4,15 @@ #include "chrome/browser/chromeos/arc/arc_util.h" +#include +#include + +#include "base/callback.h" +#include "base/files/file_path.h" #include "base/logging.h" +#include "base/sys_info.h" +#include "base/task_scheduler/post_task.h" +#include "base/threading/thread_restrictions.h" #include "chrome/browser/chromeos/arc/arc_session_manager.h" #include "chrome/browser/chromeos/login/user_flow.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" @@ -13,6 +21,7 @@ #include "chrome/common/pref_names.h" #include "components/arc/arc_util.h" #include "components/prefs/pref_service.h" +#include "components/user_manager/known_user.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" @@ -23,6 +32,39 @@ // Let IsAllowedForProfile() return "false" for any profile. bool g_disallow_for_testing = false; +// Returns whether ARC can run on the filesystem mounted at |path|. +// This function should run only on threads where IO operations are allowed. +bool IsArcCompatibleFilesystem(const base::FilePath& path) { + base::ThreadRestrictions::AssertIOAllowed(); + + // If it can be verified it is not on ecryptfs, then it is ok. + struct statfs statfs_buf; + if (statfs(path.value().c_str(), &statfs_buf) < 0) + return false; + return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; +} + +// Stores the result of IsArcCompatibleFilesystem posted back from the blocking +// task runner. +void StoreCompatibilityCheckResult(const AccountId& account_id, + const base::Closure& callback, + bool is_compatible) { + if (is_compatible) { + user_manager::known_user::SetIntegerPref( + account_id, prefs::kArcCompatibleFilesystemChosen, + arc::kFileSystemCompatible); + } + callback.Run(); +} + +FileSystemCompatibilityState GetFileSystemCompatibilityPref( + const AccountId& account_id) { + int pref_value = kFileSystemIncompatible; + user_manager::known_user::GetIntegerPref( + account_id, prefs::kArcCompatibleFilesystemChosen, &pref_value); + return static_cast(pref_value); +} + } // namespace bool IsArcAllowedForProfile(const Profile* profile) { @@ -134,4 +176,34 @@ profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); } +void UpdateArcFileSystemCompatibilityPrefIfNeeded( + const AccountId& account_id, + const base::FilePath& profile_path, + const base::Closure& callback) { + DCHECK(!callback.is_null()); + + // If ARC is not available, skip the check. + if (!IsArcAvailable()) { + callback.Run(); + return; + } + + // If the compatibility has been already confirmed, skip the check. + if (GetFileSystemCompatibilityPref(account_id) != kFileSystemIncompatible) { + callback.Run(); + return; + } + + // Otherwise, check the underlying filesystem. + base::PostTaskWithTraitsAndReplyWithResult( + FROM_HERE, + base::TaskTraits() + .WithShutdownBehavior( + base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) + .WithPriority(base::TaskPriority::USER_BLOCKING) + .MayBlock(), + base::Bind(&IsArcCompatibleFilesystem, profile_path), + base::Bind(&StoreCompatibilityCheckResult, account_id, callback)); +} + } // namespace arc diff -Nru chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_util.h chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_util.h --- chromium-browser-58.0.3029.96/chrome/browser/chromeos/arc/arc_util.h 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/chromeos/arc/arc_util.h 2017-05-09 19:02:41.000000000 +0000 @@ -5,16 +5,40 @@ #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_UTIL_H_ #define CHROME_BROWSER_CHROMEOS_ARC_ARC_UTIL_H_ +#include + +#include "base/callback_forward.h" + // Most utility should be put in components/arc/arc_util.{h,cc}, rather than // here. However, some utility implementation requires other modules defined in // chrome/, so this file contains such utilities. // Note that it is not allowed to have dependency from components/ to chrome/ // by DEPS. +class AccountId; class Profile; +namespace base { +class FilePath; +} + namespace arc { +// Values to be stored in the local state preference to keep track of the +// filesystem encryption migration status. +enum FileSystemCompatibilityState : int32_t { + // No migiration has happend, user keeps using the old file system. + kFileSystemIncompatible = 0, + // Migration has happend. New filesystem is in use. + kFileSystemCompatible = 1, + // Migration has happend, and a notification about the fact was already shown. + kFileSystemCompatibleAndNotified = 2, + + // Existing code assumes that kFileSystemIncompatible is the only state + // representing incompatibility and other values are all variants of + // "compatible" state. Be careful in the case adding a new enum value. +}; + // Returns true if ARC is allowed to run for the given profile. // Otherwise, returns false, e.g. if the Profile is not for the primary user, // ARC is not available on the device, it is in the flow to set up managed @@ -57,6 +81,14 @@ // Google Play Store, then ARC can run without opt-in. void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled); +// Checks and updates the preference value whether the underlying filesystem +// for the profile is compatible with ARC, when necessary. After it's done (or +// skipped), |callback| is run either synchronously or asynchronously. +void UpdateArcFileSystemCompatibilityPrefIfNeeded( + const AccountId& account_id, + const base::FilePath& profile_path, + const base::Closure& callback); + } // namespace arc #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_UTIL_H_ diff -Nru chromium-browser-58.0.3029.96/chrome/browser/chromeos/BUILD.gn chromium-browser-58.0.3029.110/chrome/browser/chromeos/BUILD.gn --- chromium-browser-58.0.3029.96/chrome/browser/chromeos/BUILD.gn 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/chromeos/BUILD.gn 2017-05-09 19:02:41.000000000 +0000 @@ -222,6 +222,8 @@ "arc/arc_auth_notification.h", "arc/arc_auth_service.cc", "arc/arc_auth_service.h", + "arc/arc_migration_guide_notification.cc", + "arc/arc_migration_guide_notification.h", "arc/arc_optin_uma.cc", "arc/arc_optin_uma.h", "arc/arc_play_store_enabled_preference_handler.cc", diff -Nru chromium-browser-58.0.3029.96/chrome/browser/chromeos/login/session/user_session_manager.cc chromium-browser-58.0.3029.110/chrome/browser/chromeos/login/session/user_session_manager.cc --- chromium-browser-58.0.3029.96/chrome/browser/chromeos/login/session/user_session_manager.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/chromeos/login/session/user_session_manager.cc 2017-05-09 19:02:41.000000000 +0000 @@ -30,7 +30,9 @@ #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" #include "chrome/browser/chromeos/arc/arc_service_launcher.h" +#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/base/locale_util.h" #include "chrome/browser/chromeos/boot_times_recorder.h" #include "chrome/browser/chromeos/first_run/first_run.h" @@ -512,7 +514,10 @@ user_context.GetDeviceId()); } - PrepareProfile(); + arc::UpdateArcFileSystemCompatibilityPrefIfNeeded( + user_context_.GetAccountId(), + ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), + base::Bind(&UserSessionManager::PrepareProfile, AsWeakPtr())); } void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { @@ -1806,6 +1811,10 @@ // the message accordingly. if (ShouldShowEolNotification(profile)) CheckEolStatus(profile); + + // Show the one-time notification and update the relevant pref about the + // completion of the file system migration necessary for ARC, when needed. + arc::ShowArcMigrationSuccessNotificationIfNeeded(profile); } void UserSessionManager::RespectLocalePreferenceWrapper( diff -Nru chromium-browser-58.0.3029.96/chrome/browser/extensions/test_extension_dir.cc chromium-browser-58.0.3029.110/chrome/browser/extensions/test_extension_dir.cc --- chromium-browser-58.0.3029.96/chrome/browser/extensions/test_extension_dir.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/extensions/test_extension_dir.cc 2017-05-09 19:02:42.000000000 +0000 @@ -67,7 +67,13 @@ } base::FilePath TestExtensionDir::UnpackedPath() { - return dir_.GetPath(); + // We make this absolute because it's possible that dir_ contains a symlink as + // part of it's path. When UnpackedInstaller::GetAbsolutePath() runs as part + // of loading the extension, the extension's path is converted to an absolute + // path, which actually does something like `realpath` as part of its + // resolution. If the tests are comparing paths to UnpackedPath(), then + // they'll need to compare the same absolute'd path. + return base::MakeAbsoluteFilePath(dir_.GetPath()); } } // namespace extensions diff -Nru chromium-browser-58.0.3029.96/chrome/browser/lifetime/application_lifetime_aura.cc chromium-browser-58.0.3029.110/chrome/browser/lifetime/application_lifetime_aura.cc --- chromium-browser-58.0.3029.96/chrome/browser/lifetime/application_lifetime_aura.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/lifetime/application_lifetime_aura.cc 2017-05-09 19:02:42.000000000 +0000 @@ -23,7 +23,7 @@ void HandleAppExitingForPlatform() { // Close all non browser windows now. Those includes notifications // and windows created by Ash (launcher, background, etc). - g_browser_process->notification_ui_manager()->CancelAll(); + g_browser_process->notification_ui_manager()->StartShutdown(); #if defined(USE_ASH) // This may be called before |ash::Shell| is initialized when diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/message_center_notification_manager.cc chromium-browser-58.0.3029.110/chrome/browser/notifications/message_center_notification_manager.cc --- chromium-browser-58.0.3029.96/chrome/browser/notifications/message_center_notification_manager.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/message_center_notification_manager.cc 2017-05-09 19:02:42.000000000 +0000 @@ -82,6 +82,10 @@ void MessageCenterNotificationManager::Add(const Notification& notification, Profile* profile) { + // We won't have time to process and act on this notification. + if (is_shutdown_started_) + return; + if (Update(notification, profile)) return; @@ -259,6 +263,11 @@ false /* by_user */, message_center::MessageCenter::RemoveType::ALL); } +void MessageCenterNotificationManager::StartShutdown() { + is_shutdown_started_ = true; + CancelAll(); +} + //////////////////////////////////////////////////////////////////////////////// // MessageCenter::Observer void MessageCenterNotificationManager::OnNotificationRemoved( diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/message_center_notification_manager.h chromium-browser-58.0.3029.110/chrome/browser/notifications/message_center_notification_manager.h --- chromium-browser-58.0.3029.96/chrome/browser/notifications/message_center_notification_manager.h 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/message_center_notification_manager.h 2017-05-09 19:02:42.000000000 +0000 @@ -60,6 +60,7 @@ bool CancelAllBySourceOrigin(const GURL& source_origin) override; bool CancelAllByProfile(ProfileID profile_id) override; void CancelAll() override; + void StartShutdown() override; // MessageCenterObserver void OnNotificationRemoved(const std::string& notification_id, @@ -112,6 +113,9 @@ // Keeps track of notifications specific to Google Now for UMA purposes. GoogleNowNotificationStatsCollector google_now_stats_collector_; + // Tracks if shutdown has started. + bool is_shutdown_started_ = false; + DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); }; diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/message_center_notifications_unittest.cc chromium-browser-58.0.3029.110/chrome/browser/notifications/message_center_notifications_unittest.cc --- chromium-browser-58.0.3029.96/chrome/browser/notifications/message_center_notifications_unittest.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/message_center_notifications_unittest.cc 2017-05-09 19:02:42.000000000 +0000 @@ -51,7 +51,6 @@ MessageCenter::Initialize(); #endif - TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal(); profile_manager_.reset(new TestingProfileManager(browser_process)); ASSERT_TRUE(profile_manager_->SetUp()); @@ -104,6 +103,20 @@ notification_manager()->Add(GetANotification("test"), &profile); } +TEST_F(MessageCenterNotificationManagerTest, AddNotificationOnShutdown) { + TestingProfile profile; + EXPECT_TRUE(message_center()->NotificationCount() == 0); + notification_manager()->Add(GetANotification("test"), &profile); + EXPECT_TRUE(message_center()->NotificationCount() == 1); + + // Verify the number of notifications does not increase when trying to add a + // notifcation on shutdown. + notification_manager()->StartShutdown(); + EXPECT_TRUE(message_center()->NotificationCount() == 0); + notification_manager()->Add(GetANotification("test2"), &profile); + EXPECT_TRUE(message_center()->NotificationCount() == 0); +} + TEST_F(MessageCenterNotificationManagerTest, UpdateNotification) { TestingProfile profile; EXPECT_TRUE(message_center()->NotificationCount() == 0); diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_system_observer.cc chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_system_observer.cc --- chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_system_observer.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_system_observer.cc 2017-05-09 19:02:42.000000000 +0000 @@ -32,7 +32,7 @@ const content::NotificationSource& source, const content::NotificationDetails& details) { if (type == chrome::NOTIFICATION_APP_TERMINATING) { - ui_manager_->CancelAll(); + ui_manager_->StartShutdown(); } else if (type == extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { if (!content::Source(source)->IsOffTheRecord()) { extensions::UnloadedExtensionInfo* extension_info = diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_test_util.cc chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_test_util.cc --- chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_test_util.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_test_util.cc 2017-05-09 19:02:42.000000000 +0000 @@ -52,6 +52,9 @@ void StubNotificationUIManager::Add(const Notification& notification, Profile* profile) { + if (is_shutdown_started_) + return; + notifications_.push_back(std::make_pair( notification, NotificationUIManager::GetProfileID(profile))); @@ -154,6 +157,11 @@ notifications_.clear(); } +void StubNotificationUIManager::StartShutdown() { + is_shutdown_started_ = true; + CancelAll(); +} + FullscreenStateWaiter::FullscreenStateWaiter( Browser* browser, bool desired_state) : browser_(browser), diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_test_util.h chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_test_util.h --- chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_test_util.h 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_test_util.h 2017-05-09 19:02:42.000000000 +0000 @@ -70,6 +70,7 @@ bool CancelAllBySourceOrigin(const GURL& source_origin) override; bool CancelAllByProfile(ProfileID profile_id) override; void CancelAll() override; + void StartShutdown() override; private: using NotificationPair = std::pair; @@ -77,6 +78,8 @@ base::Closure notification_added_callback_; + bool is_shutdown_started_ = false; + DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager); }; diff -Nru chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_ui_manager.h chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_ui_manager.h --- chromium-browser-58.0.3029.96/chrome/browser/notifications/notification_ui_manager.h 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/notifications/notification_ui_manager.h 2017-05-09 19:02:42.000000000 +0000 @@ -86,6 +86,11 @@ // Used when the app is terminating. virtual void CancelAll() = 0; + // Cancels all pending notifications and closes anything currently showing. + // After this is called, no new notifications can be added. Used when the app + // is terminating. + virtual void StartShutdown() = 0; + protected: NotificationUIManager() {} diff -Nru chromium-browser-58.0.3029.96/chrome/browser/process_singleton_posix.cc chromium-browser-58.0.3029.110/chrome/browser/process_singleton_posix.cc --- chromium-browser-58.0.3029.96/chrome/browser/process_singleton_posix.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/process_singleton_posix.cc 2017-05-09 19:02:42.000000000 +0000 @@ -218,11 +218,12 @@ } // Set up a sockaddr appropriate for messaging. -void SetupSockAddr(const std::string& path, struct sockaddr_un* addr) { +bool SetupSockAddr(const std::string& path, struct sockaddr_un* addr) { addr->sun_family = AF_UNIX; - CHECK(path.length() < arraysize(addr->sun_path)) - << "Socket path too long: " << path; + if (path.length() >= arraysize(addr->sun_path)) + return false; base::strlcpy(addr->sun_path, path.c_str(), arraysize(addr->sun_path)); + return true; } // Set up a socket appropriate for messaging. @@ -240,7 +241,7 @@ // Set up a socket and sockaddr appropriate for messaging. void SetupSocket(const std::string& path, int* sock, struct sockaddr_un* addr) { *sock = SetupSocketOnly(); - SetupSockAddr(path, addr); + CHECK(SetupSockAddr(path, addr)) << "Socket path too long: " << path; } // Read a symbolic link, return empty string if given path is not a symbol link. @@ -386,7 +387,12 @@ // Now we know the directory was (at that point) created by the profile // owner. Try to connect. sockaddr_un addr; - SetupSockAddr(socket_target.value(), &addr); + if (!SetupSockAddr(socket_target.value(), &addr)) { + // If a sockaddr couldn't be initialized due to too long of a socket + // path, we can be sure there isn't already a Chrome running with this + // socket path, since it would have hit the CHECK() on the path length. + return false; + } int ret = HANDLE_EINTR(connect(socket->fd(), reinterpret_cast(&addr), sizeof(addr))); @@ -405,7 +411,12 @@ // It exists, but is not a symlink (or some other error we detect // later). Just connect to it directly; this is an older version of Chrome. sockaddr_un addr; - SetupSockAddr(socket_path.value(), &addr); + if (!SetupSockAddr(socket_path.value(), &addr)) { + // If a sockaddr couldn't be initialized due to too long of a socket + // path, we can be sure there isn't already a Chrome running with this + // socket path, since it would have hit the CHECK() on the path length. + return false; + } int ret = HANDLE_EINTR(connect(socket->fd(), reinterpret_cast(&addr), sizeof(addr))); @@ -982,9 +993,14 @@ dir_mode == base::FILE_PERMISSION_USER_MASK) << "Temp directory mode is not 700: " << std::oct << dir_mode; - // Setup the socket symlink and the two cookies. + // Try to create the socket before creating the symlink, as SetupSocket may + // fail on a CHECK if the |socket_target_path| is too long, and this avoids + // leaving a dangling symlink. base::FilePath socket_target_path = socket_dir_.GetPath().Append(chrome::kSingletonSocketFilename); + SetupSocket(socket_target_path.value(), &sock, &addr); + + // Setup the socket symlink and the two cookies. base::FilePath cookie(GenerateCookie()); base::FilePath remote_cookie_path = socket_dir_.GetPath().Append(chrome::kSingletonCookieFilename); @@ -1001,8 +1017,6 @@ return false; } - SetupSocket(socket_target_path.value(), &sock, &addr); - if (bind(sock, reinterpret_cast(&addr), sizeof(addr)) < 0) { PLOG(ERROR) << "Failed to bind() " << socket_target_path.value(); CloseSocket(sock); diff -Nru chromium-browser-58.0.3029.96/chrome/browser/process_singleton_posix_unittest.cc chromium-browser-58.0.3029.110/chrome/browser/process_singleton_posix_unittest.cc --- chromium-browser-58.0.3029.96/chrome/browser/process_singleton_posix_unittest.cc 2017-05-02 19:02:47.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/process_singleton_posix_unittest.cc 2017-05-09 19:02:42.000000000 +0000 @@ -408,6 +408,24 @@ EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, NotifyOtherProcessOrCreate(url)); } +TEST_F(ProcessSingletonPosixTest, IgnoreSocketSymlinkWithTooLongTarget) { + CreateProcessSingletonOnThread(); + // Change the symlink to one with a too-long target. + char buf[PATH_MAX]; + ssize_t len = readlink(socket_path_.value().c_str(), buf, PATH_MAX); + ASSERT_GT(len, 0); + base::FilePath socket_target_path = base::FilePath(std::string(buf, len)); + base::FilePath long_socket_target_path = socket_target_path.DirName().Append( + std::string(sizeof(sockaddr_un::sun_path), 'b')); + ASSERT_EQ(0, unlink(socket_path_.value().c_str())); + ASSERT_EQ(0, symlink(long_socket_target_path.value().c_str(), + socket_path_.value().c_str())); + + // A new ProcessSingleton should ignore the invalid socket path target. + std::string url("about:blank"); + EXPECT_EQ(ProcessSingleton::PROCESS_NONE, NotifyOtherProcessOrCreate(url)); +} + #if defined(OS_MACOSX) // Test that if there is an existing lock file, and we could not flock() // it, then exit. diff -Nru chromium-browser-58.0.3029.96/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.cc chromium-browser-58.0.3029.110/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.cc --- chromium-browser-58.0.3029.96/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.cc 2017-05-02 19:02:48.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.cc 2017-05-09 19:02:42.000000000 +0000 @@ -136,7 +136,13 @@ DCHECK(config_fetcher_); DCHECK(!config_fetcher_->IsActive()); - PostCallbackAndDeleteSelf(config_fetcher_->GetSettings()); + std::unique_ptr settings( + config_fetcher_->GetSettings()); + // Use default settings if fetching of BrandcodedDefaultSettings fails. + if (!settings) + settings.reset(new BrandcodedDefaultSettings()); + + PostCallbackAndDeleteSelf(std::move(settings)); } void DefaultSettingsFetcher::PostCallbackAndDeleteSelf( diff -Nru chromium-browser-58.0.3029.96/chrome/browser/ui/webui/net_export_ui.cc chromium-browser-58.0.3029.110/chrome/browser/ui/webui/net_export_ui.cc --- chromium-browser-58.0.3029.96/chrome/browser/ui/webui/net_export_ui.cc 2017-05-02 19:02:48.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/browser/ui/webui/net_export_ui.cc 2017-05-09 19:02:43.000000000 +0000 @@ -286,10 +286,13 @@ void* params) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(select_file_dialog_); - select_file_dialog_ = nullptr; *last_save_dir.Pointer() = path.DirName(); file_writer_->StartNetLog(path, capture_mode_, GetURLRequestContexts()); + + // IMPORTANT: resetting the dialog may lead to the deletion of |path|, so keep + // this line last. + select_file_dialog_ = nullptr; } void NetExportMessageHandler::FileSelectionCanceled(void* params) { diff -Nru chromium-browser-58.0.3029.96/chrome/common/pref_names.cc chromium-browser-58.0.3029.110/chrome/common/pref_names.cc --- chromium-browser-58.0.3029.96/chrome/common/pref_names.cc 2017-05-02 19:02:48.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/common/pref_names.cc 2017-05-09 19:02:43.000000000 +0000 @@ -42,6 +42,10 @@ "arc.set_notifications_enabled_deferred"; // A preference that indicates status of Android sign-in. const char kArcSignedIn[] = "arc.signedin"; +// A preference that indicates an ARC comaptible filesystem was chosen for +// the user directory (i.e., the user finished required migration.) +const char kArcCompatibleFilesystemChosen[] = + "arc.compatible_filesystem.chosen"; #endif // A bool pref that keeps whether the child status for this profile was already diff -Nru chromium-browser-58.0.3029.96/chrome/common/pref_names.h chromium-browser-58.0.3029.110/chrome/common/pref_names.h --- chromium-browser-58.0.3029.96/chrome/common/pref_names.h 2017-05-02 19:02:48.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/common/pref_names.h 2017-05-09 19:02:43.000000000 +0000 @@ -29,6 +29,7 @@ extern const char kArcPackages[]; extern const char kArcSetNotificationsEnabledDeferred[]; extern const char kArcSignedIn[]; +extern const char kArcCompatibleFilesystemChosen[]; #endif extern const char kChildAccountStatusKnown[]; extern const char kDefaultApps[]; diff -Nru chromium-browser-58.0.3029.96/chrome/VERSION chromium-browser-58.0.3029.110/chrome/VERSION --- chromium-browser-58.0.3029.96/chrome/VERSION 2017-05-02 19:02:46.000000000 +0000 +++ chromium-browser-58.0.3029.110/chrome/VERSION 2017-05-09 19:02:40.000000000 +0000 @@ -1,4 +1,4 @@ MAJOR=58 MINOR=0 BUILD=3029 -PATCH=96 +PATCH=110 diff -Nru chromium-browser-58.0.3029.96/chromeos/dbus/update_engine_client.cc chromium-browser-58.0.3029.110/chromeos/dbus/update_engine_client.cc --- chromium-browser-58.0.3029.96/chromeos/dbus/update_engine_client.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/chromeos/dbus/update_engine_client.cc 2017-05-09 19:02:44.000000000 +0000 @@ -9,6 +9,7 @@ #include #include "base/bind.h" +#include "base/callback.h" #include "base/command_line.h" #include "base/location.h" #include "base/macros.h" @@ -105,6 +106,15 @@ } void RequestUpdateCheck(const UpdateCheckCallback& callback) override { + if (!service_available_) { + // TODO(alemate): we probably need to remember callbacks only. + // When service becomes available, we can do a single request, + // and trigger all callbacks with the same return value. + pending_tasks_.push_back( + base::Bind(&UpdateEngineClientImpl::RequestUpdateCheck, + weak_ptr_factory_.GetWeakPtr(), callback)); + return; + } dbus::MethodCall method_call( update_engine::kUpdateEngineInterface, update_engine::kAttemptUpdate); @@ -255,6 +265,13 @@ private: void OnServiceInitiallyAvailable(bool service_is_available) { if (service_is_available) { + service_available_ = true; + std::vector callbacks; + callbacks.swap(pending_tasks_); + for (const auto& callback : callbacks) { + callback.Run(); + } + // Get update engine status for the initial status. Update engine won't // send StatusUpdate signal unless there is a status change. If chrome // crashes after UPDATE_STATUS_UPDATED_NEED_REBOOT status is set, @@ -262,6 +279,7 @@ GetUpdateEngineStatus(); } else { LOG(ERROR) << "Failed to wait for D-Bus service to become available"; + pending_tasks_.clear(); } } @@ -482,6 +500,13 @@ base::ObserverList observers_; Status last_status_; + // True after update_engine's D-Bus service has become available. + bool service_available_ = false; + + // This is a list of postponed calls to update engine to be called + // after it becomes available. + std::vector pending_tasks_; + // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory weak_ptr_factory_; diff -Nru chromium-browser-58.0.3029.96/components/exo/pointer.cc chromium-browser-58.0.3029.110/components/exo/pointer.cc --- chromium-browser-58.0.3029.96/components/exo/pointer.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/components/exo/pointer.cc 2017-05-09 19:02:45.000000000 +0000 @@ -89,9 +89,8 @@ } if (surface_) { surface_->window()->SetTransform(gfx::Transform()); - WMHelper::GetInstance() - ->GetContainer(ash::kShellWindowId_MouseCursorContainer) - ->RemoveChild(surface_->window()); + if (surface_->window()->parent()) + surface_->window()->parent()->RemoveChild(surface_->window()); surface_->SetSurfaceDelegate(nullptr); surface_->RemoveSurfaceObserver(this); } diff -Nru chromium-browser-58.0.3029.96/components/exo/shell_surface.cc chromium-browser-58.0.3029.110/components/exo/shell_surface.cc --- chromium-browser-58.0.3029.96/components/exo/shell_surface.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/components/exo/shell_surface.cc 2017-05-09 19:02:45.000000000 +0000 @@ -924,6 +924,11 @@ ash::wm::WindowState* window_state, ash::wm::WindowStateType old_type) { ash::wm::WindowStateType new_type = window_state->GetStateType(); + if (old_type == ash::wm::WINDOW_STATE_TYPE_MINIMIZED || + new_type == ash::wm::WINDOW_STATE_TYPE_MINIMIZED) { + return; + } + if (ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(old_type) || ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(new_type)) { // When transitioning in/out of maximized or fullscreen mode we need to @@ -1445,7 +1450,7 @@ DCHECK(!ignore_window_bounds_changes_); ignore_window_bounds_changes_ = true; if (widget_->GetWindowBoundsInScreen() != new_widget_bounds) - widget_->SetBounds(new_widget_bounds); + widget_->GetNativeWindow()->SetBounds(new_widget_bounds); ignore_window_bounds_changes_ = false; } diff -Nru chromium-browser-58.0.3029.96/components/exo/wayland/server.cc chromium-browser-58.0.3029.110/components/exo/wayland/server.cc --- chromium-browser-58.0.3029.96/components/exo/wayland/server.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/components/exo/wayland/server.cc 2017-05-09 19:02:45.000000000 +0000 @@ -158,8 +158,9 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); // A property key containing a boolean set to true whether the current -// OnWindowActivated invocation should be ignored. -DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, false); +// OnWindowActivated invocation should be ignored. The defualt is true +// to ignore the activation event originated by creation. +DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, true); wl_resource* GetSurfaceResource(Surface* surface) { return surface->GetProperty(kSurfaceResourceKey); @@ -1935,8 +1936,8 @@ // Activation on Aura is synchronous, so activation callbacks will be called // before the flag is reset. window->SetProperty(kIgnoreWindowActivated, true); - GetUserDataAs(resource)->Activate(); - window->ClearProperty(kIgnoreWindowActivated); + shell_surface->Activate(); + window->SetProperty(kIgnoreWindowActivated, false); } void remote_surface_maximize(wl_client* client, wl_resource* resource) { @@ -2121,8 +2122,10 @@ // already activated on the client side, so do not notify about the // activation. It means that zcr_remote_shell_v1_send_activated is used // only to notify about activations originating in Aura. - if (gained_active && gained_active->GetProperty(kIgnoreWindowActivated)) + if (gained_active && gained_active->GetProperty(kIgnoreWindowActivated)) { + gained_active->SetProperty(kIgnoreWindowActivated, false); return; + } SendActivated(gained_active, lost_active); } diff -Nru chromium-browser-58.0.3029.96/components/exo/wm_helper_ash.cc chromium-browser-58.0.3029.110/components/exo/wm_helper_ash.cc --- chromium-browser-58.0.3029.96/components/exo/wm_helper_ash.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/components/exo/wm_helper_ash.cc 2017-05-09 19:02:45.000000000 +0000 @@ -53,7 +53,7 @@ } aura::Window* WMHelperAsh::GetContainer(int container_id) { - return ash::Shell::GetContainer(ash::Shell::GetTargetRootWindow(), + return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), container_id); } diff -Nru chromium-browser-58.0.3029.96/components/metrics/metrics_log.cc chromium-browser-58.0.3029.110/components/metrics/metrics_log.cc --- chromium-browser-58.0.3029.96/components/metrics/metrics_log.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/components/metrics/metrics_log.cc 2017-05-09 19:02:45.000000000 +0000 @@ -151,12 +151,7 @@ metrics::SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); -#if !defined(OS_IOS) - // On iOS, OperatingSystemArchitecture() returns values like iPad4,4 which is - // not the actual CPU architecture. Don't set it until the API is fixed. See - // crbug.com/370104 for details. hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); -#endif hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); hardware->set_hardware_class(base::SysInfo::HardwareModelName()); #if defined(OS_WIN) diff -Nru chromium-browser-58.0.3029.96/components/metrics/metrics_log_unittest.cc chromium-browser-58.0.3029.110/components/metrics/metrics_log_unittest.cc --- chromium-browser-58.0.3029.96/components/metrics/metrics_log_unittest.cc 2017-05-02 19:02:50.000000000 +0000 +++ chromium-browser-58.0.3029.110/components/metrics/metrics_log_unittest.cc 2017-05-09 19:02:45.000000000 +0000 @@ -196,9 +196,7 @@ #endif metrics::SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); -#if !defined(OS_IOS) hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); -#endif hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); hardware->set_hardware_class(base::SysInfo::HardwareModelName()); #if defined(OS_WIN) diff -Nru chromium-browser-58.0.3029.96/debian/changelog chromium-browser-58.0.3029.110/debian/changelog --- chromium-browser-58.0.3029.96/debian/changelog 2017-05-03 04:49:16.000000000 +0000 +++ chromium-browser-58.0.3029.110/debian/changelog 2017-05-10 05:23:02.000000000 +0000 @@ -1,3 +1,10 @@ +chromium-browser (58.0.3029.110-0ubuntu0.16.04.1281) xenial; urgency=medium + + * Upstream release: 58.0.3029.110 + * debian/control: bump Standards-Version to 3.9.8 + + -- Olivier Tilloy Wed, 10 May 2017 07:23:02 +0200 + chromium-browser (58.0.3029.96-0ubuntu0.16.04.1279) xenial; urgency=medium * Upstream release: 58.0.3029.96 diff -Nru chromium-browser-58.0.3029.96/debian/control chromium-browser-58.0.3029.110/debian/control --- chromium-browser-58.0.3029.96/debian/control 2017-04-21 04:48:16.000000000 +0000 +++ chromium-browser-58.0.3029.110/debian/control 2017-05-10 05:22:34.000000000 +0000 @@ -41,7 +41,7 @@ libffi-dev, chrpath, yasm -Standards-Version: 3.9.6 +Standards-Version: 3.9.8 Package: chromium-browser Architecture: i386 amd64 armhf arm64 diff -Nru chromium-browser-58.0.3029.96/DEPS chromium-browser-58.0.3029.110/DEPS --- chromium-browser-58.0.3029.96/DEPS 2017-05-02 19:02:45.000000000 +0000 +++ chromium-browser-58.0.3029.110/DEPS 2017-05-09 19:02:40.000000000 +0000 @@ -184,7 +184,7 @@ 'src/tools/swarming_client': (Var("chromium_git")) + '/external/swarming.client.git@11e31afa5d330756ff87aa12064bb5d032896cb5', 'src/v8': - (Var("chromium_git")) + '/v8/v8.git@ad0b8920f270d0cb500b3b2f6ebce319e44685ff' + (Var("chromium_git")) + '/v8/v8.git@2f06375912a79b55603cc75306738101921ce80a' } deps_os = { diff -Nru chromium-browser-58.0.3029.96/ios/chrome/browser/ui/history/history_collection_view_controller.mm chromium-browser-58.0.3029.110/ios/chrome/browser/ui/history/history_collection_view_controller.mm --- chromium-browser-58.0.3029.96/ios/chrome/browser/ui/history/history_collection_view_controller.mm 2017-05-02 19:02:53.000000000 +0000 +++ chromium-browser-58.0.3029.110/ios/chrome/browser/ui/history/history_collection_view_controller.mm 2017-05-09 19:02:47.000000000 +0000 @@ -108,20 +108,14 @@ // the empty string, all history is fetched. - (void)fetchHistoryForQuery:(NSString*)query priorToTime:(const base::Time&)time; -// Updates various elements after history items have been deleted from the -// CollectionView. -- (void)updateCollectionViewAfterDeletingEntries; // Updates header section to provide relevant information about the currently // displayed history entries. - (void)updateEntriesStatusMessage; // Removes selected items from the visible collection, but does not delete them // from browser history. - (void)removeSelectedItemsFromCollection; -// Selects all items in the collection that are not included in entries. +// Removes all items in the collection that are not included in entries. - (void)filterForHistoryEntries:(NSArray*)entries; -// Deletes all items in the collection which indexes are included in indexArray, -// needs to be run inside a performBatchUpdates block. -- (void)deleteItemsFromCollectionViewModelWithIndex:(NSArray*)indexArray; // Adds loading indicator to the top of the history collection, if one is not // already present. - (void)addLoadingIndicator; @@ -376,20 +370,16 @@ } } [self.delegate historyCollectionViewControllerDidChangeEntries:self]; - if (([self isSearching] && [searchQuery length] > 0 && - [self.currentQuery isEqualToString:searchQuery]) || - self.filterQueryResult) { - // If in search mode, filter out entries that are not - // part of the search result. - [self filterForHistoryEntries:filterResults]; - NSArray* deletedIndexPaths = - self.collectionView.indexPathsForSelectedItems; - [self deleteItemsFromCollectionViewModelWithIndex:deletedIndexPaths]; - self.filterQueryResult = NO; - } } completion:^(BOOL) { - [self updateCollectionViewAfterDeletingEntries]; + if (([self isSearching] && [searchQuery length] > 0 && + [self.currentQuery isEqualToString:searchQuery]) || + self.filterQueryResult) { + // If in search mode, filter out entries that are not + // part of the search result. + [self filterForHistoryEntries:filterResults]; + self.filterQueryResult = NO; + } }]; } @@ -574,15 +564,6 @@ _historyServiceFacade->QueryOtherFormsOfBrowsingHistory(); } -- (void)updateCollectionViewAfterDeletingEntries { - // If only the header section remains, there are no history entries. - if ([self.collectionViewModel numberOfSections] == 1) { - self.entriesType = NO_ENTRIES; - } - [self updateEntriesStatusMessage]; - [self.delegate historyCollectionViewControllerDidChangeEntries:self]; -} - - (void)updateEntriesStatusMessage { CollectionViewItem* entriesStatusItem = nil; if (!self.hasHistoryEntries) { @@ -637,27 +618,28 @@ - (void)removeSelectedItemsFromCollection { NSArray* deletedIndexPaths = self.collectionView.indexPathsForSelectedItems; [self.collectionView performBatchUpdates:^{ - [self deleteItemsFromCollectionViewModelWithIndex:deletedIndexPaths]; + [self collectionView:self.collectionView + willDeleteItemsAtIndexPaths:deletedIndexPaths]; + [self.collectionView deleteItemsAtIndexPaths:deletedIndexPaths]; + + // Remove any empty sections, except the header section. + for (int section = self.collectionView.numberOfSections - 1; section > 0; + --section) { + if (![self.collectionViewModel numberOfItemsInSection:section]) { + [self.entryInserter removeSection:section]; + } + } } completion:^(BOOL) { - [self updateCollectionViewAfterDeletingEntries]; + // If only the header section remains, there are no history entries. + if ([self.collectionViewModel numberOfSections] == 1) { + self.entriesType = NO_ENTRIES; + } + [self updateEntriesStatusMessage]; + [self.delegate historyCollectionViewControllerDidChangeEntries:self]; }]; } -- (void)deleteItemsFromCollectionViewModelWithIndex:(NSArray*)indexArray { - [self collectionView:self.collectionView - willDeleteItemsAtIndexPaths:indexArray]; - [self.collectionView deleteItemsAtIndexPaths:indexArray]; - - // Remove any empty sections, except the header section. - for (int section = self.collectionView.numberOfSections - 1; section > 0; - --section) { - if (![self.collectionViewModel numberOfItemsInSection:section]) { - [self.entryInserter removeSection:section]; - } - } -} - - (void)filterForHistoryEntries:(NSArray*)entries { self.collectionView.allowsMultipleSelection = YES; for (int section = 1; section < [self.collectionViewModel numberOfSections]; @@ -683,6 +665,7 @@ } } } + [self removeSelectedItemsFromCollection]; } - (void)addLoadingIndicator { diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSMediaRule.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSMediaRule.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSMediaRule.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSMediaRule.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -32,7 +32,7 @@ CSSMediaRule::~CSSMediaRule() {} -MediaQuerySet* CSSMediaRule::mediaQueries() const { +RefPtr CSSMediaRule::mediaQueries() const { return toStyleRuleMedia(m_groupRule.get())->mediaQueries(); } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSMediaRule.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSMediaRule.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSMediaRule.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSMediaRule.h 2017-05-09 19:03:00.000000000 +0000 @@ -53,7 +53,7 @@ CSSRule::Type type() const override { return kMediaRule; } - MediaQuerySet* mediaQueries() const; + RefPtr mediaQueries() const; mutable Member m_mediaCSSOMWrapper; }; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -202,8 +202,8 @@ didMutate(); } -void CSSStyleSheet::setMediaQueries(MediaQuerySet* mediaQueries) { - m_mediaQueries = mediaQueries; +void CSSStyleSheet::setMediaQueries(RefPtr mediaQueries) { + m_mediaQueries = std::move(mediaQueries); if (m_mediaCSSOMWrapper && m_mediaQueries) m_mediaCSSOMWrapper->reattach(m_mediaQueries.get()); } @@ -214,7 +214,7 @@ if (!m_mediaQueries) return true; - return evaluator.eval(m_mediaQueries, &m_viewportDependentMediaQueryResults, + return evaluator.eval(*m_mediaQueries, &m_viewportDependentMediaQueryResults, &m_deviceDependentMediaQueryResults); } @@ -444,9 +444,6 @@ DEFINE_TRACE(CSSStyleSheet) { visitor->trace(m_contents); - visitor->trace(m_mediaQueries); - visitor->trace(m_viewportDependentMediaQueryResults); - visitor->trace(m_deviceDependentMediaQueryResults); visitor->trace(m_ownerNode); visitor->trace(m_ownerRule); visitor->trace(m_mediaCSSOMWrapper); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSStyleSheet.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSStyleSheet.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/CSSStyleSheet.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/CSSStyleSheet.h 2017-05-09 19:03:00.000000000 +0000 @@ -100,8 +100,8 @@ void clearOwnerRule() { m_ownerRule = nullptr; } Document* ownerDocument() const; - const MediaQuerySet* mediaQueries() const { return m_mediaQueries; } - void setMediaQueries(MediaQuerySet*); + const MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } + void setMediaQueries(RefPtr); bool matchesMediaQueries(const MediaQueryEvaluator&); const MediaQueryResultList& viewportDependentMediaQueryResults() const { return m_viewportDependentMediaQueryResults; @@ -164,7 +164,7 @@ bool m_isDisabled = false; bool m_loadCompleted = false; String m_title; - Member m_mediaQueries; + RefPtr m_mediaQueries; MediaQueryResultList m_viewportDependentMediaQueryResults; MediaQueryResultList m_deviceDependentMediaQueryResults; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaList.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaList.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaList.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaList.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -21,7 +21,6 @@ #include "bindings/core/v8/ExceptionState.h" #include "core/css/CSSStyleSheet.h" -#include "core/css/MediaQuery.h" #include "core/css/MediaQueryExp.h" #include "core/css/parser/MediaQueryParser.h" #include "wtf/text/StringBuilder.h" @@ -58,7 +57,7 @@ m_queries[i] = o.m_queries[i]->copy(); } -MediaQuerySet* MediaQuerySet::create(const String& mediaString) { +RefPtr MediaQuerySet::create(const String& mediaString) { if (mediaString.isEmpty()) return MediaQuerySet::create(); @@ -66,7 +65,7 @@ } bool MediaQuerySet::set(const String& mediaString) { - MediaQuerySet* result = create(mediaString); + RefPtr result = create(mediaString); m_queries.swap(result->m_queries); return true; } @@ -75,24 +74,24 @@ // To "parse a media query" for a given string means to follow "the parse // a media query list" steps and return "null" if more than one media query // is returned, or else the returned media query. - MediaQuerySet* result = create(queryString); + RefPtr result = create(queryString); // Only continue if exactly one media query is found, as described above. if (result->m_queries.size() != 1) return true; - MediaQuery* newQuery = result->m_queries[0].release(); + std::unique_ptr newQuery = std::move(result->m_queries[0]); ASSERT(newQuery); // If comparing with any of the media queries in the collection of media // queries returns true terminate these steps. for (size_t i = 0; i < m_queries.size(); ++i) { - MediaQuery* query = m_queries[i].get(); - if (*query == *newQuery) + MediaQuery& query = *m_queries[i]; + if (query == *newQuery) return true; } - m_queries.push_back(newQuery); + m_queries.push_back(std::move(newQuery)); return true; } @@ -100,21 +99,21 @@ // To "parse a media query" for a given string means to follow "the parse // a media query list" steps and return "null" if more than one media query // is returned, or else the returned media query. - MediaQuerySet* result = create(queryStringToRemove); + RefPtr result = create(queryStringToRemove); // Only continue if exactly one media query is found, as described above. if (result->m_queries.size() != 1) return true; - MediaQuery* newQuery = result->m_queries[0].release(); + std::unique_ptr newQuery = std::move(result->m_queries[0]); ASSERT(newQuery); // Remove any media query from the collection of media queries for which // comparing with the media query returns true. bool found = false; for (size_t i = 0; i < m_queries.size(); ++i) { - MediaQuery* query = m_queries[i].get(); - if (*query == *newQuery) { + MediaQuery& query = *m_queries[i]; + if (query == *newQuery) { m_queries.remove(i); --i; found = true; @@ -124,8 +123,8 @@ return found; } -void MediaQuerySet::addMediaQuery(MediaQuery* mediaQuery) { - m_queries.push_back(mediaQuery); +void MediaQuerySet::addMediaQuery(std::unique_ptr mediaQuery) { + m_queries.push_back(std::move(mediaQuery)); } String MediaQuerySet::mediaText() const { @@ -142,16 +141,13 @@ return text.toString(); } -DEFINE_TRACE(MediaQuerySet) { - visitor->trace(m_queries); -} - -MediaList::MediaList(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet) +MediaList::MediaList(RefPtr mediaQueries, + CSSStyleSheet* parentSheet) : m_mediaQueries(mediaQueries), m_parentStyleSheet(parentSheet), m_parentRule(nullptr) {} -MediaList::MediaList(MediaQuerySet* mediaQueries, CSSRule* parentRule) +MediaList::MediaList(RefPtr mediaQueries, CSSRule* parentRule) : m_mediaQueries(mediaQueries), m_parentStyleSheet(nullptr), m_parentRule(parentRule) {} @@ -166,7 +162,8 @@ } String MediaList::item(unsigned index) const { - const HeapVector>& queries = m_mediaQueries->queryVector(); + const Vector>& queries = + m_mediaQueries->queryVector(); if (index < queries.size()) return queries[index]->cssText(); return String(); @@ -202,13 +199,12 @@ m_parentStyleSheet->didMutate(); } -void MediaList::reattach(MediaQuerySet* mediaQueries) { +void MediaList::reattach(RefPtr mediaQueries) { ASSERT(mediaQueries); m_mediaQueries = mediaQueries; } DEFINE_TRACE(MediaList) { - visitor->trace(m_mediaQueries); visitor->trace(m_parentStyleSheet); visitor->trace(m_parentRule); } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaList.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaList.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaList.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaList.h 2017-05-09 19:03:00.000000000 +0000 @@ -24,6 +24,7 @@ #include "bindings/core/v8/ScriptWrappable.h" #include "core/CoreExport.h" +#include "core/css/MediaQuery.h" #include "core/dom/ExceptionCode.h" #include "platform/heap/Handle.h" #include "wtf/Forward.h" @@ -38,24 +39,28 @@ class MediaList; class MediaQuery; -class CORE_EXPORT MediaQuerySet : public GarbageCollected { +class CORE_EXPORT MediaQuerySet : public RefCounted { public: - static MediaQuerySet* create() { return new MediaQuerySet(); } - static MediaQuerySet* create(const String& mediaString); + static RefPtr create() { + return adoptRef(new MediaQuerySet()); + } + static RefPtr create(const String& mediaString); bool set(const String&); bool add(const String&); bool remove(const String&); - void addMediaQuery(MediaQuery*); + void addMediaQuery(std::unique_ptr); - const HeapVector>& queryVector() const { + const Vector>& queryVector() const { return m_queries; } String mediaText() const; - MediaQuerySet* copy() const { return new MediaQuerySet(*this); } + RefPtr copy() const { + return adoptRef(new MediaQuerySet(*this)); + } DECLARE_TRACE(); @@ -63,21 +68,22 @@ MediaQuerySet(); MediaQuerySet(const MediaQuerySet&); - HeapVector> m_queries; + Vector> m_queries; }; -class MediaList final : public GarbageCollected, +class MediaList final : public GarbageCollectedFinalized, public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: - static MediaList* create(MediaQuerySet* mediaQueries, + static MediaList* create(RefPtr mediaQueries, CSSStyleSheet* parentSheet) { - return new MediaList(mediaQueries, parentSheet); + return new MediaList(std::move(mediaQueries), parentSheet); } - static MediaList* create(MediaQuerySet* mediaQueries, CSSRule* parentRule) { - return new MediaList(mediaQueries, parentRule); + static MediaList* create(RefPtr mediaQueries, + CSSRule* parentRule) { + return new MediaList(std::move(mediaQueries), parentRule); } unsigned length() const { return m_mediaQueries->queryVector().size(); } @@ -94,15 +100,15 @@ const MediaQuerySet* queries() const { return m_mediaQueries.get(); } - void reattach(MediaQuerySet*); + void reattach(RefPtr); DECLARE_TRACE(); private: - MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); - MediaList(MediaQuerySet*, CSSRule* parentRule); + MediaList(RefPtr, CSSStyleSheet* parentSheet); + MediaList(RefPtr, CSSRule* parentRule); - Member m_mediaQueries; + RefPtr m_mediaQueries; // Cleared in ~CSSStyleSheet destructor when oilpan is not enabled. Member m_parentStyleSheet; // Cleared in the ~CSSMediaRule and ~CSSImportRule destructors when oilpan is diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQuery.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQuery.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQuery.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQuery.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -61,29 +61,29 @@ result.append(" and "); } - result.append(m_expressions.at(0)->serialize()); + result.append(m_expressions.at(0).serialize()); for (size_t i = 1; i < m_expressions.size(); ++i) { result.append(" and "); - result.append(m_expressions.at(i)->serialize()); + result.append(m_expressions.at(i).serialize()); } return result.toString(); } -static bool expressionCompare(const Member& a, - const Member& b) { - return codePointCompare(a->serialize(), b->serialize()) < 0; +static bool expressionCompare(const MediaQueryExp& a, const MediaQueryExp& b) { + return codePointCompare(a.serialize(), b.serialize()) < 0; } -MediaQuery* MediaQuery::createNotAll() { - return new MediaQuery(MediaQuery::Not, MediaTypeNames::all, - ExpressionHeapVector()); +std::unique_ptr MediaQuery::createNotAll() { + return WTF::makeUnique(MediaQuery::Not, MediaTypeNames::all, + ExpressionHeapVector()); } -MediaQuery* MediaQuery::create(RestrictorType restrictor, - String mediaType, - ExpressionHeapVector expressions) { - return new MediaQuery(restrictor, std::move(mediaType), - std::move(expressions)); +std::unique_ptr MediaQuery::create( + RestrictorType restrictor, + String mediaType, + ExpressionHeapVector expressions) { + return WTF::makeUnique(restrictor, std::move(mediaType), + std::move(expressions)); } MediaQuery::MediaQuery(RestrictorType restrictor, @@ -95,11 +95,11 @@ nonCopyingSort(m_expressions.begin(), m_expressions.end(), expressionCompare); // Remove all duplicated expressions. - MediaQueryExp* key = 0; + MediaQueryExp key = MediaQueryExp::invalid(); for (int i = m_expressions.size() - 1; i >= 0; --i) { - MediaQueryExp* exp = m_expressions.at(i).get(); + MediaQueryExp exp = m_expressions.at(i); - if (key && *exp == *key) + if (exp == key) m_expressions.remove(i); else key = exp; @@ -112,7 +112,7 @@ m_serializationCache(o.m_serializationCache) { m_expressions.reserveInitialCapacity(o.m_expressions.size()); for (unsigned i = 0; i < o.m_expressions.size(); ++i) - m_expressions.push_back(o.m_expressions[i]->copy()); + m_expressions.push_back(o.m_expressions[i]); } MediaQuery::~MediaQuery() {} @@ -130,8 +130,4 @@ return m_serializationCache; } -DEFINE_TRACE(MediaQuery) { - visitor->trace(m_expressions); -} - } // namespace blink diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -111,51 +111,50 @@ } bool MediaQueryEvaluator::eval( - const MediaQuery* query, + const MediaQuery& query, MediaQueryResultList* viewportDependentMediaQueryResults, MediaQueryResultList* deviceDependentMediaQueryResults) const { - if (!mediaTypeMatch(query->mediaType())) - return applyRestrictor(query->restrictor(), false); + if (!mediaTypeMatch(query.mediaType())) + return applyRestrictor(query.restrictor(), false); - const ExpressionHeapVector& expressions = query->expressions(); + const ExpressionHeapVector& expressions = query.expressions(); // Iterate through expressions, stop if any of them eval to false (AND // semantics). size_t i = 0; for (; i < expressions.size(); ++i) { - bool exprResult = eval(expressions.at(i).get()); + bool exprResult = eval(expressions.at(i)); if (viewportDependentMediaQueryResults && - expressions.at(i)->isViewportDependent()) + expressions.at(i).isViewportDependent()) { viewportDependentMediaQueryResults->push_back( - new MediaQueryResult(*expressions.at(i), exprResult)); + MediaQueryResult(expressions.at(i), exprResult)); + } if (deviceDependentMediaQueryResults && - expressions.at(i)->isDeviceDependent()) + expressions.at(i).isDeviceDependent()) { deviceDependentMediaQueryResults->push_back( - new MediaQueryResult(*expressions.at(i), exprResult)); + MediaQueryResult(expressions.at(i), exprResult)); + } if (!exprResult) break; } // Assume true if we are at the end of the list, otherwise assume false. - return applyRestrictor(query->restrictor(), expressions.size() == i); + return applyRestrictor(query.restrictor(), expressions.size() == i); } bool MediaQueryEvaluator::eval( - const MediaQuerySet* querySet, + const MediaQuerySet& querySet, MediaQueryResultList* viewportDependentMediaQueryResults, MediaQueryResultList* deviceDependentMediaQueryResults) const { - if (!querySet) - return true; - - const HeapVector>& queries = querySet->queryVector(); + const Vector>& queries = querySet.queryVector(); if (!queries.size()) return true; // Empty query list evaluates to true. // Iterate over queries, stop if any of them eval to true (OR semantics). bool result = false; - for (size_t i = 0; i < queries.size() && !result; ++i) - result = eval(queries[i].get(), viewportDependentMediaQueryResults, + for (size_t i = 0; i < queries.size() && !result; ++i) { + result = eval(*queries[i], viewportDependentMediaQueryResults, deviceDependentMediaQueryResults); - + } return result; } @@ -809,7 +808,7 @@ #undef ADD_TO_FUNCTIONMAP } -bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const { +bool MediaQueryEvaluator::eval(const MediaQueryExp& expr) const { if (!m_mediaValues || !m_mediaValues->hasValues()) return true; @@ -817,9 +816,9 @@ // Call the media feature evaluation function. Assume no prefix and let // trampoline functions override the prefix if prefix is used. - EvalFunc func = gFunctionMap->at(expr->mediaFeature().impl()); + EvalFunc func = gFunctionMap->at(expr.mediaFeature().impl()); if (func) - return func(expr->expValue(), NoPrefix, *m_mediaValues); + return func(expr.expValue(), NoPrefix, *m_mediaValues); return false; } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryEvaluator.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryEvaluator.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryEvaluator.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryEvaluator.h 2017-05-09 19:03:00.000000000 +0000 @@ -41,7 +41,7 @@ class MediaValues; class MediaValuesInitialViewport; -using MediaQueryResultList = HeapVector>; +using MediaQueryResultList = Vector; // Class that evaluates css media queries as defined in // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) @@ -83,17 +83,17 @@ bool mediaTypeMatch(const String& mediaTypeToMatch) const; // Evaluates a list of media queries. - bool eval(const MediaQuerySet*, + bool eval(const MediaQuerySet&, MediaQueryResultList* viewportDependent = nullptr, MediaQueryResultList* deviceDependent = nullptr) const; // Evaluates media query. - bool eval(const MediaQuery*, + bool eval(const MediaQuery&, MediaQueryResultList* viewportDependent = nullptr, MediaQueryResultList* deviceDependent = nullptr) const; // Evaluates media query subexpression, ie "and (media-feature: value)" part. - bool eval(const MediaQueryExp*) const; + bool eval(const MediaQueryExp&) const; DECLARE_TRACE(); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -139,10 +139,10 @@ void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryEvaluator) { - Persistent querySet = nullptr; + RefPtr querySet = nullptr; for (unsigned i = 0; testCases[i].input; ++i) { querySet = MediaQuerySet::create(testCases[i].input); - EXPECT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get())); + EXPECT_EQ(testCases[i].output, mediaQueryEvaluator.eval(*querySet)); } } @@ -193,8 +193,8 @@ pageHolder.reset(); ASSERT_EQ(nullptr, frame->view()); MediaQueryEvaluator mediaQueryEvaluator(frame); - MediaQuerySet* querySet = MediaQuerySet::create("foobar"); - EXPECT_FALSE(mediaQueryEvaluator.eval(querySet)); + RefPtr querySet = MediaQuerySet::create("foobar"); + EXPECT_FALSE(mediaQueryEvaluator.eval(*querySet)); } TEST(MediaQueryEvaluatorTest, CachedFloatViewport) { diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryExp.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryExp.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryExp.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryExp.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -216,7 +216,7 @@ const MediaQueryExpValue& expValue) : m_mediaFeature(mediaFeature), m_expValue(expValue) {} -MediaQueryExp* MediaQueryExp::createIfValid( +MediaQueryExp MediaQueryExp::create( const String& mediaFeature, const Vector& tokenList) { ASSERT(!mediaFeature.isNull()); @@ -233,7 +233,7 @@ if (token.type() == IdentToken) { CSSValueID ident = token.id(); if (!featureWithValidIdent(lowerMediaFeature, ident)) - return nullptr; + return invalid(); expValue.id = ident; expValue.isID = true; } else if (token.type() == NumberToken || token.type() == PercentageToken || @@ -258,10 +258,10 @@ expValue.unit = CSSPrimitiveValue::UnitType::Number; expValue.isValue = true; } else { - return nullptr; + return invalid(); } } else { - return nullptr; + return invalid(); } } else if (tokenList.size() == 3 && featureWithAspectRatio(lowerMediaFeature)) { @@ -271,22 +271,22 @@ const CSSParserToken& delimiter = tokenList[1]; const CSSParserToken& denominator = tokenList[2]; if (delimiter.type() != DelimiterToken || delimiter.delimiter() != '/') - return nullptr; + return invalid(); if (numerator.type() != NumberToken || numerator.numericValue() <= 0 || numerator.numericValueType() != IntegerValueType) - return nullptr; + return invalid(); if (denominator.type() != NumberToken || denominator.numericValue() <= 0 || denominator.numericValueType() != IntegerValueType) - return nullptr; + return invalid(); expValue.numerator = (unsigned)numerator.numericValue(); expValue.denominator = (unsigned)denominator.numericValue(); expValue.isRatio = true; } else { - return nullptr; + return invalid(); } - return new MediaQueryExp(lowerMediaFeature, expValue); + return MediaQueryExp(lowerMediaFeature, expValue); } MediaQueryExp::~MediaQueryExp() {} diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryExp.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryExp.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryExp.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryExp.h 2017-05-09 19:03:00.000000000 +0000 @@ -77,17 +77,26 @@ } }; -class CORE_EXPORT MediaQueryExp - : public GarbageCollectedFinalized { +class CORE_EXPORT MediaQueryExp { + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); + public: - static MediaQueryExp* createIfValid(const String& mediaFeature, - const Vector&); + // Returns an invalid MediaQueryExp if the arguments are invalid. + static MediaQueryExp create(const String& mediaFeature, + const Vector&); + static MediaQueryExp invalid() { + return MediaQueryExp(String(), MediaQueryExpValue()); + } + + MediaQueryExp(const MediaQueryExp& other); ~MediaQueryExp(); const String& mediaFeature() const { return m_mediaFeature; } MediaQueryExpValue expValue() const { return m_expValue; } + bool isValid() const { return !m_mediaFeature.isNull(); } + bool operator==(const MediaQueryExp& other) const; bool isViewportDependent() const; @@ -96,11 +105,6 @@ String serialize() const; - MediaQueryExp* copy() const { return new MediaQueryExp(*this); } - - MediaQueryExp(const MediaQueryExp& other); - - DEFINE_INLINE_TRACE() {} private: MediaQueryExp(const String&, const MediaQueryExpValue&); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQuery.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQuery.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQuery.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQuery.h 2017-05-09 19:03:00.000000000 +0000 @@ -39,17 +39,19 @@ namespace blink { class MediaQueryExp; -using ExpressionHeapVector = HeapVector>; +using ExpressionHeapVector = Vector; -class CORE_EXPORT MediaQuery : public GarbageCollectedFinalized { +class CORE_EXPORT MediaQuery { public: enum RestrictorType { Only, Not, None }; - static MediaQuery* create(RestrictorType, - String mediaType, - ExpressionHeapVector); - static MediaQuery* createNotAll(); + static std::unique_ptr create(RestrictorType, + String mediaType, + ExpressionHeapVector); + static std::unique_ptr createNotAll(); + MediaQuery(RestrictorType, String media_type, ExpressionHeapVector); + MediaQuery(const MediaQuery&); ~MediaQuery(); RestrictorType restrictor() const { return m_restrictor; } @@ -58,14 +60,13 @@ bool operator==(const MediaQuery& other) const; String cssText() const; - MediaQuery* copy() const { return new MediaQuery(*this); } + std::unique_ptr copy() const { + return WTF::makeUnique(*this); + } DECLARE_TRACE(); private: - MediaQuery(RestrictorType, String mediaType, ExpressionHeapVector); - MediaQuery(const MediaQuery&); - MediaQuery& operator=(const MediaQuery&) = delete; RestrictorType m_restrictor; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryList.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryList.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryList.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryList.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -29,13 +29,13 @@ MediaQueryList* MediaQueryList::create(ExecutionContext* context, MediaQueryMatcher* matcher, - MediaQuerySet* media) { - return new MediaQueryList(context, matcher, media); + RefPtr media) { + return new MediaQueryList(context, matcher, RefPtr(media)); } MediaQueryList::MediaQueryList(ExecutionContext* context, MediaQueryMatcher* matcher, - MediaQuerySet* media) + RefPtr media) : ContextLifecycleObserver(context), m_matcher(matcher), m_media(media), @@ -116,7 +116,6 @@ DEFINE_TRACE(MediaQueryList) { visitor->trace(m_matcher); - visitor->trace(m_media); visitor->trace(m_listeners); EventTargetWithInlineData::trace(visitor); ContextLifecycleObserver::trace(visitor); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryList.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryList.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryList.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryList.h 2017-05-09 19:03:00.000000000 +0000 @@ -52,7 +52,7 @@ public: static MediaQueryList* create(ExecutionContext*, MediaQueryMatcher*, - MediaQuerySet*); + RefPtr); ~MediaQueryList() override; String media() const; @@ -86,12 +86,12 @@ ExecutionContext* getExecutionContext() const override; private: - MediaQueryList(ExecutionContext*, MediaQueryMatcher*, MediaQuerySet*); + MediaQueryList(ExecutionContext*, MediaQueryMatcher*, RefPtr); bool updateMatches(); Member m_matcher; - Member m_media; + RefPtr m_media; using ListenerList = HeapListHashSet>; ListenerList m_listeners; bool m_matchesDirty; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryMatcher.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryMatcher.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryMatcher.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryMatcher.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -66,7 +66,7 @@ m_evaluator = createEvaluator(); if (m_evaluator) - return m_evaluator->eval(media); + return m_evaluator->eval(*media); return false; } @@ -75,7 +75,7 @@ if (!m_document) return nullptr; - MediaQuerySet* media = MediaQuerySet::create(query); + RefPtr media = MediaQuerySet::create(query); return MediaQueryList::create(m_document, this, media); } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryMatcherTest.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryMatcherTest.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQueryMatcherTest.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQueryMatcherTest.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -17,11 +17,11 @@ DummyPageHolder::create(IntSize(500, 500)); MediaQueryMatcher* matcher = MediaQueryMatcher::create(pageHolder->document()); - MediaQuerySet* querySet = MediaQuerySet::create(MediaTypeNames::all); - ASSERT_TRUE(matcher->evaluate(querySet)); + RefPtr querySet = MediaQuerySet::create(MediaTypeNames::all); + ASSERT_TRUE(matcher->evaluate(querySet.get())); matcher->documentDetached(); - ASSERT_FALSE(matcher->evaluate(querySet)); + ASSERT_FALSE(matcher->evaluate(querySet.get())); } } // namespace blink diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -182,7 +182,7 @@ }; for (unsigned i = 0; testCases[i].input; ++i) { - MediaQuerySet* querySet = MediaQuerySet::create(testCases[i].input); + RefPtr querySet = MediaQuerySet::create(testCases[i].input); testMediaQuery(testCases[i], *querySet); } } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/MediaConditionTest.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/MediaConditionTest.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/MediaConditionTest.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/MediaConditionTest.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -38,7 +38,7 @@ // FIXME: We should test comma-seperated media conditions for (unsigned i = 0; testCases[i].input; ++i) { CSSTokenizer tokenizer(testCases[i].input); - MediaQuerySet* mediaConditionQuerySet = + RefPtr mediaConditionQuerySet = MediaQueryParser::parseMediaCondition(tokenizer.tokenRange()); ASSERT_EQ(mediaConditionQuerySet->queryVector().size(), (unsigned)1); String queryText = mediaConditionQuerySet->queryVector()[0]->cssText(); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -10,15 +10,17 @@ namespace blink { -MediaQuerySet* MediaQueryParser::parseMediaQuerySet(const String& queryString) { +RefPtr MediaQueryParser::parseMediaQuerySet( + const String& queryString) { return parseMediaQuerySet(CSSTokenizer(queryString).tokenRange()); } -MediaQuerySet* MediaQueryParser::parseMediaQuerySet(CSSParserTokenRange range) { +RefPtr MediaQueryParser::parseMediaQuerySet( + CSSParserTokenRange range) { return MediaQueryParser(MediaQuerySetParser).parseImpl(range); } -MediaQuerySet* MediaQueryParser::parseMediaCondition( +RefPtr MediaQueryParser::parseMediaCondition( CSSParserTokenRange range) { return MediaQueryParser(MediaConditionParser).parseImpl(range); } @@ -225,7 +227,7 @@ } // The state machine loop -MediaQuerySet* MediaQueryParser::parseImpl(CSSParserTokenRange range) { +RefPtr MediaQueryParser::parseImpl(CSSParserTokenRange range) { while (!range.atEnd()) processToken(range.consume()); @@ -256,20 +258,18 @@ m_expressions.clear(); } -MediaQuery* MediaQueryData::takeMediaQuery() { - MediaQuery* mediaQuery = MediaQuery::create( +std::unique_ptr MediaQueryData::takeMediaQuery() { + std::unique_ptr mediaQuery = MediaQuery::create( m_restrictor, std::move(m_mediaType), std::move(m_expressions)); clear(); return mediaQuery; } bool MediaQueryData::addExpression() { - MediaQueryExp* expression = - MediaQueryExp::createIfValid(m_mediaFeature, m_valueList); - bool isValid = !!expression; + MediaQueryExp expression = MediaQueryExp::create(m_mediaFeature, m_valueList); m_expressions.push_back(expression); m_valueList.clear(); - return isValid; + return expression.isValid(); } bool MediaQueryData::tryAddParserToken(CSSParserTokenType type, diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h 2017-05-09 19:03:00.000000000 +0000 @@ -36,7 +36,7 @@ bool addExpression(); bool tryAddParserToken(CSSParserTokenType, const CSSParserToken&); void setMediaType(const String&); - MediaQuery* takeMediaQuery(); + std::unique_ptr takeMediaQuery(); inline bool currentMediaQueryChanged() const { return (m_restrictor != MediaQuery::None || m_mediaTypeSet || @@ -56,9 +56,9 @@ WTF_MAKE_NONCOPYABLE(MediaQueryParser); public: - static MediaQuerySet* parseMediaQuerySet(const String&); - static MediaQuerySet* parseMediaQuerySet(CSSParserTokenRange); - static MediaQuerySet* parseMediaCondition(CSSParserTokenRange); + static RefPtr parseMediaQuerySet(const String&); + static RefPtr parseMediaQuerySet(CSSParserTokenRange); + static RefPtr parseMediaCondition(CSSParserTokenRange); private: enum ParserType { @@ -69,7 +69,7 @@ MediaQueryParser(ParserType); virtual ~MediaQueryParser(); - MediaQuerySet* parseImpl(CSSParserTokenRange); + RefPtr parseImpl(CSSParserTokenRange); void processToken(const CSSParserToken&); @@ -95,7 +95,7 @@ State m_state; ParserType m_parserType; MediaQueryData m_mediaQueryData; - Member m_querySet; + RefPtr m_querySet; MediaQueryBlockWatcher m_blockWatcher; const static State ReadRestrictor; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -53,7 +53,7 @@ } bool SizesAttributeParser::mediaConditionMatches( - MediaQuerySet* mediaCondition) { + const MediaQuerySet& mediaCondition) { // A Media Condition cannot have a media type other then screen. MediaQueryEvaluator mediaQueryEvaluator(*m_mediaValues); return mediaQueryEvaluator.eval(mediaCondition); @@ -80,9 +80,10 @@ if (!calculateLengthInPixels( range.makeSubRange(lengthTokenStart, lengthTokenEnd), length)) continue; - MediaQuerySet* mediaCondition = MediaQueryParser::parseMediaCondition( - range.makeSubRange(mediaConditionStart, lengthTokenStart)); - if (!mediaCondition || !mediaConditionMatches(mediaCondition)) + RefPtr mediaCondition = + MediaQueryParser::parseMediaCondition( + range.makeSubRange(mediaConditionStart, lengthTokenStart)); + if (!mediaCondition || !mediaConditionMatches(*mediaCondition)) continue; m_length = length; m_lengthWasSet = true; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.h 2017-05-09 19:03:00.000000000 +0000 @@ -26,10 +26,10 @@ bool parse(CSSParserTokenRange); float effectiveSize(); bool calculateLengthInPixels(CSSParserTokenRange, float& result); - bool mediaConditionMatches(MediaQuerySet* mediaCondition); + bool mediaConditionMatches(const MediaQuerySet& mediaCondition); float effectiveSizeDefaultValue(); - Member m_mediaCondition; + RefPtr m_mediaCondition; Member m_mediaValues; float m_length; bool m_lengthWasSet; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/MediaQueryResult.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/MediaQueryResult.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/MediaQueryResult.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/MediaQueryResult.h 2017-05-09 19:03:00.000000000 +0000 @@ -29,21 +29,19 @@ namespace blink { -class MediaQueryResult : public GarbageCollected { - WTF_MAKE_NONCOPYABLE(MediaQueryResult); +class MediaQueryResult { + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); public: MediaQueryResult(const MediaQueryExp& expr, bool result) - : m_expression(&expr), m_result(result) {} + : m_expression(expr), m_result(result) {} - DEFINE_INLINE_TRACE() { visitor->trace(m_expression); } - - const MediaQueryExp* expression() const { return m_expression; } + const MediaQueryExp& expression() const { return m_expression; } bool result() const { return m_result; } private: - Member m_expression; + const MediaQueryExp m_expression; bool m_result; }; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -253,8 +253,6 @@ DEFINE_TRACE(ScopedStyleResolver) { visitor->trace(m_scope); visitor->trace(m_authorStyleSheets); - visitor->trace(m_viewportDependentMediaQueryResults); - visitor->trace(m_deviceDependentMediaQueryResults); visitor->trace(m_keyframesRuleMap); visitor->trace(m_treeBoundaryCrossingRuleSet); } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h 2017-05-09 19:03:00.000000000 +0000 @@ -43,7 +43,8 @@ // This class selects a ComputedStyle for a given element based on a collection // of stylesheets. -class ScopedStyleResolver final : public GarbageCollected { +class ScopedStyleResolver final + : public GarbageCollectedFinalized { WTF_MAKE_NONCOPYABLE(ScopedStyleResolver); public: diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -103,7 +103,7 @@ } else if (rule->isMediaRule()) { StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); if (!mediaRule->mediaQueries() || - m_initialViewportMedium->eval(mediaRule->mediaQueries(), + m_initialViewportMedium->eval(*mediaRule->mediaQueries(), &m_viewportDependentMediaQueryResults, &m_deviceDependentMediaQueryResults)) collectViewportChildRules(mediaRule->childRules(), origin); @@ -123,7 +123,7 @@ if (!importRule->styleSheet()->hasViewportRule()) continue; if (importRule->mediaQueries() && - m_initialViewportMedium->eval(importRule->mediaQueries(), + m_initialViewportMedium->eval(*importRule->mediaQueries(), &m_viewportDependentMediaQueryResults, &m_deviceDependentMediaQueryResults)) collectViewportRulesFromAuthorSheetContents(*importRule->styleSheet()); @@ -144,7 +144,7 @@ if (!contents.hasViewportRule() && contents.importRules().isEmpty()) return; if (sheet.mediaQueries() && - !m_initialViewportMedium->eval(sheet.mediaQueries(), + !m_initialViewportMedium->eval(*sheet.mediaQueries(), &m_viewportDependentMediaQueryResults, &m_deviceDependentMediaQueryResults)) return; @@ -304,8 +304,8 @@ auto& results = m_viewportDependentMediaQueryResults; for (unsigned i = 0; i < results.size(); i++) { - if (m_initialViewportMedium->eval(results[i]->expression()) != - results[i]->result()) { + if (m_initialViewportMedium->eval(results[i].expression()) != + results[i].result()) { m_needsUpdate = CollectRules; break; } @@ -338,8 +338,6 @@ visitor->trace(m_document); visitor->trace(m_propertySet); visitor->trace(m_initialViewportMedium); - visitor->trace(m_viewportDependentMediaQueryResults); - visitor->trace(m_deviceDependentMediaQueryResults); } } // namespace blink diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h 2017-05-09 19:03:00.000000000 +0000 @@ -43,7 +43,7 @@ class StyleRuleViewport; class CORE_EXPORT ViewportStyleResolver - : public GarbageCollected { + : public GarbageCollectedFinalized { public: static ViewportStyleResolver* create(Document& document) { return new ViewportStyleResolver(document); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/RuleFeature.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/RuleFeature.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/RuleFeature.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/RuleFeature.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -1206,8 +1206,6 @@ DEFINE_TRACE(RuleFeatureSet) { visitor->trace(m_siblingRules); visitor->trace(m_uncommonAttributeRules); - visitor->trace(m_viewportDependentMediaQueryResults); - visitor->trace(m_deviceDependentMediaQueryResults); } void RuleFeatureSet::InvalidationSetFeatures::add( diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/RuleSet.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/RuleSet.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/RuleSet.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/RuleSet.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -302,7 +302,7 @@ } else if (rule->isMediaRule()) { StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); if (!mediaRule->mediaQueries() || - medium.eval(mediaRule->mediaQueries(), + medium.eval(*mediaRule->mediaQueries(), &m_features.viewportDependentMediaQueryResults(), &m_features.deviceDependentMediaQueryResults())) addChildRules(mediaRule->childRules(), medium, addRuleFlags); @@ -330,7 +330,7 @@ StyleRuleImport* importRule = importRules[i].get(); if (importRule->styleSheet() && (!importRule->mediaQueries() || - medium.eval(importRule->mediaQueries(), + medium.eval(*importRule->mediaQueries(), &m_features.viewportDependentMediaQueryResults(), &m_features.deviceDependentMediaQueryResults()))) addRulesFromSheet(importRule->styleSheet(), medium, addRuleFlags); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleMedia.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleMedia.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleMedia.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleMedia.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -53,12 +53,12 @@ if (!documentElement) return false; - MediaQuerySet* media = MediaQuerySet::create(); + RefPtr media = MediaQuerySet::create(); if (!media->set(query)) return false; MediaQueryEvaluator screenEval(frame()); - return screenEval.eval(media); + return screenEval.eval(*media); } DEFINE_TRACE(StyleMedia) { diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRule.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRule.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRule.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRule.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -352,7 +352,7 @@ : StyleRuleGroup(conditionRule), m_conditionText(conditionRule.m_conditionText) {} -StyleRuleMedia::StyleRuleMedia(MediaQuerySet* media, +StyleRuleMedia::StyleRuleMedia(RefPtr media, HeapVector>& adoptRules) : StyleRuleCondition(Media, adoptRules), m_mediaQueries(media) {} @@ -363,7 +363,6 @@ } DEFINE_TRACE_AFTER_DISPATCH(StyleRuleMedia) { - visitor->trace(m_mediaQueries); StyleRuleCondition::traceAfterDispatch(visitor); } diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRule.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRule.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRule.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRule.h 2017-05-09 19:03:00.000000000 +0000 @@ -238,7 +238,7 @@ class CORE_EXPORT StyleRuleMedia : public StyleRuleCondition { public: - static StyleRuleMedia* create(MediaQuerySet* media, + static StyleRuleMedia* create(RefPtr media, HeapVector>& adoptRules) { return new StyleRuleMedia(media, adoptRules); } @@ -250,10 +250,11 @@ DECLARE_TRACE_AFTER_DISPATCH(); private: - StyleRuleMedia(MediaQuerySet*, HeapVector>& adoptRules); + StyleRuleMedia(RefPtr, + HeapVector>& adoptRules); StyleRuleMedia(const StyleRuleMedia&); - Member m_mediaQueries; + RefPtr m_mediaQueries; }; class StyleRuleSupports : public StyleRuleCondition { diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRuleImport.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRuleImport.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRuleImport.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRuleImport.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -32,11 +32,12 @@ namespace blink { StyleRuleImport* StyleRuleImport::create(const String& href, - MediaQuerySet* media) { + RefPtr media) { return new StyleRuleImport(href, media); } -StyleRuleImport::StyleRuleImport(const String& href, MediaQuerySet* media) +StyleRuleImport::StyleRuleImport(const String& href, + RefPtr media) : StyleRuleBase(Import), m_parentStyleSheet(nullptr), m_styleSheetClient(new ImportedStyleSheetClient(this)), @@ -58,7 +59,6 @@ DEFINE_TRACE_AFTER_DISPATCH(StyleRuleImport) { visitor->trace(m_styleSheetClient); visitor->trace(m_parentStyleSheet); - visitor->trace(m_mediaQueries); visitor->trace(m_styleSheet); visitor->trace(m_resource); StyleRuleBase::traceAfterDispatch(visitor); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRuleImport.h chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRuleImport.h --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/css/StyleRuleImport.h 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/css/StyleRuleImport.h 2017-05-09 19:03:00.000000000 +0000 @@ -36,7 +36,7 @@ USING_PRE_FINALIZER(StyleRuleImport, dispose); public: - static StyleRuleImport* create(const String& href, MediaQuerySet*); + static StyleRuleImport* create(const String& href, RefPtr); ~StyleRuleImport(); @@ -93,7 +93,7 @@ const String& charset, const CSSStyleSheetResource*); - StyleRuleImport(const String& href, MediaQuerySet*); + StyleRuleImport(const String& href, RefPtr); void dispose(); @@ -101,7 +101,7 @@ Member m_styleSheetClient; String m_strHref; - Member m_mediaQueries; + RefPtr m_mediaQueries; Member m_styleSheet; Member m_resource; bool m_loading; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/dom/StyleElement.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/dom/StyleElement.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/dom/StyleElement.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/dom/StyleElement.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -150,11 +150,11 @@ // If type is empty or CSS, this is a CSS style sheet. const AtomicString& type = this->type(); if (isCSS(element, type) && passesContentSecurityPolicyChecks) { - MediaQuerySet* mediaQueries = MediaQuerySet::create(media()); + RefPtr mediaQueries = MediaQuerySet::create(media()); MediaQueryEvaluator screenEval("screen"); MediaQueryEvaluator printEval("print"); - if (screenEval.eval(mediaQueries) || printEval.eval(mediaQueries)) { + if (screenEval.eval(*mediaQueries) || printEval.eval(*mediaQueries)) { m_loading = true; TextPosition startPosition = m_startPosition == TextPosition::belowRangePosition() diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/dom/StyleEngine.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/dom/StyleEngine.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/dom/StyleEngine.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/dom/StyleEngine.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -1110,7 +1110,7 @@ const auto& results = m_globalRuleSet.ruleFeatureSet().viewportDependentMediaQueryResults(); for (unsigned i = 0; i < results.size(); ++i) { - if (evaluator.eval(results[i]->expression()) != results[i]->result()) + if (evaluator.eval(results[i].expression()) != results[i].result()) return true; } return false; @@ -1121,7 +1121,7 @@ const auto& results = m_globalRuleSet.ruleFeatureSet().deviceDependentMediaQueryResults(); for (unsigned i = 0; i < results.size(); ++i) { - if (evaluator.eval(results[i]->expression()) != results[i]->result()) + if (evaluator.eval(results[i].expression()) != results[i].result()) return true; } return false; diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -75,7 +75,7 @@ return; } - MediaQuerySet* set = MediaQuerySet::create(media); + RefPtr set = MediaQuerySet::create(media); m_mediaQueryList = MediaQueryList::create(&document(), &document().mediaQueryMatcher(), set); addMediaQueryListListener(); diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/html/LinkStyle.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/html/LinkStyle.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/html/LinkStyle.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/html/LinkStyle.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -313,9 +313,9 @@ bool mediaQueryMatches = true; LocalFrame* frame = loadingFrame(); if (!m_owner->media().isEmpty() && frame) { - MediaQuerySet* media = MediaQuerySet::create(m_owner->media()); + RefPtr media = MediaQuerySet::create(m_owner->media()); MediaQueryEvaluator evaluator(frame); - mediaQueryMatches = evaluator.eval(media); + mediaQueryMatches = evaluator.eval(*media); } // Don't hold up layout tree construction and script execution on diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -127,9 +127,9 @@ static bool mediaAttributeMatches(const MediaValuesCached& mediaValues, const String& attributeValue) { - MediaQuerySet* mediaQueries = MediaQuerySet::create(attributeValue); + RefPtr mediaQueries = MediaQuerySet::create(attributeValue); MediaQueryEvaluator mediaQueryEvaluator(mediaValues); - return mediaQueryEvaluator.eval(mediaQueries); + return mediaQueryEvaluator.eval(*mediaQueries); } class TokenPreloadScanner::StartTagScanner { diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -1580,7 +1580,8 @@ } const MediaQuerySet* queries = media->queries(); - const HeapVector>& queryVector = queries->queryVector(); + const Vector>& queryVector = + queries->queryVector(); LocalFrame* frame = nullptr; if (parentStyleSheet) { if (Document* document = parentStyleSheet->ownerDocument()) @@ -1597,15 +1598,15 @@ MediaValues* mediaValues = MediaValues::createDynamicIfFrameExists(frame); bool hasMediaQueryItems = false; for (size_t i = 0; i < queryVector.size(); ++i) { - MediaQuery* query = queryVector.at(i).get(); - const ExpressionHeapVector& expressions = query->expressions(); + MediaQuery& query = *queryVector.at(i); + const ExpressionHeapVector& expressions = query.expressions(); std::unique_ptr> expressionArray = protocol::Array::create(); bool hasExpressionItems = false; for (size_t j = 0; j < expressions.size(); ++j) { - MediaQueryExp* mediaQueryExp = expressions.at(j).get(); - MediaQueryExpValue expValue = mediaQueryExp->expValue(); + const MediaQueryExp& mediaQueryExp = expressions.at(j); + MediaQueryExpValue expValue = mediaQueryExp.expValue(); if (!expValue.isValue) continue; const char* valueName = @@ -1614,7 +1615,7 @@ mediaQueryExpression = protocol::CSS::MediaQueryExpression::create() .setValue(expValue.value) .setUnit(String(valueName)) - .setFeature(mediaQueryExp->mediaFeature()) + .setFeature(mediaQueryExp.mediaFeature()) .build(); if (inspectorStyleSheet && media->parentRule()) diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/layout/LayoutText.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/layout/LayoutText.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/layout/LayoutText.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/layout/LayoutText.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -1728,7 +1728,8 @@ void LayoutText::setText(PassRefPtr text, bool force) { ASSERT(text); - if (!force && equal(m_text.impl(), text.get())) + bool equalText = equal(m_text.impl(), text.get()); + if (equalText && !force) return; setTextInternal(std::move(text)); @@ -1741,8 +1742,14 @@ LayoutInvalidationReason::TextChanged); m_knownToHaveNoOverflowAndNoFallbackFonts = false; - if (AXObjectCache* cache = document().existingAXObjectCache()) - cache->textChanged(this); + // Don't bother updating the AX tree if there's no change. Otherwise, when + // typing in password fields, we would announce each "dot" twice: once when a + // character is typed, and second when that character is hidden. + if (!equalText) { + AXObjectCache* cache = document().existingAXObjectCache(); + if (cache) + cache->textChanged(this); + } TextAutosizer* textAutosizer = document().textAutosizer(); if (textAutosizer) diff -Nru chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/loader/LinkLoader.cpp chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/loader/LinkLoader.cpp --- chromium-browser-58.0.3029.96/third_party/WebKit/Source/core/loader/LinkLoader.cpp 2017-05-02 19:03:08.000000000 +0000 +++ chromium-browser-58.0.3029.110/third_party/WebKit/Source/core/loader/LinkLoader.cpp 2017-05-09 19:03:00.000000000 +0000 @@ -294,9 +294,9 @@ } // Preload only if media matches - MediaQuerySet* mediaQueries = MediaQuerySet::create(media); + RefPtr mediaQueries = MediaQuerySet::create(media); MediaQueryEvaluator evaluator(*mediaValues); - if (!evaluator.eval(mediaQueries)) + if (!evaluator.eval(*mediaQueries)) return nullptr; } if (caller == LinkCalledFromHeader) diff -Nru chromium-browser-58.0.3029.96/v8/include/v8-version.h chromium-browser-58.0.3029.110/v8/include/v8-version.h --- chromium-browser-58.0.3029.96/v8/include/v8-version.h 2017-05-02 19:04:09.000000000 +0000 +++ chromium-browser-58.0.3029.110/v8/include/v8-version.h 2017-05-09 19:04:03.000000000 +0000 @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 8 #define V8_BUILD_NUMBER 283 -#define V8_PATCH_LEVEL 37 +#define V8_PATCH_LEVEL 38 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff -Nru chromium-browser-58.0.3029.96/v8/src/arm/code-stubs-arm.cc chromium-browser-58.0.3029.110/v8/src/arm/code-stubs-arm.cc --- chromium-browser-58.0.3029.96/v8/src/arm/code-stubs-arm.cc 2017-05-02 19:04:09.000000000 +0000 +++ chromium-browser-58.0.3029.110/v8/src/arm/code-stubs-arm.cc 2017-05-09 19:04:03.000000000 +0000 @@ -2655,6 +2655,7 @@ void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { if (masm->isolate()->function_entry_hook() != NULL) { ProfileEntryHookStub stub(masm->isolate()); + masm->MaybeCheckConstPool(); PredictableCodeSizeScope predictable(masm); predictable.ExpectSize(masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize); diff -Nru chromium-browser-58.0.3029.96/v8/src/arm/macro-assembler-arm.cc chromium-browser-58.0.3029.110/v8/src/arm/macro-assembler-arm.cc --- chromium-browser-58.0.3029.96/v8/src/arm/macro-assembler-arm.cc 2017-05-02 19:04:09.000000000 +0000 +++ chromium-browser-58.0.3029.110/v8/src/arm/macro-assembler-arm.cc 2017-05-09 19:04:03.000000000 +0000 @@ -88,13 +88,11 @@ return CallSize(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond); } - -void MacroAssembler::Call(Address target, - RelocInfo::Mode rmode, - Condition cond, - TargetAddressStorageMode mode) { +void MacroAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond, + TargetAddressStorageMode mode, + bool check_constant_pool) { // Check if we have to emit the constant pool before we block it. - MaybeCheckConstPool(); + if (check_constant_pool) MaybeCheckConstPool(); // Block constant pool for the call instruction sequence. BlockConstPoolScope block_const_pool(this); Label start; @@ -142,7 +140,8 @@ void MacroAssembler::Call(Handle code, RelocInfo::Mode rmode, TypeFeedbackId ast_id, Condition cond, - TargetAddressStorageMode mode) { + TargetAddressStorageMode mode, + bool check_constant_pool) { Label start; bind(&start); DCHECK(RelocInfo::IsCodeTarget(rmode)); @@ -2416,7 +2415,8 @@ TypeFeedbackId ast_id, Condition cond) { DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. - Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond); + Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond, + CAN_INLINE_TARGET_ADDRESS, false); } diff -Nru chromium-browser-58.0.3029.96/v8/src/arm/macro-assembler-arm.h chromium-browser-58.0.3029.110/v8/src/arm/macro-assembler-arm.h --- chromium-browser-58.0.3029.96/v8/src/arm/macro-assembler-arm.h 2017-05-02 19:04:09.000000000 +0000 +++ chromium-browser-58.0.3029.110/v8/src/arm/macro-assembler-arm.h 2017-05-09 19:04:03.000000000 +0000 @@ -107,12 +107,13 @@ void Jump(Address target, RelocInfo::Mode rmode, Condition cond = al); void Jump(Handle code, RelocInfo::Mode rmode, Condition cond = al); void Call(Register target, Condition cond = al); - void Call(Address target, RelocInfo::Mode rmode, - Condition cond = al, - TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS); + void Call(Address target, RelocInfo::Mode rmode, Condition cond = al, + TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS, + bool check_constant_pool = true); void Call(Handle code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, TypeFeedbackId ast_id = TypeFeedbackId::None(), Condition cond = al, - TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS); + TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS, + bool check_constant_pool = true); int CallSize(Handle code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, TypeFeedbackId ast_id = TypeFeedbackId::None(), diff -Nru chromium-browser-58.0.3029.96/v8/src/crankshaft/arm/lithium-codegen-arm.cc chromium-browser-58.0.3029.110/v8/src/crankshaft/arm/lithium-codegen-arm.cc --- chromium-browser-58.0.3029.96/v8/src/crankshaft/arm/lithium-codegen-arm.cc 2017-05-02 19:04:10.000000000 +0000 +++ chromium-browser-58.0.3029.110/v8/src/crankshaft/arm/lithium-codegen-arm.cc 2017-05-09 19:04:03.000000000 +0000 @@ -688,7 +688,7 @@ // Block literal pool emission to ensure nop indicating no inlined smi code // is in the correct position. Assembler::BlockConstPoolScope block_const_pool(masm()); - __ Call(code, mode, TypeFeedbackId::None(), al, storage_mode); + __ Call(code, mode, TypeFeedbackId::None(), al, storage_mode, false); RecordSafepointWithLazyDeopt(instr, safepoint_mode); // Signal that we don't inline smi code before these stubs in the @@ -5228,6 +5228,7 @@ __ cmp(sp, Operand(ip)); __ b(hs, &done); Handle stack_check = isolate()->builtins()->StackCheck(); + masm()->MaybeCheckConstPool(); PredictableCodeSizeScope predictable(masm()); predictable.ExpectSize(CallCodeSize(stack_check, RelocInfo::CODE_TARGET)); DCHECK(instr->context()->IsRegister()); diff -Nru chromium-browser-58.0.3029.96/v8/src/full-codegen/arm/full-codegen-arm.cc chromium-browser-58.0.3029.110/v8/src/full-codegen/arm/full-codegen-arm.cc --- chromium-browser-58.0.3029.96/v8/src/full-codegen/arm/full-codegen-arm.cc 2017-05-02 19:04:10.000000000 +0000 +++ chromium-browser-58.0.3029.110/v8/src/full-codegen/arm/full-codegen-arm.cc 2017-05-09 19:04:03.000000000 +0000 @@ -312,10 +312,12 @@ __ cmp(sp, Operand(ip)); __ b(hs, &ok); Handle stack_check = isolate()->builtins()->StackCheck(); + masm_->MaybeCheckConstPool(); PredictableCodeSizeScope predictable(masm_); predictable.ExpectSize( masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); - __ Call(stack_check, RelocInfo::CODE_TARGET); + __ Call(stack_check, RelocInfo::CODE_TARGET, TypeFeedbackId::None(), al, + CAN_INLINE_TARGET_ADDRESS, false); __ bind(&ok); }