diff --git a/AUTHORS b/AUTHORS index e39f227..7d172b41 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -505,6 +505,7 @@ Naoki Takano <takano.naoki@gmail.com> Naveen Bobbili <naveenbobbili@motorola.com> Naveen Bobbili <qghc36@motorola.com> +Naveen Kumar Devaraj <devarajn@amazon.com> Naveen Kumar S G <naveensg@samsung.com> Nayan Kumar K <qtc746@motorola.com> Nedeljko Babic <nedeljko.babic@imgtec.com>
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java index ff33c778..846722b 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
@@ -4,15 +4,10 @@ package org.chromium.android_webview; -import android.content.Context; -import android.content.Intent; import android.view.KeyEvent; -import org.chromium.base.Log; import org.chromium.content.browser.ContentViewClient; -import java.net.URISyntaxException; - /** * ContentViewClient implementation for WebView */ @@ -22,40 +17,12 @@ private final AwContentsClient mAwContentsClient; private final AwSettings mAwSettings; private final AwContents mAwContents; - private final Context mContext; - public AwContentViewClient(AwContentsClient awContentsClient, AwSettings awSettings, - AwContents awContents, Context context) { + public AwContentViewClient( + AwContentsClient awContentsClient, AwSettings awSettings, AwContents awContents) { mAwContentsClient = awContentsClient; mAwSettings = awSettings; mAwContents = awContents; - mContext = context; - } - - @Override - public void onBackgroundColorChanged(int color) { - mAwContentsClient.onBackgroundColorChanged(color); - } - - @Override - public void onStartContentIntent(Context context, String contentUrl, boolean isMainFrame) { - // Make sure that this URL is a valid scheme for this callback if interpreted as an intent, - // even though we don't dispatch it as an intent here, because many WebView apps will once - // it reaches them. - String scheme = null; - try { - Intent intent = Intent.parseUri(contentUrl, Intent.URI_INTENT_SCHEME); - scheme = intent.getScheme(); - } catch (URISyntaxException e) { - // Just don't set the scheme, it will be rejected. - } - if (!isAcceptableContentIntentScheme(scheme)) { - Log.w(TAG, "Invalid scheme for URI %s", contentUrl); - return; - } - // Comes from WebViewImpl::detectContentOnTouch in Blink, so must be user-initiated, and - // isn't a redirect. - mAwContentsClient.shouldIgnoreNavigation(context, contentUrl, isMainFrame, true, false); } @Override @@ -63,7 +30,7 @@ if (mAwContentsClient.hasWebViewClient()) { // The check below is reflecting Chrome's behavior and is a workaround for // http://b/7697782. - if (!ContentViewClient.shouldPropagateKey(event.getKeyCode())) return true; + if (!shouldPropagateKey(event.getKeyCode())) return true; return mAwContentsClient.shouldOverrideKeyEvent(event); }
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index abf2191..a3dd23d 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -758,7 +758,7 @@ mAwViewMethods = new AwViewMethodsImpl(); mFullScreenTransitionsState = new FullScreenTransitionsState( mContainerView, mInternalAccessAdapter, mAwViewMethods); - mContentViewClient = new AwContentViewClient(contentsClient, settings, this, mContext); + mContentViewClient = new AwContentViewClient(contentsClient, settings, this); mLayoutSizer = dependencyFactory.createLayoutSizer(); mSettings = settings; mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); @@ -1051,8 +1051,8 @@ mWindowAndroid = getWindowAndroid(mContext); mContentViewCore = new ContentViewCore(mContext, PRODUCT_VERSION); - mViewAndroidDelegate = new AwViewAndroidDelegate(mContainerView, - mContentViewCore.getRenderCoordinates()); + mViewAndroidDelegate = new AwViewAndroidDelegate( + mContainerView, mContentsClient, mContentViewCore.getRenderCoordinates()); initializeContentViewCore(mContentViewCore, mContext, mViewAndroidDelegate, mInternalAccessAdapter, webContents, new AwGestureStateListener(), mContentViewClient, mWindowAndroid.getWindowAndroid());
diff --git a/android_webview/java/src/org/chromium/android_webview/AwViewAndroidDelegate.java b/android_webview/java/src/org/chromium/android_webview/AwViewAndroidDelegate.java index 80753a42..cd1d0dc 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwViewAndroidDelegate.java +++ b/android_webview/java/src/org/chromium/android_webview/AwViewAndroidDelegate.java
@@ -4,6 +4,7 @@ package org.chromium.android_webview; +import android.content.Intent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -21,6 +22,9 @@ * Implementation of the abstract class {@link ViewAndroidDelegate} for WebView. */ public class AwViewAndroidDelegate extends ViewAndroidDelegate { + /** Used for logging. */ + private static final String TAG = "AwVAD"; + /** * The current container view. This view can be updated with * {@link #updateCurrentContainerView()}. @@ -33,6 +37,7 @@ */ private final Map<View, Position> mAnchorViews = new LinkedHashMap<>(); + private final AwContentsClient mContentsClient; private final RenderCoordinates mRenderCoordinates; /** @@ -59,8 +64,10 @@ } @VisibleForTesting - public AwViewAndroidDelegate(ViewGroup containerView, RenderCoordinates renderCoordinates) { + public AwViewAndroidDelegate(ViewGroup containerView, AwContentsClient contentsClient, + RenderCoordinates renderCoordinates) { mContainerView = containerView; + mContentsClient = contentsClient; mRenderCoordinates = renderCoordinates; } @@ -137,6 +144,24 @@ } @Override + public void onBackgroundColorChanged(int color) { + mContentsClient.onBackgroundColorChanged(color); + } + + @Override + public void startContentIntent(Intent intent, String contentUrl, boolean isMainFrame) { + // Make sure that this URL is a valid scheme for this callback if interpreted as an intent, + // even though we don't dispatch it as an intent here, because many WebView apps will once + // it reaches them. + assert intent != null; + + // Comes from WebViewImpl::detectContentOnTouch in Blink, so must be user-initiated, and + // isn't a redirect. + mContentsClient.shouldIgnoreNavigation( + mContainerView.getContext(), contentUrl, isMainFrame, true, false); + } + + @Override public ViewGroup getContainerView() { return mContainerView; }
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsAnchorViewTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsAnchorViewTest.java index ea1578e..237eaa565 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsAnchorViewTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsAnchorViewTest.java
@@ -27,7 +27,7 @@ public void setUp() throws Exception { super.setUp(); mContainerView = new FrameLayout(getActivity()); - mViewDelegate = new AwViewAndroidDelegate(mContainerView, new RenderCoordinates()); + mViewDelegate = new AwViewAndroidDelegate(mContainerView, null, new RenderCoordinates()); } @Feature({"AndroidWebView"})
diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn index ada42526..aedff7e 100644 --- a/build/config/linux/BUILD.gn +++ b/build/config/linux/BUILD.gn
@@ -92,5 +92,9 @@ "gobject-2.0", "gthread-2.0", ] + defines = [ + "GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32", + "GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26", + ] } }
diff --git a/chrome/VERSION b/chrome/VERSION index 72740b2..933627eb 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=58 MINOR=0 -BUILD=3022 +BUILD=3023 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java index eda49a7..c6901165 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -106,7 +106,6 @@ import org.chromium.printing.PrintingControllerImpl; import org.chromium.ui.base.LocalizationUtils; import org.chromium.ui.base.PageTransition; -import org.chromium.ui.base.ViewAndroidDelegate; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.mojom.WindowOpenDisposition; @@ -376,26 +375,6 @@ private class TabContentViewClient extends ContentViewClient { @Override - public void onBackgroundColorChanged(int color) { - Tab.this.onBackgroundColorChanged(color); - } - - @Override - public void onTopControlsChanged(float topControlsOffsetY, float topContentOffsetY) { - super.onTopControlsChanged(topControlsOffsetY, topContentOffsetY); - onOffsetsChanged(topControlsOffsetY, mPreviousBottomControlsOffsetY, - topContentOffsetY, isShowingSadTab()); - } - - @Override - public void onBottomControlsChanged(float bottomControlsOffsetY, - float bottomContentOffsetY) { - super.onBottomControlsChanged(bottomControlsOffsetY, bottomContentOffsetY); - onOffsetsChanged(mPreviousTopControlsOffsetY, bottomControlsOffsetY, - mPreviousContentOffsetY, isShowingSadTab()); - } - - @Override public void onImeEvent() { // Some text was set in the page. Don't reuse it if a tab is // open from the same external application, we might lose some @@ -410,33 +389,6 @@ } @Override - public int getSystemWindowInsetLeft() { - ChromeActivity activity = getActivity(); - if (activity != null && activity.getInsetObserverView() != null) { - return activity.getInsetObserverView().getSystemWindowInsetsLeft(); - } - return 0; - } - - @Override - public int getSystemWindowInsetTop() { - ChromeActivity activity = getActivity(); - if (activity != null && activity.getInsetObserverView() != null) { - return activity.getInsetObserverView().getSystemWindowInsetsTop(); - } - return 0; - } - - @Override - public int getSystemWindowInsetRight() { - ChromeActivity activity = getActivity(); - if (activity != null && activity.getInsetObserverView() != null) { - return activity.getInsetObserverView().getSystemWindowInsetsRight(); - } - return 0; - } - - @Override public int getSystemWindowInsetBottom() { ChromeActivity activity = getActivity(); if (activity != null && activity.getInsetObserverView() != null) { @@ -1632,8 +1584,7 @@ ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc); cv.setContentDescription(mThemedApplicationContext.getResources().getString( R.string.accessibility_content_view)); - cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents, - getWindowAndroid()); + cvc.initialize(new TabViewAndroidDelegate(this, cv), cv, webContents, getWindowAndroid()); ChromeActionModeCallback actionModeCallback = new ChromeActionModeCallback( mThemedApplicationContext, this, cvc.getActionModeCallbackHelper()); cvc.setActionModeCallback(actionModeCallback); @@ -2214,7 +2165,7 @@ * Called when the background color for the content changes. * @param color The current for the background. */ - protected void onBackgroundColorChanged(int color) { + void onBackgroundColorChanged(int color) { for (TabObserver observer : mObservers) observer.onBackgroundColorChanged(this, color); } @@ -2514,23 +2465,25 @@ * Called when offset values related with fullscreen functionality has been changed by the * compositor. * @param topControlsOffsetY The Y offset of the top controls in physical pixels. + * {@code Float.NaN} if the value is invalid and the cached value should be used. * @param bottomControlsOffsetY The Y offset of the bottom controls in physical pixels. + * {@code Float.NaN} if the value is invalid and the cached value should be used. * @param contentOffsetY The Y offset of the content in physical pixels. - * @param isNonFullscreenPage Whether a current page is non-fullscreen page or not. */ - private void onOffsetsChanged( - float topControlsOffsetY, float bottomControlsOffsetY, float contentOffsetY, - boolean isNonFullscreenPage) { - mPreviousTopControlsOffsetY = topControlsOffsetY; - mPreviousBottomControlsOffsetY = bottomControlsOffsetY; - mPreviousContentOffsetY = contentOffsetY; + void onOffsetsChanged( + float topControlsOffsetY, float bottomControlsOffsetY, float contentOffsetY) { + if (!Float.isNaN(topControlsOffsetY)) mPreviousTopControlsOffsetY = topControlsOffsetY; + if (!Float.isNaN(bottomControlsOffsetY)) { + mPreviousBottomControlsOffsetY = bottomControlsOffsetY; + } + if (!Float.isNaN(contentOffsetY)) mPreviousContentOffsetY = contentOffsetY; if (mFullscreenManager == null) return; - if (isNonFullscreenPage || isNativePage()) { + if (isShowingSadTab() || isNativePage()) { mFullscreenManager.setPositionsForTabToNonFullscreen(); } else { - mFullscreenManager.setPositionsForTab(topControlsOffsetY, bottomControlsOffsetY, - contentOffsetY); + mFullscreenManager.setPositionsForTab(mPreviousTopControlsOffsetY, + mPreviousBottomControlsOffsetY, mPreviousContentOffsetY); } TabModelImpl.setActualTabSwitchLatencyMetricRequired(); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabViewAndroidDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabViewAndroidDelegate.java new file mode 100644 index 0000000..e4689e0e --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabViewAndroidDelegate.java
@@ -0,0 +1,59 @@ +// 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. + +package org.chromium.chrome.browser.tab; + +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.view.ViewGroup; + +import org.chromium.base.Log; +import org.chromium.base.metrics.RecordUserAction; +import org.chromium.ui.base.ViewAndroidDelegate; + +/** + * Implementation of the abstract class {@link ViewAndroidDelegate} for Chrome. + */ +class TabViewAndroidDelegate extends ViewAndroidDelegate { + /** Used for logging. */ + private static final String TAG = "TabVAD"; + + private final Tab mTab; + private final ViewGroup mContainerView; + + TabViewAndroidDelegate(Tab tab, ViewGroup containerView) { + mTab = tab; + mContainerView = containerView; + } + + @Override + public void onBackgroundColorChanged(int color) { + mTab.onBackgroundColorChanged(color); + } + + @Override + public void onTopControlsChanged(float topControlsOffsetY, float topContentOffsetY) { + mTab.onOffsetsChanged(topControlsOffsetY, Float.NaN, topContentOffsetY); + } + + @Override + public void onBottomControlsChanged(float bottomControlsOffsetY, float bottomContentOffsetY) { + mTab.onOffsetsChanged(Float.NaN, bottomControlsOffsetY, Float.NaN); + } + + @Override + public void startContentIntent(Intent intent, String intentUrl, boolean isMainFrame) { + try { + RecordUserAction.record("Android.ContentDetectorActivated"); + mContainerView.getContext().startActivity(intent); + } catch (ActivityNotFoundException ex) { + Log.w(TAG, "No application can handle %s", intentUrl); + } + } + + @Override + public ViewGroup getContainerView() { + return mContainerView; + } +}
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni index 97cce29..73e6102 100644 --- a/chrome/android/java_sources.gni +++ b/chrome/android/java_sources.gni
@@ -970,6 +970,7 @@ "java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java", "java/src/org/chromium/chrome/browser/tab/TabStateBrowserControlsVisibilityDelegate.java", "java/src/org/chromium/chrome/browser/tab/TabUma.java", + "java/src/org/chromium/chrome/browser/tab/TabViewAndroidDelegate.java", "java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java", "java/src/org/chromium/chrome/browser/tab/TabWebContentsObserver.java", "java/src/org/chromium/chrome/browser/tabmodel/AsyncTabParams.java",
diff --git a/chrome/browser/chromeos/arc/arc_session_manager.cc b/chrome/browser/chromeos/arc/arc_session_manager.cc index 6710fbe..64c3226 100644 --- a/chrome/browser/chromeos/arc/arc_session_manager.cc +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
@@ -60,9 +60,6 @@ // Skip creating UI in unit tests bool g_disable_ui_for_testing = false; -// Use specified ash::ShelfDelegate for unit tests. -ash::ShelfDelegate* g_shelf_delegate_for_testing = nullptr; - // The Android management check is disabled by default, it's used only for // testing. bool g_enable_check_android_management_for_testing = false; @@ -72,14 +69,6 @@ // but present the UI to try again. constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5); -ash::ShelfDelegate* GetShelfDelegate() { - if (g_shelf_delegate_for_testing) - return g_shelf_delegate_for_testing; - if (ash::WmShell::HasInstance()) - return ash::WmShell::Get()->shelf_delegate(); - return nullptr; -} - } // namespace ArcSessionManager::ArcSessionManager( @@ -149,12 +138,6 @@ } // static -void ArcSessionManager::SetShelfDelegateForTesting( - ash::ShelfDelegate* shelf_delegate) { - g_shelf_delegate_for_testing = shelf_delegate; -} - -// static void ArcSessionManager::EnableCheckAndroidManagementForTesting() { g_enable_check_android_management_for_testing = true; } @@ -536,7 +519,9 @@ // Remove the pinned Play Store icon launcher in Shelf. // This is only for non-Managed cases. In managed cases, it is expected // to be "disabled" rather than "removed", so keep it here. - ash::ShelfDelegate* shelf_delegate = GetShelfDelegate(); + auto* shelf_delegate = ash::WmShell::HasInstance() + ? ash::WmShell::Get()->shelf_delegate() + : nullptr; if (shelf_delegate) shelf_delegate->UnpinAppWithID(ArcSupportHost::kHostAppId); }
diff --git a/chrome/browser/chromeos/arc/arc_session_manager.h b/chrome/browser/chromeos/arc/arc_session_manager.h index 6f85e91..d519235 100644 --- a/chrome/browser/chromeos/arc/arc_session_manager.h +++ b/chrome/browser/chromeos/arc/arc_session_manager.h
@@ -22,10 +22,6 @@ class ArcAppLauncher; class Profile; -namespace ash { -class ShelfDelegate; -} - namespace user_prefs { class PrefRegistrySyncable; } @@ -118,7 +114,6 @@ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); static void DisableUIForTesting(); - static void SetShelfDelegateForTesting(ash::ShelfDelegate* shelf_delegate); static void EnableCheckAndroidManagementForTesting(); // Returns true if ARC is allowed to run for the current session.
diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.cc b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.cc index f15330f0..8e00c4e6 100644 --- a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.cc +++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.cc
@@ -56,7 +56,7 @@ storage::WatcherManager* ArcDocumentsProviderBackendDelegate::GetWatcherManager( storage::FileSystemType type) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK_CURRENTLY_ON(BrowserThread::IO); NOTREACHED(); // Non-watchable file system. return nullptr; }
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc index 79aae0f..717de13 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
@@ -7,13 +7,10 @@ #include <sys/statvfs.h> #include <algorithm> -#include <set> #include <utility> -#include <vector> #include "base/files/file_util.h" #include "base/memory/ptr_util.h" -#include "base/memory/weak_ptr.h" #include "base/posix/eintr_wrapper.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -307,6 +304,26 @@ return RespondNow(NoArguments()); } +namespace { + +void PostResponseCallbackTaskToUIThread( + const FileWatchFunctionBase::ResponseCallback& callback, + bool success) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(callback, success)); +} + +void PostNotificationCallbackTaskToUIThread( + const storage::WatcherManager::NotificationCallback& callback, + storage::WatcherManager::ChangeType type) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(callback, type)); +} + +} // namespace + void FileWatchFunctionBase::Respond(bool success) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -336,63 +353,95 @@ return true; } - PerformFileWatchOperation(file_system_context, file_system_url, - extension_id()); + file_manager::EventRouter* const event_router = + file_manager::EventRouterFactory::GetForProfile(GetProfile()); + + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&FileWatchFunctionBase::RunAsyncOnIOThread, + this, file_system_context, file_system_url, + event_router->GetWeakPtr())); return true; } -void FileManagerPrivateInternalAddFileWatchFunction::PerformFileWatchOperation( +void FileWatchFunctionBase::RunAsyncOnIOThread( scoped_refptr<storage::FileSystemContext> file_system_context, const storage::FileSystemURL& file_system_url, - const std::string& extension_id) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - file_manager::EventRouter* const event_router = - file_manager::EventRouterFactory::GetForProfile(GetProfile()); + base::WeakPtr<file_manager::EventRouter> event_router) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); storage::WatcherManager* const watcher_manager = file_system_context->GetWatcherManager(file_system_url.type()); - if (watcher_manager) { - watcher_manager->AddWatcher( - file_system_url, false /* recursive */, + + if (!watcher_manager) { + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind( - &StatusCallbackToResponseCallback, - base::Bind(&FileManagerPrivateInternalAddFileWatchFunction::Respond, - this)), - base::Bind(&file_manager::EventRouter::OnWatcherManagerNotification, - event_router->GetWeakPtr(), file_system_url, extension_id)); + &FileWatchFunctionBase::PerformFallbackFileWatchOperationOnUIThread, + this, file_system_url, event_router)); return; } + PerformFileWatchOperationOnIOThread(file_system_context, watcher_manager, + file_system_url, event_router); +} + +void FileManagerPrivateInternalAddFileWatchFunction:: + PerformFileWatchOperationOnIOThread( + scoped_refptr<storage::FileSystemContext> file_system_context, + storage::WatcherManager* watcher_manager, + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + + watcher_manager->AddWatcher( + file_system_url, false /* recursive */, + base::Bind(&StatusCallbackToResponseCallback, + base::Bind(&PostResponseCallbackTaskToUIThread, + base::Bind(&FileWatchFunctionBase::Respond, this))), + base::Bind( + &PostNotificationCallbackTaskToUIThread, + base::Bind(&file_manager::EventRouter::OnWatcherManagerNotification, + event_router, file_system_url, extension_id()))); +} + +void FileManagerPrivateInternalAddFileWatchFunction:: + PerformFallbackFileWatchOperationOnUIThread( + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(event_router); + // Obsolete. Fallback code if storage::WatcherManager is not implemented. - event_router->AddFileWatch( - file_system_url.path(), file_system_url.virtual_path(), extension_id, - base::Bind(&FileManagerPrivateInternalAddFileWatchFunction::Respond, - this)); + event_router->AddFileWatch(file_system_url.path(), + file_system_url.virtual_path(), extension_id(), + base::Bind(&FileWatchFunctionBase::Respond, this)); } void FileManagerPrivateInternalRemoveFileWatchFunction:: - PerformFileWatchOperation( + PerformFileWatchOperationOnIOThread( scoped_refptr<storage::FileSystemContext> file_system_context, + storage::WatcherManager* watcher_manager, const storage::FileSystemURL& file_system_url, - const std::string& extension_id) { + base::WeakPtr<file_manager::EventRouter> event_router) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + + watcher_manager->RemoveWatcher( + file_system_url, false /* recursive */, + base::Bind( + &StatusCallbackToResponseCallback, + base::Bind(&PostResponseCallbackTaskToUIThread, + base::Bind(&FileWatchFunctionBase::Respond, this)))); +} + +void FileManagerPrivateInternalRemoveFileWatchFunction:: + PerformFallbackFileWatchOperationOnUIThread( + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - - file_manager::EventRouter* const event_router = - file_manager::EventRouterFactory::GetForProfile(GetProfile()); - - storage::WatcherManager* const watcher_manager = - file_system_context->GetWatcherManager(file_system_url.type()); - if (watcher_manager) { - watcher_manager->RemoveWatcher( - file_system_url, false /* recursive */, - base::Bind(&StatusCallbackToResponseCallback, - base::Bind(&FileWatchFunctionBase::Respond, this))); - return; - } + DCHECK(event_router); // Obsolete. Fallback code if storage::WatcherManager is not implemented. - event_router->RemoveFileWatch(file_system_url.path(), extension_id); + event_router->RemoveFileWatch(file_system_url.path(), extension_id()); Respond(true); }
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h index 21b4f23..e2e75c5 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h
@@ -10,9 +10,14 @@ #include <stddef.h> #include <stdint.h> +#include <memory> +#include <set> #include <string> +#include <vector> +#include "base/callback_forward.h" #include "base/macros.h" +#include "base/memory/weak_ptr.h" #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" #include "chrome/browser/extensions/chrome_extension_function.h" #include "chrome/browser/extensions/chrome_extension_function_details.h" @@ -24,9 +29,11 @@ namespace storage { class FileSystemContext; class FileSystemURL; +class WatcherManager; } // namespace storage namespace file_manager { +class EventRouter; namespace util { struct EntryDefinition; typedef std::vector<EntryDefinition> EntryDefinitionList; @@ -82,20 +89,37 @@ // directories. class FileWatchFunctionBase : public LoggedAsyncExtensionFunction { public: + using ResponseCallback = base::Callback<void(bool success)>; + // Calls SendResponse() with |success| converted to base::Value. void Respond(bool success); protected: ~FileWatchFunctionBase() override {} - // Performs a file watch operation (ex. adds or removes a file watch). - virtual void PerformFileWatchOperation( + // Performs a file watch operation (ex. adds or removes a file watch) on + // the IO thread with storage::WatcherManager. + virtual void PerformFileWatchOperationOnIOThread( scoped_refptr<storage::FileSystemContext> file_system_context, + storage::WatcherManager* watcher_manager, const storage::FileSystemURL& file_system_url, - const std::string& extension_id) = 0; + base::WeakPtr<file_manager::EventRouter> event_router) = 0; + + // Performs a file watch operation (ex. adds or removes a file watch) on + // the UI thread with file_manager::EventRouter. This is a fallback operation + // called only when WatcherManager is unavailable. + virtual void PerformFallbackFileWatchOperationOnUIThread( + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router) = 0; // AsyncExtensionFunction overrides. bool RunAsync() override; + + private: + void RunAsyncOnIOThread( + scoped_refptr<storage::FileSystemContext> file_system_context, + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router); }; // Implements the chrome.fileManagerPrivate.addFileWatch method. @@ -110,10 +134,14 @@ ~FileManagerPrivateInternalAddFileWatchFunction() override {} // FileWatchFunctionBase override. - void PerformFileWatchOperation( + void PerformFileWatchOperationOnIOThread( scoped_refptr<storage::FileSystemContext> file_system_context, + storage::WatcherManager* watcher_manager, const storage::FileSystemURL& file_system_url, - const std::string& extension_id) override; + base::WeakPtr<file_manager::EventRouter> event_router) override; + void PerformFallbackFileWatchOperationOnUIThread( + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router) override; }; @@ -129,10 +157,14 @@ ~FileManagerPrivateInternalRemoveFileWatchFunction() override {} // FileWatchFunctionBase override. - void PerformFileWatchOperation( + void PerformFileWatchOperationOnIOThread( scoped_refptr<storage::FileSystemContext> file_system_context, + storage::WatcherManager* watcher_manager, const storage::FileSystemURL& file_system_url, - const std::string& extension_id) override; + base::WeakPtr<file_manager::EventRouter> event_router) override; + void PerformFallbackFileWatchOperationOnUIThread( + const storage::FileSystemURL& file_system_url, + base::WeakPtr<file_manager::EventRouter> event_router) override; }; // Implements the chrome.fileManagerPrivate.getSizeStats method.
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.cc b/chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.cc index 61085739..bfeb4f5 100644 --- a/chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.cc +++ b/chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.cc
@@ -79,7 +79,7 @@ storage::WatcherManager* BackendDelegate::GetWatcherManager( storage::FileSystemType type) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_EQ(storage::kFileSystemTypeProvided, type); return watcher_manager_.get(); }
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/watcher_manager.cc b/chrome/browser/chromeos/file_system_provider/fileapi/watcher_manager.cc index 837d152ad..0a2b63a7 100644 --- a/chrome/browser/chromeos/file_system_provider/fileapi/watcher_manager.cc +++ b/chrome/browser/chromeos/file_system_provider/fileapi/watcher_manager.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/file_system_provider/fileapi/watcher_manager.h" +#include "base/files/file.h" #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h" #include "content/public/browser/browser_thread.h" @@ -14,16 +15,30 @@ namespace chromeos { namespace file_system_provider { -WatcherManager::WatcherManager() { -} -WatcherManager::~WatcherManager() { +namespace { + +using StatusCallback = storage::WatcherManager::StatusCallback; +using NotificationCallback = storage::WatcherManager::NotificationCallback; +using ChangeType = storage::WatcherManager::ChangeType; + +void CallStatusCallbackOnIOThread(const StatusCallback& callback, + base::File::Error error) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(callback, error)); } -void WatcherManager::AddWatcher( - const storage::FileSystemURL& url, - bool recursive, - const StatusCallback& callback, - const NotificationCallback& notification_callback) { +void CallNotificationCallbackOnIOThread(const NotificationCallback& callback, + ChangeType type) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(callback, type)); +} + +void AddWatcherOnUIThread(const storage::FileSystemURL& url, + bool recursive, + const StatusCallback& callback, + const NotificationCallback& notification_callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); util::FileSystemURLParser parser(url); @@ -40,9 +55,9 @@ notification_callback); } -void WatcherManager::RemoveWatcher(const storage::FileSystemURL& url, - bool recursive, - const StatusCallback& callback) { +void RemoveWatcherOnUIThread(const storage::FileSystemURL& url, + bool recursive, + const StatusCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); util::FileSystemURLParser parser(url); @@ -55,5 +70,34 @@ url.origin(), parser.file_path(), recursive, callback); } +} // namespace + +WatcherManager::WatcherManager() = default; +WatcherManager::~WatcherManager() = default; + +void WatcherManager::AddWatcher( + const storage::FileSystemURL& url, + bool recursive, + const StatusCallback& callback, + const NotificationCallback& notification_callback) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&AddWatcherOnUIThread, url, recursive, + base::Bind(&CallStatusCallbackOnIOThread, callback), + base::Bind(&CallNotificationCallbackOnIOThread, + notification_callback))); +} + +void WatcherManager::RemoveWatcher(const storage::FileSystemURL& url, + bool recursive, + const StatusCallback& callback) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&RemoveWatcherOnUIThread, url, recursive, + base::Bind(&CallStatusCallbackOnIOThread, callback))); +} + } // namespace file_system_provider } // namespace chromeos
diff --git a/chrome/browser/chromeos/fileapi/mtp_watcher_manager.cc b/chrome/browser/chromeos/fileapi/mtp_watcher_manager.cc index 58439f8e..5eb3f5b 100644 --- a/chrome/browser/chromeos/fileapi/mtp_watcher_manager.cc +++ b/chrome/browser/chromeos/fileapi/mtp_watcher_manager.cc
@@ -4,6 +4,10 @@ #include "chrome/browser/chromeos/fileapi/mtp_watcher_manager.h" +#include "content/public/browser/browser_thread.h" + +using content::BrowserThread; + namespace chromeos { MTPWatcherManager::MTPWatcherManager( @@ -20,6 +24,7 @@ bool recursive, const StatusCallback& callback, const NotificationCallback& notification_callback) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); device_media_async_file_util_->AddWatcher(url, recursive, callback, notification_callback); } @@ -27,6 +32,7 @@ void MTPWatcherManager::RemoveWatcher(const storage::FileSystemURL& url, bool recursive, const StatusCallback& callback) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); device_media_async_file_util_->RemoveWatcher(url, recursive, callback); }
diff --git a/chrome/browser/resources/md_bookmarks/compiled_resources2.gyp b/chrome/browser/resources/md_bookmarks/compiled_resources2.gyp index 2926f53..a263751 100644 --- a/chrome/browser/resources/md_bookmarks/compiled_resources2.gyp +++ b/chrome/browser/resources/md_bookmarks/compiled_resources2.gyp
@@ -62,6 +62,7 @@ 'dependencies': [ '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu', '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar', + '<(EXTERNS_GYP):chrome_extensions', ], 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'], },
diff --git a/chrome/browser/resources/md_bookmarks/store.js b/chrome/browser/resources/md_bookmarks/store.js index eb4cb11..bb4334b 100644 --- a/chrome/browser/resources/md_bookmarks/store.js +++ b/chrome/browser/resources/md_bookmarks/store.js
@@ -79,6 +79,8 @@ // Attach bookmarks API listeners. chrome.bookmarks.onRemoved.addListener(this.onBookmarkRemoved_.bind(this)); chrome.bookmarks.onChanged.addListener(this.onBookmarkChanged_.bind(this)); + chrome.bookmarks.onImportBegan.addListener(this.onImportBegan_.bind(this)); + chrome.bookmarks.onImportEnded.addListener(this.onImportEnded_.bind(this)); }, ////////////////////////////////////////////////////////////////////////////// @@ -326,6 +328,23 @@ this.updateSearchDisplay_(); }, + /** + * Called when importing bookmark is started. + */ + onImportBegan_: function() { + // TODO(rongjie): pause onCreated once this event is used. + }, + + /** + * Called when importing bookmark node is finished. + */ + onImportEnded_: function() { + chrome.bookmarks.getTree(function(results) { + this.setupStore_(results[0]); + this.updateSelectedDisplay_(); + }.bind(this)); + }, + ////////////////////////////////////////////////////////////////////////////// // bookmarks-store, bookmarks app event listeners:
diff --git a/chrome/browser/resources/md_bookmarks/toolbar.js b/chrome/browser/resources/md_bookmarks/toolbar.js index 53f002b..5b80c74 100644 --- a/chrome/browser/resources/md_bookmarks/toolbar.js +++ b/chrome/browser/resources/md_bookmarks/toolbar.js
@@ -43,12 +43,14 @@ }, /** @private */ - onAddImportTap_: function() { + onImportTap_: function() { + chrome.bookmarks.import(); this.closeDropdownMenu_(); }, /** @private */ - onAddExportTap_: function() { + onExportTap_: function() { + chrome.bookmarks.export(); this.closeDropdownMenu_(); },
diff --git a/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html b/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html index bcb5b9a0..a493752 100644 --- a/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html +++ b/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html
@@ -10,7 +10,7 @@ <dom-module id="settings-channel-switcher-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{aboutChangeChannel}</div> <div class="body"> <!-- TODO(dbeam): this can be policy-controlled. Show this in the UI.
diff --git a/chrome/browser/resources/settings/android_apps_page/android_apps_page.html b/chrome/browser/resources/settings/android_apps_page/android_apps_page.html index b488c06..be48d94 100644 --- a/chrome/browser/resources/settings/android_apps_page/android_apps_page.html +++ b/chrome/browser/resources/settings/android_apps_page/android_apps_page.html
@@ -45,7 +45,7 @@ </div> <!-- Confirm disable android apps dialog --> - <dialog is="cr-dialog" id="confirmDisableDialog" + <dialog is="cr-dialog" id="confirmDisableDialog" close-text="$i18n{close}" on-cancel="onConfirmDisableDialogCancel_"> <div class="title">$i18n{androidAppsDisableDialogTitle}</div> <div class="body" inner-h-t-m-l="[[getDialogBody_()]]"></div>
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html index c4790f7f..c662c3c6 100644 --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.html
@@ -69,7 +69,7 @@ } </style> <dialog is="cr-dialog" id="dialog" on-cancel="onDialogCanceled_" - on-closed="onDialogCanceled_"> + close-text="$i18n{close}" on-closed="onDialogCanceled_"> <div class="title">$i18n{bluetoothPairDevicePageTitle}</div> <div class="body"> <div class="contents layout vertical center center-justified">
diff --git a/chrome/browser/resources/settings/certificate_manager_page/ca_trust_edit_dialog.html b/chrome/browser/resources/settings/certificate_manager_page/ca_trust_edit_dialog.html index d8e1a23..e801dcb2 100644 --- a/chrome/browser/resources/settings/certificate_manager_page/ca_trust_edit_dialog.html +++ b/chrome/browser/resources/settings/certificate_manager_page/ca_trust_edit_dialog.html
@@ -16,7 +16,7 @@ } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{certificateManagerCaTrustEditDialogTitle}</div> <div class="body"> <div>[[explanationText_]]</div>
diff --git a/chrome/browser/resources/settings/certificate_manager_page/certificate_delete_confirmation_dialog.html b/chrome/browser/resources/settings/certificate_manager_page/certificate_delete_confirmation_dialog.html index b20af21..ad4fc87c 100644 --- a/chrome/browser/resources/settings/certificate_manager_page/certificate_delete_confirmation_dialog.html +++ b/chrome/browser/resources/settings/certificate_manager_page/certificate_delete_confirmation_dialog.html
@@ -8,7 +8,7 @@ <dom-module id="settings-certificate-delete-confirmation-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[getTitleText_(model, certificateType)]]</div> <div class="body"> <div>[[getDescriptionText_(model, certificateType)]]</div>
diff --git a/chrome/browser/resources/settings/certificate_manager_page/certificate_password_decryption_dialog.html b/chrome/browser/resources/settings/certificate_manager_page/certificate_password_decryption_dialog.html index 1d5716fc..cc87a2e 100644 --- a/chrome/browser/resources/settings/certificate_manager_page/certificate_password_decryption_dialog.html +++ b/chrome/browser/resources/settings/certificate_manager_page/certificate_password_decryption_dialog.html
@@ -9,7 +9,7 @@ <dom-module id="settings-certificate-password-decryption-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{certificateManagerDecryptPasswordTitle}</div> <div class="body"> <paper-input type="password" id="password"
diff --git a/chrome/browser/resources/settings/certificate_manager_page/certificate_password_encryption_dialog.html b/chrome/browser/resources/settings/certificate_manager_page/certificate_password_encryption_dialog.html index 6b3c4bd7..95da2bf5 100644 --- a/chrome/browser/resources/settings/certificate_manager_page/certificate_password_encryption_dialog.html +++ b/chrome/browser/resources/settings/certificate_manager_page/certificate_password_encryption_dialog.html
@@ -13,7 +13,7 @@ margin-bottom: 20px; } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{certificateManagerEncryptPasswordTitle}</div> <div class="body"> <div>$i18n{certificateManagerEncryptPasswordDescription}</div>
diff --git a/chrome/browser/resources/settings/certificate_manager_page/certificates_error_dialog.html b/chrome/browser/resources/settings/certificate_manager_page/certificates_error_dialog.html index 0b5f094..d28922a 100644 --- a/chrome/browser/resources/settings/certificate_manager_page/certificates_error_dialog.html +++ b/chrome/browser/resources/settings/certificate_manager_page/certificates_error_dialog.html
@@ -7,7 +7,7 @@ <dom-module id="settings-certificates-error-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[model.title]]</div> <div class="body"> <div>[[model.description]]</div>
diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html index 8a864884..93472c08 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html
@@ -99,7 +99,7 @@ } </style> - <dialog is="cr-dialog" id="dialog" ignore-popstate> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}" ignore-popstate> <div class="title">$i18n{clearBrowsingData}</div> <div class="body"> <div class="row">
diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/history_deletion_dialog.html b/chrome/browser/resources/settings/clear_browsing_data_dialog/history_deletion_dialog.html index 35df0f3..43b2a94 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/history_deletion_dialog.html +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/history_deletion_dialog.html
@@ -10,7 +10,7 @@ } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{historyDeletionDialogTitle}</div> <div class="body">$i18nRaw{historyDeletionDialogBody}</div> <div class="button-container">
diff --git a/chrome/browser/resources/settings/device_page/display_overscan_dialog.html b/chrome/browser/resources/settings/device_page/display_overscan_dialog.html index 075e6e9f..f8b3c9d 100644 --- a/chrome/browser/resources/settings/device_page/display_overscan_dialog.html +++ b/chrome/browser/resources/settings/device_page/display_overscan_dialog.html
@@ -42,7 +42,8 @@ padding: 4px 8px 0; } </style> - <dialog is="cr-dialog" id="dialog" on-close="close"> + <dialog is="cr-dialog" id="dialog" on-close="close" + close-text="$i18n{close}"> <div class="title">$i18n{displayOverscanPageTitle}</div> <div class="body"> <div class="subtitle" >$i18n{displayOverscanSubtitle}</div>
diff --git a/chrome/browser/resources/settings/device_page/drive_cache_dialog.html b/chrome/browser/resources/settings/device_page/drive_cache_dialog.html index a3caa0c..286faa7 100644 --- a/chrome/browser/resources/settings/device_page/drive_cache_dialog.html +++ b/chrome/browser/resources/settings/device_page/drive_cache_dialog.html
@@ -7,7 +7,7 @@ <dom-module id="settings-drive-cache-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{storageClearDriveCacheDialogTitle}</div> <div class="body"> <span>$i18n{storageClearDriveCacheDialogDescription}</span>
diff --git a/chrome/browser/resources/settings/internet_page/network_proxy.html b/chrome/browser/resources/settings/internet_page/network_proxy.html index cb52e13..f2c2b8d9 100644 --- a/chrome/browser/resources/settings/internet_page/network_proxy.html +++ b/chrome/browser/resources/settings/internet_page/network_proxy.html
@@ -205,7 +205,7 @@ <!-- Confirm Allow shared proxies dialog --> <dialog is="cr-dialog" id="confirmAllowSharedDialog" - on-cancel="onAllowSharedDialogCancel_"> + close-text="$i18n{close}" on-cancel="onAllowSharedDialogCancel_"> <div class="title">$i18n{networkProxyAllowSharedWarningTitle}</div> <div class="body">$i18n{networkProxyAllowSharedWarningMessage}</div> <div class="button-container">
diff --git a/chrome/browser/resources/settings/internet_page/network_siminfo.html b/chrome/browser/resources/settings/internet_page/network_siminfo.html index 250ae0a..73a8126 100644 --- a/chrome/browser/resources/settings/internet_page/network_siminfo.html +++ b/chrome/browser/resources/settings/internet_page/network_siminfo.html
@@ -90,7 +90,7 @@ </div> <!-- Enter PIN dialog --> - <dialog is="cr-dialog" id="enterPinDialog"> + <dialog is="cr-dialog" id="enterPinDialog" close-text="$i18n{close}"> <div class="title">$i18n{networkSimEnterPinTitle}</div> <div class="body"> <paper-input id="enterPin" class="pin" no-label-float @@ -110,7 +110,7 @@ </dialog> <!-- Change PIN dialog --> - <dialog is="cr-dialog" id="changePinDialog"> + <dialog is="cr-dialog" id="changePinDialog" close-text="$i18n{close}"> <div class="title">$i18n{networkSimChangePinTitle}</div> <div class="body"> <paper-input id="changePinOld" class="pin" no-label-float @@ -136,7 +136,7 @@ </dialog> <!-- Unlock PIN dialog --> - <dialog is="cr-dialog" id="unlockPinDialog"> + <dialog is="cr-dialog" id="unlockPinDialog" close-text="$i18n{close}"> <div class="title">$i18n{networkSimLockedTitle}</div> <div class="body"> <paper-input id="unlockPin" class="pin" no-label-float @@ -156,7 +156,7 @@ </dialog> <!-- Unlock PUK dialog --> - <dialog is="cr-dialog" id="unlockPukDialog"> + <dialog is="cr-dialog" id="unlockPukDialog" close-text="$i18n{close}"> <div class="title">$i18n{networkSimLockedTitle}</div> <div class="body"> <div>
diff --git a/chrome/browser/resources/settings/languages_page/add_languages_dialog.html b/chrome/browser/resources/settings/languages_page/add_languages_dialog.html index 00378f1..3323239 100644 --- a/chrome/browser/resources/settings/languages_page/add_languages_dialog.html +++ b/chrome/browser/resources/settings/languages_page/add_languages_dialog.html
@@ -26,7 +26,7 @@ -webkit-padding-start: 20px; } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{addLanguagesDialogTitle}</div> <div class="body"> <!-- TODO(michaelpg): Dynamic language search/filtering. -->
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html index f8865fe..1838ba50 100644 --- a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html +++ b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.html
@@ -8,7 +8,7 @@ <dom-module id="settings-startup-url-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[dialogTitle_]]</div> <div class="body"> <paper-input always-float-label id="url" label="$i18n{onStartupSiteUrl}"
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html b/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html index 3a175f4b..fb1280e 100644 --- a/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html +++ b/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html
@@ -54,7 +54,7 @@ } } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[title_]]</div> <div class="body"> <template is="dom-repeat" items="[[addressWrapper_]]">
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html index f00e88c..8b9e398 100644 --- a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html +++ b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html
@@ -43,7 +43,7 @@ } </style> <template> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[title_]]</div> <div class="body"> <div>
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html b/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html index 76db55f..57539bb 100644 --- a/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html +++ b/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html
@@ -22,7 +22,7 @@ --iron-icon-fill-color: var(--paper-grey-600); } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{passwordDetailsTitle}</div> <div class="body"> <paper-input id="websiteInput" label="$i18n{editPasswordWebsiteLabel}"
diff --git a/chrome/browser/resources/settings/people_page/easy_unlock_turn_off_dialog.html b/chrome/browser/resources/settings/people_page/easy_unlock_turn_off_dialog.html index c2948c3..d3f92aa 100644 --- a/chrome/browser/resources/settings/people_page/easy_unlock_turn_off_dialog.html +++ b/chrome/browser/resources/settings/people_page/easy_unlock_turn_off_dialog.html
@@ -11,7 +11,7 @@ <dom-module id="easy-unlock-turn-off-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[getTitleText_(status_)]]</div> <div class="body"> [[getDescriptionText_(status_)]]
diff --git a/chrome/browser/resources/settings/people_page/import_data_dialog.html b/chrome/browser/resources/settings/people_page/import_data_dialog.html index 92aad8b..989941b 100644 --- a/chrome/browser/resources/settings/people_page/import_data_dialog.html +++ b/chrome/browser/resources/settings/people_page/import_data_dialog.html
@@ -34,7 +34,7 @@ width: 100%; } </style> - <dialog is="cr-dialog" id="dialog" ignore-popstate> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}" ignore-popstate> <div class="title">$i18n{importTitle}</div> <div class="body"> <div hidden$="[[!hasImportStatus_(
diff --git a/chrome/browser/resources/settings/people_page/people_page.html b/chrome/browser/resources/settings/people_page/people_page.html index 6b6b770b..742e7ec4 100644 --- a/chrome/browser/resources/settings/people_page/people_page.html +++ b/chrome/browser/resources/settings/people_page/people_page.html
@@ -369,7 +369,7 @@ </settings-animated-pages> <dialog is="cr-dialog" id="disconnectDialog" on-close="onDisconnectClosed_" - ignore-popstate> + close-text="$i18n{close}" ignore-popstate> <div class="title">$i18n{syncDisconnectTitle}</div> <div class="body"> <div inner-h-t-m-l="[[getDisconnectExplanationHtml_(syncStatus.domain)]]">
diff --git a/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html b/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html index 3b41f9b..da9925a 100644 --- a/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html +++ b/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html
@@ -51,7 +51,8 @@ } </style> - <dialog is="cr-dialog" id="dialog" on-close="close"> + <dialog is="cr-dialog" id="dialog" on-close="close" + close-text="$i18n{close}"> <div class="title">$i18n{configureFingerprintTitle}</div> <div class="body"> <div class="settings-box first">
diff --git a/chrome/browser/resources/settings/people_page/setup_pin_dialog.html b/chrome/browser/resources/settings/people_page/setup_pin_dialog.html index e97849d..6ff721fc 100644 --- a/chrome/browser/resources/settings/people_page/setup_pin_dialog.html +++ b/chrome/browser/resources/settings/people_page/setup_pin_dialog.html
@@ -33,7 +33,8 @@ } </style> - <dialog is="cr-dialog" id="dialog" on-close="close"> + <dialog is="cr-dialog" id="dialog" on-close="close" + close-text="$i18n{close}"> <div class="title">[[getTitleMessage_(isConfirmStep_)]]</div> <div class="body"> <!-- Warning/error; only shown if title is hidden. Id is needed for
diff --git a/chrome/browser/resources/settings/people_page/users_add_user_dialog.html b/chrome/browser/resources/settings/people_page/users_add_user_dialog.html index 2db4c7e..0082feca 100644 --- a/chrome/browser/resources/settings/people_page/users_add_user_dialog.html +++ b/chrome/browser/resources/settings/people_page/users_add_user_dialog.html
@@ -17,7 +17,7 @@ }; } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{addUsers}</div> <div class="body"> <paper-input id="addUserInput" label="$i18n{addUsersEmail}" autofocus
diff --git a/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html b/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html index 0c7967d7..4afc3444 100644 --- a/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html +++ b/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html
@@ -117,7 +117,7 @@ } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title"> <content select=".dialog-title"></content> </div>
diff --git a/chrome/browser/resources/settings/reset_page/powerwash_dialog.html b/chrome/browser/resources/settings/reset_page/powerwash_dialog.html index 8c34f76..5d83ffb 100644 --- a/chrome/browser/resources/settings/reset_page/powerwash_dialog.html +++ b/chrome/browser/resources/settings/reset_page/powerwash_dialog.html
@@ -10,7 +10,7 @@ <template> <style include="settings-shared"> </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{powerwashDialogTitle}</div> <div class="body"> <span>
diff --git a/chrome/browser/resources/settings/reset_page/reset_profile_banner.html b/chrome/browser/resources/settings/reset_page/reset_profile_banner.html index dffea73..669d8c3a 100644 --- a/chrome/browser/resources/settings/reset_page/reset_profile_banner.html +++ b/chrome/browser/resources/settings/reset_page/reset_profile_banner.html
@@ -7,7 +7,7 @@ <dom-module id="settings-reset-profile-banner"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog" ignore-popstate> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}" ignore-popstate> <div class="title">$i18n{resetAutomatedDialogTitle}</div> <div class="body"> <span id="description">
diff --git a/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html b/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html index f79901b..f471d72 100644 --- a/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html +++ b/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html
@@ -23,7 +23,7 @@ margin: 0 8px; } </style> - <dialog is="cr-dialog" id="dialog" ignore-popstate> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}" ignore-popstate> <div class="title"> [[getPageTitle_(isTriggered_, triggeredResetToolName_)]] </div>
diff --git a/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html b/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html index 29f265b..6d067b4 100644 --- a/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html +++ b/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html
@@ -8,7 +8,7 @@ <dom-module id="settings-search-engine-dialog"> <template> <style include="settings-shared"></style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">[[dialogTitle_]]</div> <div class="body" on-keypress="onKeypress_"> <paper-input always-float-label id="searchEngine"
diff --git a/chrome/browser/resources/settings/site_settings/add_site_dialog.html b/chrome/browser/resources/settings/site_settings/add_site_dialog.html index ae83db37..d1a148b 100644 --- a/chrome/browser/resources/settings/site_settings/add_site_dialog.html +++ b/chrome/browser/resources/settings/site_settings/add_site_dialog.html
@@ -17,7 +17,7 @@ margin-top: 15px; } </style> - <dialog is="cr-dialog" id="dialog"> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> <div class="title">$i18n{addSiteTitle}</div> <div class="body"> <iron-a11y-keys id="keys" keys="enter"
diff --git a/chrome/browser/resources/settings/site_settings/site_data.html b/chrome/browser/resources/settings/site_settings/site_data.html index 6e04cb5..9abe572 100644 --- a/chrome/browser/resources/settings/site_settings/site_data.html +++ b/chrome/browser/resources/settings/site_settings/site_data.html
@@ -68,7 +68,7 @@ </div> <!-- Confirm Delete dialog --> - <dialog is="cr-dialog" id="confirmDeleteDialog"> + <dialog is="cr-dialog" id="confirmDeleteDialog" close-text="$i18n{close}"> <div class="title">$i18n{siteSettingsCookieRemoveDialogTitle}</div> <div class="body">[[confirmationDeleteMsg_]]</div> <div class="button-container">
diff --git a/chrome/browser/resources/settings/site_settings/site_details.html b/chrome/browser/resources/settings/site_settings/site_details.html index dace4e1fb..029e887b 100644 --- a/chrome/browser/resources/settings/site_settings/site_details.html +++ b/chrome/browser/resources/settings/site_settings/site_details.html
@@ -24,7 +24,7 @@ } </style> <!-- Confirm Delete dialog --> - <dialog is="cr-dialog" id="confirmDeleteDialog"> + <dialog is="cr-dialog" id="confirmDeleteDialog" close-text="$i18n{close}"> <div class="title">$i18n{siteSettingsSiteRemoveDialogTitle}</div> <div class="body">[[confirmationDeleteMsg_]]</div> <div class="button-container">
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 9d9951f..ad88173 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1774,8 +1774,6 @@ "views/location_bar/icon_label_bubble_view.h", "views/location_bar/keyword_hint_view.cc", "views/location_bar/keyword_hint_view.h", - "views/location_bar/location_bar_decoration_view.cc", - "views/location_bar/location_bar_decoration_view.h", "views/location_bar/location_bar_layout.cc", "views/location_bar/location_bar_layout.h", "views/location_bar/location_bar_view.cc",
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc index 8e58f1f..fd07a7d 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
@@ -282,6 +282,52 @@ DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); }; +// Proxies to ShelfDelegate invocation to the given +// ChromeLauncherControllerImpl instance. Because of ownership management, +// ChromeLauncherControllerImpl instance cannot be injected to WmShell. +// This wraps the instance, so that it can be injected. +class ProxyShelfDelegate : public ash::ShelfDelegate { + public: + explicit ProxyShelfDelegate(ChromeLauncherControllerImpl* controller) + : controller_(controller) {} + ~ProxyShelfDelegate() override = default; + + ash::ShelfID GetShelfIDForAppID(const std::string& app_id) override { + return controller_->GetShelfIDForAppID(app_id); + }; + + ash::ShelfID GetShelfIDForAppIDAndLaunchID( + const std::string& app_id, + const std::string& launch_id) override { + return controller_->GetShelfIDForAppIDAndLaunchID(app_id, launch_id); + } + + bool HasShelfIDToAppIDMapping(ash::ShelfID id) const override { + return controller_->HasShelfIDToAppIDMapping(id); + } + + const std::string& GetAppIDForShelfID(ash::ShelfID id) override { + return controller_->GetAppIDForShelfID(id); + } + + void PinAppWithID(const std::string& app_id) override { + return controller_->PinAppWithID(app_id); + } + + bool IsAppPinned(const std::string& app_id) override { + return controller_->IsAppPinned(app_id); + } + + void UnpinAppWithID(const std::string& app_id) override { + return controller_->UnpinAppWithID(app_id); + } + + private: + ChromeLauncherControllerImpl* const controller_; + + DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate); +}; + } // namespace class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest { @@ -508,6 +554,13 @@ launcher_controller_->Init(); } + // This needs to be called after InitLaunchController(), or its family. + // It is not supported to recreate the instance. + void SetShelfDelegate() { + ash::WmShell::Get()->SetShelfDelegateForTesting( + base::MakeUnique<ProxyShelfDelegate>(launcher_controller_.get())); + } + void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { app_service_->MergeDataAndStartSyncing( syncer::APP_LIST, init_sync_list, @@ -3586,8 +3639,9 @@ // Initially pins are imported from legacy pref based model. StartPrefSyncService(syncer::SyncDataList()); - arc::ArcSessionManager::SetShelfDelegateForTesting( - launcher_controller_.get()); + // Inject |launcher_controller_| as ShelfDelegate to verify the behavior + // of removing pinned icon in ArcSessionManager::OnOptInPreferenceChanged(). + SetShelfDelegate(); // Initial run, ARC is not managed and disabled, Play Store pin should be // available. @@ -3737,8 +3791,6 @@ EnableArc(true); InitLauncherController(); - arc::ArcSessionManager::SetShelfDelegateForTesting( - launcher_controller_.get()); ash::ScreenOrientationController* controller = ash::Shell::GetInstance()->screen_orientation_controller(); @@ -3789,8 +3841,6 @@ EnableTabletMode(true); InitLauncherController(); - arc::ArcSessionManager::SetShelfDelegateForTesting( - launcher_controller_.get()); InitApps(); ash::ScreenOrientationController* controller = @@ -3888,8 +3938,6 @@ EnableTabletMode(true); InitLauncherController(); - arc::ArcSessionManager::SetShelfDelegateForTesting( - launcher_controller_.get()); InitApps(); ash::ScreenOrientationController* controller = @@ -3947,8 +3995,6 @@ arc_test_.SetUp(profile()); InitLauncherController(); ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); - arc::ArcSessionManager::SetShelfDelegateForTesting( - launcher_controller_.get()); ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); EnableArc(false);
diff --git a/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h b/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h index da6e6fd..50a3c9a3 100644 --- a/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h +++ b/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h
@@ -28,8 +28,6 @@ void Update(); // Implement |LocationBarDecoration|. - // N.B. - this is identical to LocationBarDecorationView's OnClick - // and canHandleClick. bool AcceptsMousePress() override; bool OnMousePressed(NSRect frame, NSPoint location) override; NSPoint GetBubblePointInFrame(NSRect frame) override;
diff --git a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc deleted file mode 100644 index 0a93b5ac..0000000 --- a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc +++ /dev/null
@@ -1,52 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/views/location_bar/location_bar_decoration_view.h" - -#include "ui/events/event.h" - -LocationBarDecorationView::LocationBarDecorationView() - : could_handle_click_(true) { - SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); -} - -LocationBarDecorationView::~LocationBarDecorationView() {} - -bool LocationBarDecorationView::OnMousePressed(const ui::MouseEvent& event) { - if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) { - // Do nothing until mouse is released. - could_handle_click_ = CanHandleClick(); - return true; - } - - return false; -} - -void LocationBarDecorationView::OnMouseReleased(const ui::MouseEvent& event) { - if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location()) && - could_handle_click_ && CanHandleClick()) { - OnClick(); - } -} - -bool LocationBarDecorationView::OnKeyPressed(const ui::KeyEvent& event) { - if (event.key_code() == ui::VKEY_SPACE || - event.key_code() == ui::VKEY_RETURN) { - OnClick(); - return true; - } - - return false; -} - -void LocationBarDecorationView::OnGestureEvent(ui::GestureEvent* event) { - if (event->type() == ui::ET_GESTURE_TAP) { - OnClick(); - event->SetHandled(); - } -} - -bool LocationBarDecorationView::CanHandleClick() const { - return true; -}
diff --git a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h deleted file mode 100644 index 3f73081..0000000 --- a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h +++ /dev/null
@@ -1,48 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_DECORATION_VIEW_H_ -#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_DECORATION_VIEW_H_ - -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "ui/views/controls/image_view.h" - -//////////////////////////////////////////////////////////////////////////////// -// -// LocationBarDecorationView -// -// An abstract class to provide common functionality to all icons that show up -// in the omnibox (like the bookmarks star or SSL lock). -// -//////////////////////////////////////////////////////////////////////////////// -class LocationBarDecorationView : public views::ImageView { - public: - LocationBarDecorationView(); - ~LocationBarDecorationView() override; - - // views::ImageView: - bool OnMousePressed(const ui::MouseEvent& event) override; - void OnMouseReleased(const ui::MouseEvent& event) override; - bool OnKeyPressed(const ui::KeyEvent& event) override; - void OnGestureEvent(ui::GestureEvent* event) override; - - protected: - // Whether this icon should currently be able to process a mouse click. Called - // both on mouse up and mouse down; must return true both times to for - // |OnClick()| to be called. - virtual bool CanHandleClick() const; - - // Called when a user mouses up, taps, or presses a key on this icon. - virtual void OnClick() = 0; - - private: - // Set when the user's mouse goes down to determine whether |CanHandleClick()| - // was true at that point. - bool could_handle_click_; - - DISALLOW_COPY_AND_ASSIGN(LocationBarDecorationView); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_DECORATION_VIEW_H_
diff --git a/chrome/common/extensions/docs/templates/intros/webRequest.html b/chrome/common/extensions/docs/templates/intros/webRequest.html index 1f578c5..df737dc 100644 --- a/chrome/common/extensions/docs/templates/intros/webRequest.html +++ b/chrome/common/extensions/docs/templates/intros/webRequest.html
@@ -210,6 +210,11 @@ <code>onHeadersReceived</code>), or providing authentication credentials (<code>onAuthRequired</code>).</p> +<p>If the optional <code>opt_extraInfoSpec</code> array contains the string +<code>'asyncBlocking'</code> instead (only allowed for +<code>onAuthRequired</code>), the extension can generate the +$(ref:webRequest.BlockingResponse) asynchronously. + <p>The $(ref:webRequest.RequestFilter) <code>filter</code> allows limiting the requests for which events are triggered in various dimensions:
diff --git a/chrome/installer/linux/debian/expected_deps_x64_jessie b/chrome/installer/linux/debian/expected_deps_x64_jessie index ab8362a..7f59311a 100644 --- a/chrome/installer/linux/debian/expected_deps_x64_jessie +++ b/chrome/installer/linux/debian/expected_deps_x64_jessie
@@ -11,7 +11,7 @@ libgcc1 (>= 1:4.1.1) libgconf-2-4 (>= 3.2.5) libgdk-pixbuf2.0-0 (>= 2.22.0) -libglib2.0-0 (>= 2.41.1) +libglib2.0-0 (>= 2.28.0) libgtk2.0-0 (>= 2.24.0) libnspr4 (>= 2:4.9-2~) | libnspr4-0d (>= 1.8.0.10) libnss3 (>= 2:3.13.4-2~) | libnss3-1d (>= 3.12.4)
diff --git a/components/arc/common/file_system.mojom b/components/arc/common/file_system.mojom index de13a03..0fc8ecb 100644 --- a/components/arc/common/file_system.mojom +++ b/components/arc/common/file_system.mojom
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Next MinVersion: 3 +// Next MinVersion: 4 module arc.mojom; @@ -29,7 +29,31 @@ uint64 last_modified; }; -// Next method ID: 5 +// Describes the type of a change made to a document. +[Extensible] +enum ChangeType { + // Indicates that the child document list of the watched directory was + // changed. Note that a watcher can be installed only on directory for now. + CHANGED = 0, + + // Indicates that the watched document itself was deleted. + // When OnDocumentChanged() is called with this change type, the corresponding + // watcher has been already uninstalled and the host should not call + // RemoveWatcher(). + DELETED = 1, +}; + + +// Next method ID: 1 +interface FileSystemHost { + // Called when a watched document was changed. + // |type| describes the type of change made to the document. If |type| is + // DELETED, the watcher has been already removed and the host should not call + // RemoveWatcher(). + [MinVersion=3] OnDocumentChanged@0(int64 watcher_id, ChangeType type); +}; + +// Next method ID: 8 interface FileSystemInstance { // Notes about Android Documents Provider: // @@ -47,6 +71,21 @@ // https://developer.android.com/guide/topics/providers/document-provider.html // https://developer.android.com/reference/android/provider/DocumentsContract.html + // Installs a document watcher to watch updates of a document. + // + // Note: Currently, watchers can be installed only on directories, and only + // directory content changes are notified. + // + // On success, a positive unique integer is returned as a watcher ID. + // FileSystemHost.OnDocumentChanged() will be called with the watcher ID + // on directory content changes. + // On failure, -1 is returned. + // + // It is allowed to install multiple watchers to the same directory. In that + // case, different watcher IDs are returned. + [MinVersion=3] AddWatcher@6(string authority, string document_id) => + (int64 watcher_id); + // Queries child documents of the directory specified by |authority| and // |parent_document_id| in Documents Provider. // If such a directory does not exist, null is returned. @@ -65,10 +104,24 @@ // streams), -1 is returned. [MinVersion=1] GetFileSize@1(string url) => (int64 size); + // Establishes full-duplex communication with the host. + [MinVersion=3] Init@5(FileSystemHost host_ptr); + // Asks the ContentResolver to get a FD to read the file specified by the // URL. [MinVersion=1] OpenFileToRead@2(string url) => (handle? fd); + // Uninstalls a document watcher. + // + // After this method call returns, OnDocumentChanged() will never be called + // with the watcher ID. Whether OnDocumentChanged() is called or not after + // this method is called and before this method returns is undefined. + // + // It fails if the specified watcher does not exist. Note that a watcher + // can be automatically uninstalled when a watched document is deleted + // (notified by OnDocumentChanged() with |type| = DELETED). + [MinVersion=3] RemoveWatcher@7(int64 watcher_id) => (bool success); + // Requests MediaProvider to scan specified files. // When the specified file does not exist, the corresponding entry in // MediaProvider is removed.
diff --git a/components/arc/test/fake_file_system_instance.cc b/components/arc/test/fake_file_system_instance.cc index 040500d..4a3dcc89 100644 --- a/components/arc/test/fake_file_system_instance.cc +++ b/components/arc/test/fake_file_system_instance.cc
@@ -7,6 +7,8 @@ #include <string.h> #include <unistd.h> +#include <utility> + #include "base/bind.h" #include "base/files/file.h" #include "base/files/file_path.h" @@ -96,6 +98,10 @@ DCHECK(thread_checker_.CalledOnValidThread()); } +bool FakeFileSystemInstance::InitCalled() { + return host_; +} + void FakeFileSystemInstance::AddFile(const File& file) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_EQ(0u, files_.count(std::string(file.url))); @@ -115,6 +121,40 @@ } } +void FakeFileSystemInstance::TriggerWatchers(const std::string& authority, + const std::string& document_id, + mojom::ChangeType type) { + DCHECK(thread_checker_.CalledOnValidThread()); + if (!host_) { + LOG(ERROR) << "FileSystemHost is not available."; + return; + } + auto iter = document_to_watchers_.find(DocumentKey(authority, document_id)); + if (iter == document_to_watchers_.end()) + return; + for (int64_t watcher_id : iter->second) { + host_->OnDocumentChanged(watcher_id, type); + } +} + +void FakeFileSystemInstance::AddWatcher(const std::string& authority, + const std::string& document_id, + const AddWatcherCallback& callback) { + DCHECK(thread_checker_.CalledOnValidThread()); + DocumentKey key(authority, document_id); + auto iter = documents_.find(key); + if (iter == documents_.end()) { + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback, -1)); + return; + } + int64_t watcher_id = next_watcher_id_++; + document_to_watchers_[key].insert(watcher_id); + watcher_to_document_.insert(std::make_pair(watcher_id, key)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(callback, watcher_id)); +} + void FakeFileSystemInstance::GetFileSize(const std::string& url, const GetFileSizeCallback& callback) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -194,6 +234,29 @@ base::Passed(base::make_optional(std::move(children))))); } +void FakeFileSystemInstance::Init(mojom::FileSystemHostPtr host) { + DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK(host); + DCHECK(!host_); + host_ = std::move(host); +} + +void FakeFileSystemInstance::RemoveWatcher( + int64_t watcher_id, + const RemoveWatcherCallback& callback) { + DCHECK(thread_checker_.CalledOnValidThread()); + auto iter = watcher_to_document_.find(watcher_id); + if (iter == watcher_to_document_.end()) { + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback, false)); + return; + } + document_to_watchers_[iter->second].erase(watcher_id); + watcher_to_document_.erase(iter); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback, true)); +} + void FakeFileSystemInstance::RequestMediaScan( const std::vector<std::string>& paths) { DCHECK(thread_checker_.CalledOnValidThread());
diff --git a/components/arc/test/fake_file_system_instance.h b/components/arc/test/fake_file_system_instance.h index 37ed417..a019368 100644 --- a/components/arc/test/fake_file_system_instance.h +++ b/components/arc/test/fake_file_system_instance.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <map> +#include <set> #include <string> #include <utility> #include <vector> @@ -102,13 +103,24 @@ FakeFileSystemInstance(); ~FakeFileSystemInstance() override; + // Returns true if Init() has been called. + bool InitCalled(); + // Adds a file accessible by content URL based methods. void AddFile(const File& file); // Adds a document accessible by document provider based methods. void AddDocument(const Document& document); + // Triggers watchers installed to a document. + void TriggerWatchers(const std::string& authority, + const std::string& document_id, + mojom::ChangeType type); + // mojom::FileSystemInstance: + void AddWatcher(const std::string& authority, + const std::string& document_id, + const AddWatcherCallback& callback) override; void GetChildDocuments(const std::string& authority, const std::string& document_id, const GetChildDocumentsCallback& callback) override; @@ -117,8 +129,11 @@ const GetDocumentCallback& callback) override; void GetFileSize(const std::string& url, const GetFileSizeCallback& callback) override; + void Init(mojom::FileSystemHostPtr host) override; void OpenFileToRead(const std::string& url, const OpenFileToReadCallback& callback) override; + void RemoveWatcher(int64_t watcher_id, + const RemoveWatcherCallback& callback) override; void RequestMediaScan(const std::vector<std::string>& paths) override; private: @@ -130,6 +145,8 @@ base::ScopedTempDir temp_dir_; + mojom::FileSystemHostPtr host_; + // Mapping from a content URL to a file. std::map<std::string, File> files_; @@ -139,6 +156,14 @@ // Mapping from a document key to its child documents. std::map<DocumentKey, std::vector<DocumentKey>> child_documents_; + // Mapping from a document key to its watchers. + std::map<DocumentKey, std::set<int64_t>> document_to_watchers_; + + // Mapping from a watcher ID to a document key. + std::map<int64_t, DocumentKey> watcher_to_document_; + + int64_t next_watcher_id_ = 1; + DISALLOW_COPY_AND_ASSIGN(FakeFileSystemInstance); };
diff --git a/components/autofill/core/browser/BUILD.gn b/components/autofill/core/browser/BUILD.gn index fb237cad..884296c 100644 --- a/components/autofill/core/browser/BUILD.gn +++ b/components/autofill/core/browser/BUILD.gn
@@ -139,6 +139,9 @@ "webdata/autofill_profile_syncable_service.h", "webdata/autofill_table.cc", "webdata/autofill_table.h", + "webdata/autofill_table_encryptor.h", + "webdata/autofill_table_encryptor_factory.cc", + "webdata/autofill_table_encryptor_factory.h", "webdata/autofill_wallet_metadata_syncable_service.cc", "webdata/autofill_wallet_metadata_syncable_service.h", "webdata/autofill_wallet_syncable_service.cc", @@ -150,6 +153,8 @@ "webdata/autofill_webdata_service.cc", "webdata/autofill_webdata_service.h", "webdata/autofill_webdata_service_observer.h", + "webdata/system_encryptor.cc", + "webdata/system_encryptor.h", "webdata/web_data_model_type_controller.cc", "webdata/web_data_model_type_controller.h", ]
diff --git a/components/autofill/core/browser/webdata/autofill_table.cc b/components/autofill/core/browser/webdata/autofill_table.cc index bd342ffb..72cf35b 100644 --- a/components/autofill/core/browser/webdata/autofill_table.cc +++ b/components/autofill/core/browser/webdata/autofill_table.cc
@@ -30,11 +30,12 @@ #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/webdata/autofill_change.h" #include "components/autofill/core/browser/webdata/autofill_entry.h" +#include "components/autofill/core/browser/webdata/autofill_table_encryptor.h" +#include "components/autofill/core/browser/webdata/autofill_table_encryptor_factory.h" #include "components/autofill/core/common/autofill_clock.h" #include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/autofill_util.h" #include "components/autofill/core/common/form_field_data.h" -#include "components/os_crypt/os_crypt.h" #include "components/sync/base/model_type.h" #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/model_type_state.pb.h" @@ -129,17 +130,19 @@ } void BindEncryptedCardToColumn(sql::Statement* s, - int column_index, - const base::string16& number) { + int column_index, + const base::string16& number, + const AutofillTableEncryptor& encryptor) { std::string encrypted_data; - OSCrypt::EncryptString16(number, &encrypted_data); + encryptor.EncryptString16(number, &encrypted_data); s->BindBlob(column_index, encrypted_data.data(), static_cast<int>(encrypted_data.length())); } void BindCreditCardToStatement(const CreditCard& credit_card, const Time& modification_date, - sql::Statement* s) { + sql::Statement* s, + const AutofillTableEncryptor& encryptor) { DCHECK(base::IsValidGUID(credit_card.guid())); int index = 0; s->BindString(index++, credit_card.guid()); @@ -147,8 +150,8 @@ s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME_FULL)); s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_MONTH)); s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR)); - BindEncryptedCardToColumn(s, index++, - credit_card.GetRawInfo(CREDIT_CARD_NUMBER)); + BindEncryptedCardToColumn( + s, index++, credit_card.GetRawInfo(CREDIT_CARD_NUMBER), encryptor); s->BindInt64(index++, credit_card.use_count()); s->BindInt64(index++, credit_card.use_date().ToTimeT()); @@ -157,8 +160,10 @@ s->BindString(index++, credit_card.billing_address_id()); } -base::string16 UnencryptedCardFromColumn(const sql::Statement& s, - int column_index) { +base::string16 UnencryptedCardFromColumn( + const sql::Statement& s, + int column_index, + const AutofillTableEncryptor& encryptor) { base::string16 credit_card_number; int encrypted_number_len = s.ColumnByteLength(column_index); if (encrypted_number_len) { @@ -166,12 +171,14 @@ encrypted_number.resize(encrypted_number_len); memcpy(&encrypted_number[0], s.ColumnBlob(column_index), encrypted_number_len); - OSCrypt::DecryptString16(encrypted_number, &credit_card_number); + encryptor.DecryptString16(encrypted_number, &credit_card_number); } return credit_card_number; } -std::unique_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) { +std::unique_ptr<CreditCard> CreditCardFromStatement( + const sql::Statement& s, + const AutofillTableEncryptor& encryptor) { std::unique_ptr<CreditCard> credit_card(new CreditCard); int index = 0; @@ -183,7 +190,7 @@ credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); credit_card->SetRawInfo(CREDIT_CARD_NUMBER, - UnencryptedCardFromColumn(s, index++)); + UnencryptedCardFromColumn(s, index++, encryptor)); credit_card->set_use_count(s.ColumnInt64(index++)); credit_card->set_use_date(Time::FromTimeT(s.ColumnInt64(index++))); credit_card->set_modification_date(Time::FromTimeT(s.ColumnInt64(index++))); @@ -399,7 +406,10 @@ // static const size_t AutofillTable::kMaxDataLength = 1024; -AutofillTable::AutofillTable() { +AutofillTable::AutofillTable() + : autofill_table_encryptor_( + AutofillTableEncryptorFactory::GetInstance()->Create()) { + DCHECK(autofill_table_encryptor_); } AutofillTable::~AutofillTable() { @@ -1165,7 +1175,8 @@ " card_number_encrypted, use_count, use_date, date_modified, origin," " billing_address_id)" "VALUES (?,?,?,?,?,?,?,?,?,?)")); - BindCreditCardToStatement(credit_card, AutofillClock::Now(), &s); + BindCreditCardToStatement(credit_card, AutofillClock::Now(), &s, + *autofill_table_encryptor_); if (!s.Run()) return false; @@ -1188,7 +1199,7 @@ if (!s.Step()) return std::unique_ptr<CreditCard>(); - return CreditCardFromStatement(s); + return CreditCardFromStatement(s, *autofill_table_encryptor_); } bool AutofillTable::GetCreditCards( @@ -1237,7 +1248,8 @@ // If the card_number_encrypted field is nonempty, we can assume this card // is a full card, otherwise it's masked. - base::string16 full_card_number = UnencryptedCardFromColumn(s, index++); + base::string16 full_card_number = + UnencryptedCardFromColumn(s, index++, *autofill_table_encryptor_); base::string16 last_four = s.ColumnString16(index++); CreditCard::RecordType record_type = full_card_number.empty() ? CreditCard::MASKED_SERVER_CARD : @@ -1344,7 +1356,7 @@ s.BindString(0, masked.server_id()); std::string encrypted_data; - OSCrypt::EncryptString16(full_number, &encrypted_data); + autofill_table_encryptor_->EncryptString16(full_number, &encrypted_data); s.BindBlob(1, encrypted_data.data(), static_cast<int>(encrypted_data.length())); s.BindInt64(2, AutofillClock::Now().ToInternalValue()); // unmask_date @@ -1478,7 +1490,7 @@ update_modification_date ? AutofillClock::Now() : old_credit_card->modification_date(), - &s); + &s, *autofill_table_encryptor_); bool result = s.Run(); DCHECK_GT(db_->GetLastChangeCount(), 0);
diff --git a/components/autofill/core/browser/webdata/autofill_table.h b/components/autofill/core/browser/webdata/autofill_table.h index dc08b9b5..f3f8a14 100644 --- a/components/autofill/core/browser/webdata/autofill_table.h +++ b/components/autofill/core/browser/webdata/autofill_table.h
@@ -29,6 +29,7 @@ class AutofillChange; class AutofillEntry; class AutofillProfile; +class AutofillTableEncryptor; class AutofillTableTest; class CreditCard; @@ -546,6 +547,8 @@ bool InitAutofillSyncMetadataTable(); bool InitModelTypeStateTable(); + std::unique_ptr<AutofillTableEncryptor> autofill_table_encryptor_; + DISALLOW_COPY_AND_ASSIGN(AutofillTable); };
diff --git a/components/autofill/core/browser/webdata/autofill_table_encryptor.h b/components/autofill/core/browser/webdata/autofill_table_encryptor.h new file mode 100644 index 0000000..2391cd7 --- /dev/null +++ b/components/autofill/core/browser/webdata/autofill_table_encryptor.h
@@ -0,0 +1,26 @@ +// 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 COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_ENCRYPTOR_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_ENCRYPTOR_H_ + +#include <string> + +#include "base/strings/string16.h" + +namespace autofill { +// Encryptor used by Autofill table. +class AutofillTableEncryptor { + public: + virtual ~AutofillTableEncryptor() = default; + + virtual bool EncryptString16(const base::string16& plaintext, + std::string* ciphertext) const = 0; + virtual bool DecryptString16(const std::string& ciphertext, + base::string16* plaintext) const = 0; +}; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_ENCRYPTOR_H_
diff --git a/components/autofill/core/browser/webdata/autofill_table_encryptor_factory.cc b/components/autofill/core/browser/webdata/autofill_table_encryptor_factory.cc new file mode 100644 index 0000000..6ee6516 --- /dev/null +++ b/components/autofill/core/browser/webdata/autofill_table_encryptor_factory.cc
@@ -0,0 +1,33 @@ +// 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 "components/autofill/core/browser/webdata/autofill_table_encryptor_factory.h" + +#include "base/memory/ptr_util.h" +#include "base/memory/singleton.h" +#include "components/autofill/core/browser/webdata/system_encryptor.h" + +namespace autofill { + +AutofillTableEncryptorFactory::AutofillTableEncryptorFactory() = default; + +AutofillTableEncryptorFactory::~AutofillTableEncryptorFactory() = default; + +AutofillTableEncryptorFactory* AutofillTableEncryptorFactory::GetInstance() { + return base::Singleton<AutofillTableEncryptorFactory>::get(); +} + +std::unique_ptr<AutofillTableEncryptor> +AutofillTableEncryptorFactory::Create() { + DCHECK(sequence_checker_.CalledOnValidSequence()); + return delegate_ ? delegate_->Create() : base::MakeUnique<SystemEncryptor>(); +} + +void AutofillTableEncryptorFactory::SetDelegate( + std::unique_ptr<Delegate> delegate) { + DCHECK(sequence_checker_.CalledOnValidSequence()); + delegate_ = std::move(delegate); +} + +} // namespace autofill
diff --git a/components/autofill/core/browser/webdata/autofill_table_encryptor_factory.h b/components/autofill/core/browser/webdata/autofill_table_encryptor_factory.h new file mode 100644 index 0000000..aa0d52de6 --- /dev/null +++ b/components/autofill/core/browser/webdata/autofill_table_encryptor_factory.h
@@ -0,0 +1,53 @@ +// 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 COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_ENCRYPTOR_FACTORY_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_ENCRYPTOR_FACTORY_H_ + +#include <memory> + +#include "base/sequence_checker.h" + +namespace base { +template <typename T> +struct DefaultSingletonTraits; +} // namespace base + +namespace autofill { + +class AutofillTableEncryptor; + +// Factory for creating Autofill table encryptor. +// If |delegate_| is set, then |delegate_| is used to create encryptor, +// else default encrytor (SystemEncryptor) is returned. +class AutofillTableEncryptorFactory { + public: + // Embedders are recommended to use this delegate to inject + // their encryptor into Autofill table. + class Delegate { + public: + virtual ~Delegate() = default; + + virtual std::unique_ptr<AutofillTableEncryptor> Create() = 0; + }; + + static AutofillTableEncryptorFactory* GetInstance(); + + std::unique_ptr<AutofillTableEncryptor> Create(); + + void SetDelegate(std::unique_ptr<Delegate> delegate); + + private: + AutofillTableEncryptorFactory(); + ~AutofillTableEncryptorFactory(); + + std::unique_ptr<Delegate> delegate_; + base::SequenceChecker sequence_checker_; + + friend struct base::DefaultSingletonTraits<AutofillTableEncryptorFactory>; + DISALLOW_COPY_AND_ASSIGN(AutofillTableEncryptorFactory); +}; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_ENCRYPTOR_FACTORY_H_
diff --git a/components/autofill/core/browser/webdata/system_encryptor.cc b/components/autofill/core/browser/webdata/system_encryptor.cc new file mode 100644 index 0000000..7b16c089 --- /dev/null +++ b/components/autofill/core/browser/webdata/system_encryptor.cc
@@ -0,0 +1,21 @@ +// 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 "components/autofill/core/browser/webdata/system_encryptor.h" + +#include "components/os_crypt/os_crypt.h" + +namespace autofill { + +bool SystemEncryptor::EncryptString16(const base::string16& plaintext, + std::string* ciphertext) const { + return ::OSCrypt::EncryptString16(plaintext, ciphertext); +} + +bool SystemEncryptor::DecryptString16(const std::string& ciphertext, + base::string16* plaintext) const { + return ::OSCrypt::DecryptString16(ciphertext, plaintext); +} + +} // namespace autofill
diff --git a/components/autofill/core/browser/webdata/system_encryptor.h b/components/autofill/core/browser/webdata/system_encryptor.h new file mode 100644 index 0000000..e6efb42 --- /dev/null +++ b/components/autofill/core/browser/webdata/system_encryptor.h
@@ -0,0 +1,30 @@ +// 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 COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_SYSTEM_ENCRYPTOR_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_SYSTEM_ENCRYPTOR_H_ + +#include "base/macros.h" +#include "components/autofill/core/browser/webdata/autofill_table_encryptor.h" + +namespace autofill { +// Default encryptor used in Autofill table. +class SystemEncryptor : public AutofillTableEncryptor { + public: + SystemEncryptor() = default; + ~SystemEncryptor() override = default; + + bool EncryptString16(const base::string16& plaintext, + std::string* ciphertext) const override; + + bool DecryptString16(const std::string& ciphertext, + base::string16* plaintext) const override; + + private: + DISALLOW_COPY_AND_ASSIGN(SystemEncryptor); +}; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_SYSTEM_ENCRYPTOR_H_
diff --git a/components/printing/renderer/print_web_view_helper.cc b/components/printing/renderer/print_web_view_helper.cc index e59e372e..173fb4381 100644 --- a/components/printing/renderer/print_web_view_helper.cc +++ b/components/printing/renderer/print_web_view_helper.cc
@@ -1854,15 +1854,9 @@ double css_scale_factor = 1.0f; #if BUILDFLAG(ENABLE_PRINT_PREVIEW) - if (params.params.scale_factor >= kEpsilon) - css_scale_factor = params.params.scale_factor; + if (params.params.scale_factor >= kEpsilon) + css_scale_factor = params.params.scale_factor; #endif - - // Save the original page size here to avoid rounding errors incurred by - // converting to pixels and back and by scaling the page for reflow and - // scaling back. Windows uses |page_size_in_dpi| for the actual page size - // so requires an accurate value. - gfx::Size original_page_size = params.params.page_size; ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, ignore_css_margins_, &css_scale_factor, &page_layout_in_points); @@ -1870,10 +1864,19 @@ gfx::Rect content_area; GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, &content_area); - + int dpi = static_cast<int>(params.params.dpi); // Calculate the actual page size and content area in dpi. if (page_size_in_dpi) { - *page_size_in_dpi = original_page_size; + // Windows uses this for the actual page size. We have scaled page size + // to get blink to reflow the page, so scale it back to the real size + // before returning it. + *page_size_in_dpi = + gfx::Size(static_cast<int>(ConvertUnitDouble(page_size.width(), + kPointsPerInch, dpi) * + css_scale_factor), + static_cast<int>(ConvertUnitDouble(page_size.height(), + kPointsPerInch, dpi) * + css_scale_factor)); } if (content_area_in_dpi) {
diff --git a/components/printing/test/mock_printer.cc b/components/printing/test/mock_printer.cc index 1a38b7a..4197dc60 100644 --- a/components/printing/test/mock_printer.cc +++ b/components/printing/test/mock_printer.cc
@@ -40,13 +40,6 @@ } } -void UpdatePageSizeAndScaling(const gfx::Size& page_size, - int scale_factor, - PrintMsg_Print_Params* params) { - params->page_size = page_size; - params->scale_factor = static_cast<double>(scale_factor) / 100.0; -} - } // namespace MockPrinterPage::MockPrinterPage(const void* source_data, @@ -168,9 +161,7 @@ void MockPrinter::UpdateSettings(int cookie, PrintMsg_PrintPages_Params* params, const std::vector<int>& pages, - int margins_type, - const gfx::Size& page_size, - int scale_factor) { + int margins_type) { if (document_cookie_ == -1) { document_cookie_ = CreateDocumentCookie(); } @@ -178,8 +169,6 @@ params->pages = pages; SetPrintParams(&(params->params)); UpdateMargins(margins_type, dpi_, &(params->params)); - if (!page_size.IsEmpty()) - UpdatePageSizeAndScaling(page_size, scale_factor, ¶ms->params); printer_status_ = PRINTER_PRINTING; }
diff --git a/components/printing/test/mock_printer.h b/components/printing/test/mock_printer.h index 9492a6b..5eaba45 100644 --- a/components/printing/test/mock_printer.h +++ b/components/printing/test/mock_printer.h
@@ -85,9 +85,7 @@ void UpdateSettings(int cookie, PrintMsg_PrintPages_Params* params, const std::vector<int>& page_range_array, - int margins_type, - const gfx::Size& page_size, - int scale_factor); + int margins_type); void SetPrintedPagesCount(int cookie, int number_pages); void PrintPage(const PrintHostMsg_DidPrintPage_Params& params);
diff --git a/components/printing/test/print_mock_render_thread.cc b/components/printing/test/print_mock_render_thread.cc index 74013e34..cc8205a 100644 --- a/components/printing/test/print_mock_render_thread.cc +++ b/components/printing/test/print_mock_render_thread.cc
@@ -15,7 +15,6 @@ #include "printing/features/features.h" #include "printing/page_range.h" #include "printing/print_job_constants.h" -#include "printing/units.h" #include "testing/gtest/include/gtest/gtest.h" #if BUILDFLAG(ENABLE_PRINTING) @@ -163,32 +162,9 @@ new_ranges.push_back(range); } } - - // Get media size - const base::DictionaryValue* media_size_value = nullptr; - gfx::Size page_size; - if (job_settings.GetDictionary(printing::kSettingMediaSize, - &media_size_value)) { - int width_microns = 0; - int height_microns = 0; - if (media_size_value->GetInteger(printing::kSettingMediaSizeWidthMicrons, - &width_microns) && - media_size_value->GetInteger(printing::kSettingMediaSizeHeightMicrons, - &height_microns)) { - float device_microns_per_unit = - (printing::kHundrethsMMPerInch * 10.0f) / printing::kDefaultPdfDpi; - page_size = gfx::Size(width_microns / device_microns_per_unit, - height_microns / device_microns_per_unit); - } - } - - // Get scaling - int scale_factor = 100; - job_settings.GetInteger(printing::kSettingScaleFactor, &scale_factor); - std::vector<int> pages(printing::PageRange::GetPages(new_ranges)); - printer_->UpdateSettings(document_cookie, params, pages, margins_type, - page_size, scale_factor); + printer_->UpdateSettings(document_cookie, params, pages, margins_type); + job_settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly, ¶ms->params.selection_only); job_settings.GetBoolean(printing::kSettingShouldPrintBackgrounds,
diff --git a/components/printing/test/print_web_view_helper_browsertest.cc b/components/printing/test/print_web_view_helper_browsertest.cc index ce387743..279ae825 100644 --- a/components/printing/test/print_web_view_helper_browsertest.cc +++ b/components/printing/test/print_web_view_helper_browsertest.cc
@@ -24,7 +24,6 @@ #include "ipc/ipc_listener.h" #include "printing/features/features.h" #include "printing/print_job_constants.h" -#include "printing/units.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/platform/WebMouseEvent.h" #include "third_party/WebKit/public/platform/WebString.h" @@ -211,20 +210,6 @@ } #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) -#if defined(OS_WIN) - // Verifies that the correct page size was returned. - void VerifyPrintedPageSize(const gfx::Size& page_size) { - const IPC::Message* print_msg = - render_thread_->sink().GetUniqueMessageMatching( - PrintHostMsg_DidPrintPage::ID); - PrintHostMsg_DidPrintPage::Param post_did_print_page_param; - PrintHostMsg_DidPrintPage::Read(print_msg, &post_did_print_page_param); - gfx::Size page_size_received = - std::get<0>(post_did_print_page_param).page_size; - EXPECT_EQ(page_size, page_size_received); - } -#endif - // Verifies whether the pages printed or not. void VerifyPagesPrinted(bool printed) { const IPC::Message* print_msg = @@ -986,41 +971,6 @@ VerifyPagesPrinted(true); } -// Tests that when printing non-default scaling values, the page size returned -// by PrintWebViewHelper is still the real physical page size. See -// crbug.com/686384 -TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintForPrintPreviewWithScaling) { - LoadHTML(kPrintPreviewHTML); - - // Fill in some dummy values. - base::DictionaryValue dict; - CreatePrintSettingsDictionary(&dict); - - // Media size - gfx::Size page_size_in = gfx::Size(240, 480); - float device_microns_per_unit = - (printing::kHundrethsMMPerInch * 10.0f) / printing::kDefaultPdfDpi; - int height_microns = - static_cast<int>(page_size_in.height() * device_microns_per_unit); - int width_microns = - static_cast<int>(page_size_in.width() * device_microns_per_unit); - auto media_size = base::MakeUnique<base::DictionaryValue>(); - media_size->SetInteger(kSettingMediaSizeHeightMicrons, height_microns); - media_size->SetInteger(kSettingMediaSizeWidthMicrons, width_microns); - - // Non default scaling value - dict.SetInteger(kSettingScaleFactor, 80); - dict.Set(kSettingMediaSize, media_size.release()); - - OnPrintForPrintPreview(dict); - - VerifyPrintFailed(false); - VerifyPagesPrinted(true); -#if defined(OS_WIN) - VerifyPrintedPageSize(page_size_in); -#endif -} - // Tests that printing from print preview fails and receiving error messages // through that channel all works. TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintForPrintPreviewFail) {
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index b1f3ee5..af72e45 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc
@@ -418,8 +418,6 @@ const gfx::SizeF& viewport_size, const float top_controls_height, const float top_controls_shown_ratio, - const float bottom_controls_height, - const float bottom_controls_shown_ratio, bool is_mobile_optimized_hint, const gfx::SelectionBound& selection_start) { JNIEnv* env = AttachCurrentThread(); @@ -449,20 +447,11 @@ page_scale_factor_limits.x(), page_scale_factor_limits.y(), content_size.width(), content_size.height(), viewport_size.width(), viewport_size.height(), top_controls_height, top_controls_shown_ratio, - bottom_controls_height, bottom_controls_shown_ratio, is_mobile_optimized_hint, has_insertion_marker, is_insertion_marker_visible, insertion_marker_horizontal, insertion_marker_top, insertion_marker_bottom); } -void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); - if (obj.is_null()) - return; - Java_ContentViewCore_onBackgroundColorChanged(env, obj, color); -} - void ContentViewCoreImpl::ShowSelectPopupMenu( RenderFrameHost* frame, const gfx::Rect& bounds, @@ -652,18 +641,6 @@ y_dip); } -void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, - bool is_main_frame) { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); - if (j_obj.is_null()) - return; - ScopedJavaLocalRef<jstring> jcontent_url = - ConvertUTF8ToJavaString(env, content_url.spec()); - Java_ContentViewCore_startContentIntent(env, j_obj, jcontent_url, - is_main_frame); -} - void ContentViewCoreImpl::ShowDisambiguationPopup( const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) {
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 1241f11..20b20f8 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h
@@ -307,8 +307,6 @@ const gfx::SizeF& viewport_size, const float top_controls_height, const float top_controls_shown_ratio, - const float bottom_controls_height, - const float bottom_controls_shown_ratio, bool is_mobile_optimized_hint, const gfx::SelectionBound& selection_start); @@ -324,7 +322,6 @@ int composition_end, bool show_ime_if_needed, bool reply_to_request); - void OnBackgroundColorChanged(SkColor color); bool HasFocus(); void RequestDisallowInterceptTouchEvent(); @@ -336,8 +333,6 @@ const gfx::PointF& selection_anchor, const gfx::RectF& selection_rect); - void StartContentIntent(const GURL& content_url, bool is_main_frame); - // Shows the disambiguation popup // |rect_pixels| --> window coordinates which |zoomed_bitmap| represents // |zoomed_bitmap| --> magnified image of potential touch targets
diff --git a/content/browser/push_messaging/push_messaging_manager.cc b/content/browser/push_messaging/push_messaging_manager.cc index 9f4c262..c3ee50e 100644 --- a/content/browser/push_messaging/push_messaging_manager.cc +++ b/content/browser/push_messaging/push_messaging_manager.cc
@@ -115,6 +115,7 @@ GURL requesting_origin; int64_t service_worker_registration_id; PushSubscriptionOptions options; + SubscribeCallback callback; // The following member should only be read if FromDocument() is true. int render_frame_id; }; @@ -128,8 +129,7 @@ // Public Register methods on UI thread -------------------------------------- // Called via PostTask from IO thread. - void RegisterOnUI(const SubscribeCallback& callback, - const RegisterData& data); + void RegisterOnUI(const RegisterData& data); // Public Unregister methods on UI thread ------------------------------------ @@ -170,12 +170,10 @@ // Private Register methods on UI thread ------------------------------------- - void DidRequestPermissionInIncognito(const SubscribeCallback& callback, - const RegisterData& data, + void DidRequestPermissionInIncognito(const RegisterData& data, blink::mojom::PermissionStatus status); - void DidRegister(const SubscribeCallback& callback, - const RegisterData& data, + void DidRegister(const RegisterData& data, const std::string& push_registration_id, const std::vector<uint8_t>& p256dh, const std::vector<uint8_t>& auth, @@ -266,6 +264,7 @@ data.render_frame_id = render_frame_id; data.service_worker_registration_id = service_worker_registration_id; + data.callback = callback; data.options = options; ServiceWorkerRegistration* service_worker_registration = @@ -273,8 +272,7 @@ data.service_worker_registration_id); if (!service_worker_registration || !service_worker_registration->active_version()) { - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_NO_SERVICE_WORKER); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_NO_SERVICE_WORKER); return; } data.requesting_origin = service_worker_registration->pattern().GetOrigin(); @@ -285,11 +283,10 @@ data.service_worker_registration_id, {kPushRegistrationIdServiceWorkerKey, kPushSenderIdServiceWorkerKey}, base::Bind(&PushMessagingManager::DidCheckForExistingRegistration, - weak_factory_io_to_io_.GetWeakPtr(), callback, data)); + weak_factory_io_to_io_.GetWeakPtr(), data)); } void PushMessagingManager::DidCheckForExistingRegistration( - const SubscribeCallback& callback, const RegisterData& data, const std::vector<std::string>& push_registration_id_and_sender_id, ServiceWorkerStatusCode service_worker_status) { @@ -301,24 +298,22 @@ std::string fixed_sender_id = FixSenderInfo(data.options.sender_info, stored_sender_id); if (fixed_sender_id.empty()) { - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_NO_SENDER_ID); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_NO_SENDER_ID); return; } if (fixed_sender_id != stored_sender_id) { - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_SENDER_ID_MISMATCH); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_SENDER_ID_MISMATCH); return; } - auto callback_ui = base::Bind(&PushMessagingManager::DidGetEncryptionKeys, - weak_factory_io_to_io_.GetWeakPtr(), callback, - data, push_registration_id); + auto callback = base::Bind(&PushMessagingManager::DidGetEncryptionKeys, + weak_factory_io_to_io_.GetWeakPtr(), data, + push_registration_id); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&Core::GetEncryptionInfoOnUI, base::Unretained(ui_core_.get()), data.requesting_origin, data.service_worker_registration_id, fixed_sender_id, - callback_ui)); + callback)); return; } // TODO(johnme): The spec allows the register algorithm to reject with an @@ -327,22 +322,20 @@ // attempting to do a fresh registration? // https://w3c.github.io/push-api/#widl-PushRegistrationManager-register-Promise-PushRegistration if (!data.options.sender_info.empty()) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&Core::RegisterOnUI, base::Unretained(ui_core_.get()), - callback, data)); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(&Core::RegisterOnUI, + base::Unretained(ui_core_.get()), data)); } else { // There is no existing registration and the sender_info passed in was // empty, but perhaps there is a stored sender id we can use. service_worker_context_->GetRegistrationUserData( data.service_worker_registration_id, {kPushSenderIdServiceWorkerKey}, base::Bind(&PushMessagingManager::DidGetSenderIdFromStorage, - weak_factory_io_to_io_.GetWeakPtr(), callback, data)); + weak_factory_io_to_io_.GetWeakPtr(), data)); } } void PushMessagingManager::DidGetEncryptionKeys( - const SubscribeCallback& callback, const RegisterData& data, const std::string& push_registration_id, bool success, @@ -350,25 +343,22 @@ const std::vector<uint8_t>& auth) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!success) { - SendSubscriptionError(callback, data, + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_PUBLIC_KEY_UNAVAILABLE); return; } - SendSubscriptionSuccess(callback, data, - PUSH_REGISTRATION_STATUS_SUCCESS_FROM_CACHE, + SendSubscriptionSuccess(data, PUSH_REGISTRATION_STATUS_SUCCESS_FROM_CACHE, push_registration_id, p256dh, auth); } void PushMessagingManager::DidGetSenderIdFromStorage( - const SubscribeCallback& callback, const RegisterData& data, const std::vector<std::string>& stored_sender_id, ServiceWorkerStatusCode service_worker_status) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (service_worker_status != SERVICE_WORKER_OK) { - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_NO_SENDER_ID); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_NO_SENDER_ID); return; } DCHECK_EQ(1u, stored_sender_id.size()); @@ -377,8 +367,7 @@ std::string fixed_sender_id = FixSenderInfo(data.options.sender_info, stored_sender_id[0]); if (fixed_sender_id.empty()) { - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_NO_SENDER_ID); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_NO_SENDER_ID); return; } RegisterData mutated_data = data; @@ -386,11 +375,10 @@ BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&Core::RegisterOnUI, base::Unretained(ui_core_.get()), - callback, mutated_data)); + mutated_data)); } void PushMessagingManager::Core::RegisterOnUI( - const SubscribeCallback& callback, const PushMessagingManager::RegisterData& data) { DCHECK_CURRENTLY_ON(BrowserThread::UI); PushMessagingService* push_service = service(); @@ -402,8 +390,7 @@ BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PushMessagingManager::SendSubscriptionError, io_parent_, - callback, data, - PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE)); + data, PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE)); } else { // Prevent websites from detecting incognito mode, by emulating what would // have happened if we had a PushMessagingService available. @@ -412,7 +399,7 @@ BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PushMessagingManager::SendSubscriptionError, io_parent_, - callback, data, + data, PUSH_REGISTRATION_STATUS_INCOGNITO_PERMISSION_DENIED)); } else { RenderFrameHost* render_frame_host = @@ -432,7 +419,7 @@ BrowserThread::IO, FROM_HERE, base::Bind( &PushMessagingManager::SendSubscriptionError, io_parent_, - callback, data, + data, PUSH_REGISTRATION_STATUS_INCOGNITO_PERMISSION_DENIED)); return; @@ -446,7 +433,7 @@ data.requesting_origin, false /* user_gesture */, base::Bind( &PushMessagingManager::Core::DidRequestPermissionInIncognito, - weak_factory_ui_to_ui_.GetWeakPtr(), callback, data)); + weak_factory_ui_to_ui_.GetWeakPtr(), data)); } } } @@ -458,18 +445,17 @@ data.requesting_origin, data.service_worker_registration_id, render_process_id_, data.render_frame_id, data.options, base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(), - callback, data)); + data)); } else { push_service->SubscribeFromWorker( data.requesting_origin, data.service_worker_registration_id, data.options, base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(), - callback, data)); + data)); } } void PushMessagingManager::Core::DidRequestPermissionInIncognito( - const SubscribeCallback& callback, const RegisterData& data, blink::mojom::PermissionStatus status) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -477,13 +463,11 @@ DCHECK_EQ(blink::mojom::PermissionStatus::DENIED, status); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&PushMessagingManager::SendSubscriptionError, io_parent_, - callback, data, + base::Bind(&PushMessagingManager::SendSubscriptionError, io_parent_, data, PUSH_REGISTRATION_STATUS_INCOGNITO_PERMISSION_DENIED)); } void PushMessagingManager::Core::DidRegister( - const SubscribeCallback& callback, const RegisterData& data, const std::string& push_registration_id, const std::vector<uint8_t>& p256dh, @@ -494,17 +478,16 @@ BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PushMessagingManager::PersistRegistrationOnIO, io_parent_, - callback, data, push_registration_id, p256dh, auth)); + data, push_registration_id, p256dh, auth)); } else { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PushMessagingManager::SendSubscriptionError, io_parent_, - callback, data, status)); + data, status)); } } void PushMessagingManager::PersistRegistrationOnIO( - const SubscribeCallback& callback, const RegisterData& data, const std::string& push_registration_id, const std::vector<uint8_t>& p256dh, @@ -515,12 +498,11 @@ {{kPushRegistrationIdServiceWorkerKey, push_registration_id}, {kPushSenderIdServiceWorkerKey, data.options.sender_info}}, base::Bind(&PushMessagingManager::DidPersistRegistrationOnIO, - weak_factory_io_to_io_.GetWeakPtr(), callback, data, + weak_factory_io_to_io_.GetWeakPtr(), data, push_registration_id, p256dh, auth)); } void PushMessagingManager::DidPersistRegistrationOnIO( - const SubscribeCallback& callback, const RegisterData& data, const std::string& push_registration_id, const std::vector<uint8_t>& p256dh, @@ -528,30 +510,27 @@ ServiceWorkerStatusCode service_worker_status) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (service_worker_status == SERVICE_WORKER_OK) { - SendSubscriptionSuccess(callback, data, + SendSubscriptionSuccess(data, PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE, push_registration_id, p256dh, auth); } else { // TODO(johnme): Unregister, so PushMessagingServiceImpl can decrease count. - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_STORAGE_ERROR); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_STORAGE_ERROR); } } void PushMessagingManager::SendSubscriptionError( - const SubscribeCallback& callback, const RegisterData& data, PushRegistrationStatus status) { // Only called from IO thread, but would be safe to call from UI thread. DCHECK_CURRENTLY_ON(BrowserThread::IO); - callback.Run(status, base::nullopt /* endpoint */, - base::nullopt /* options */, base::nullopt /* p256dh */, - base::nullopt /* auth */); + data.callback.Run(status, base::nullopt /* endpoint */, + base::nullopt /* options */, base::nullopt /* p256dh */, + base::nullopt /* auth */); RecordRegistrationStatus(status); } void PushMessagingManager::SendSubscriptionSuccess( - const SubscribeCallback& callback, const RegisterData& data, PushRegistrationStatus status, const std::string& push_subscription_id, @@ -563,15 +542,14 @@ // This shouldn't be possible in incognito mode, since we've already checked // that we have an existing registration. Hence it's ok to throw an error. DCHECK(!ui_core_->is_incognito()); - SendSubscriptionError(callback, data, - PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE); + SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE); return; } const GURL endpoint = CreateEndpoint( IsApplicationServerKey(data.options.sender_info), push_subscription_id); - callback.Run(status, endpoint, data.options, p256dh, auth); + data.callback.Run(status, endpoint, data.options, p256dh, auth); RecordRegistrationStatus(status); }
diff --git a/content/browser/push_messaging/push_messaging_manager.h b/content/browser/push_messaging/push_messaging_manager.h index d2056d5..9457fab1 100644 --- a/content/browser/push_messaging/push_messaging_manager.h +++ b/content/browser/push_messaging/push_messaging_manager.h
@@ -62,32 +62,27 @@ ~PushMessagingManager() override; void DidCheckForExistingRegistration( - const SubscribeCallback& callback, const RegisterData& data, const std::vector<std::string>& push_registration_id, ServiceWorkerStatusCode service_worker_status); - void DidGetEncryptionKeys(const SubscribeCallback& callback, - const RegisterData& data, + void DidGetEncryptionKeys(const RegisterData& data, const std::string& push_registration_id, bool success, const std::vector<uint8_t>& p256dh, const std::vector<uint8_t>& auth); - void DidGetSenderIdFromStorage(const SubscribeCallback& callback, - const RegisterData& data, + void DidGetSenderIdFromStorage(const RegisterData& data, const std::vector<std::string>& sender_id, ServiceWorkerStatusCode service_worker_status); // Called via PostTask from UI thread. - void PersistRegistrationOnIO(const SubscribeCallback& callback, - const RegisterData& data, + void PersistRegistrationOnIO(const RegisterData& data, const std::string& push_registration_id, const std::vector<uint8_t>& p256dh, const std::vector<uint8_t>& auth); void DidPersistRegistrationOnIO( - const SubscribeCallback& callback, const RegisterData& data, const std::string& push_registration_id, const std::vector<uint8_t>& p256dh, @@ -95,12 +90,10 @@ ServiceWorkerStatusCode service_worker_status); // Called both from IO thread, and via PostTask from UI thread. - void SendSubscriptionError(const SubscribeCallback& callback, - const RegisterData& data, + void SendSubscriptionError(const RegisterData& data, PushRegistrationStatus status); // Called both from IO thread, and via PostTask from UI thread. - void SendSubscriptionSuccess(const SubscribeCallback& callback, - const RegisterData& data, + void SendSubscriptionSuccess(const RegisterData& data, PushRegistrationStatus status, const std::string& push_subscription_id, const std::vector<uint8_t>& p256dh,
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index f2c74b3..bf8d780 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -399,6 +399,10 @@ display_compositor::GLHelper::SCALER_QUALITY_GOOD); } +bool FloatEquals(float a, float b) { + return std::abs(a - b) < FLT_EPSILON; +} + } // namespace void RenderWidgetHostViewAndroid::OnContextLost() { @@ -434,6 +438,8 @@ synchronous_compositor_client_(nullptr), frame_evictor_(new DelegatedFrameEvictor(this)), observing_root_window_(false), + prev_top_shown_pix_(0.f), + prev_bottom_shown_pix_(0.f), weak_ptr_factory_(this) { // Set the layer which will hold the content layer for this view. The content // layer is managed by the DelegatedFrameHost. @@ -784,8 +790,7 @@ if (delegated_frame_host_) delegated_frame_host_->UpdateBackgroundColor(color); - if (content_view_core_) - content_view_core_->OnBackgroundColorChanged(color); + view_.OnBackgroundColorChanged(color); } void RenderWidgetHostViewAndroid::SetNeedsBeginFrames(bool needs_begin_frames) { @@ -799,8 +804,7 @@ void RenderWidgetHostViewAndroid::OnStartContentIntent( const GURL& content_url, bool is_main_frame) { - if (content_view_core_) - content_view_core_->StartContentIntent(content_url, is_main_frame); + view_.StartContentIntent(content_url, is_main_frame); } bool RenderWidgetHostViewAndroid::OnTouchEvent( @@ -1268,6 +1272,28 @@ frame_metadata.top_controls_height * frame_metadata.top_controls_shown_ratio)); + float dip_scale = ui::GetScaleFactorForNativeView(GetNativeView()); + float top_controls_pix = frame_metadata.top_controls_height * dip_scale; + float top_shown_pix = + top_controls_pix * frame_metadata.top_controls_shown_ratio; + bool top_changed = !FloatEquals(top_shown_pix, prev_top_shown_pix_); + + float bottom_controls_pix = frame_metadata.bottom_controls_height * dip_scale; + float bottom_shown_pix = + bottom_controls_pix * frame_metadata.bottom_controls_shown_ratio; + bool bottom_changed = !FloatEquals(bottom_shown_pix, prev_bottom_shown_pix_); + + if (top_changed) { + float translate = top_shown_pix - top_controls_pix; + view_.OnTopControlsChanged(translate, top_shown_pix); + prev_top_shown_pix_ = top_shown_pix; + } + if (bottom_changed) { + float translate = bottom_controls_pix - bottom_shown_pix; + view_.OnBottomControlsChanged(translate, bottom_shown_pix); + prev_bottom_shown_pix_ = bottom_shown_pix; + } + // All offsets and sizes are in CSS pixels. content_view_core_->UpdateFrameInfo( frame_metadata.root_scroll_offset, @@ -1278,8 +1304,6 @@ frame_metadata.scrollable_viewport_size, frame_metadata.top_controls_height, frame_metadata.top_controls_shown_ratio, - frame_metadata.bottom_controls_height, - frame_metadata.bottom_controls_shown_ratio, is_mobile_optimized, frame_metadata.selection.start); }
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 9ac9184..dc3c6e705 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -378,6 +378,9 @@ // The last scroll offset of the view. gfx::Vector2dF last_scroll_offset_; + float prev_top_shown_pix_; + float prev_bottom_shown_pix_; + base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid);
diff --git a/content/child/push_messaging/push_provider.cc b/content/child/push_messaging/push_provider.cc index f61a9a2..7807c14d 100644 --- a/content/child/push_messaging/push_provider.cc +++ b/content/child/push_messaging/push_provider.cc
@@ -136,20 +136,18 @@ content_options, // Safe to use base::Unretained because |push_messaging_manager_ |is owned // by |this|. - base::Bind(&PushProvider::SubscribeCallback, base::Unretained(this), + base::Bind(&PushProvider::DidSubscribe, base::Unretained(this), base::Passed(&callbacks))); } -void PushProvider::SubscribeCallback( +void PushProvider::DidSubscribe( std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, content::PushRegistrationStatus status, const base::Optional<GURL>& endpoint, const base::Optional<content::PushSubscriptionOptions>& options, const base::Optional<std::vector<uint8_t>>& p256dh, const base::Optional<std::vector<uint8_t>>& auth) { - if (!callbacks) { - return; - } + DCHECK(callbacks); if (status == PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE || status == PUSH_REGISTRATION_STATUS_SUCCESS_FROM_CACHE) { @@ -180,19 +178,17 @@ service_worker_registration_id, // Safe to use base::Unretained because |push_messaging_manager_ |is owned // by |this|. - base::Bind(&PushProvider::UnsubscribeCallback, base::Unretained(this), + base::Bind(&PushProvider::DidUnsubscribe, base::Unretained(this), base::Passed(&callbacks))); } -void PushProvider::UnsubscribeCallback( +void PushProvider::DidUnsubscribe( std::unique_ptr<blink::WebPushUnsubscribeCallbacks> callbacks, bool is_success, bool did_unsubscribe, blink::WebPushError::ErrorType error_type, const base::Optional<std::string>& error_message) { - if (!callbacks) { - return; - } + DCHECK(callbacks); if (is_success) { callbacks->onSuccess(did_unsubscribe); @@ -215,19 +211,18 @@ service_worker_registration_id, // Safe to use base::Unretained because |push_messaging_manager_ |is owned // by |this|. - base::Bind(&PushProvider::GetSubscriptionCallback, base::Unretained(this), + base::Bind(&PushProvider::DidGetSubscription, base::Unretained(this), base::Passed(&callbacks))); } -void PushProvider::GetSubscriptionCallback( +void PushProvider::DidGetSubscription( std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, content::PushGetRegistrationStatus status, const base::Optional<GURL>& endpoint, const base::Optional<content::PushSubscriptionOptions>& options, const base::Optional<std::vector<uint8_t>>& p256dh, const base::Optional<std::vector<uint8_t>>& auth) { - if (!callbacks) - return; + DCHECK(callbacks); if (status == PUSH_GETREGISTRATION_STATUS_SUCCESS) { DCHECK(endpoint); @@ -259,17 +254,16 @@ service_worker_registration_id, options.userVisibleOnly, // Safe to use base::Unretained because |push_messaging_manager_ |is owned // by |this|. - base::Bind(&PushProvider::GetPermissionStatusCallback, - base::Unretained(this), base::Passed(&callbacks))); + base::Bind(&PushProvider::DidGetPermissionStatus, base::Unretained(this), + base::Passed(&callbacks))); } -void PushProvider::GetPermissionStatusCallback( +void PushProvider::DidGetPermissionStatus( std::unique_ptr<blink::WebPushPermissionStatusCallbacks> callbacks, bool is_success, blink::WebPushPermissionStatus status, blink::WebPushError::ErrorType error) { - if (!callbacks) - return; + DCHECK(callbacks); if (is_success) { callbacks->onSuccess(status);
diff --git a/content/child/push_messaging/push_provider.h b/content/child/push_messaging/push_provider.h index 1b9c9a7..5f89d7f 100644 --- a/content/child/push_messaging/push_provider.h +++ b/content/child/push_messaging/push_provider.h
@@ -67,7 +67,7 @@ static void GetInterface(mojom::PushMessagingRequest request); - void SubscribeCallback( + void DidSubscribe( std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, content::PushRegistrationStatus status, const base::Optional<GURL>& endpoint, @@ -75,14 +75,14 @@ const base::Optional<std::vector<uint8_t>>& p256dh, const base::Optional<std::vector<uint8_t>>& auth); - void UnsubscribeCallback( + void DidUnsubscribe( std::unique_ptr<blink::WebPushUnsubscribeCallbacks> callbacks, bool is_success, bool did_unsubscribe, blink::WebPushError::ErrorType error_type, const base::Optional<std::string>& error_message); - void GetSubscriptionCallback( + void DidGetSubscription( std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, content::PushGetRegistrationStatus status, const base::Optional<GURL>& endpoint, @@ -90,7 +90,7 @@ const base::Optional<std::vector<uint8_t>>& p256dh, const base::Optional<std::vector<uint8_t>>& auth); - void GetPermissionStatusCallback( + void DidGetPermissionStatus( std::unique_ptr<blink::WebPushPermissionStatusCallbacks> callbacks, bool is_success, blink::WebPushPermissionStatus status,
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java index be561324..6ef25210 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
@@ -4,14 +4,8 @@ package org.chromium.content.browser; -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.Intent; import android.view.KeyEvent; -import org.chromium.base.Log; -import org.chromium.base.metrics.RecordUserAction; - /** * Main callback class used by ContentView. * @@ -20,103 +14,21 @@ * The memory and reference ownership of this class is unusual - see the .cc file and ContentView * for more details. * - * TODO(mkosiba): Rid this class of default implementations. This class is used by both WebView and - * the browser and we don't want a the browser-specific default implementation to accidentally leak - * over to WebView. - * * WARNING: ConteViewClient is going away. Do not add new stuff in this class. */ public class ContentViewClient { - // Tag used for logging. - private static final String TAG = "cr_ContentViewClient"; - - private static final String GEO_SCHEME = "geo"; - private static final String TEL_SCHEME = "tel"; - private static final String MAILTO_SCHEME = "mailto"; - - /** - * Called whenever the background color of the page changes as notified by WebKit. - * @param color The new ARGB color of the page background. - */ - public void onBackgroundColorChanged(int color) { - } - - /** - * Notifies the client of the position of the top controls. - * @param topControlsOffsetY The Y offset of the top controls in physical pixels. - * @param topContentOffsetY The Y offset of the content in physical pixels. - */ - public void onTopControlsChanged(float browserControlsOffsetY, float topContentOffsetY) {} - - /** - * Notifies the client of the position of the bottom controls. - * @param bottomControlsOffsetY The Y offset of the bottom controls in physical pixels. - * @param bottomContentOffsetY The Y offset of the content in physical pixels. - */ - public void onBottomControlsChanged(float bottomControlsOffsetY, float bottomContentOffsetY) { } - - public boolean shouldOverrideKeyEvent(KeyEvent event) { - int keyCode = event.getKeyCode(); - - if (!shouldPropagateKey(keyCode)) return true; - - return false; - } - /** * Called when an ImeEvent is sent to the page. Can be used to know when some text is entered * in a page. */ - public void onImeEvent() { - } + public void onImeEvent() {} /** * Notified when the editability of the focused node changes. * * @param editable Whether the focused node is editable. */ - public void onFocusedNodeEditabilityChanged(boolean editable) { - } - - /** - * Check whether the given scheme is one of the acceptable schemes for onStartContentIntent. - * - * @param scheme The scheme to check. - * @return true if the scheme is okay, false if it should be blocked. - */ - protected boolean isAcceptableContentIntentScheme(String scheme) { - return GEO_SCHEME.equals(scheme) || TEL_SCHEME.equals(scheme) - || MAILTO_SCHEME.equals(scheme); - } - - /** - * Called when a new content intent is requested to be started. - */ - public void onStartContentIntent(Context context, String intentUrl, boolean isMainFrame) { - Intent intent; - // Perform generic parsing of the URI to turn it into an Intent. - try { - intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME); - - String scheme = intent.getScheme(); - if (!isAcceptableContentIntentScheme(scheme)) { - Log.w(TAG, "Invalid scheme for URI %s", intentUrl); - return; - } - - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } catch (Exception ex) { - Log.w(TAG, "Bad URI %s", intentUrl, ex); - return; - } - - try { - RecordUserAction.record("Android.ContentDetectorActivated"); - context.startActivity(intent); - } catch (ActivityNotFoundException ex) { - Log.w(TAG, "No application can handle %s", intentUrl); - } - } + public void onFocusedNodeEditabilityChanged(boolean editable) {} /** * Check whether a key should be propagated to the embedder or not. @@ -147,33 +59,10 @@ } /** - * Returns the left system window inset in pixels. The system window inset represents the area - * of a full-screen window that is partially or fully obscured by the status bar, navigation - * bar, IME or other system windows. - * @return The left system window inset. + * @see {@link #shouldPropagateKey(int) */ - public int getSystemWindowInsetLeft() { - return 0; - } - - /** - * Returns the top system window inset in pixels. The system window inset represents the area of - * a full-screen window that is partially or fully obscured by the status bar, navigation bar, - * IME or other system windows. - * @return The top system window inset. - */ - public int getSystemWindowInsetTop() { - return 0; - } - - /** - * Returns the right system window inset in pixels. The system window inset represents the area - * of a full-screen window that is partially or fully obscured by the status bar, navigation - * bar, IME or other system windows. - * @return The right system window inset. - */ - public int getSystemWindowInsetRight() { - return 0; + public boolean shouldOverrideKeyEvent(KeyEvent event) { + return !shouldPropagateKey(event.getKeyCode()); } /**
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index ac344eb..b25e034 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -827,11 +827,6 @@ return mContentViewClient; } - @CalledByNative - private void onBackgroundColorChanged(int color) { - getContentViewClient().onBackgroundColorChanged(color); - } - /** * @return Viewport width in physical pixels as set from onSizeChanged. */ @@ -1806,7 +1801,6 @@ float minPageScaleFactor, float maxPageScaleFactor, float contentWidth, float contentHeight, float viewportWidth, float viewportHeight, float browserControlsHeightDp, float browserControlsShownRatio, - float bottomControlsHeightDp, float bottomControlsShownRatio, boolean isMobileOptimizedHint, boolean hasInsertionMarker, boolean isInsertionMarkerVisible, float insertionMarkerHorizontal, float insertionMarkerTop, float insertionMarkerBottom) { @@ -1821,8 +1815,6 @@ mViewportHeightPix / (deviceScale * pageScaleFactor)); final float topBarShownPix = browserControlsHeightDp * deviceScale * browserControlsShownRatio; - final float bottomBarShownPix = bottomControlsHeightDp * deviceScale - * bottomControlsShownRatio; final boolean contentSizeChanged = contentWidth != mRenderCoordinates.getContentWidthCss() @@ -1838,8 +1830,6 @@ || scrollOffsetY != mRenderCoordinates.getScrollY(); final boolean topBarChanged = Float.compare(topBarShownPix, mRenderCoordinates.getContentOffsetYPix()) != 0; - final boolean bottomBarChanged = Float.compare(bottomBarShownPix, mRenderCoordinates - .getContentOffsetYPixBottom()) != 0; final boolean needHidePopupZoomer = contentSizeChanged || scrollChanged; @@ -1853,12 +1843,9 @@ (int) mRenderCoordinates.getScrollYPix()); } - mRenderCoordinates.updateFrameInfo( - scrollOffsetX, scrollOffsetY, - contentWidth, contentHeight, - viewportWidth, viewportHeight, - pageScaleFactor, minPageScaleFactor, maxPageScaleFactor, - topBarShownPix, bottomBarShownPix); + mRenderCoordinates.updateFrameInfo(scrollOffsetX, scrollOffsetY, contentWidth, + contentHeight, viewportWidth, viewportHeight, pageScaleFactor, minPageScaleFactor, + maxPageScaleFactor, topBarShownPix); if (scrollChanged || topBarChanged) { for (mGestureStateListenersIterator.rewind(); @@ -1877,15 +1864,6 @@ } } - if (topBarChanged) { - float topBarTranslate = topBarShownPix - browserControlsHeightDp * deviceScale; - getContentViewClient().onTopControlsChanged(topBarTranslate, topBarShownPix); - } - if (bottomBarChanged) { - float bottomBarTranslate = bottomControlsHeightDp * deviceScale - bottomBarShownPix; - getContentViewClient().onBottomControlsChanged(bottomBarTranslate, bottomBarShownPix); - } - if (mBrowserAccessibilityManager != null) { mBrowserAccessibilityManager.notifyFrameInfoInitialized(); } @@ -2304,11 +2282,6 @@ return mRenderCoordinates.getPageScaleFactor(); } - @CalledByNative - private void startContentIntent(String contentUrl, boolean isMainFrame) { - getContentViewClient().onStartContentIntent(getContext(), contentUrl, isMainFrame); - } - @Override public void onAccessibilityStateChanged(boolean enabled) { setAccessibilityState(enabled);
diff --git a/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java b/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java index fcce242..d2f3bd85 100644 --- a/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java +++ b/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java
@@ -46,7 +46,6 @@ private float mWheelScrollFactor; private float mTopContentOffsetYPix; - private float mBottomContentOffsetYPix; private boolean mHasFrameInfo; @@ -82,19 +81,16 @@ } } - void updateFrameInfo( - float scrollXCss, float scrollYCss, - float contentWidthCss, float contentHeightCss, - float viewportWidthCss, float viewportHeightCss, + void updateFrameInfo(float scrollXCss, float scrollYCss, float contentWidthCss, + float contentHeightCss, float viewportWidthCss, float viewportHeightCss, float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor, - float contentOffsetYPix, float contentOffsetYPixBottom) { + float contentOffsetYPix) { mScrollXCss = scrollXCss; mScrollYCss = scrollYCss; mPageScaleFactor = pageScaleFactor; mMinPageScaleFactor = minPageScaleFactor; mMaxPageScaleFactor = maxPageScaleFactor; mTopContentOffsetYPix = contentOffsetYPix; - mBottomContentOffsetYPix = contentOffsetYPixBottom; updateContentSizeCss(contentWidthCss, contentHeightCss); mLastFrameViewportWidthCss = viewportWidthCss; @@ -333,13 +329,6 @@ } /** - * @return The Physical on-screen Y offset amount below the bottom controls. - */ - public float getContentOffsetYPixBottom() { - return mBottomContentOffsetYPix; - } - - /** * @return Current page scale factor (maps CSS pixels to DIP pixels). */ public float getPageScaleFactor() {
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java index 4a6fa245..0c2fac8 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java
@@ -6,13 +6,15 @@ import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; +import android.app.Activity; import android.net.Uri; +import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.UrlUtils; import org.chromium.content.browser.test.util.DOMUtils; import org.chromium.content.browser.test.util.TestCallbackHelperContainer; import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper; -import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnStartContentIntentHelper; +import org.chromium.content_shell.ShellViewAndroidDelegate.ContentIntentHandler; import org.chromium.content_shell_apk.ContentShellTestBase; import java.util.concurrent.TimeUnit; @@ -25,6 +27,41 @@ private static final long WAIT_TIMEOUT_SECONDS = scaleTimeout(10); private TestCallbackHelperContainer mCallbackHelper; + private TestContentIntentHandler mContentIntentHandler; + + /** + * CallbackHelper for OnStartContentIntent. + */ + private static class OnStartContentIntentHelper extends CallbackHelper { + private String mIntentUrl; + public void notifyCalled(String intentUrl) { + mIntentUrl = intentUrl; + notifyCalled(); + } + public String getIntentUrl() { + assert getCallCount() > 0; + return mIntentUrl; + } + } + + /** + * ContentIntentHandler impl to test content detection. + */ + private static class TestContentIntentHandler implements ContentIntentHandler { + private OnStartContentIntentHelper mOnStartContentIntentHelper; + + public OnStartContentIntentHelper getOnStartContentIntentHelper() { + if (mOnStartContentIntentHelper == null) { + mOnStartContentIntentHelper = new OnStartContentIntentHelper(); + } + return mOnStartContentIntentHelper; + } + + @Override + public void onIntentUrlReceived(String intentUrl) { + mOnStartContentIntentHelper.notifyCalled(intentUrl); + } + } /** * Returns the TestCallbackHelperContainer associated with this ContentView, @@ -37,12 +74,28 @@ return mCallbackHelper; } + @Override + protected void setUp() throws Exception { + super.setUp(); + mContentIntentHandler = new TestContentIntentHandler(); + } + + @Override + protected void setActivity(Activity activity) { + super.setActivity(activity); + getActivity() + .getShellManager() + .getActiveShell() + .getViewAndroidDelegate() + .setContentIntentHandler(mContentIntentHandler); + } + /** * Encodes the provided content string into an escaped url as intents do. * @param content Content to escape into a url. * @return Escaped url. */ - protected String urlForContent(String content) { + protected static String urlForContent(String content) { return Uri.encode(content).replaceAll("%20", "+"); } @@ -62,9 +115,8 @@ * @return The content url of the received intent or null if none. */ protected String scrollAndTapExpectingIntent(String id) throws Throwable { - TestCallbackHelperContainer callbackHelperContainer = getTestCallbackHelperContainer(); OnStartContentIntentHelper onStartContentIntentHelper = - callbackHelperContainer.getOnStartContentIntentHelper(); + mContentIntentHandler.getOnStartContentIntentHelper(); int currentCallCount = onStartContentIntentHelper.getCallCount(); DOMUtils.clickNode(getContentViewCore(), id); @@ -93,4 +145,4 @@ TimeUnit.SECONDS); getInstrumentation().waitForIdleSync(); } -} +} \ No newline at end of file
diff --git a/content/public/test/android/BUILD.gn b/content/public/test/android/BUILD.gn index a2bd7c8..2d1af8a 100644 --- a/content/public/test/android/BUILD.gn +++ b/content/public/test/android/BUILD.gn
@@ -38,7 +38,6 @@ "javatests/src/org/chromium/content/browser/test/util/KeyUtils.java", "javatests/src/org/chromium/content/browser/test/util/RenderProcessLimit.java", "javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java", - "javatests/src/org/chromium/content/browser/test/util/TestContentViewClient.java", "javatests/src/org/chromium/content/browser/test/util/TestInputMethodManagerWrapper.java", "javatests/src/org/chromium/content/browser/test/util/TestTouchUtils.java", "javatests/src/org/chromium/content/browser/test/util/TestWebContentsObserver.java",
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java index c06fa6c..701106e 100644 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java
@@ -17,12 +17,9 @@ * This class is used to provide callback hooks for tests and related classes. */ public class TestCallbackHelperContainer { - private final TestContentViewClient mTestContentViewClient; private TestWebContentsObserver mTestWebContentsObserver; public TestCallbackHelperContainer(final ContentViewCore contentViewCore) { - mTestContentViewClient = new TestContentViewClient(); - contentViewCore.setContentViewClient(mTestContentViewClient); // TODO(yfriedman): Change callers to be executed on the UI thread. Unfortunately this is // super convenient as the caller is nearly always on the test thread which is fine to block // and it's cumbersome to keep bouncing to the UI thread. @@ -35,12 +32,6 @@ }); } - protected TestCallbackHelperContainer( - TestContentViewClient viewClient, TestWebContentsObserver contentsObserver) { - mTestContentViewClient = viewClient; - mTestWebContentsObserver = contentsObserver; - } - /** * CallbackHelper for OnPageCommitVisible. */ @@ -181,21 +172,6 @@ } } - /** - * CallbackHelper for OnStartContentIntent. - */ - public static class OnStartContentIntentHelper extends CallbackHelper { - private String mIntentUrl; - public void notifyCalled(String intentUrl) { - mIntentUrl = intentUrl; - notifyCalled(); - } - public String getIntentUrl() { - assert getCallCount() > 0; - return mIntentUrl; - } - } - public OnPageStartedHelper getOnPageStartedHelper() { return mTestWebContentsObserver.getOnPageStartedHelper(); } @@ -207,8 +183,4 @@ public OnReceivedErrorHelper getOnReceivedErrorHelper() { return mTestWebContentsObserver.getOnReceivedErrorHelper(); } - - public OnStartContentIntentHelper getOnStartContentIntentHelper() { - return mTestContentViewClient.getOnStartContentIntentHelper(); - } }
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestContentViewClient.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestContentViewClient.java deleted file mode 100644 index 7fda5207b..0000000 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestContentViewClient.java +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.content.browser.test.util; - -import android.content.Context; - -import org.chromium.content.browser.ContentViewClient; -import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnStartContentIntentHelper; - -/** - * The default ContentViewClient used by ContentView tests. - * <p> - * Tests that need to supply their own ContentViewClient should do that - * by extending this one. - */ -public class TestContentViewClient extends ContentViewClient { - - private final OnStartContentIntentHelper mOnStartContentIntentHelper; - - public TestContentViewClient() { - mOnStartContentIntentHelper = new OnStartContentIntentHelper(); - } - - public OnStartContentIntentHelper getOnStartContentIntentHelper() { - return mOnStartContentIntentHelper; - } - - /** - * ATTENTION!: When overriding the following method, be sure to call - * the corresponding method in the super class. Otherwise - * {@link CallbackHelper#waitForCallback()} methods will - * stop working! - */ - - @Override - public void onStartContentIntent(Context context, String contentUrl, boolean isMainFrame) { - mOnStartContentIntentHelper.notifyCalled(contentUrl); - } -}
diff --git a/content/renderer/push_messaging/push_messaging_client.cc b/content/renderer/push_messaging/push_messaging_client.cc index 3cef773..0ec384e 100644 --- a/content/renderer/push_messaging/push_messaging_client.cc +++ b/content/renderer/push_messaging/push_messaging_client.cc
@@ -77,10 +77,9 @@ // Get the sender_info from the manifest since it wasn't provided by // the caller. if (manifest.IsEmpty()) { - SubscribeCallback(std::move(callbacks), - PUSH_REGISTRATION_STATUS_MANIFEST_EMPTY_OR_MISSING, - base::nullopt, base::nullopt, base::nullopt, - base::nullopt); + DidSubscribe(std::move(callbacks), + PUSH_REGISTRATION_STATUS_MANIFEST_EMPTY_OR_MISSING, + base::nullopt, base::nullopt, base::nullopt, base::nullopt); return; } @@ -105,9 +104,8 @@ ->registrationId(); if (options.sender_info.empty()) { - SubscribeCallback(std::move(callbacks), - PUSH_REGISTRATION_STATUS_NO_SENDER_ID, base::nullopt, - base::nullopt, base::nullopt, base::nullopt); + DidSubscribe(std::move(callbacks), PUSH_REGISTRATION_STATUS_NO_SENDER_ID, + base::nullopt, base::nullopt, base::nullopt, base::nullopt); return; } @@ -116,11 +114,11 @@ routing_id(), service_worker_registration_id, options, // Safe to use base::Unretained because |push_messaging_manager_ |is // owned by |this|. - base::Bind(&PushMessagingClient::SubscribeCallback, - base::Unretained(this), base::Passed(&callbacks))); + base::Bind(&PushMessagingClient::DidSubscribe, base::Unretained(this), + base::Passed(&callbacks))); } -void PushMessagingClient::SubscribeCallback( +void PushMessagingClient::DidSubscribe( std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, content::PushRegistrationStatus status, const base::Optional<GURL>& endpoint,
diff --git a/content/renderer/push_messaging/push_messaging_client.h b/content/renderer/push_messaging/push_messaging_client.h index 430d601..4cda6e4 100644 --- a/content/renderer/push_messaging/push_messaging_client.h +++ b/content/renderer/push_messaging/push_messaging_client.h
@@ -59,7 +59,7 @@ const PushSubscriptionOptions& options, std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks); - void SubscribeCallback( + void DidSubscribe( std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, content::PushRegistrationStatus status, const base::Optional<GURL>& endpoint,
diff --git a/content/shell/android/BUILD.gn b/content/shell/android/BUILD.gn index 3eed8d5..278ab5f 100644 --- a/content/shell/android/BUILD.gn +++ b/content/shell/android/BUILD.gn
@@ -55,6 +55,7 @@ "java/src/org/chromium/content_shell/Shell.java", "java/src/org/chromium/content_shell/ShellLayoutTestUtils.java", "java/src/org/chromium/content_shell/ShellManager.java", + "java/src/org/chromium/content_shell/ShellViewAndroidDelegate.java", ] }
diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java index e2f82e34..6215bf40 100644 --- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java +++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
@@ -36,7 +36,6 @@ import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.WebContents; -import org.chromium.ui.base.ViewAndroidDelegate; import org.chromium.ui.base.WindowAndroid; /** @@ -68,6 +67,7 @@ private long mNativeShell; private ContentViewRenderView mContentViewRenderView; private WindowAndroid mWindow; + private ShellViewAndroidDelegate mViewAndroidDelegate; private boolean mLoading; private boolean mIsFullscreen; @@ -286,6 +286,10 @@ } } + public ShellViewAndroidDelegate getViewAndroidDelegate() { + return mViewAndroidDelegate; + } + /** * Initializes the ContentView based on the native tab contents pointer passed in. * @param webContents A {@link WebContents} object. @@ -296,8 +300,8 @@ Context context = getContext(); mContentViewCore = new ContentViewCore(context, ""); ContentView cv = ContentView.createContentView(context, mContentViewCore); - mContentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, - webContents, mWindow); + mViewAndroidDelegate = new ShellViewAndroidDelegate(cv); + mContentViewCore.initialize(mViewAndroidDelegate, cv, webContents, mWindow); mContentViewCore.setActionModeCallback(defaultActionCallback()); mContentViewCore.setContentViewClient(mContentViewClient); mWebContents = mContentViewCore.getWebContents();
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ShellViewAndroidDelegate.java b/content/shell/android/java/src/org/chromium/content_shell/ShellViewAndroidDelegate.java new file mode 100644 index 0000000..b1102b3 --- /dev/null +++ b/content/shell/android/java/src/org/chromium/content_shell/ShellViewAndroidDelegate.java
@@ -0,0 +1,52 @@ +// 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. + +package org.chromium.content_shell; + +import android.content.Intent; +import android.view.ViewGroup; + +import org.chromium.ui.base.ViewAndroidDelegate; + +/** + * Implementation of the abstract class {@link ViewAndroidDelegate} for content shell. + * Extended for testing. + */ +public class ShellViewAndroidDelegate extends ViewAndroidDelegate { + private final ViewGroup mContainerView; + private ContentIntentHandler mContentIntentHandler; + + /** + * Interface used to define/modify what {@link #startContentIntent} does. + */ + public interface ContentIntentHandler { + /** + * Called when intent url from content is received. + * @param intentUrl intent url. + */ + void onIntentUrlReceived(String intentUrl); + } + + public ShellViewAndroidDelegate(ViewGroup containerView) { + mContainerView = containerView; + } + + /** + * Set the {@link ContentIntentHandler} for {@link #starContentIntent}. + * @param handler Handler to inject to {@link #startContentIntent}. + */ + public void setContentIntentHandler(ContentIntentHandler handler) { + mContentIntentHandler = handler; + } + + @Override + public void startContentIntent(Intent intent, String intentUrl, boolean isMainFrame) { + if (mContentIntentHandler != null) mContentIntentHandler.onIntentUrlReceived(intentUrl); + } + + @Override + public ViewGroup getContainerView() { + return mContainerView; + } +}
diff --git a/content/test/gpu/gpu_tests/pixel_expectations.py b/content/test/gpu/gpu_tests/pixel_expectations.py index b766c33..457efd2 100644 --- a/content/test/gpu/gpu_tests/pixel_expectations.py +++ b/content/test/gpu/gpu_tests/pixel_expectations.py
@@ -49,3 +49,28 @@ self.Flaky('Pixel_OffscreenCanvas2DResizeOnWorker', ['win10', ('intel', 0x1912)], bug=690663) + + # TODO(kainino): temporary expectations due to expected result changes + # http://crrev.com/2707623002 + self.Fail('Pixel_2DCanvasWebGL', ['android']) + self.Fail('Pixel_CSS3DBlueBox', ['android']) + self.Fail('Pixel_Canvas2DRedBox', ['android']) + self.Fail('Pixel_CanvasDisplayLinearRGBAccelerated2D', ['android']) + self.Fail('Pixel_CanvasDisplayLinearRGBUnaccelerated2DGPUCompositing', ['android']) + self.Fail('Pixel_OffscreenCanvas2DResizeOnWorker', ['android']) + self.Fail('Pixel_OffscreenCanvasAccelerated2D', ['android']) + self.Fail('Pixel_OffscreenCanvasAccelerated2DWorker', ['android']) + self.Fail('Pixel_OffscreenCanvasTransferAfterStyleResize', ['android']) + self.Fail('Pixel_OffscreenCanvasTransferBeforeStyleResize', ['android']) + self.Fail('Pixel_OffscreenCanvasTransferToImageBitmap', ['android']) + self.Fail('Pixel_OffscreenCanvasTransferToImageBitmapWorker', ['android']) + self.Fail('Pixel_OffscreenCanvasUnaccelerated2DGPUCompositing', ['android']) + self.Fail('Pixel_OffscreenCanvasUnaccelerated2DGPUCompositingWorker', ['android']) + self.Fail('Pixel_OffscreenCanvasWebGLDefault', ['android']) + self.Fail('Pixel_OffscreenCanvasWebGLDefaultWorker', ['android']) + self.Fail('Pixel_OffscreenCanvasWebglResizeOnWorker', ['android']) + self.Fail('Pixel_WebGLGreenTriangle_AA_Alpha', ['android']) + self.Fail('Pixel_WebGLGreenTriangle_AA_NoAlpha', ['android']) + self.Fail('Pixel_WebGLGreenTriangle_NoAA_Alpha', ['android']) + self.Fail('Pixel_WebGLGreenTriangle_NoAA_NoAlpha', ['android']) + self.Fail('Pixel_WebGLTransparentGreenTriangle_NoAlpha_ImplicitClear', ['android'])
diff --git a/extensions/common/api/web_request.json b/extensions/common/api/web_request.json index 2aeecc85..82b2df3 100644 --- a/extensions/common/api/web_request.json +++ b/extensions/common/api/web_request.json
@@ -362,7 +362,7 @@ "name": "onAuthRequired", "nocompile": true, "type": "function", - "description": "Fired when an authentication failure is received. The listener has three options: it can provide authentication credentials, it can cancel the request and display the error page, or it can take no action on the challenge. If bad user credentials are provided, this may be called multiple times for the same request.", + "description": "Fired when an authentication failure is received. The listener has three options: it can provide authentication credentials, it can cancel the request and display the error page, or it can take no action on the challenge. If bad user credentials are provided, this may be called multiple times for the same request. Note, only one of <code>'blocking'</code> or <code>'asyncBlocking'</code> modes must be specified in the <code>extraInfoSpec</code> parameter.", "parameters": [ { "type": "object", @@ -388,7 +388,8 @@ { "type": "function", "optional": true, - "name": "callback", + "description" : "Only valid if <code>'asyncBlocking'</code> is specified as one of the <code>OnAuthRequiredOptions</code>.", + "name": "asyncCallback", "parameters": [ {"name": "response", "$ref": "BlockingResponse"} ]
diff --git a/gpu/config/gpu_driver_bug_list_json.cc b/gpu/config/gpu_driver_bug_list_json.cc index 611a898..3006d298 100644 --- a/gpu/config/gpu_driver_bug_list_json.cc +++ b/gpu/config/gpu_driver_bug_list_json.cc
@@ -19,7 +19,7 @@ { "name": "gpu driver bug list", // Please update the version number whenever you change this file. - "version": "9.30", + "version": "9.31", "entries": [ { "id": 1, @@ -84,8 +84,13 @@ { "id": 19, "description": "Disable depth textures on Android with Qualcomm GPUs", + "cr_bugs": [682075], "os": { - "type": "android" + "type": "android", + "version": { + "op": "<", + "value": "6.0" + } }, "gl_vendor": "Qualcomm.*", "features": [ @@ -419,10 +424,14 @@ }, { "id": 52, - "cr_bugs": [449116, 471200, 612474], + "cr_bugs": [449116, 471200, 612474, 682075], "description": "ES3 MSAA is broken on Qualcomm", "os": { - "type": "android" + "type": "android", + "version": { + "op": "<", + "value": "6.0" + } }, "gl_vendor": "Qualcomm.*", "features": [
diff --git a/gpu/config/software_rendering_list_json.cc b/gpu/config/software_rendering_list_json.cc index 5e76ecf..a61563ad 100644 --- a/gpu/config/software_rendering_list_json.cc +++ b/gpu/config/software_rendering_list_json.cc
@@ -18,7 +18,7 @@ { "name": "software rendering list", // Please update the version number whenever you change this file. - "version": "12.15", + "version": "12.16", "entries": [ { "id": 1, @@ -1485,6 +1485,22 @@ "features": [ "all" ] + }, + { + "id": 135, + "description": "Key parts of WebGL 2 broken on old Qualcomm drivers (depth texture, MSAA)", + "cr_bugs": [682753, 682075], + "os": { + "type": "android", + "version": { + "op": "<", + "value": "6.0" + } + }, + "gl_vendor": "Qualcomm.*", + "features": [ + "webgl2" + ] } ] }
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index b62e5636..9fd8093 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc
@@ -1256,6 +1256,9 @@ } // Any kind of error stops the pipeline. + // + // TODO (tguilbert): Move this out to PipelineController to make the state + // changes more consistent. See crbug.com/695734. Stop(); }
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index 89e56fa7..7c395746 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc
@@ -145,9 +145,9 @@ } base::TimeDelta GetCurrentTimeInternal(WebMediaPlayerImpl* p_this) { - // We wrap currentTime() instead of using pipeline_.GetMediaTime() since there - // are a variety of cases in which that time is not accurate; e.g., while - // remoting and during a pause or seek. + // We wrap currentTime() instead of using pipeline_controller_.GetMediaTime() + // since there are a variety of cases in which that time is not accurate; + // e.g., while remoting and during a pause or seek. return base::TimeDelta::FromSecondsD(p_this->currentTime()); } @@ -186,9 +186,8 @@ media_task_runner_(params.media_task_runner()), worker_task_runner_(params.worker_task_runner()), media_log_(params.media_log()), - pipeline_(media_task_runner_, media_log_.get()), pipeline_controller_( - &pipeline_, + base::MakeUnique<PipelineImpl>(media_task_runner_, media_log_.get()), base::Bind(&WebMediaPlayerImpl::CreateRenderer, base::Unretained(this)), base::Bind(&WebMediaPlayerImpl::OnPipelineSeeked, AsWeakPtr()), @@ -283,8 +282,8 @@ // Finalize any watch time metrics before destroying the pipeline. watch_time_reporter_.reset(); - // Pipeline must be stopped before it is destroyed. - pipeline_.Stop(); + // The underlying Pipeline must be stopped before it is destroyed. + pipeline_controller_.Stop(); if (last_reported_memory_usage_) adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); @@ -308,8 +307,8 @@ DVLOG(1) << __func__ << "(" << load_type << ", " << url << ", " << cors_mode << ")"; if (!defer_load_cb_.is_null()) { - defer_load_cb_.Run(base::Bind( - &WebMediaPlayerImpl::DoLoad, AsWeakPtr(), load_type, url, cors_mode)); + defer_load_cb_.Run(base::Bind(&WebMediaPlayerImpl::DoLoad, AsWeakPtr(), + load_type, url, cors_mode)); return; } DoLoad(load_type, url, cors_mode); @@ -433,7 +432,7 @@ // TODO(sandersd): Do we want to reset the idle timer here? delegate_->SetIdle(delegate_id_, false); paused_ = false; - pipeline_.SetPlaybackRate(playback_rate_); + pipeline_controller_.SetPlaybackRate(playback_rate_); background_pause_timer_.Stop(); if (data_source_) @@ -471,13 +470,14 @@ } #endif - pipeline_.SetPlaybackRate(0.0); + pipeline_controller_.SetPlaybackRate(0.0); // pause() may be called after playback has ended and the HTMLMediaElement // requires that currentTime() == duration() after ending. We want to ensure // |paused_time_| matches currentTime() in this case or a future seek() may // incorrectly discard what it thinks is a seek to the existing time. - paused_time_ = ended_ ? GetPipelineMediaDuration() : pipeline_.GetMediaTime(); + paused_time_ = + ended_ ? GetPipelineMediaDuration() : pipeline_controller_.GetMediaTime(); if (observer_) observer_->OnPaused(); @@ -574,7 +574,7 @@ playback_rate_ = rate; if (!paused_) { - pipeline_.SetPlaybackRate(rate); + pipeline_controller_.SetPlaybackRate(rate); if (data_source_) data_source_->MediaPlaybackRateChanged(rate); } @@ -584,7 +584,7 @@ DVLOG(1) << __func__ << "(" << volume << ")"; DCHECK(main_task_runner_->BelongsToCurrentThread()); volume_ = volume; - pipeline_.SetVolume(volume_ * volume_multiplier_); + pipeline_controller_.SetVolume(volume_ * volume_multiplier_); if (watch_time_reporter_) watch_time_reporter_->OnVolumeChange(volume); @@ -673,7 +673,7 @@ } MEDIA_LOG(INFO, media_log_) << "Enabled audio tracks: [" << logstr.str() << "]"; - pipeline_.OnEnabledAudioTracksChanged(enabledMediaTrackIds); + pipeline_controller_.OnEnabledAudioTracksChanged(enabledMediaTrackIds); } void WebMediaPlayerImpl::selectedVideoTrackChanged( @@ -685,7 +685,7 @@ selected_video_track_id = MediaTrack::Id(selectedTrackId->utf8().data()); MEDIA_LOG(INFO, media_log_) << "Selected video track: [" << selected_video_track_id.value_or("") << "]"; - pipeline_.OnSelectedVideoTrackChanged(selected_video_track_id); + pipeline_controller_.OnSelectedVideoTrackChanged(selected_video_track_id); } blink::WebSize WebMediaPlayerImpl::naturalSize() const { @@ -702,7 +702,7 @@ return cast_impl_.IsPaused(); #endif - return pipeline_.GetPlaybackRate() == 0.0f; + return pipeline_controller_.GetPlaybackRate() == 0.0f; } bool WebMediaPlayerImpl::seeking() const { @@ -763,7 +763,7 @@ if (paused_) return paused_time_.InSecondsF(); - return pipeline_.GetMediaTime().InSecondsF(); + return pipeline_controller_.GetMediaTime().InSecondsF(); } WebMediaPlayer::NetworkState WebMediaPlayerImpl::getNetworkState() const { @@ -785,12 +785,12 @@ DCHECK(main_task_runner_->BelongsToCurrentThread()); Ranges<base::TimeDelta> buffered_time_ranges = - pipeline_.GetBufferedTimeRanges(); + pipeline_controller_.GetBufferedTimeRanges(); const base::TimeDelta duration = GetPipelineMediaDuration(); if (duration != kInfiniteDuration) { - buffered_data_source_host_.AddBufferedTimeRanges( - &buffered_time_ranges, duration); + buffered_data_source_host_.AddBufferedTimeRanges(&buffered_time_ranges, + duration); } return ConvertToWebTimeRanges(buffered_time_ranges); } @@ -844,7 +844,7 @@ DCHECK(main_task_runner_->BelongsToCurrentThread()); // Note: Separate variables used to ensure both methods are called every time. - const bool pipeline_progress = pipeline_.DidLoadingProgress(); + const bool pipeline_progress = pipeline_controller_.DidLoadingProgress(); const bool data_progress = buffered_data_source_host_.DidLoadingProgress(); const bool did_loading_progress = pipeline_progress || data_progress; @@ -1067,8 +1067,8 @@ // Keep the reference to the CDM, as it shouldn't be destroyed until // after the pipeline is done with the |cdm_context|. pending_cdm_ = std::move(cdm_reference); - pipeline_.SetCdm(cdm_context, - base::Bind(&WebMediaPlayerImpl::OnCdmAttached, AsWeakPtr())); + pipeline_controller_.SetCdm( + cdm_context, base::Bind(&WebMediaPlayerImpl::OnCdmAttached, AsWeakPtr())); } void WebMediaPlayerImpl::OnCdmAttached(bool success) { @@ -1106,10 +1106,10 @@ if (isRemote()) { paused_time_ = base::TimeDelta::FromSecondsD(cast_impl_.currentTime()); } else { - paused_time_ = pipeline_.GetMediaTime(); + paused_time_ = pipeline_controller_.GetMediaTime(); } #else - paused_time_ = pipeline_.GetMediaTime(); + paused_time_ = pipeline_controller_.GetMediaTime(); #endif } else { DCHECK(watch_time_reporter_); @@ -1359,12 +1359,10 @@ const WebInbandTextTrackImpl::Kind web_kind = static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); - const blink::WebString web_label = - blink::WebString::fromUTF8(config.label()); + const blink::WebString web_label = blink::WebString::fromUTF8(config.label()); const blink::WebString web_language = blink::WebString::fromUTF8(config.language()); - const blink::WebString web_id = - blink::WebString::fromUTF8(config.id()); + const blink::WebString web_id = blink::WebString::fromUTF8(config.id()); std::unique_ptr<WebInbandTextTrackImpl> web_inband_text_track( new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id)); @@ -1520,7 +1518,8 @@ void WebMediaPlayerImpl::ScheduleRestart() { // TODO(watk): All restart logic should be moved into PipelineController. - if (pipeline_.IsRunning() && !pipeline_controller_.IsPipelineSuspended()) { + if (pipeline_controller_.IsPipelineRunning() && + !pipeline_controller_.IsPipelineSuspended()) { pending_suspend_resume_cycle_ = true; UpdatePlayState(); } @@ -1648,9 +1647,8 @@ else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) SetNetworkState(WebMediaPlayer::NetworkStateLoading); media_log_->AddEvent( - media_log_->CreateBooleanEvent( - MediaLogEvent::NETWORK_ACTIVITY_SET, - "is_downloading_data", is_downloading)); + media_log_->CreateBooleanEvent(MediaLogEvent::NETWORK_ACTIVITY_SET, + "is_downloading_data", is_downloading)); } void WebMediaPlayerImpl::OnSurfaceCreated(int surface_id) { @@ -1802,17 +1800,15 @@ return audio_source_provider_.get(); } -static void GetCurrentFrameAndSignal( - VideoFrameCompositor* compositor, - scoped_refptr<VideoFrame>* video_frame_out, - base::WaitableEvent* event) { +static void GetCurrentFrameAndSignal(VideoFrameCompositor* compositor, + scoped_refptr<VideoFrame>* video_frame_out, + base::WaitableEvent* event) { TRACE_EVENT0("media", "GetCurrentFrameAndSignal"); *video_frame_out = compositor->GetCurrentFrameAndUpdateIfStale(); event->Signal(); } -scoped_refptr<VideoFrame> -WebMediaPlayerImpl::GetCurrentFrameFromCompositor() { +scoped_refptr<VideoFrame> WebMediaPlayerImpl::GetCurrentFrameFromCompositor() { DCHECK(main_task_runner_->BelongsToCurrentThread()); TRACE_EVENT0("media", "WebMediaPlayerImpl::GetCurrentFrameFromCompositor"); @@ -1826,11 +1822,10 @@ scoped_refptr<VideoFrame> video_frame; base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, base::WaitableEvent::InitialState::NOT_SIGNALED); - compositor_task_runner_->PostTask(FROM_HERE, - base::Bind(&GetCurrentFrameAndSignal, - base::Unretained(compositor_), - &video_frame, - &event)); + compositor_task_runner_->PostTask( + FROM_HERE, + base::Bind(&GetCurrentFrameAndSignal, base::Unretained(compositor_), + &video_frame, &event)); event.Wait(); return video_frame; } @@ -2224,7 +2219,8 @@ // Don't pause video while the pipeline is stopped, resuming or seeking. // Also if the video is paused already. - if (!pipeline_.IsRunning() || is_pipeline_resuming_ || seeking_ || paused_) + if (!pipeline_controller_.IsPipelineRunning() || is_pipeline_resuming_ || + seeking_ || paused_) return; // OnPause() will set |paused_when_hidden_| to false and call @@ -2236,7 +2232,8 @@ void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { // Don't change video track while the pipeline is stopped, resuming or // seeking. - if (!pipeline_.IsRunning() || is_pipeline_resuming_ || seeking_) + if (!pipeline_controller_.IsPipelineRunning() || is_pipeline_resuming_ || + seeking_) return; if (video_track_disabled_) { @@ -2269,7 +2266,8 @@ PipelineStatistics WebMediaPlayerImpl::GetPipelineStatistics() const { DCHECK(main_task_runner_->BelongsToCurrentThread()); - return pipeline_statistics_for_test_.value_or(pipeline_.GetStatistics()); + return pipeline_statistics_for_test_.value_or( + pipeline_controller_.GetStatistics()); } void WebMediaPlayerImpl::SetPipelineMediaDurationForTest( @@ -2281,7 +2279,7 @@ DCHECK(main_task_runner_->BelongsToCurrentThread()); return pipeline_media_duration_for_test_.value_or( - pipeline_.GetMediaDuration()); + pipeline_controller_.GetMediaDuration()); } void WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame(
diff --git a/media/blink/webmediaplayer_impl.h b/media/blink/webmediaplayer_impl.h index 1ab3b5c..c01d94f 100644 --- a/media/blink/webmediaplayer_impl.h +++ b/media/blink/webmediaplayer_impl.h
@@ -478,9 +478,7 @@ scoped_refptr<base::TaskRunner> worker_task_runner_; scoped_refptr<MediaLog> media_log_; - // |pipeline_controller_| references |pipeline_| and therefore must be - // constructed after and destructed before |pipeline_|. - PipelineImpl pipeline_; + // |pipeline_controller_| owns an instance of Pipeline. PipelineController pipeline_controller_; // The LoadType passed in the |load_type| parameter of the load() call.
diff --git a/media/filters/pipeline_controller.cc b/media/filters/pipeline_controller.cc index e999d92..e5d0245 100644 --- a/media/filters/pipeline_controller.cc +++ b/media/filters/pipeline_controller.cc
@@ -10,14 +10,14 @@ namespace media { PipelineController::PipelineController( - Pipeline* pipeline, + std::unique_ptr<Pipeline> pipeline, const RendererFactoryCB& renderer_factory_cb, const SeekedCB& seeked_cb, const SuspendedCB& suspended_cb, const BeforeResumeCB& before_resume_cb, const ResumedCB& resumed_cb, const PipelineStatusCB& error_cb) - : pipeline_(pipeline), + : pipeline_(std::move(pipeline)), renderer_factory_cb_(renderer_factory_cb), seeked_cb_(seeked_cb), suspended_cb_(suspended_cb), @@ -38,7 +38,7 @@ DCHECK(thread_checker_.CalledOnValidThread()); } -// TODO(sandersd): If there is a pending suspend, don't call pipeline_.Start() +// TODO(sandersd): If there is a pending suspend, don't call pipeline_->Start() // until Resume(). void PipelineController::Start(Demuxer* demuxer, Pipeline::Client* client, @@ -246,4 +246,69 @@ } } +void PipelineController::Stop() { + // For the moment, Stop() is only called on WMPI destruction, and updating the + // state of |this| is not relevant. Eventually, Start()/Stop() will be called + // in order to swap between demuxer types, and this will need to be adressed. + // + // TODO(tguilbert): Clarify the appropriate state changes when Stop() is + // called. See crbug.com/695734. + pipeline_->Stop(); +} + +bool PipelineController::IsPipelineRunning() const { + return pipeline_->IsRunning(); +} + +double PipelineController::GetPlaybackRate() const { + return pipeline_->GetPlaybackRate(); +} + +void PipelineController::SetPlaybackRate(double playback_rate) { + pipeline_->SetPlaybackRate(playback_rate); +} + +float PipelineController::GetVolume() const { + return pipeline_->GetVolume(); +} + +void PipelineController::SetVolume(float volume) { + pipeline_->SetVolume(volume); +} + +base::TimeDelta PipelineController::GetMediaTime() const { + return pipeline_->GetMediaTime(); +} + +Ranges<base::TimeDelta> PipelineController::GetBufferedTimeRanges() const { + return pipeline_->GetBufferedTimeRanges(); +} + +base::TimeDelta PipelineController::GetMediaDuration() const { + return pipeline_->GetMediaDuration(); +} + +bool PipelineController::DidLoadingProgress() { + return pipeline_->DidLoadingProgress(); +} + +PipelineStatistics PipelineController::GetStatistics() const { + return pipeline_->GetStatistics(); +} + +void PipelineController::SetCdm(CdmContext* cdm_context, + const CdmAttachedCB& cdm_attached_cb) { + pipeline_->SetCdm(cdm_context, cdm_attached_cb); +} + +void PipelineController::OnEnabledAudioTracksChanged( + const std::vector<MediaTrack::Id>& enabledTrackIds) { + pipeline_->OnEnabledAudioTracksChanged(enabledTrackIds); +} + +void PipelineController::OnSelectedVideoTrackChanged( + base::Optional<MediaTrack::Id> selected_track_id) { + pipeline_->OnSelectedVideoTrackChanged(selected_track_id); +} + } // namespace media
diff --git a/media/filters/pipeline_controller.h b/media/filters/pipeline_controller.h index 5ce6341..79cb14b 100644 --- a/media/filters/pipeline_controller.h +++ b/media/filters/pipeline_controller.h
@@ -15,7 +15,6 @@ #include "media/base/renderer.h" namespace media { - class Demuxer; // PipelineController wraps a Pipeline to expose the one-at-a-time operations @@ -23,8 +22,10 @@ // pending operations and dispatches them when possible. Duplicate requests // (such as seeking twice to the same time) may be elided. // -// TODO(sandersd): -// - Expose an operation that restarts via suspend+resume. +// TODO(sandersd/tguilbert): +// - Expose an operation that replaces the Renderer (via Suspend/Resume). +// - Expose an operation that replaces the Demuxer (via Start/Stop). This will +// also implicitly replace the Renderer. // - Block invalid calls after an error occurs. class MEDIA_EXPORT PipelineController { public: @@ -44,8 +45,8 @@ using BeforeResumeCB = base::Callback<void()>; using ResumedCB = base::Callback<void()>; - // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must - // outlive the resulting PipelineController. The callbacks are: + // Construct a PipelineController wrapping |pipeline_|. + // The callbacks are: // - |renderer_factory_cb| is called by PipelineController to create new // renderers when starting and resuming. // - |seeked_cb| is called upon reaching a stable state if a seek occured. @@ -54,7 +55,7 @@ // - |resumed_cb| is called immediately after resuming. // - |error_cb| is called if any operation on |pipeline_| does not result // in PIPELINE_OK or its error callback is called. - PipelineController(Pipeline* pipeline, + PipelineController(std::unique_ptr<Pipeline> pipeline, const RendererFactoryCB& renderer_factory_cb, const SeekedCB& seeked_cb, const SuspendedCB& suspended_cb, @@ -108,6 +109,24 @@ // Returns true if |pipeline_| is suspended. bool IsPipelineSuspended(); + // Subset of the Pipeline interface directly exposing |pipeline_|. + void Stop(); + bool IsPipelineRunning() const; + double GetPlaybackRate() const; + void SetPlaybackRate(double playback_rate); + float GetVolume() const; + void SetVolume(float volume); + base::TimeDelta GetMediaTime() const; + Ranges<base::TimeDelta> GetBufferedTimeRanges() const; + base::TimeDelta GetMediaDuration() const; + bool DidLoadingProgress(); + PipelineStatistics GetStatistics() const; + void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb); + void OnEnabledAudioTracksChanged( + const std::vector<MediaTrack::Id>& enabledTrackIds); + void OnSelectedVideoTrackChanged( + base::Optional<MediaTrack::Id> selected_track_id); + private: // Attempts to make progress from the current state to the target state. void Dispatch(); @@ -116,7 +135,7 @@ void OnPipelineStatus(State state, PipelineStatus pipeline_status); // The Pipeline we are managing state for. - Pipeline* pipeline_ = nullptr; + std::unique_ptr<Pipeline> pipeline_; // Factory for Renderers, used for Start() and Resume(). RendererFactoryCB renderer_factory_cb_;
diff --git a/media/filters/pipeline_controller_unittest.cc b/media/filters/pipeline_controller_unittest.cc index 228014d..f3cb9e2 100644 --- a/media/filters/pipeline_controller_unittest.cc +++ b/media/filters/pipeline_controller_unittest.cc
@@ -32,7 +32,8 @@ class PipelineControllerTest : public ::testing::Test, public Pipeline::Client { public: PipelineControllerTest() - : pipeline_controller_(&pipeline_, + : pipeline_(new StrictMock<MockPipeline>()), + pipeline_controller_(std::unique_ptr<Pipeline>(pipeline_), base::Bind(&PipelineControllerTest::CreateRenderer, base::Unretained(this)), base::Bind(&PipelineControllerTest::OnSeeked, @@ -51,9 +52,9 @@ PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) { EXPECT_FALSE(pipeline_controller_.IsStable()); PipelineStatusCB start_cb; - EXPECT_CALL(pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb)); + EXPECT_CALL(*pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb)); pipeline_controller_.Start(&demuxer_, this, is_streaming, is_static); - Mock::VerifyAndClear(&pipeline_); + Mock::VerifyAndClear(pipeline_); EXPECT_FALSE(pipeline_controller_.IsStable()); return start_cb; } @@ -71,9 +72,9 @@ PipelineStatusCB SeekPipeline(base::TimeDelta time) { EXPECT_TRUE(pipeline_controller_.IsStable()); PipelineStatusCB seek_cb; - EXPECT_CALL(pipeline_, Seek(time, _)).WillOnce(SaveArg<1>(&seek_cb)); + EXPECT_CALL(*pipeline_, Seek(time, _)).WillOnce(SaveArg<1>(&seek_cb)); pipeline_controller_.Seek(time, true); - Mock::VerifyAndClear(&pipeline_); + Mock::VerifyAndClear(pipeline_); EXPECT_FALSE(pipeline_controller_.IsStable()); return seek_cb; } @@ -81,9 +82,9 @@ PipelineStatusCB SuspendPipeline() { EXPECT_TRUE(pipeline_controller_.IsStable()); PipelineStatusCB suspend_cb; - EXPECT_CALL(pipeline_, Suspend(_)).WillOnce(SaveArg<0>(&suspend_cb)); + EXPECT_CALL(*pipeline_, Suspend(_)).WillOnce(SaveArg<0>(&suspend_cb)); pipeline_controller_.Suspend(); - Mock::VerifyAndClear(&pipeline_); + Mock::VerifyAndClear(pipeline_); EXPECT_TRUE(pipeline_controller_.IsSuspended()); EXPECT_FALSE(pipeline_controller_.IsStable()); EXPECT_FALSE(pipeline_controller_.IsPipelineSuspended()); @@ -93,13 +94,13 @@ PipelineStatusCB ResumePipeline() { EXPECT_TRUE(pipeline_controller_.IsPipelineSuspended()); PipelineStatusCB resume_cb; - EXPECT_CALL(pipeline_, Resume(_, _, _)) + EXPECT_CALL(*pipeline_, Resume(_, _, _)) .WillOnce( DoAll(SaveArg<1>(&last_resume_time_), SaveArg<2>(&resume_cb))); - EXPECT_CALL(pipeline_, GetMediaTime()) + EXPECT_CALL(*pipeline_, GetMediaTime()) .WillRepeatedly(Return(base::TimeDelta())); pipeline_controller_.Resume(); - Mock::VerifyAndClear(&pipeline_); + Mock::VerifyAndClear(pipeline_); EXPECT_FALSE(pipeline_controller_.IsSuspended()); EXPECT_FALSE(pipeline_controller_.IsStable()); EXPECT_FALSE(pipeline_controller_.IsPipelineSuspended()); @@ -141,7 +142,7 @@ base::MessageLoop message_loop_; NiceMock<MockDemuxer> demuxer_; - StrictMock<MockPipeline> pipeline_; + StrictMock<MockPipeline>* pipeline_; PipelineController pipeline_controller_; bool was_seeked_ = false; @@ -247,7 +248,7 @@ // When the first seek is completed (or aborted) the second should be issued. EXPECT_CALL(demuxer_, StartWaitingForSeek(seek_time_2)); - EXPECT_CALL(pipeline_, Seek(seek_time_2, _)); + EXPECT_CALL(*pipeline_, Seek(seek_time_2, _)); Complete(seek_cb_1); } @@ -264,7 +265,7 @@ base::RunLoop().RunUntilIdle(); // Expect the suspend to trigger when the seek is completed. - EXPECT_CALL(pipeline_, Suspend(_)); + EXPECT_CALL(*pipeline_, Suspend(_)); Complete(seek_cb); } @@ -302,7 +303,7 @@ base::RunLoop().RunUntilIdle(); // Expect the third seek to trigger when the first seek completes. - EXPECT_CALL(pipeline_, Seek(seek_time_3, _)); + EXPECT_CALL(*pipeline_, Seek(seek_time_3, _)); Complete(seek_cb_1); } @@ -335,7 +336,7 @@ base::RunLoop().RunUntilIdle(); // Expect the second seek to trigger when the first seek completes. - EXPECT_CALL(pipeline_, Seek(seek_time, _)); + EXPECT_CALL(*pipeline_, Seek(seek_time, _)); Complete(seek_cb_1); }
diff --git a/storage/browser/fileapi/watcher_manager.h b/storage/browser/fileapi/watcher_manager.h index 64c3106..0d5901b 100644 --- a/storage/browser/fileapi/watcher_manager.h +++ b/storage/browser/fileapi/watcher_manager.h
@@ -17,6 +17,9 @@ // An interface for providing entry observing capability for file system // backends. // +// All member functions must be called on the IO thread. Callbacks will be +// called on the IO thread. +// // It is NOT valid to give null callback to this class, and implementors // can assume that they don't get any null callbacks. class WatcherManager {
diff --git a/third_party/WebKit/LayoutTests/editing/pasteboard/paste-text-013.html b/third_party/WebKit/LayoutTests/editing/pasteboard/paste-text-013.html index 68f38ef..f46d303 100644 --- a/third_party/WebKit/LayoutTests/editing/pasteboard/paste-text-013.html +++ b/third_party/WebKit/LayoutTests/editing/pasteboard/paste-text-013.html
@@ -4,7 +4,7 @@ See this bug: <a href="rdar://problem/3918712"><rdar://problem/3918712></a> "Paste as Quotation" in Mail just pastes (<blockquote> tag seems to be lost). Should see one box with blockquoted "foo" text, followed by another box with an "x" (not in a blockquote) and "foo" (in a blockquote). -<div id="sample" contenteditable><div><blockquote class="Apple-paste-as-quotation">foo</blockquote></div></div> +<div id="sample" contenteditable><div><blockquote>foo</blockquote></div></div> <div id="log"></div> <script> test(function() {
diff --git a/third_party/WebKit/LayoutTests/fast/forms/text/text-change-event-after-clear-in-submit.html b/third_party/WebKit/LayoutTests/fast/forms/text/text-change-event-after-clear-in-submit.html new file mode 100644 index 0000000..2998315 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/text/text-change-event-after-clear-in-submit.html
@@ -0,0 +1,33 @@ +<!DOCTYPE html> +<body> +<script src="../../../resources/testharness.js"></script> +<script src="../../../resources/testharnessreport.js"></script> +<form><input><input type=submit></form> +<script> +test(() => { + assert_exists(window, 'eventSender'); + let form = document.querySelector('form'); + let text = document.querySelector('input'); + let submit = document.querySelectorAll('input')[1]; + var lastChangeValue = ''; + form.addEventListener('submit', (event) => { + text.value = ''; + event.preventDefault(); + }); + text.addEventListener('change', () => { lastChangeValue = text.value; }); + + text.focus(); + eventSender.keyDown('f'); + eventSender.keyDown('Enter'); // Trigger implicit submission + assert_equals(lastChangeValue, 'f'); + lastChangeValue = null; + assert_equals(document.activeElement, text); + assert_equals(text.value, ''); + + eventSender.keyDown('f'); + eventSender.keyDown('Enter'); // Trigger implicit submission again. + assert_equals(lastChangeValue, 'f', 'The second submission should trigger change event.'); + +}, 'Clearing INPUT value in submit event handler should not prevent next change event. crbug.com/695349'); +</script> +</body>
diff --git a/third_party/WebKit/LayoutTests/usb/usb-in-transfer-result.html b/third_party/WebKit/LayoutTests/usb/usb-in-transfer-result.html new file mode 100644 index 0000000..8f08030 --- /dev/null +++ b/third_party/WebKit/LayoutTests/usb/usb-in-transfer-result.html
@@ -0,0 +1,31 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +'use strict'; + +test(t => { + let data_view = new DataView(Uint8Array.from([1, 2, 3, 4]).buffer); + let result = new USBInTransferResult('ok', data_view); + assert_equals(result.status, 'ok'); + assert_equals(result.data.getInt32(0), 16909060); +}, 'Can construct a USBInTransferResult'); + +test(t => { + let result = new USBInTransferResult('stall'); + assert_equals(result.status, 'stall'); + assert_equals(result.data, null); + + result = new USBInTransferResult('babble', null); + assert_equals(result.status, 'babble'); + assert_equals(result.data, null); +}, 'Can construct a USBInTransferResult without a DataView'); + +test(t => { + assert_throws(TypeError(), () => new USBInTransferResult('invalid_status')); +}, 'Cannot construct USBInTransferResult with an invalid status'); + +test(t => { + assert_throws(TypeError(), () => new USBInTransferResult()); +}, 'Cannot construct USBInTransferResult without a status'); +</script>
diff --git a/third_party/WebKit/LayoutTests/usb/usb-isochronous-in-transfer-packet.html b/third_party/WebKit/LayoutTests/usb/usb-isochronous-in-transfer-packet.html new file mode 100644 index 0000000..a2c0a013 --- /dev/null +++ b/third_party/WebKit/LayoutTests/usb/usb-isochronous-in-transfer-packet.html
@@ -0,0 +1,33 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +'use strict'; + +test(t => { + let data_view = new DataView(Uint8Array.from([1, 2, 3, 4]).buffer); + let packet = new USBIsochronousInTransferPacket('ok', data_view); + assert_equals(packet.status, 'ok'); + assert_equals(packet.data.getInt32(0), 16909060); +}, 'Can construct a USBIsochronousInTransferPacket'); + +test(t => { + let packet = new USBIsochronousInTransferPacket('stall'); + assert_equals(packet.status, 'stall'); + assert_equals(packet.data, null); + + packet = new USBIsochronousInTransferPacket('stall', null); + assert_equals(packet.status, 'stall'); + assert_equals(packet.data, null); +}, 'Can construct a USBIsochronousInTransferPacket without a DataView'); + +test(t => { + assert_throws(TypeError(), () => { + new USBIsochronousInTransferPacket('invalid_status'); + }); +}, 'Cannot construct USBIsochronousInTransferPacket with an invalid status'); + +test(t => { + assert_throws(TypeError(), () => new USBIsochronousInTransferPacket()); +}, 'Cannot construct USBIsochronousInTransferPacket without a status'); +</script>
diff --git a/third_party/WebKit/LayoutTests/usb/usb-isochronous-in-transfer-result.html b/third_party/WebKit/LayoutTests/usb/usb-isochronous-in-transfer-result.html new file mode 100644 index 0000000..8241150 --- /dev/null +++ b/third_party/WebKit/LayoutTests/usb/usb-isochronous-in-transfer-result.html
@@ -0,0 +1,42 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +'use strict'; + + +test(t => { + let data_view = new DataView(Uint8Array.from([1, 2, 3, 4]).buffer); + let packet_data_view = new DataView(data_view.buffer); + let packets = [ + new USBIsochronousInTransferPacket('ok', packet_data_view), + new USBIsochronousInTransferPacket('stall') + ]; + + let result = new USBIsochronousInTransferResult(packets, data_view); + assert_equals(result.data.getInt32(0), 16909060); + assert_equals(result.packets.length, 2); + assert_equals(result.packets[0].status, 'ok'); + assert_equals(result.packets[0].data.getInt32(0), 16909060); + assert_equals(result.packets[1].status, 'stall'); + assert_equals(result.packets[1].data, null); +}, 'Can construct a USBIsochronousInTransferResult'); + +test(t => { + let packets = [ + new USBIsochronousInTransferPacket('stall'), + new USBIsochronousInTransferPacket('stall') + ]; + let result = new USBIsochronousInTransferResult(packets); + assert_equals(result.data, null); + assert_equals(result.packets.length, 2); + assert_equals(result.packets[0].status, 'stall'); + assert_equals(result.packets[0].data, null); + assert_equals(result.packets[1].status, 'stall'); + assert_equals(result.packets[1].data, null); +}, 'Can construct a USBIsochronousInTransferResult without a DataView'); + +test(t => { + assert_throws(TypeError(), () => new USBIsochronousInTransferResult()); +}, 'Cannot construct a USBIsochronousInTransferResult without packets'); +</script>
diff --git a/third_party/WebKit/LayoutTests/usb/usb-isochronous-out-transfer-packet.html b/third_party/WebKit/LayoutTests/usb/usb-isochronous-out-transfer-packet.html new file mode 100644 index 0000000..af5dbc6 --- /dev/null +++ b/third_party/WebKit/LayoutTests/usb/usb-isochronous-out-transfer-packet.html
@@ -0,0 +1,26 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +'use strict'; + +test(t => { + let packet = new USBIsochronousOutTransferPacket('ok', 42); + assert_equals(packet.status, 'ok'); + assert_equals(packet.bytesWritten, 42); + + packet = new USBIsochronousOutTransferPacket('stall'); + assert_equals(packet.status, 'stall'); + assert_equals(packet.bytesWritten, 0); +}, 'Can construct USBIsochronousOutTransferPacket'); + +test(t => { + assert_throws(TypeError(), () => { + new USBIsochronousOutTransferPacket('invalid_status'); + }); +}, 'Cannot construct USBIsochronousOutTransferPacket with an invalid status'); + +test(t => { + assert_throws(TypeError(), () => new USBIsochronousOutTransferPacket()); +}, 'Cannot construct USBIsochronousOutTransferPacket without a status'); +</script>
diff --git a/third_party/WebKit/LayoutTests/usb/usb-isochronous-out-transfer-result.html b/third_party/WebKit/LayoutTests/usb/usb-isochronous-out-transfer-result.html new file mode 100644 index 0000000..8d7c6c3f --- /dev/null +++ b/third_party/WebKit/LayoutTests/usb/usb-isochronous-out-transfer-result.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +'use strict'; + +test(t => { + let packets = [ + new USBIsochronousOutTransferPacket('ok', 42), + new USBIsochronousOutTransferPacket('stall') + ]; + + let result = new USBIsochronousOutTransferResult(packets); + assert_equals(result.packets.length, 2); + assert_equals(result.packets[0].status, 'ok'); + assert_equals(result.packets[0].bytesWritten, 42); + assert_equals(result.packets[1].status, 'stall'); + assert_equals(result.packets[1].bytesWritten, 0); +}, 'Can construct a USBIsochronousOutTransferResult'); + +test(t => { + assert_throws(TypeError(), () => new USBIsochronousOutTransferResult()); +}, 'Cannot construct a USBIsochronousOutTransferResult without packets'); +</script>
diff --git a/third_party/WebKit/LayoutTests/usb/usb-out-transfer-result.html b/third_party/WebKit/LayoutTests/usb/usb-out-transfer-result.html new file mode 100644 index 0000000..92f4de5 --- /dev/null +++ b/third_party/WebKit/LayoutTests/usb/usb-out-transfer-result.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> +'use strict'; + +test(t => { + let result = new USBOutTransferResult('ok', 42); + assert_equals(result.status, 'ok'); + assert_equals(result.bytesWritten, 42); + + result = new USBOutTransferResult('stall'); + assert_equals(result.status, 'stall'); + assert_equals(result.bytesWritten, 0); +}, 'Can construct USBOutTransferResult'); + +test(t => { + assert_throws(TypeError(), () => new USBOutTransferResult('invalid_status')); +}, 'Cannot construct USBOutTransferResult with an invalid status'); + +test(t => { + assert_throws(TypeError(), () => new USBOutTransferResult()); +}, 'Cannot construct USBOutTransferResult without a status'); +</script>
diff --git a/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py b/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py new file mode 100644 index 0000000..cda46c2b --- /dev/null +++ b/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py
@@ -0,0 +1,128 @@ +# Copyright 2017 The Chromium Authors. All rights reserved. +# coding=utf-8 +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +from collections import Counter +import itertools +from operator import itemgetter + + +def sort_and_groupby(list_to_sort, key=None): + """Returns a generator of (key, list), sorting and grouping list by key.""" + list_to_sort.sort(key=key) + return ((k, list(g)) for k, g in itertools.groupby(list_to_sort, key)) + + +def effective_overload_set(F): # pylint: disable=invalid-name + """Returns the effective overload set of an overloaded function. + + An effective overload set is the set of overloaded functions + signatures + (type list of arguments, with optional and variadic arguments included or + not), and is used in the overload resolution algorithm. + + For example, given input [f1(optional long x), f2(DOMString s)], the output + is informally [f1(), f1(long), f2(DOMString)], and formally + [(f1, [], []), (f1, [long], [optional]), (f2, [DOMString], [required])]. + + Currently the optionality list is a list of |is_optional| booleans (True + means optional, False means required); to support variadics this needs to + be tri-valued as required, optional, or variadic. + + Formally: + An effective overload set represents the allowable invocations for a + particular operation, constructor (specified with [Constructor] or + [NamedConstructor]), legacy caller or callback function. + + An additional argument N (argument count) is needed when overloading + variadics, but we don't use that currently. + + Spec: http://heycam.github.io/webidl/#dfn-effective-overload-set + + Formally the input and output lists are sets, but methods are stored + internally as dicts, which can't be stored in a set because they are not + hashable, so we use lists instead. + + Arguments: + F: list of overloads for a given callable name. + + Returns: + S: list of tuples of the form (callable, type list, optionality list). + """ + # Code closely follows the algorithm in the spec, for clarity and + # correctness, and hence is not very Pythonic. + + # 1. Initialize S to ∅. + # (We use a list because we can't use a set, as noted above.) + S = [] # pylint: disable=invalid-name + + # 2. Let F be a set with elements as follows, according to the kind of + # effective overload set: + # (Passed as argument, nothing to do.) + + # 3. & 4. (maxarg, m) are only needed for variadics, not used. + + # 5. For each operation, extended attribute or callback function X in F: + for X in F: # X is the "callable". pylint: disable=invalid-name + arguments = X['arguments'] # pylint: disable=invalid-name + # 1. Let n be the number of arguments X is declared to take. + n = len(arguments) # pylint: disable=invalid-name + # 2. Let t0..n−1 be a list of types, where ti is the type of X’s + # argument at index i. + # (“type list”) + t = tuple(argument['idl_type_object'] # pylint: disable=invalid-name + for argument in arguments) + # 3. Let o0..n−1 be a list of optionality values, where oi is “variadic” + # if X’s argument at index i is a final, variadic argument, “optional” + # if the argument is optional, and “required” otherwise. + # (“optionality list”) + # (We’re just using a boolean for optional/variadic vs. required.) + o = tuple(argument['is_optional'] # pylint: disable=invalid-name + or argument['is_variadic'] for argument in arguments) + # 4. Add to S the tuple <X, t0..n−1, o0..n−1>. + S.append((X, t, o)) + # 5. If X is declared to be variadic, then: + # (Not used, so not implemented.) + # 6. Initialize i to n−1. + i = n - 1 + # 7. While i ≥ 0: + # Spec bug (fencepost error); should be “While i > 0:” + # https://www.w3.org/Bugs/Public/show_bug.cgi?id=25590 + while i > 0: + # 1. If argument i of X is not optional, then break this loop. + if not o[i]: + break + # 2. Otherwise, add to S the tuple <X, t0..i−1, o0..i−1>. + S.append((X, t[:i], o[:i])) + # 3. Set i to i−1. + i = i - 1 + # 8. If n > 0 and all arguments of X are optional, then add to S the + # tuple <X, (), ()> (where “()” represents the empty list). + if n > 0 and all(oi for oi in o): + S.append((X, [], [])) + # 6. The effective overload set is S. + return S + + +def effective_overload_set_by_length(overloads): + def type_list_length(entry): + # Entries in the effective overload set are 3-tuples: + # (callable, type list, optionality list) + return len(entry[1]) + + effective_overloads = effective_overload_set(overloads) + return list(sort_and_groupby(effective_overloads, type_list_length)) + + +def method_overloads_by_name(methods): + """Returns generator of overloaded methods by name: [name, [method]]""" + # Filter to only methods that are actually overloaded + method_counts = Counter(method['name'] for method in methods) + overloaded_method_names = set(name + for name, count in method_counts.iteritems() + if count > 1) + overloaded_methods = [method for method in methods + if method['name'] in overloaded_method_names] + + # Group by name (generally will be defined together, but not necessarily) + return sort_and_groupby(overloaded_methods, itemgetter('name'))
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_interface.py b/third_party/WebKit/Source/bindings/scripts/v8_interface.py index 2b66480..0486326 100644 --- a/third_party/WebKit/Source/bindings/scripts/v8_interface.py +++ b/third_party/WebKit/Source/bindings/scripts/v8_interface.py
@@ -33,13 +33,13 @@ Design doc: http://www.chromium.org/developers/design-documents/idl-compiler """ - -from collections import defaultdict -import itertools -from operator import itemgetter, or_ +from operator import or_ from idl_definitions import IdlOperation, IdlArgument from idl_types import IdlType, inherits_interface +from overload_set_algorithm import effective_overload_set_by_length +from overload_set_algorithm import method_overloads_by_name + import v8_attributes from v8_globals import includes import v8_methods @@ -745,18 +745,6 @@ overloads[-1]['overloads']['name'] = name -def method_overloads_by_name(methods): - """Returns generator of overloaded methods by name: [name, [method]]""" - # Filter to only methods that are actually overloaded - method_counts = Counter(method['name'] for method in methods) - overloaded_method_names = set(name - for name, count in method_counts.iteritems() - if count > 1) - overloaded_methods = [method for method in methods - if method['name'] in overloaded_method_names] - - # Group by name (generally will be defined together, but not necessarily) - return sort_and_groupby(overloaded_methods, itemgetter('name')) def overloads_context(interface, overloads): @@ -878,104 +866,6 @@ } -def effective_overload_set(F): - """Returns the effective overload set of an overloaded function. - - An effective overload set is the set of overloaded functions + signatures - (type list of arguments, with optional and variadic arguments included or - not), and is used in the overload resolution algorithm. - - For example, given input [f1(optional long x), f2(DOMString s)], the output - is informally [f1(), f1(long), f2(DOMString)], and formally - [(f1, [], []), (f1, [long], [optional]), (f2, [DOMString], [required])]. - - Currently the optionality list is a list of |is_optional| booleans (True - means optional, False means required); to support variadics this needs to - be tri-valued as required, optional, or variadic. - - Formally: - An effective overload set represents the allowable invocations for a - particular operation, constructor (specified with [Constructor] or - [NamedConstructor]), legacy caller or callback function. - - An additional argument N (argument count) is needed when overloading - variadics, but we don't use that currently. - - Spec: http://heycam.github.io/webidl/#dfn-effective-overload-set - - Formally the input and output lists are sets, but methods are stored - internally as dicts, which can't be stored in a set because they are not - hashable, so we use lists instead. - - Arguments: - F: list of overloads for a given callable name. - - Returns: - S: list of tuples of the form (callable, type list, optionality list). - """ - # Code closely follows the algorithm in the spec, for clarity and - # correctness, and hence is not very Pythonic. - - # 1. Initialize S to ∅. - # (We use a list because we can't use a set, as noted above.) - S = [] - - # 2. Let F be a set with elements as follows, according to the kind of - # effective overload set: - # (Passed as argument, nothing to do.) - - # 3. & 4. (maxarg, m) are only needed for variadics, not used. - - # 5. For each operation, extended attribute or callback function X in F: - for X in F: # X is the "callable", F is the overloads. - arguments = X['arguments'] - # 1. Let n be the number of arguments X is declared to take. - n = len(arguments) - # 2. Let t0..n−1 be a list of types, where ti is the type of X’s - # argument at index i. - # (“type list”) - t = tuple(argument['idl_type_object'] for argument in arguments) - # 3. Let o0..n−1 be a list of optionality values, where oi is “variadic” - # if X’s argument at index i is a final, variadic argument, “optional” - # if the argument is optional, and “required” otherwise. - # (“optionality list”) - # (We’re just using a boolean for optional/variadic vs. required.) - o = tuple(argument['is_optional'] or argument['is_variadic'] - for argument in arguments) - # 4. Add to S the tuple <X, t0..n−1, o0..n−1>. - S.append((X, t, o)) - # 5. If X is declared to be variadic, then: - # (Not used, so not implemented.) - # 6. Initialize i to n−1. - i = n - 1 - # 7. While i ≥ 0: - # Spec bug (fencepost error); should be “While i > 0:” - # https://www.w3.org/Bugs/Public/show_bug.cgi?id=25590 - while i > 0: - # 1. If argument i of X is not optional, then break this loop. - if not o[i]: - break - # 2. Otherwise, add to S the tuple <X, t0..i−1, o0..i−1>. - S.append((X, t[:i], o[:i])) - # 3. Set i to i−1. - i = i - 1 - # 8. If n > 0 and all arguments of X are optional, then add to S the - # tuple <X, (), ()> (where “()” represents the empty list). - if n > 0 and all(oi for oi in o): - S.append((X, [], [])) - # 6. The effective overload set is S. - return S - - -def effective_overload_set_by_length(overloads): - def type_list_length(entry): - # Entries in the effective overload set are 3-tuples: - # (callable, type list, optionality list) - return len(entry[1]) - - effective_overloads = effective_overload_set(overloads) - return list(sort_and_groupby(effective_overloads, type_list_length)) - def distinguishing_argument_index(entries): """Returns the distinguishing argument index for a sequence of entries. @@ -1256,14 +1146,6 @@ # Utility functions ################################################################################ -def Counter(iterable): - # Once using Python 2.7, using collections.Counter - counter = defaultdict(lambda: 0) - for item in iterable: - counter[item] += 1 - return counter - - def common(dicts, f): """Returns common result of f across an iterable of dicts, or None. @@ -1294,12 +1176,6 @@ return common(dicts, lambda d: d.get(key)) -def sort_and_groupby(l, key=None): - """Returns a generator of (key, list), sorting and grouping list by key.""" - l.sort(key=key) - return ((k, list(g)) for k, g in itertools.groupby(l, key)) - - ################################################################################ # Constructors ################################################################################
diff --git a/third_party/WebKit/Source/core/css/MediaValues.cpp b/third_party/WebKit/Source/core/css/MediaValues.cpp index 5ac7d79..4b00df2f 100644 --- a/third_party/WebKit/Source/core/css/MediaValues.cpp +++ b/third_party/WebKit/Source/core/css/MediaValues.cpp
@@ -89,7 +89,7 @@ } int MediaValues::calculateDefaultFontSize(LocalFrame* frame) { - return frame->host()->settings().getDefaultFontSize(); + return frame->page()->settings().getDefaultFontSize(); } const String MediaValues::calculateMediaType(LocalFrame* frame) { @@ -101,7 +101,7 @@ WebDisplayMode MediaValues::calculateDisplayMode(LocalFrame* frame) { ASSERT(frame); - WebDisplayMode mode = frame->host()->settings().getDisplayModeOverride(); + WebDisplayMode mode = frame->page()->settings().getDisplayModeOverride(); if (mode != WebDisplayModeUndefined) return mode;
diff --git a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp index 49c51fc4..45c87e95 100644 --- a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp +++ b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp
@@ -59,6 +59,14 @@ return nullptr; } +// ComputedStylePropertyMap::getAllInternal/get should return computed styles +// (as opposed to resolved styles a la getComputedStyle()). +// +// Property values are read from an up-to-date ComputedStyle and converted into +// CSSStyleValues. This has not been implemented for all properties yet. +// Unsupported properties fall back to using resolved styles & converting them +// to CSSStyleValues via StyleValueFactory. For some types of values, such as +// images, the difference between the two is minor. CSSStyleValueVector ComputedStylePropertyMap::getAllInternal( CSSPropertyID propertyID) { CSSStyleValueVector styleValueVector; @@ -67,16 +75,17 @@ if (!node || !node->inActiveDocument()) { return styleValueVector; } + + // Update style before getting the value for the property node->document().updateStyleAndLayoutTreeForNode(node); node = this->node(); if (!node) { return styleValueVector; } // I have copied this from - // CSSComputedStyleDeclaration::computeComputedStyle(). I don't know if - // there is any use in passing m_pseudoId if node is not already a - // PseudoElement, but passing - // pseudo_Id when it IS already a PseudoElement leads to disaster. + // CSSComputedStyleDeclaration::computeComputedStyle(). I don't know if there + // is any use in passing m_pseudoId if node is not already a PseudoElement, + // but passing pseudo_Id when it IS already a PseudoElement leads to disaster. const ComputedStyle* style = node->ensureComputedStyle( node->isPseudoElement() ? PseudoIdNone : m_pseudoId); node = this->node(); @@ -129,10 +138,8 @@ break; } default: - // TODO(rjwright): Add a flag argument to - // ComputedStyleCSSValyeMapping::get that makes it return - // just the raw value off the ComputedStyle, and not zoom adjusted or - // anything like that. + // For properties not yet handled above, fall back to using resolved + // style. const CSSValue* value = ComputedStyleCSSValueMapping::get( propertyID, *style, nullptr, node, false); if (value) {
diff --git a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h index 6fb8e019..62334aa7 100644 --- a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h +++ b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h
@@ -12,6 +12,14 @@ namespace blink { +// This class implements computed StylePropertMapReadOnly in the Typed CSSOM +// API. The specification is here: +// https://drafts.css-houdini.org/css-typed-om-1/#computed-stylepropertymapreadonly-objects +// +// The computed StylePropertyMapReadOnly retrieves computed styles and returns +// them as CSSStyleValues. The IDL for this class is in StylePropertyMap.idl. +// The computed StylePropertyMapReadOnly for an element is accessed via +// window.getComputedStyleMap(element) (see WindowGetComputedStyle.idl/h) class CORE_EXPORT ComputedStylePropertyMap : public ImmutableStylePropertyMap { WTF_MAKE_NONCOPYABLE(ComputedStylePropertyMap);
diff --git a/third_party/WebKit/Source/core/editing/BUILD.gn b/third_party/WebKit/Source/core/editing/BUILD.gn index 46d172fc..cbb366f7 100644 --- a/third_party/WebKit/Source/core/editing/BUILD.gn +++ b/third_party/WebKit/Source/core/editing/BUILD.gn
@@ -122,6 +122,8 @@ "commands/ReplaceNodeWithSpanCommand.h", "commands/ReplaceSelectionCommand.cpp", "commands/ReplaceSelectionCommand.h", + "commands/SetCharacterDataCommand.cpp", + "commands/SetCharacterDataCommand.h", "commands/SetNodeAttributeCommand.cpp", "commands/SetNodeAttributeCommand.h", "commands/SimplifyMarkupCommand.cpp", @@ -249,6 +251,7 @@ "commands/DeleteSelectionCommandTest.cpp", "commands/InsertListCommandTest.cpp", "commands/ReplaceSelectionCommandTest.cpp", + "commands/SetCharacterDataCommandTest.cpp", "commands/TypingCommandTest.cpp", "iterators/BackwardsTextBufferTest.cpp", "iterators/CharacterIteratorTest.cpp",
diff --git a/third_party/WebKit/Source/core/editing/commands/EditCommand.h b/third_party/WebKit/Source/core/editing/commands/EditCommand.h index 668b52e6..c075cb7 100644 --- a/third_party/WebKit/Source/core/editing/commands/EditCommand.h +++ b/third_party/WebKit/Source/core/editing/commands/EditCommand.h
@@ -78,7 +78,7 @@ DoNotAssumeContentIsAlwaysEditable, }; -class SimpleEditCommand : public EditCommand { +class CORE_EXPORT SimpleEditCommand : public EditCommand { public: virtual void doUnapply() = 0; virtual void doReapply(); // calls doApply()
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp index bdf2737..773302a6 100644 --- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -518,17 +518,6 @@ shouldMerge(endOfInsertedContent, next); } -static bool isMailPasteAsQuotationHTMLBlockQuoteElement(const Node* node) { - if (!node || !node->isHTMLElement()) - return false; - const HTMLElement& element = toHTMLElement(*node); - if (!element.hasTagName(blockquoteTag) || - element.getAttribute(classAttr) != ApplePasteAsQuotation) - return false; - UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuotation); - return true; -} - static bool isHTMLHeaderElement(const Node* a) { if (!a || !a->isHTMLElement()) return false; @@ -552,9 +541,7 @@ Node* destinationNode = destination.deepEquivalent().anchorNode(); Element* sourceBlock = enclosingBlock(sourceNode); Element* destinationBlock = enclosingBlock(destinationNode); - return !enclosingNodeOfType(source.deepEquivalent(), - &isMailPasteAsQuotationHTMLBlockQuoteElement) && - sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || + return sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || isMailHTMLBlockquoteElement(sourceBlock)) && enclosingListChild(sourceBlock) == enclosingListChild(destinationNode) && @@ -617,11 +604,10 @@ // allowed to override those from the source document, see // <rdar://problem/4930986> and <rdar://problem/5089327>. HTMLQuoteElement* blockquoteElement = - !context || isMailPasteAsQuotationHTMLBlockQuoteElement(context) - ? toHTMLQuoteElement(context) - : toHTMLQuoteElement(enclosingNodeOfType( - Position::firstPositionInNode(context), - isMailHTMLBlockquoteElement, CanCrossEditingBoundary)); + !context ? toHTMLQuoteElement(context) + : toHTMLQuoteElement(enclosingNodeOfType( + Position::firstPositionInNode(context), + isMailHTMLBlockquoteElement, CanCrossEditingBoundary)); // EditingStyle::removeStyleFromRulesAndContext() uses StyleResolver, // which requires clean style. @@ -878,8 +864,7 @@ // Handling the case where we are doing Paste as Quotation or pasting into // quoted content is more complicated (see handleStyleSpans) and doesn't // receive the optimization. - if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || - enclosingNodeOfType(firstPositionInOrBeforeNode(topNode), + if (enclosingNodeOfType(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)) return; @@ -1022,11 +1007,6 @@ UseCounter::EditingAppleConvertedSpace); return true; } - if (classAttributeValue == ApplePasteAsQuotation) { - UseCounter::count(element->document(), - UseCounter::EditingApplePasteAsQuotation); - return true; - } return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element); } @@ -1604,11 +1584,6 @@ return; } - if (HTMLQuoteElement* mailBlockquote = toHTMLQuoteElement(enclosingNodeOfType( - positionAtStartOfInsertedContent().deepEquivalent(), - isMailPasteAsQuotationHTMLBlockQuoteElement))) - removeElementAttribute(mailBlockquote, classAttr); - if (shouldPerformSmartReplace()) { addSpacesForSmartReplace(editingState); if (editingState->isAborted())
diff --git a/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommand.cpp b/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommand.cpp new file mode 100644 index 0000000..3a25468e --- /dev/null +++ b/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommand.cpp
@@ -0,0 +1,73 @@ +// 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 "core/editing/commands/SetCharacterDataCommand.h" + +#include "core/editing/EditingUtilities.h" +#include "core/frame/Settings.h" +#include "core/layout/LayoutText.h" + +namespace blink { + +SetCharacterDataCommand::SetCharacterDataCommand(Text* node, + unsigned offset, + unsigned count, + const String& text) + : SimpleEditCommand(node->document()), + m_node(node), + m_offset(offset), + m_count(count), + m_newText(text) { + DCHECK(m_node); + DCHECK_LE(m_offset, m_node->length()); + DCHECK_LE(m_offset + m_count, m_node->length()); + // Callers shouldn't be trying to perform no-op replacements + DCHECK(!(count == 0 && text.length() == 0)); +} + +void SetCharacterDataCommand::doApply(EditingState*) { + // TODO(editing-dev): The use of updateStyleAndLayoutTree() + // needs to be audited. See http://crbug.com/590369 for more details. + document().updateStyleAndLayoutTree(); + if (!hasEditableStyle(*m_node)) + return; + + DummyExceptionStateForTesting exceptionState; + m_previousTextForUndo = + m_node->substringData(m_offset, m_count, exceptionState); + if (exceptionState.hadException()) + return; + + const bool passwordEchoEnabled = + document().settings() && document().settings()->getPasswordEchoEnabled(); + + if (passwordEchoEnabled) { + LayoutText* layoutText = m_node->layoutObject(); + if (layoutText && layoutText->isSecure()) { + layoutText->momentarilyRevealLastTypedCharacter(m_offset + + m_newText.length() - 1); + } + } + + m_node->replaceData(m_offset, m_count, m_newText, + IGNORE_EXCEPTION_FOR_TESTING); +} + +void SetCharacterDataCommand::doUnapply() { + // TODO(editing-dev): The use of updateStyleAndLayoutTree() + // needs to be audited. See http://crbug.com/590369 for more details. + document().updateStyleAndLayoutTree(); + if (!hasEditableStyle(*m_node)) + return; + + m_node->replaceData(m_offset, m_newText.length(), m_previousTextForUndo, + IGNORE_EXCEPTION_FOR_TESTING); +} + +DEFINE_TRACE(SetCharacterDataCommand) { + visitor->trace(m_node); + SimpleEditCommand::trace(visitor); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommand.h b/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommand.h new file mode 100644 index 0000000..aa3353a --- /dev/null +++ b/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommand.h
@@ -0,0 +1,42 @@ +// 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 SetCharacterDataCommand_h +#define SetCharacterDataCommand_h + +#include "core/editing/commands/EditCommand.h" + +namespace blink { + +class CORE_EXPORT SetCharacterDataCommand final : public SimpleEditCommand { + public: + static SetCharacterDataCommand* create(Text* node, + unsigned offset, + unsigned count, + const String& text) { + return new SetCharacterDataCommand(node, offset, count, text); + } + + DECLARE_VIRTUAL_TRACE(); + + private: + SetCharacterDataCommand(Text* node, + unsigned offset, + unsigned count, + const String& text); + + // EditCommand implementation + void doApply(EditingState*) final; + void doUnapply() final; + + const Member<Text> m_node; + const unsigned m_offset; + const unsigned m_count; + String m_previousTextForUndo; + const String m_newText; +}; + +} // namespace blink + +#endif // SetCharacterDataCommand_h
diff --git a/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommandTest.cpp new file mode 100644 index 0000000..b8828e1 --- /dev/null +++ b/third_party/WebKit/Source/core/editing/commands/SetCharacterDataCommandTest.cpp
@@ -0,0 +1,107 @@ +// 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 "core/editing/commands/SetCharacterDataCommand.h" + +#include "core/editing/EditingTestBase.h" +#include "core/editing/commands/EditingState.h" + +namespace blink { + +class SetCharacterDataCommandTest : public EditingTestBase {}; + +TEST_F(SetCharacterDataCommandTest, replaceTextWithSameLength) { + setBodyContent("<div contenteditable>This is a good test case</div>"); + + SimpleEditCommand* command = SetCharacterDataCommand::create( + toText(document().body()->firstChild()->firstChild()), 10, 4, "lame"); + + command->doReapply(); + EXPECT_EQ("This is a lame test case", + toText(document().body()->firstChild()->firstChild())->wholeText()); + + command->doUnapply(); + EXPECT_EQ("This is a good test case", + toText(document().body()->firstChild()->firstChild())->wholeText()); +} + +TEST_F(SetCharacterDataCommandTest, replaceTextWithLongerText) { + setBodyContent("<div contenteditable>This is a good test case</div>"); + + SimpleEditCommand* command = SetCharacterDataCommand::create( + toText(document().body()->firstChild()->firstChild()), 10, 4, "lousy"); + + command->doReapply(); + EXPECT_EQ("This is a lousy test case", + toText(document().body()->firstChild()->firstChild())->wholeText()); + + command->doUnapply(); + EXPECT_EQ("This is a good test case", + toText(document().body()->firstChild()->firstChild())->wholeText()); +} + +TEST_F(SetCharacterDataCommandTest, replaceTextWithShorterText) { + setBodyContent("<div contenteditable>This is a good test case</div>"); + + SimpleEditCommand* command = SetCharacterDataCommand::create( + toText(document().body()->firstChild()->firstChild()), 10, 4, "meh"); + + command->doReapply(); + EXPECT_EQ("This is a meh test case", + toText(document().body()->firstChild()->firstChild())->wholeText()); + + command->doUnapply(); + EXPECT_EQ("This is a good test case", + toText(document().body()->firstChild()->firstChild())->wholeText()); +} + +TEST_F(SetCharacterDataCommandTest, insertTextIntoEmptyNode) { + setBodyContent("<div contenteditable />"); + + document().body()->firstChild()->appendChild( + document().createEditingTextNode("")); + + SimpleEditCommand* command = SetCharacterDataCommand::create( + toText(document().body()->firstChild()->firstChild()), 0, 0, "hello"); + + command->doReapply(); + EXPECT_EQ("hello", + toText(document().body()->firstChild()->firstChild())->wholeText()); + + command->doUnapply(); + EXPECT_EQ("", + toText(document().body()->firstChild()->firstChild())->wholeText()); +} + +TEST_F(SetCharacterDataCommandTest, insertTextAtEndOfNonEmptyNode) { + setBodyContent("<div contenteditable>Hello</div>"); + + SimpleEditCommand* command = SetCharacterDataCommand::create( + toText(document().body()->firstChild()->firstChild()), 5, 0, ", world!"); + + command->doReapply(); + EXPECT_EQ("Hello, world!", + toText(document().body()->firstChild()->firstChild())->wholeText()); + + command->doUnapply(); + EXPECT_EQ("Hello", + toText(document().body()->firstChild()->firstChild())->wholeText()); +} + +TEST_F(SetCharacterDataCommandTest, replaceEntireNode) { + setBodyContent("<div contenteditable>Hello</div>"); + + SimpleEditCommand* command = SetCharacterDataCommand::create( + toText(document().body()->firstChild()->firstChild()), 0, 5, "Bye"); + + command->doReapply(); + EXPECT_EQ("Bye", + toText(document().body()->firstChild()->firstChild())->wholeText()); + + command->doUnapply(); + EXPECT_EQ("Hello", + toText(document().body()->firstChild()->firstChild())->wholeText()); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/core/editing/serializers/HTMLInterchange.h b/third_party/WebKit/Source/core/editing/serializers/HTMLInterchange.h index cbf2abb2..5addf94 100644 --- a/third_party/WebKit/Source/core/editing/serializers/HTMLInterchange.h +++ b/third_party/WebKit/Source/core/editing/serializers/HTMLInterchange.h
@@ -34,7 +34,6 @@ #define AppleInterchangeNewline "Apple-interchange-newline" #define AppleConvertedSpace "Apple-converted-space" -#define ApplePasteAsQuotation "Apple-paste-as-quotation" #define AppleTabSpanClass "Apple-tab-span" enum EAnnotateForInterchange {
diff --git a/third_party/WebKit/Source/core/frame/Frame.cpp b/third_party/WebKit/Source/core/frame/Frame.cpp index 21c11bf..dd7e0fe5 100644 --- a/third_party/WebKit/Source/core/frame/Frame.cpp +++ b/third_party/WebKit/Source/core/frame/Frame.cpp
@@ -384,8 +384,8 @@ } Settings* Frame::settings() const { - if (m_host) - return &m_host->settings(); + if (page()) + return &page()->settings(); return nullptr; }
diff --git a/third_party/WebKit/Source/core/frame/FrameHost.cpp b/third_party/WebKit/Source/core/frame/FrameHost.cpp index ac2dae81..104d7b1 100644 --- a/third_party/WebKit/Source/core/frame/FrameHost.cpp +++ b/third_party/WebKit/Source/core/frame/FrameHost.cpp
@@ -74,14 +74,6 @@ return *m_page; } -Settings& FrameHost::settings() { - return m_page->settings(); -} - -const Settings& FrameHost::settings() const { - return m_page->settings(); -} - ChromeClient& FrameHost::chromeClient() { return m_page->chromeClient(); }
diff --git a/third_party/WebKit/Source/core/frame/FrameHost.h b/third_party/WebKit/Source/core/frame/FrameHost.h index d9c65a00..f9471fd 100644 --- a/third_party/WebKit/Source/core/frame/FrameHost.h +++ b/third_party/WebKit/Source/core/frame/FrameHost.h
@@ -49,7 +49,6 @@ class Page; struct PageScaleConstraints; class PageScaleConstraintsSet; -class Settings; class TopDocumentRootScrollerController; class UseCounter; class VisualViewport; @@ -63,6 +62,7 @@ // browser-level concept and Blink core/ only knows about its LocalFrame (and // FrameHost). Separating Page from the rest of core/ through this indirection // allows us to slowly refactor Page without breaking the rest of core. +// TODO(sashab): Merge FrameHost back into Page. crbug.com/688614 class CORE_EXPORT FrameHost final : public GarbageCollectedFinalized<FrameHost> { WTF_MAKE_NONCOPYABLE(FrameHost); @@ -71,13 +71,9 @@ static FrameHost* create(Page&); ~FrameHost(); - // Careful: This function will eventually be removed. Page& page(); const Page& page() const; - Settings& settings(); - const Settings& settings() const; - ChromeClient& chromeClient(); const ChromeClient& chromeClient() const;
diff --git a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp index 4810ed8..9d7afb2 100644 --- a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp +++ b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
@@ -911,12 +911,12 @@ if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - ChromeClient& chromeClient = host->chromeClient(); - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) + ChromeClient& chromeClient = page->chromeClient(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) return lroundf(chromeClient.rootWindowRect().height() * chromeClient.screenInfo().deviceScaleFactor); return chromeClient.rootWindowRect().height(); @@ -926,12 +926,12 @@ if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - ChromeClient& chromeClient = host->chromeClient(); - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) + ChromeClient& chromeClient = page->chromeClient(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) return lroundf(chromeClient.rootWindowRect().width() * chromeClient.screenInfo().deviceScaleFactor); @@ -947,15 +947,19 @@ if (!view) return FloatSize(); - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return FloatSize(); + // If we have a Page, we must have a FrameHost. + FrameHost* host = frame()->host(); + DCHECK(host); + // The main frame's viewport size depends on the page scale. Since the // initial page scale depends on the content width and is set after a // layout, perform one now so queries during page load will use the up to // date viewport. - if (host->settings().getViewportEnabled() && frame()->isMainFrame()) + if (page->settings().getViewportEnabled() && frame()->isMainFrame()) document()->updateStyleAndLayoutIgnorePendingStylesheets(); // FIXME: This is potentially too much work. We really only need to know the @@ -967,7 +971,7 @@ ->updateStyleAndLayoutIgnorePendingStylesheets(); } - return frame()->isMainFrame() && !host->settings().getInertVisualViewport() + return frame()->isMainFrame() && !page->settings().getInertVisualViewport() ? FloatSize(host->visualViewport().visibleRect().size()) : FloatSize(view->visibleContentRect(scrollbarInclusion).size()); } @@ -994,12 +998,12 @@ if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - ChromeClient& chromeClient = host->chromeClient(); - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) + ChromeClient& chromeClient = page->chromeClient(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) return lroundf(chromeClient.rootWindowRect().x() * chromeClient.screenInfo().deviceScaleFactor); return chromeClient.rootWindowRect().x(); @@ -1009,22 +1013,22 @@ if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - ChromeClient& chromeClient = host->chromeClient(); - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) + ChromeClient& chromeClient = page->chromeClient(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) return lroundf(chromeClient.rootWindowRect().y() * chromeClient.screenInfo().deviceScaleFactor); return chromeClient.rootWindowRect().y(); } double LocalDOMWindow::scrollX() const { - if (!frame() || !frame()->host()) + if (!frame() || !frame()->page()) return 0; - if (!frame()->host()->settings().getInertVisualViewport()) + if (!frame()->page()->settings().getInertVisualViewport()) return m_visualViewport->pageX(); FrameView* view = frame()->view(); @@ -1039,10 +1043,10 @@ } double LocalDOMWindow::scrollY() const { - if (!frame() || !frame()->host()) + if (!frame() || !frame()->page()) return 0; - if (!frame()->host()->settings().getInertVisualViewport()) + if (!frame()->page()->settings().getInertVisualViewport()) return m_visualViewport->pageY(); FrameView* view = frame()->view(); @@ -1167,14 +1171,14 @@ if (!view) return; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return; x = ScrollableArea::normalizeNonFiniteScroll(x); y = ScrollableArea::normalizeNonFiniteScroll(y); - ScrollableArea* viewport = host->settings().getInertVisualViewport() + ScrollableArea* viewport = page->settings().getInertVisualViewport() ? view->layoutViewportScrollableArea() : view->getScrollableArea(); @@ -1207,8 +1211,8 @@ if (!view) return; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return; x = ScrollableArea::normalizeNonFiniteScroll(x); @@ -1221,7 +1225,7 @@ ScrollOffset layoutOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoomFactor()); - ScrollableArea* viewport = host->settings().getInertVisualViewport() + ScrollableArea* viewport = page->settings().getInertVisualViewport() ? view->layoutViewportScrollableArea() : view->getScrollableArea(); viewport->setScrollOffset(layoutOffset, ProgrammaticScroll, @@ -1236,8 +1240,8 @@ if (!view) return; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return; // It is only necessary to have an up-to-date layout if the position may be @@ -1250,7 +1254,7 @@ double scaledX = 0.0; double scaledY = 0.0; - ScrollableArea* viewport = host->settings().getInertVisualViewport() + ScrollableArea* viewport = page->settings().getInertVisualViewport() ? view->layoutViewportScrollableArea() : view->getScrollableArea();
diff --git a/third_party/WebKit/Source/core/frame/Screen.cpp b/third_party/WebKit/Source/core/frame/Screen.cpp index 0abf20f..530c0bb 100644 --- a/third_party/WebKit/Source/core/frame/Screen.cpp +++ b/third_party/WebKit/Source/core/frame/Screen.cpp
@@ -34,6 +34,7 @@ #include "core/frame/Settings.h" #include "core/inspector/InspectorInstrumentation.h" #include "core/page/ChromeClient.h" +#include "core/page/Page.h" #include "public/platform/WebScreenInfo.h" namespace blink { @@ -43,27 +44,27 @@ int Screen::height() const { if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { - WebScreenInfo screenInfo = host->chromeClient().screenInfo(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { + WebScreenInfo screenInfo = page->chromeClient().screenInfo(); return lroundf(screenInfo.rect.height * screenInfo.deviceScaleFactor); } - return host->chromeClient().screenInfo().rect.height; + return page->chromeClient().screenInfo().rect.height; } int Screen::width() const { if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { - WebScreenInfo screenInfo = host->chromeClient().screenInfo(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { + WebScreenInfo screenInfo = page->chromeClient().screenInfo(); return lroundf(screenInfo.rect.width * screenInfo.deviceScaleFactor); } - return host->chromeClient().screenInfo().rect.width; + return page->chromeClient().screenInfo().rect.width; } unsigned Screen::colorDepth() const { @@ -83,55 +84,55 @@ int Screen::availLeft() const { if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { - WebScreenInfo screenInfo = host->chromeClient().screenInfo(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { + WebScreenInfo screenInfo = page->chromeClient().screenInfo(); return lroundf(screenInfo.availableRect.x * screenInfo.deviceScaleFactor); } - return static_cast<int>(host->chromeClient().screenInfo().availableRect.x); + return static_cast<int>(page->chromeClient().screenInfo().availableRect.x); } int Screen::availTop() const { if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { - WebScreenInfo screenInfo = host->chromeClient().screenInfo(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { + WebScreenInfo screenInfo = page->chromeClient().screenInfo(); return lroundf(screenInfo.availableRect.y * screenInfo.deviceScaleFactor); } - return static_cast<int>(host->chromeClient().screenInfo().availableRect.y); + return static_cast<int>(page->chromeClient().screenInfo().availableRect.y); } int Screen::availHeight() const { if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { - WebScreenInfo screenInfo = host->chromeClient().screenInfo(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { + WebScreenInfo screenInfo = page->chromeClient().screenInfo(); return lroundf(screenInfo.availableRect.height * screenInfo.deviceScaleFactor); } - return host->chromeClient().screenInfo().availableRect.height; + return page->chromeClient().screenInfo().availableRect.height; } int Screen::availWidth() const { if (!frame()) return 0; - FrameHost* host = frame()->host(); - if (!host) + Page* page = frame()->page(); + if (!page) return 0; - if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { - WebScreenInfo screenInfo = host->chromeClient().screenInfo(); + if (page->settings().getReportScreenSizeInPhysicalPixelsQuirk()) { + WebScreenInfo screenInfo = page->chromeClient().screenInfo(); return lroundf(screenInfo.availableRect.width * screenInfo.deviceScaleFactor); } - return host->chromeClient().screenInfo().availableRect.width; + return page->chromeClient().screenInfo().availableRect.width; } DEFINE_TRACE(Screen) {
diff --git a/third_party/WebKit/Source/core/frame/VisualViewport.cpp b/third_party/WebKit/Source/core/frame/VisualViewport.cpp index a107295..9203358 100644 --- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp +++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
@@ -270,7 +270,7 @@ frameHost().page().scrollingCoordinator()) coordinator->scrollableAreaScrollLayerDidChange(this); - if (!frameHost().settings().getInertVisualViewport()) { + if (!frameHost().page().settings().getInertVisualViewport()) { if (Document* document = mainFrame()->document()) document->enqueueScrollEventForNode(document); } @@ -377,7 +377,7 @@ // Set masks to bounds so the compositor doesn't clobber a manually // set inner viewport container layer size. m_innerViewportContainerLayer->setMasksToBounds( - frameHost().settings().getMainFrameClipsContent()); + frameHost().page().settings().getMainFrameClipsContent()); m_innerViewportContainerLayer->setSize(FloatSize(m_size)); m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( @@ -411,7 +411,7 @@ return; if (visualViewportSuppliesScrollbars() && - !frameHost().settings().getHideScrollbars()) { + !frameHost().page().settings().getHideScrollbars()) { if (!m_overlayScrollbarHorizontal->parent()) m_innerViewportContainerLayer->addChild( m_overlayScrollbarHorizontal.get()); @@ -494,11 +494,11 @@ } bool VisualViewport::visualViewportSuppliesScrollbars() const { - return frameHost().settings().getViewportEnabled(); + return frameHost().page().settings().getViewportEnabled(); } bool VisualViewport::scrollAnimatorEnabled() const { - return frameHost().settings().getScrollAnimatorEnabled(); + return frameHost().page().settings().getScrollAnimatorEnabled(); } HostWindow* VisualViewport::getHostWindow() const {
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp index aeeb8785..50a1339 100644 --- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -1265,8 +1265,12 @@ HTMLFormElement* formForSubmission = m_inputTypeView->formForSubmission(); // Form may never have been present, or may have been destroyed by code // responding to the change event. - if (formForSubmission) + if (formForSubmission) { formForSubmission->submitImplicitly(evt, canTriggerImplicitSubmission()); + // We treat implicit submission is something like blur()-then-focus(). So + // we reset the last value. crbug.com/695349. + setTextAsOfLastFormControlChangeEvent(value()); + } evt->setDefaultHandled(); return;
diff --git a/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.cpp b/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.cpp index a909ce4..190097f 100644 --- a/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.cpp +++ b/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.cpp
@@ -27,6 +27,7 @@ #include "core/html/shadow/SpinButtonElement.h" #include "core/HTMLNames.h" +#include "core/dom/TaskRunnerHelper.h" #include "core/events/MouseEvent.h" #include "core/events/WheelEvent.h" #include "core/frame/LocalFrame.h" @@ -48,7 +49,10 @@ m_capturing(false), m_upDownState(Indeterminate), m_pressStartingState(Indeterminate), - m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired) {} + m_repeatingTimer( + TaskRunnerHelper::get(TaskType::UnspecedTimer, &document), + this, + &SpinButtonElement::repeatingTimerFired) {} SpinButtonElement* SpinButtonElement::create(Document& document, SpinButtonOwner& spinButtonOwner) {
diff --git a/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.h b/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.h index 62653851..3f2e2b26 100644 --- a/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.h +++ b/third_party/WebKit/Source/core/html/shadow/SpinButtonElement.h
@@ -98,7 +98,7 @@ bool m_capturing; UpDownState m_upDownState; UpDownState m_pressStartingState; - Timer<SpinButtonElement> m_repeatingTimer; + TaskRunnerTimer<SpinButtonElement> m_repeatingTimer; }; DEFINE_TYPE_CASTS(SpinButtonElement,
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp index 02ae092..2f08838 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
@@ -745,19 +745,36 @@ // be resolved using the available width of the containing block. Therefore we // don't use containingBlockLogicalWidthForContent() here, but instead // explicitly call availableWidth on our containing block. - if (!style()->left().isAuto()) { - if (!style()->right().isAuto() && - !containingBlock->style()->isLeftToRightDirection()) - offset.setWidth( - -valueForLength(style()->right(), containingBlock->availableWidth())); - else - offset.expand( - valueForLength(style()->left(), containingBlock->availableWidth()), - LayoutUnit()); - } else if (!style()->right().isAuto()) { - offset.expand( - -valueForLength(style()->right(), containingBlock->availableWidth()), - LayoutUnit()); + // https://drafts.csswg.org/css-position-3/#rel-pos + Optional<LayoutUnit> left; + Optional<LayoutUnit> right; + if (!style()->left().isAuto()) + left = valueForLength(style()->left(), containingBlock->availableWidth()); + if (!style()->right().isAuto()) + right = valueForLength(style()->right(), containingBlock->availableWidth()); + if (!left && !right) { + left = LayoutUnit(); + right = LayoutUnit(); + } + if (!left) + left = -right.value(); + if (!right) + right = -left.value(); + bool isLtr = containingBlock->style()->isLeftToRightDirection(); + WritingMode writingMode = containingBlock->style()->getWritingMode(); + switch (writingMode) { + case WritingMode::kHorizontalTb: + if (isLtr) + offset.expand(left.value(), LayoutUnit()); + else + offset.setWidth(-right.value()); + break; + case WritingMode::kVerticalRl: + offset.setWidth(-right.value()); + break; + case WritingMode::kVerticalLr: + offset.expand(left.value(), LayoutUnit()); + break; } // If the containing block of a relatively positioned element does not specify @@ -766,22 +783,47 @@ // <html> and <body> assume the size of the viewport. In this case, calculate // the percent offset based on this height. // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. + + Optional<LayoutUnit> top; + Optional<LayoutUnit> bottom; if (!style()->top().isAuto() && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || !style()->top().isPercentOrCalc() || - containingBlock->stretchesToViewport())) - offset.expand( - LayoutUnit(), - valueForLength(style()->top(), containingBlock->availableHeight())); - - else if (!style()->bottom().isAuto() && - (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || - !style()->bottom().isPercentOrCalc() || - containingBlock->stretchesToViewport())) - offset.expand( - LayoutUnit(), - -valueForLength(style()->bottom(), containingBlock->availableHeight())); - + containingBlock->stretchesToViewport())) { + top = valueForLength(style()->top(), containingBlock->availableHeight()); + } + if (!style()->bottom().isAuto() && + (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || + !style()->bottom().isPercentOrCalc() || + containingBlock->stretchesToViewport())) { + bottom = + valueForLength(style()->bottom(), containingBlock->availableHeight()); + } + if (!top && !bottom) { + top = LayoutUnit(); + bottom = LayoutUnit(); + } + if (!top) + top = -bottom.value(); + if (!bottom) + bottom = -top.value(); + switch (writingMode) { + case WritingMode::kHorizontalTb: + offset.expand(LayoutUnit(), top.value()); + break; + case WritingMode::kVerticalRl: + if (isLtr) + offset.expand(LayoutUnit(), top.value()); + else + offset.setHeight(-bottom.value()); + break; + case WritingMode::kVerticalLr: + if (isLtr) + offset.expand(LayoutUnit(), top.value()); + else + offset.setHeight(-bottom.value()); + break; + } return offset; }
diff --git a/third_party/WebKit/Source/core/layout/OWNERS b/third_party/WebKit/Source/core/layout/OWNERS index 1937721..06d2212 100644 --- a/third_party/WebKit/Source/core/layout/OWNERS +++ b/third_party/WebKit/Source/core/layout/OWNERS
@@ -1,23 +1,15 @@ cbiesinger@chromium.org chrishtr@chromium.org -dsinclair@chromium.org -dstockwell@chromium.org eae@chromium.org esprehn@chromium.org fmalita@chromium.org fs@opera.com -kouhei@chromium.org mstensho@opera.com -ojan@chromium.org pdr@chromium.org -rob.buis@samsung.com schenney@chromium.org -senorblanco@chromium.org skobes@chromium.org svillar@igalia.com -timloh@chromium.org tkent@chromium.org -vollick@chromium.org wangxianzhu@chromium.org # TEAM: layout-dev@
diff --git a/third_party/WebKit/Source/devtools/front_end/Images/src/optimize_png.hashes b/third_party/WebKit/Source/devtools/front_end/Images/src/optimize_png.hashes index 45b233b..1965213 100644 --- a/third_party/WebKit/Source/devtools/front_end/Images/src/optimize_png.hashes +++ b/third_party/WebKit/Source/devtools/front_end/Images/src/optimize_png.hashes
@@ -5,9 +5,9 @@ "checkboxCheckmark.svg": "f039bf85cee42ad5c30ca3bfdce7912a", "errorWave.svg": "e183fa242a22ed4784a92f6becbc2c45", "smallIcons.svg": "044ba42204fd8ae030835e2ca78433bf", - "toolbarButtonGlyphs.svg": "3db0c30256dd19d51b088f6855052030", + "toolbarButtonGlyphs.svg": "fa5911823785a90273dfea76fe4ce512", "breakpoint.svg": "69cd92d807259c022791112809b97799", "treeoutlineTriangles.svg": "017d2f89437df0afc6b9cd5ff43735d9", "audits_logo_bw.svg": "203dcb2ba32ef0f4595ad45bb8feffab", "audits_logo.svg": "647095d7981857c22a816eef12f75b91" -} +} \ No newline at end of file
diff --git a/third_party/WebKit/Source/devtools/front_end/Images/src/svg2png.hashes b/third_party/WebKit/Source/devtools/front_end/Images/src/svg2png.hashes index 1eecefc..1965213 100644 --- a/third_party/WebKit/Source/devtools/front_end/Images/src/svg2png.hashes +++ b/third_party/WebKit/Source/devtools/front_end/Images/src/svg2png.hashes
@@ -5,7 +5,7 @@ "checkboxCheckmark.svg": "f039bf85cee42ad5c30ca3bfdce7912a", "errorWave.svg": "e183fa242a22ed4784a92f6becbc2c45", "smallIcons.svg": "044ba42204fd8ae030835e2ca78433bf", - "toolbarButtonGlyphs.svg": "3db0c30256dd19d51b088f6855052030", + "toolbarButtonGlyphs.svg": "fa5911823785a90273dfea76fe4ce512", "breakpoint.svg": "69cd92d807259c022791112809b97799", "treeoutlineTriangles.svg": "017d2f89437df0afc6b9cd5ff43735d9", "audits_logo_bw.svg": "203dcb2ba32ef0f4595ad45bb8feffab",
diff --git a/third_party/WebKit/Source/devtools/front_end/Images/src/toolbarButtonGlyphs.svg b/third_party/WebKit/Source/devtools/front_end/Images/src/toolbarButtonGlyphs.svg index c0a3f4d..c07f8f8 100644 --- a/third_party/WebKit/Source/devtools/front_end/Images/src/toolbarButtonGlyphs.svg +++ b/third_party/WebKit/Source/devtools/front_end/Images/src/toolbarButtonGlyphs.svg
@@ -9,23 +9,23 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - height="192" + height="168" version="1.1" width="352" xml:space="preserve" id="svg3395" - inkscape:version="0.48.4 r9939" + inkscape:version="0.92.0 r" sodipodi:docname="toolbarButtonGlyphs.svg"><metadata id="metadata3773"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><sodipodi:namedview showgrid="true" id="namedview3397" - inkscape:zoom="11.313708" - inkscape:cx="83.592365" - inkscape:cy="12.060079" - inkscape:window-width="1941" - inkscape:window-height="1436" + inkscape:zoom="2.8284271" + inkscape:cx="196.27229" + inkscape:cy="85.656284" + inkscape:window-width="1278" + inkscape:window-height="746" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="0" @@ -621,7 +621,7 @@ style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><g id="g2488"><path transform="matrix(0.36,0,0,0.36,125.49998,127.46)" - d="m 53,14 c 0,1.656854 -1.343146,3 -3,3 -1.656854,0 -3,-1.343146 -3,-3 0,-1.656854 1.343146,-3 3,-3 1.656854,0 3,1.343146 3,3 z" + d="m 53,14 a 3,3 0 1 1 -6,0 3,3 0 1 1 6,0 z" sodipodi:ry="3" sodipodi:rx="3" sodipodi:cy="14" @@ -658,7 +658,11 @@ id="g2472"><path id="path3509-0" d="m 240.76701,127 -1.53402,0 0,4.23299 -4.23299,0 0,1.53402 4.23299,0 0,4.23299 1.53402,0 0,-4.23299 4.23299,0 0,-1.53402 -4.23299,0 0,-4.23299 z" - inkscape:connector-curvature="0" /></g><g + inkscape:connector-curvature="0" /></g><path + style="fill:none" + inkscape:connector-curvature="0" + d="m 228.56466,156.76923 h 48 v 48 h -48 z" + id="path3712" /><g id="g2462"><path id="path3714" d="m 310.7696,127.0439 -1.81599,-1.81636 c -0.30331,-0.30338 -0.79716,-0.30338 -1.10048,0 l -2.43038,2.43089 -1.48935,-1.49354 -1.10047,1.1007 1.10437,1.1046 L 297,135.30504 V 139 h 3.69419 l 6.9373,-6.93874 1.10048,1.1046 1.10048,-1.10072 -1.49324,-1.49353 2.43039,-2.43089 c 0.3072,-0.30338 0.3072,-0.79345 0,-1.09682 z m -10.72092,10.40033 -1.49324,-1.49354 6.27235,-6.27365 1.49323,1.49354 -6.27234,6.27365 z" @@ -720,7 +724,7 @@ style="fill:none" /><g id="g2256"><path transform="matrix(1.4142135,0,0,1.4142135,-86.874996,-12.771743)" - d="m 209.92234,31.304852 c 0,0.585786 -0.47487,1.06066 -1.06066,1.06066 -0.58579,0 -1.06066,-0.474874 -1.06066,-1.06066 0,-0.585787 0.47487,-1.060661 1.06066,-1.060661 0.58579,0 1.06066,0.474874 1.06066,1.060661 z" + d="m 209.92234,31.304852 a 1.0606602,1.0606602 0 1 1 -2.12132,0 1.0606602,1.0606602 0 1 1 2.12132,0 z" sodipodi:ry="1.0606602" sodipodi:rx="1.0606602" sodipodi:cy="31.304852" @@ -735,10 +739,10 @@ sodipodi:cy="31.304852" sodipodi:rx="1.0606602" sodipodi:ry="1.0606602" - d="m 209.92234,31.304852 c 0,0.585786 -0.47487,1.06066 -1.06066,1.06066 -0.58579,0 -1.06066,-0.474874 -1.06066,-1.06066 0,-0.585787 0.47487,-1.060661 1.06066,-1.060661 0.58579,0 1.06066,0.474874 1.06066,1.060661 z" + d="m 209.92234,31.304852 a 1.0606602,1.0606602 0 1 1 -2.12132,0 1.0606602,1.0606602 0 1 1 2.12132,0 z" transform="matrix(1.4142135,0,0,1.4142135,-86.874986,-7.771742)" /><path transform="matrix(1.4142135,0,0,1.4142135,-86.874986,-2.771743)" - d="m 209.92234,31.304852 c 0,0.585786 -0.47487,1.06066 -1.06066,1.06066 -0.58579,0 -1.06066,-0.474874 -1.06066,-1.06066 0,-0.585787 0.47487,-1.060661 1.06066,-1.060661 0.58579,0 1.06066,0.474874 1.06066,1.060661 z" + d="m 209.92234,31.304852 a 1.0606602,1.0606602 0 1 1 -2.12132,0 1.0606602,1.0606602 0 1 1 2.12132,0 z" sodipodi:ry="1.0606602" sodipodi:rx="1.0606602" sodipodi:cy="31.304852" @@ -748,36 +752,27 @@ sodipodi:type="arc" /></g><g id="g2378"><path id="path3288" - d="m 23,157 -2,0 0,2 2,0 z" - inkscape:connector-curvature="0" /><path + d="m 23,157 -2,0 0,2 2,0 z" /><path id="path3286" - d="m 23,161 -2,0 0,2 c 1,0 2,-1 2,-2 z" - inkscape:connector-curvature="0" /><path + d="m 23,161 -2,0 0,2 c 1,0 2,-1 2,-2 z" /><path id="path3284" - d="m 23,153 -2,0 0,2 2,0 z" - inkscape:connector-curvature="0" /><path + d="m 23,153 -2,0 0,2 2,0 z" /><path id="path3282" - d="m 21,149 0,2 2,0 c 0,-1 -1,-2 -2,-2 z" - inkscape:connector-curvature="0" /><path + d="m 21,149 0,2 2,0 c 0,-1 -1,-2 -2,-2 z" /><path sodipodi:nodetypes="scccss" inkscape:connector-curvature="0" id="path3280" d="m 11,163 4,0 0,-6 -6,0 0,4 c 0,1.1 0.9,2 2,2 z" /><path id="path3278" - d="m 11,153 -2,0 0,2 2,0 z" - inkscape:connector-curvature="0" /><path + d="m 11,153 -2,0 0,2 2,0 z" /><path id="path3276" - d="m 19,149 -2,0 0,2 2,0 z" - inkscape:connector-curvature="0" /><path + d="m 19,149 -2,0 0,2 2,0 z" /><path id="path3274" - d="m 19,161 -2,0 0,2 2,0 z" - inkscape:connector-curvature="0" /><path + d="m 19,161 -2,0 0,2 2,0 z" /><path id="path3272" - d="m 11,149 c -1,0 -2,1 -2,2 l 2,0 z" - inkscape:connector-curvature="0" /><path + d="m 11,149 c -1,0 -2,1 -2,2 l 2,0 z" /><path id="path3231" - d="m 15,149 -2,0 0,2 2,0 z" - inkscape:connector-curvature="0" /></g><g + d="m 15,149 -2,0 0,2 2,0 z" /></g><g id="g2383"><g id="g4042"><path sodipodi:type="arc" @@ -787,7 +782,7 @@ sodipodi:cy="155.38257" sodipodi:rx="4.3973203" sodipodi:ry="4.6182914" - d="m 80.87534,155.38257 c 0,2.55061 -1.968747,4.61829 -4.39732,4.61829 -2.428573,0 -4.397321,-2.06768 -4.397321,-4.61829 0,-2.55061 1.968748,-4.61829 4.397321,-4.61829 2.428573,0 4.39732,2.06768 4.39732,4.61829 z" + d="m 80.87534,155.38257 a 4.3973203,4.6182914 0 1 1 -8.794641,0 4.3973203,4.6182914 0 1 1 8.794641,0 z" transform="matrix(1.1939089,0,0,1.1367841,-44.307792,-20.636427)" /><rect style="fill:#000000;fill-opacity:1;stroke:none" id="rect4010" @@ -797,10 +792,9 @@ y="155" rx="0.38569456" ry="0" /></g></g><path - d="M 0,0 H 24 V 24 H 0 z" - id="path3242" - inkscape:connector-curvature="0" - style="fill:none" /><g + d="M0 0h24v24H0z" + fill="none" + id="path3242" /><g id="g2387"><path inkscape:connector-curvature="0" id="path3240" @@ -948,7 +942,7 @@ sketch:type="MSShapeGroup" /></g></g></g></g><polygon style="opacity:0.5;fill:none;stroke:none" id="bounds-5" - points="0,0 16,0 16,16 0,16 " + points="16,0 16,16 0,16 0,0 " transform="translate(232.08128,27.81372)" /><g id="g3185"><path id="path3730" @@ -1030,13 +1024,12 @@ id="path3294" /></g><g id="g2191"><path id="path3555-5" - d="m 16,6 c -3.31,0 -6,2.69 -6,6 0,3.31 2.69,6 6,6 3.31,0 6,-2.69 6,-6 l -2,0 c 0,2.209139 -1.790861,4 -4,4 -2.209139,0 -4,-1.790861 -4,-4 0,-2.2091389 1.790861,-4 4,-4 1.275627,0 2.392569,0.6012713 3.125,1.53125 l 2.34375,0 C 20.526539,7.4496106 18.430781,6 16,6 z" - inkscape:connector-curvature="0" /><path + d="M 16 6 C 12.69 6 10 8.69 10 12 C 10 15.31 12.69 18 16 18 C 19.31 18 22 15.31 22 12 L 20 12 C 20 14.209139 18.209139 16 16 16 C 13.790861 16 12 14.209139 12 12 C 12 9.7908611 13.790861 8 16 8 C 17.275627 8 18.392569 8.6012713 19.125 9.53125 L 21.46875 9.53125 C 20.526539 7.4496106 18.430781 6 16 6 z " /><path sodipodi:nodetypes="cccc" inkscape:connector-curvature="0" id="path3660" d="m 21.090773,6.879988 0,3.0918004 -3.0918,0 z" - style="fill:#000000;stroke:#000000;stroke-width:1.06808329px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /></g><path + style="fill:#000000;stroke:#000000;stroke-width:1.06808328999999991px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /></g><path style="fill:none" inkscape:connector-curvature="0" d="m 169,29 h 18 v 18 h -18 z" @@ -1074,7 +1067,7 @@ id="path4367-6-6" /><path style="fill:none" inkscape:connector-curvature="0" - d="m 295.25,75.250001 h 20 V 95.25 h -20 z" + d="m 295.25,75.250001 h 20 v 20 h -20 z" id="path5182-06" /><path style="fill:none" inkscape:connector-curvature="0" @@ -1097,7 +1090,7 @@ id="path4367-6-8" /><path style="fill:none" inkscape:connector-curvature="0" - d="m 327.25,75.250001 h 20 V 95.25 h -20 z" + d="m 327.25,75.250001 h 20 v 20 h -20 z" id="path5182-7" /><path style="fill:none" inkscape:connector-curvature="0" @@ -1125,7 +1118,7 @@ style="fill:#ffffff;fill-opacity:0;stroke:none" id="bg-2" x="191.87378" - y="-0.043567657" + y="-0.0435686" width="14" height="14" /><g id="g2271"><circle @@ -1147,7 +1140,7 @@ style="fill:#000000;stroke:none" /></g><path style="fill:none" inkscape:connector-curvature="0" - d="m 292.76613,72.135146 h 24 V 96.13515 h -24 z" + d="m 292.76613,72.135146 h 24 v 24 h -24 z" id="path3652" /><path style="fill:none" inkscape:connector-curvature="0" @@ -1155,7 +1148,7 @@ id="path3763" /><path style="fill:none" inkscape:connector-curvature="0" - d="m 236.19418,70.013825 h 24 V 94.01382 h -24 z" + d="m 236.19418,70.013825 h 24 v 24 h -24 z" id="path3343" /><g id="g2237"><path id="path3345" @@ -1240,7 +1233,7 @@ id="rect3639-9" transform="scale(-1,1)" /></g></g><g id="g2528"><g - transform="matrix(0,-1,1,0,88,395)" + transform="rotate(-90,241.5,153.5)" id="g1088"><rect height="12" width="14" @@ -1277,7 +1270,7 @@ width="1" height="13" /></g></g></g><g id="g2442"><g - transform="matrix(0,-1,1,0,168,379)" + transform="rotate(-90,273.5,105.5)" id="g1243"><rect height="12" width="14" @@ -1297,7 +1290,7 @@ transform="scale(-1,1)" /></g></g><g id="g2448"><g id="g1248-3" - transform="matrix(0,-1,1,0,200,315)"><rect + transform="rotate(-90,257.5,57.5)"><rect height="12" width="14" x="-214.5" @@ -1313,131 +1306,4 @@ x="-211" y="102" id="rect3633-4-9" - transform="scale(-1,1)" /></g></g><g - id="g3829" - transform="translate(1,0)"><path - inkscape:connector-curvature="0" - id="path3519-7" - d="m 20,180 0,-7 2,0 0,7 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3521-5" - d="m 17,179 0,-6 2,0 0,6 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3523-3" - d="m 14,181 0,-8 2,0 0,8 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3525-5" - d="m 11,185 0,-12 2,0 0,12 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-6" - d="m 8,177 0,-4 2,0 0,4 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3519-7-2" - d="m 20,180 0,-7 2,0 0,7 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3521-5-9" - d="m 17,179 0,-6 2,0 0,6 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3523-3-1" - d="m 14,181 0,-8 2,0 0,8 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-2" - d="m 11,185 0,-12 2,0 0,12 -2,0 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-6-7" - d="m 8,177 0,-4 2,0 0,4 -2,0 z" /></g><g - id="g3899"><path - inkscape:connector-curvature="0" - id="path3519-7-9" - d="m 48,185 -7,0 0,2 7,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3521-5-3" - d="m 47,182 -6,0 0,2 6,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3523-3-6" - d="m 49,179 -8,0 0,2 8,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-0" - d="m 53,176 -12,0 0,2 12,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-6-6" - d="m 45,173 -4,0 0,2 4,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3519-7-2-2" - d="m 48,185 -7,0 0,2 7,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3521-5-9-6" - d="m 47,182 -6,0 0,2 6,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3523-3-1-1" - d="m 53,179 -12,0 0,2 12,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-2-8" - d="m 55,176 -14,0 0,2 14,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-6-7-7" - d="m 45,173 -4,0 0,2 4,0 0,-2 z" /></g><g - id="g5005"><path - inkscape:connector-curvature="0" - id="path3519-7-9-2" - d="m 84,185 -8,0 0,2 8,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3523-3-6-2" - d="m 86,179 -7,0 0,2 7,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3521-5-9-6-9" - d="m 83,182 -4,0 0,2 4,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-2-8-2" - d="m 88,176 -12,0 0,2 12,0 0,-2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-6-7-7-8" - d="m 79,173 -6,0 0,2 6,0 0,-2 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9" - d="m 77,176 0,2 -4,0 0,-2 4,0 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-3" - d="m 77,185 0,2 -4,0 0,-2 4,0 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-3-1" - d="m 80,179 0,2 -4,0 0,-2 4,0 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-3-1-7" - d="m 80,182 0,2 -4,0 0,-2 4,0 z" /></g><g - id="g5016"><path - inkscape:connector-curvature="0" - id="path3519-7-9-2-4" - d="m 104,175 8,0 0,-2 -8,0 0,2 z" /><path - inkscape:connector-curvature="0" - id="path3523-3-6-2-5" - d="m 104,181 7,0 0,-2 -7,0 0,2 z" /><path - inkscape:connector-curvature="0" - id="path3521-5-9-6-9-0" - d="m 104,178 4,0 0,-2 -4,0 0,2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-2-8-2-3" - d="m 104,184 12,0 0,-2 -12,0 0,2 z" /><path - inkscape:connector-curvature="0" - id="path3525-5-6-7-7-8-6" - d="m 113,187 6,0 0,-2 -6,0 0,2 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-1" - d="m 115,184 0,-2 4,0 0,2 -4,0 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-3-0" - d="m 112,175 0,-2 7,0 0,2 -7,0 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-3-1-6" - d="m 110,181 0,-2 6,0 0,2 -6,0 z" /><path - style="opacity:0.4" - inkscape:connector-curvature="0" - id="path3517-7-9-3-1-7-3" - d="m 108,178 0,-2 8,0 0,2 -8,0 z" /></g></svg> \ No newline at end of file + transform="scale(-1,1)" /></g></g></svg> \ No newline at end of file
diff --git a/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs.png b/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs.png index c3d678c..6e29b0e9 100644 --- a/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs.png +++ b/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs.png Binary files differ
diff --git a/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs_2x.png b/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs_2x.png index 450877f..46d3416 100644 --- a/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs_2x.png +++ b/third_party/WebKit/Source/devtools/front_end/Images/toolbarButtonGlyphs_2x.png Binary files differ
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js index 295a7fd..a9de61fd 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
@@ -118,10 +118,6 @@ this._tabbedPane.appendTab(viewMode.BottomUp, Common.UIString('Bottom-Up'), new UI.VBox()); this._tabbedPane.appendTab(viewMode.CallTree, Common.UIString('Call Tree'), new UI.VBox()); this._tabbedPane.appendTab(viewMode.EventLog, Common.UIString('Event Log'), new UI.VBox()); - this._tabbedPane.setTabIcon(viewMode.FlameChart, UI.Icon.create('largeicon-perf-flamechart')); - this._tabbedPane.setTabIcon(viewMode.BottomUp, UI.Icon.create('largeicon-perf-bottom-up-tree')); - this._tabbedPane.setTabIcon(viewMode.CallTree, UI.Icon.create('largeicon-perf-call-tree')); - this._tabbedPane.setTabIcon(viewMode.EventLog, UI.Icon.create('largeicon-perf-event-list')); this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._onMainViewChanged.bind(this)); this._tabbedPane.selectTab(this._viewModeSetting.get()); } else { @@ -143,6 +139,9 @@ Extensions.extensionServer.addEventListener( Extensions.ExtensionServer.Events.TraceProviderAdded, this._appendExtensionsToToolbar, this); SDK.targetManager.addEventListener(SDK.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChanged, this); + + /** @type {!SDK.TracingModel.Event}|undefined */ + this._selectedSearchResult; } /**
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Icon.js b/third_party/WebKit/Source/devtools/front_end/ui/Icon.js index 4dd053c..0b3c08a 100644 --- a/third_party/WebKit/Source/devtools/front_end/ui/Icon.js +++ b/third_party/WebKit/Source/devtools/front_end/ui/Icon.js
@@ -169,10 +169,6 @@ 'largeicon-dock-to-bottom': {x: -32, y: -24, width: 28, height: 24, spritesheet: 'largeicons', isMask: true}, 'largeicon-undock': {x: 0, y: -48, width: 28, height: 24, spritesheet: 'largeicons', isMask: true}, 'largeicon-settings-gear': {x: -288, y: -72, width: 28, height: 24, spritesheet: 'largeicons', isMask: true}, - 'largeicon-perf-flamechart': {x: -4, y: -168, width: 24, height: 24, spritesheet: 'largeicons', isMask: true}, - 'largeicon-perf-event-list': {x: -36, y: -168, width: 24, height: 24, spritesheet: 'largeicons', isMask: true}, - 'largeicon-perf-call-tree': {x: -68, y: -168, width: 24, height: 24, spritesheet: 'largeicons', isMask: true}, - 'largeicon-perf-bottom-up-tree': {x: -100, y: -168, width: 24, height: 24, spritesheet: 'largeicons', isMask: true}, 'largeicon-show-left-sidebar': {x: -160, y: -72, width: 28, height: 24, spritesheet: 'largeicons', isMask: true}, 'largeicon-hide-left-sidebar': {x: -192, y: -72, width: 28, height: 24, spritesheet: 'largeicons', isMask: true},
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/inspectorCommon.css b/third_party/WebKit/Source/devtools/front_end/ui/inspectorCommon.css index d7b2f886..935bf339 100644 --- a/third_party/WebKit/Source/devtools/front_end/ui/inspectorCommon.css +++ b/third_party/WebKit/Source/devtools/front_end/ui/inspectorCommon.css
@@ -343,12 +343,12 @@ .spritesheet-largeicons:not(.icon-mask) { background-image: -webkit-image-set(url(Images/toolbarButtonGlyphs.png) 1x, url(Images/toolbarButtonGlyphs_2x.png) 2x); - background-size: 352px 192px; + background-size: 352px 168px; } .spritesheet-largeicons.icon-mask { -webkit-mask-image: -webkit-image-set(url(Images/toolbarButtonGlyphs.png) 1x, url(Images/toolbarButtonGlyphs_2x.png) 2x); - -webkit-mask-size: 352px 192px; + -webkit-mask-size: 352px 168px; } .spritesheet-resourceicons:not(.icon-mask) { @@ -372,7 +372,7 @@ .force-white-icons [is=ui-icon].spritesheet-largeicons, [is=ui-icon].force-white-icons.spritesheet-largeicons { -webkit-mask-image: -webkit-image-set(url(Images/toolbarButtonGlyphs.png) 1x, url(Images/toolbarButtonGlyphs_2x.png) 2x); - -webkit-mask-size: 352px 192px; + -webkit-mask-size: 352px 168px; background-image: unset; background-size: unset; background: unset;
diff --git a/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp b/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp index 190f62b..a0e7960 100644 --- a/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp +++ b/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp
@@ -5,7 +5,6 @@ #include "modules/storage/DOMWindowStorage.h" #include "core/dom/Document.h" -#include "core/frame/FrameHost.h" #include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalFrame.h" #include "core/frame/Settings.h" @@ -124,8 +123,8 @@ return m_localStorage; } // FIXME: Seems this check should be much higher? - FrameHost* host = document->frameHost(); - if (!host || !host->settings().getLocalStorageEnabled()) + Page* page = document->page(); + if (!page || !page->settings().getLocalStorageEnabled()) return nullptr; StorageArea* storageArea = StorageNamespace::localStorageArea(document->getSecurityOrigin());
diff --git a/third_party/WebKit/Source/modules/webusb/USBDevice.cpp b/third_party/WebKit/Source/modules/webusb/USBDevice.cpp index a2f6345..c0dfbedb 100644 --- a/third_party/WebKit/Source/modules/webusb/USBDevice.cpp +++ b/third_party/WebKit/Source/modules/webusb/USBDevice.cpp
@@ -779,11 +779,12 @@ return; DOMException* error = convertFatalTransferStatus(status); - if (error) + if (error) { resolver->reject(error); - else + } else { resolver->resolve( USBInTransferResult::create(convertTransferStatus(status), data)); + } } void USBDevice::asyncControlTransferOut(unsigned transferLength, @@ -793,11 +794,12 @@ return; DOMException* error = convertFatalTransferStatus(status); - if (error) + if (error) { resolver->reject(error); - else + } else { resolver->resolve(USBOutTransferResult::create( convertTransferStatus(status), transferLength)); + } } void USBDevice::asyncClearHalt(ScriptPromiseResolver* resolver, bool success) { @@ -818,11 +820,12 @@ return; DOMException* error = convertFatalTransferStatus(status); - if (error) + if (error) { resolver->reject(error); - else + } else { resolver->resolve( USBInTransferResult::create(convertTransferStatus(status), data)); + } } void USBDevice::asyncTransferOut(unsigned transferLength, @@ -832,11 +835,12 @@ return; DOMException* error = convertFatalTransferStatus(status); - if (error) + if (error) { resolver->reject(error); - else + } else { resolver->resolve(USBOutTransferResult::create( convertTransferStatus(status), transferLength)); + } } void USBDevice::asyncIsochronousTransferIn( @@ -857,11 +861,13 @@ resolver->reject(error); return; } + DOMDataView* dataView = nullptr; + if (buffer) { + dataView = + DOMDataView::create(buffer, byteOffset, packet->transferred_length); + } packets.push_back(USBIsochronousInTransferPacket::create( - convertTransferStatus(packet->status), - buffer ? DOMDataView::create(buffer, byteOffset, - packet->transferred_length) - : nullptr)); + convertTransferStatus(packet->status), dataView)); byteOffset += packet->length; } resolver->resolve(USBIsochronousInTransferResult::create(buffer, packets));
diff --git a/third_party/WebKit/Source/modules/webusb/USBInTransferResult.h b/third_party/WebKit/Source/modules/webusb/USBInTransferResult.h index 0317a43..9423366 100644 --- a/third_party/WebKit/Source/modules/webusb/USBInTransferResult.h +++ b/third_party/WebKit/Source/modules/webusb/USBInTransferResult.h
@@ -22,17 +22,24 @@ public: static USBInTransferResult* create(const String& status, const Optional<Vector<uint8_t>>& data) { + DOMDataView* dataView = nullptr; + if (data) { + dataView = DOMDataView::create( + DOMArrayBuffer::create(data->data(), data->size()), 0, data->size()); + } + return new USBInTransferResult(status, dataView); + } + + static USBInTransferResult* create(const String& status) { + return new USBInTransferResult(status, nullptr); + } + + static USBInTransferResult* create(const String& status, DOMDataView* data) { return new USBInTransferResult(status, data); } - USBInTransferResult(const String& status, - const Optional<Vector<uint8_t>>& data) - : m_status(status), - m_data(data ? DOMDataView::create( - DOMArrayBuffer::create(data->data(), data->size()), - 0, - data->size()) - : nullptr) {} + USBInTransferResult(const String& status, DOMDataView* data) + : m_status(status), m_data(data) {} virtual ~USBInTransferResult() {}
diff --git a/third_party/WebKit/Source/modules/webusb/USBInTransferResult.idl b/third_party/WebKit/Source/modules/webusb/USBInTransferResult.idl index c204cdd3..60c6965 100644 --- a/third_party/WebKit/Source/modules/webusb/USBInTransferResult.idl +++ b/third_party/WebKit/Source/modules/webusb/USBInTransferResult.idl
@@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://wicg.github.io/webusb/#transfers +// https://wicg.github.io/webusb/#usbintransferresult [ OriginTrialEnabled=WebUSB, + Constructor(USBTransferStatus status, optional DataView? data) ] interface USBInTransferResult { - readonly attribute DataView data; + readonly attribute DataView? data; readonly attribute USBTransferStatus status; };
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.h b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.h index 0c4c11d..7c1ec937 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.h +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.h
@@ -18,6 +18,10 @@ DEFINE_WRAPPERTYPEINFO(); public: + static USBIsochronousInTransferPacket* create(const String& status) { + return new USBIsochronousInTransferPacket(status, nullptr); + } + static USBIsochronousInTransferPacket* create(const String& status, DOMDataView* data) { return new USBIsochronousInTransferPacket(status, data);
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.idl b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.idl index 0aeb1ca..e483f689 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.idl +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferPacket.idl
@@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://wicg.github.io/webusb/#idl-def-usbisochronousintransferpacket +// https://wicg.github.io/webusb/#usbisochronousintransferpacket [ OriginTrialEnabled=WebUSB, + Constructor(USBTransferStatus status, optional DataView? data) ] interface USBIsochronousInTransferPacket { readonly attribute USBTransferStatus status; - readonly attribute DataView data; + readonly attribute DataView? data; };
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.h b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.h index 2e73d26..accbaca82 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.h +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.h
@@ -23,17 +23,26 @@ static USBIsochronousInTransferResult* create( DOMArrayBuffer* data, const HeapVector<Member<USBIsochronousInTransferPacket>>& packets) { + DOMDataView* dataView = DOMDataView::create(data, 0, data->byteLength()); + return new USBIsochronousInTransferResult(dataView, packets); + } + + static USBIsochronousInTransferResult* create( + const HeapVector<Member<USBIsochronousInTransferPacket>>& packets, + DOMDataView* data) { return new USBIsochronousInTransferResult(data, packets); } - USBIsochronousInTransferResult( - DOMArrayBuffer* data, - const HeapVector<Member<USBIsochronousInTransferPacket>>& packets) - : m_packets(packets) { - unsigned byteLength = data->byteLength(); - m_data = DOMDataView::create(data, 0, byteLength); + static USBIsochronousInTransferResult* create( + const HeapVector<Member<USBIsochronousInTransferPacket>>& packets) { + return new USBIsochronousInTransferResult(nullptr, packets); } + USBIsochronousInTransferResult( + DOMDataView* data, + const HeapVector<Member<USBIsochronousInTransferPacket>>& packets) + : m_data(data), m_packets(packets) {} + virtual ~USBIsochronousInTransferResult() {} DOMDataView* data() const { return m_data; }
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.idl b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.idl index b18898c..6deb1fee7 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.idl +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousInTransferResult.idl
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://wicg.github.io/webusb/#idl-def-usbisochronousintransferresult +// https://wicg.github.io/webusb/#usbisochronousintransferresult [ OriginTrialEnabled=WebUSB, + Constructor(sequence<USBIsochronousInTransferPacket> packets, + optional DataView? data) ] interface USBIsochronousInTransferResult { - readonly attribute DataView data; + readonly attribute DataView? data; readonly attribute sequence<USBIsochronousInTransferPacket> packets; };
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.h b/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.h index b7992dd9..b397fea0 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.h +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.h
@@ -17,6 +17,10 @@ DEFINE_WRAPPERTYPEINFO(); public: + static USBIsochronousOutTransferPacket* create(const String& status) { + return new USBIsochronousOutTransferPacket(status, 0); + } + static USBIsochronousOutTransferPacket* create(const String& status, unsigned bytesWritten) { return new USBIsochronousOutTransferPacket(status, bytesWritten);
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.idl b/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.idl index fc35e9d..90e11269 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.idl +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferPacket.idl
@@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://wicg.github.io/webusb/#idl-def-usbisochronousouttransferpacket +// https://wicg.github.io/webusb/#usbisochronousouttransferpacket [ OriginTrialEnabled=WebUSB, + Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0) ] interface USBIsochronousOutTransferPacket { - readonly attribute USBTransferStatus status; readonly attribute unsigned long bytesWritten; + readonly attribute USBTransferStatus status; };
diff --git a/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferResult.idl b/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferResult.idl index 8021204..507af62 100644 --- a/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferResult.idl +++ b/third_party/WebKit/Source/modules/webusb/USBIsochronousOutTransferResult.idl
@@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://wicg.github.io/webusb/#idl-def-usbisochronousouttransferresult +// https://wicg.github.io/webusb/#usbisochronousouttransferresult [ OriginTrialEnabled=WebUSB, + Constructor(sequence<USBIsochronousOutTransferPacket> packets) ] interface USBIsochronousOutTransferResult { readonly attribute sequence<USBIsochronousOutTransferPacket> packets; };
diff --git a/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.h b/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.h index fe6dc6f5..7dcaa24 100644 --- a/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.h +++ b/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.h
@@ -17,6 +17,10 @@ DEFINE_WRAPPERTYPEINFO(); public: + static USBOutTransferResult* create(const String& status) { + return new USBOutTransferResult(status, 0); + } + static USBOutTransferResult* create(const String& status, unsigned bytesWritten) { return new USBOutTransferResult(status, bytesWritten);
diff --git a/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.idl b/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.idl index 58d441b..20d95a8 100644 --- a/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.idl +++ b/third_party/WebKit/Source/modules/webusb/USBOutTransferResult.idl
@@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://wicg.github.io/webusb/#transfers +// https://wicg.github.io/webusb/#usbouttransferresult [ OriginTrialEnabled=WebUSB, + Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0) ] interface USBOutTransferResult { readonly attribute unsigned long bytesWritten; readonly attribute USBTransferStatus status;
diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5 b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5 index edb57c4..564230b 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5 +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5
@@ -726,7 +726,7 @@ }, { name: "PresentationReceiver", - status: "test", + status: "experimental", }, { name: "PushMessaging",
diff --git a/third_party/WebKit/Source/web/InspectorOverlay.cpp b/third_party/WebKit/Source/web/InspectorOverlay.cpp index 4c14f47..721586a 100644 --- a/third_party/WebKit/Source/web/InspectorOverlay.cpp +++ b/third_party/WebKit/Source/web/InspectorOverlay.cpp
@@ -512,7 +512,7 @@ pageClients.chromeClient = m_overlayChromeClient.get(); m_overlayPage = Page::create(pageClients); - Settings& settings = m_frameImpl->frame()->host()->settings(); + Settings& settings = m_frameImpl->frame()->page()->settings(); Settings& overlaySettings = m_overlayPage->settings(); overlaySettings.genericFontFamilySettings().updateStandard(
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 27c87d26..ab7dbcf 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -1203,7 +1203,7 @@ ], 'gpu_fyi_tests_chromeos_ozone_release_trybot': [ - 'gpu_fyi_tests', 'release_trybot', 'chromeos', 'ozone', 'system_gbm_libdrm', + 'gpu_fyi_tests', 'release_trybot', 'chromeos', 'ozone_linux', 'system_gbm_libdrm', ], 'gpu_fyi_tests_chromeos_release_trybot': [ @@ -1859,7 +1859,7 @@ }, 'system_gbm_libdrm': { - 'gn_args': ('use_system_libdrm=true', 'use_system_minigbm=true'), + 'gn_args': 'use_system_libdrm=true use_system_minigbm=true', }, 'syzyasan': {
diff --git a/tools/perf/benchmarks/blink_perf.py b/tools/perf/benchmarks/blink_perf.py index ce33a8fa..743656c 100644 --- a/tools/perf/benchmarks/blink_perf.py +++ b/tools/perf/benchmarks/blink_perf.py
@@ -193,7 +193,6 @@ subdir = 'DOM' -@benchmark.Disabled('win') # http://crbug.com/588819 class BlinkPerfEvents(_BlinkPerfBenchmark): tag = 'events' subdir = 'Events'
diff --git a/ui/accessibility/ax_tree_fuzzer.cc b/ui/accessibility/ax_tree_fuzzer.cc index eed3444..de4b22d 100644 --- a/ui/accessibility/ax_tree_fuzzer.cc +++ b/ui/accessibility/ax_tree_fuzzer.cc
@@ -43,8 +43,8 @@ // Run with --v=1 to aid in debugging a specific crash. VLOG(1) << "Input accessibility tree:\n" << initial_state.ToString(); - ui::AXTree tree; EmptyAXTreeDelegate delegate; + ui::AXTree tree; tree.SetDelegate(&delegate); tree.Unserialize(initial_state);
diff --git a/ui/android/BUILD.gn b/ui/android/BUILD.gn index 243e57f..2374b2a4 100644 --- a/ui/android/BUILD.gn +++ b/ui/android/BUILD.gn
@@ -61,6 +61,7 @@ "//ui/display", "//ui/gfx", "//ui/gfx/geometry", + "//url", ] }
diff --git a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java index 9a9d89b..bf674594 100644 --- a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java +++ b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java
@@ -5,6 +5,7 @@ package org.chromium.ui.base; import android.content.ClipData; +import android.content.Intent; import android.graphics.Bitmap; import android.os.Build; import android.view.View; @@ -13,18 +14,26 @@ import android.widget.ImageView; import org.chromium.base.ApiCompatibilityUtils; +import org.chromium.base.Log; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; +import java.net.URISyntaxException; + /** * Class to acquire, position, and remove anchor views from the implementing View. */ @JNINamespace("ui") public abstract class ViewAndroidDelegate { + private static final String TAG = "ViewAndroidDelegate"; // TODO(hush): use View#DRAG_FLAG_GLOBAL when Chromium starts to build with API 24. private static final int DRAG_FLAG_GLOBAL = 1 << 8; + private static final String GEO_SCHEME = "geo"; + private static final String TEL_SCHEME = "tel"; + private static final String MAILTO_SCHEME = "mailto"; + /** * @return An anchor view that can be used to anchor decoration views like Autofill popup. */ @@ -105,6 +114,57 @@ } /** + * Called whenever the background color of the page changes as notified by Blink. + * @param color The new ARGB color of the page background. + */ + @CalledByNative + public void onBackgroundColorChanged(int color) {} + + /** + * Notify the client of the position of the top controls. + * @param topControlsOffsetY The Y offset of the top controls in physical pixels. + * @param topContentOffsetY The Y offset of the content in physical pixels. + */ + @CalledByNative + public void onTopControlsChanged(float topControlsOffsetY, float topContentOffsetY) {} + + /** + * Notify the client of the position of the bottom controls. + * @param bottomControlsOffsetY The Y offset of the bottom controls in physical pixels. + * @param bottomContentOffsetY The Y offset of the content in physical pixels. + */ + @CalledByNative + public void onBottomControlsChanged(float bottomControlsOffsetY, float bottomContentOffsetY) {} + + /** + * Called when a new content intent is requested to be started. + * Invokes {@link #startContentIntent(Intent, String, boolean)} only if the parsed + * intent is valid and the scheme is acceptable. + */ + @CalledByNative + private void onStartContentIntent(String intentUrl, boolean isMainFrame) { + Intent intent; + try { + intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME); + } catch (URISyntaxException e) { + Log.d(TAG, "Bad URI %s", intentUrl, e); + return; + } + String scheme = intent.getScheme(); + if (!(GEO_SCHEME.equals(scheme) || TEL_SCHEME.equals(scheme) + || MAILTO_SCHEME.equals(scheme))) { + Log.d(TAG, "Invalid scheme for URI %s", intentUrl); + return; + } + startContentIntent(intent, intentUrl, isMainFrame); + } + + /** + * Start a new content intent. + */ + public void startContentIntent(Intent intent, String intentUrl, boolean isMainFrame) {} + + /** * @return container view that the anchor views are added to. May be null. */ @CalledByNative
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc index 251c165..1d5b1466 100644 --- a/ui/android/view_android.cc +++ b/ui/android/view_android.cc
@@ -7,14 +7,17 @@ #include <algorithm> #include "base/android/jni_android.h" +#include "base/android/jni_string.h" #include "cc/layers/layer.h" #include "jni/ViewAndroidDelegate_jni.h" #include "ui/android/window_android.h" #include "ui/display/display.h" #include "ui/display/screen.h" +#include "url/gurl.h" namespace ui { +using base::android::ConvertUTF8ToJavaString; using base::android::JavaRef; using base::android::ScopedJavaLocalRef; @@ -184,4 +187,44 @@ jimage); } +void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { + ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); + if (delegate.is_null()) + return; + JNIEnv* env = base::android::AttachCurrentThread(); + Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); +} + +void ViewAndroid::OnTopControlsChanged(float top_controls_offset, + float top_content_offset) { + ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); + if (delegate.is_null()) + return; + JNIEnv* env = base::android::AttachCurrentThread(); + Java_ViewAndroidDelegate_onTopControlsChanged( + env, delegate, top_controls_offset, top_content_offset); +} + +void ViewAndroid::OnBottomControlsChanged(float bottom_controls_offset, + float bottom_content_offset) { + ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); + if (delegate.is_null()) + return; + JNIEnv* env = base::android::AttachCurrentThread(); + Java_ViewAndroidDelegate_onBottomControlsChanged( + env, delegate, bottom_controls_offset, bottom_content_offset); +} + +void ViewAndroid::StartContentIntent(const GURL& content_url, + bool is_main_frame) { + ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); + if (delegate.is_null()) + return; + JNIEnv* env = base::android::AttachCurrentThread(); + ScopedJavaLocalRef<jstring> jcontent_url = + ConvertUTF8ToJavaString(env, content_url.spec()); + Java_ViewAndroidDelegate_onStartContentIntent(env, delegate, jcontent_url, + is_main_frame); +} + } // namespace ui
diff --git a/ui/android/view_android.h b/ui/android/view_android.h index 68adf34..0abd77c 100644 --- a/ui/android/view_android.h +++ b/ui/android/view_android.h
@@ -12,6 +12,8 @@ #include "ui/android/ui_android_export.h" #include "ui/gfx/geometry/rect_f.h" +class GURL; + namespace cc { class Layer; } @@ -90,6 +92,13 @@ bool StartDragAndDrop(const base::android::JavaRef<jstring>& jtext, const base::android::JavaRef<jobject>& jimage); + void OnBackgroundColorChanged(unsigned int color); + void OnTopControlsChanged(float top_controls_offset, + float top_content_offset); + void OnBottomControlsChanged(float bottom_controls_offset, + float bottom_content_offset); + void StartContentIntent(const GURL& content_url, bool is_main_frame); + ScopedAnchorView AcquireAnchorView(); void SetAnchorRect(const base::android::JavaRef<jobject>& anchor, const gfx::RectF& bounds);
diff --git a/ui/aura/test/test_focus_client.cc b/ui/aura/test/test_focus_client.cc index 027afe6..b32122f 100644 --- a/ui/aura/test/test_focus_client.cc +++ b/ui/aura/test/test_focus_client.cc
@@ -36,7 +36,6 @@ if (window && !window->CanFocus()) return; - aura::Window* lost_focus = focused_window_; if (focused_window_) observer_manager_.Remove(focused_window_); aura::Window* old_focused_window = focused_window_; @@ -45,7 +44,7 @@ observer_manager_.Add(focused_window_); for (aura::client::FocusChangeObserver& observer : focus_observers_) - observer.OnWindowFocused(focused_window_, lost_focus); + observer.OnWindowFocused(focused_window_, old_focused_window); client::FocusChangeObserver* observer = client::GetFocusChangeObserver(old_focused_window); if (observer)
diff --git a/ui/file_manager/gallery/js/compiled_resources.gyp b/ui/file_manager/gallery/js/compiled_resources.gyp index d7b996fd..5a5c3fe 100644 --- a/ui/file_manager/gallery/js/compiled_resources.gyp +++ b/ui/file_manager/gallery/js/compiled_resources.gyp
@@ -136,6 +136,7 @@ './image_editor/filter.js', './image_editor/image_encoder.js', './image_editor/exif_encoder.js', + './gallery_constants.js', './dimmable_ui_controller.js', './entry_list_watcher.js', './error_banner.js',
diff --git a/ui/file_manager/gallery/js/compiled_resources2.gyp b/ui/file_manager/gallery/js/compiled_resources2.gyp index 1f7eb26..ec96d1b 100644 --- a/ui/file_manager/gallery/js/compiled_resources2.gyp +++ b/ui/file_manager/gallery/js/compiled_resources2.gyp
@@ -8,14 +8,25 @@ # 'target_name': 'background', # 'includes': ['../../compile_js2.gypi'], # }, -# { -# 'target_name': 'dimmable_ui_controller', -# 'includes': ['../../compile_js2.gypi'], -# }, -# { -# 'target_name': 'entry_list_watcher', -# 'includes': ['../../compile_js2.gypi'], -# }, + { + 'target_name': 'dimmable_ui_controller', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', + '<(EXTERNS_GYP):chrome_extensions', + 'gallery_constants', + ], + 'includes': ['../../compile_js2.gypi'], + }, + { + 'target_name': 'entry_list_watcher', + 'dependencies': [ + '../../externs/compiled_resources2.gyp:platform', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', + '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:array_data_model', + '<(EXTERNS_GYP):file_manager_private', + ], + 'includes': ['../../compile_js2.gypi'], + }, { 'target_name': 'error_banner', 'dependencies': [ @@ -27,6 +38,10 @@ # 'target_name': 'gallery', # 'includes': ['../../compile_js2.gypi'], # }, + { + 'target_name': 'gallery_constants', + 'includes': ['../../compile_js2.gypi'], + }, # { # 'target_name': 'gallery_data_model', # 'dependencies': [
diff --git a/ui/file_manager/gallery/js/dimmable_ui_controller.js b/ui/file_manager/gallery/js/dimmable_ui_controller.js index 3837374..6632d1d 100644 --- a/ui/file_manager/gallery/js/dimmable_ui_controller.js +++ b/ui/file_manager/gallery/js/dimmable_ui_controller.js
@@ -31,12 +31,12 @@ this.isCursorInTools_ = false; /** - * @private {Gallery.Mode|undefined} + * @private {GalleryMode|undefined} */ this.mode_ = undefined; /** - * @private {Gallery.SubMode|undefined} + * @private {GallerySubMode|undefined} */ this.subMode_ = undefined; @@ -98,8 +98,8 @@ /** * Returns true if this controller should be disabled. - * @param {Gallery.Mode|undefined} mode - * @param {Gallery.SubMode|undefined} subMode + * @param {GalleryMode|undefined} mode + * @param {GallerySubMode|undefined} subMode * @param {boolean} loading * @param {boolean} spokenFeedbackEnabled * @param {boolean} renaming @@ -107,19 +107,17 @@ */ DimmableUIController.shouldBeDisabled = function( mode, subMode, loading, spokenFeedbackEnabled, renaming) { - return spokenFeedbackEnabled || - mode === undefined || - subMode === undefined || - mode === Gallery.Mode.THUMBNAIL || - (mode === Gallery.Mode.SLIDE && subMode === Gallery.SubMode.EDIT) || - (mode === Gallery.Mode.SLIDE && subMode === Gallery.SubMode.BROWSE && + return spokenFeedbackEnabled || mode === undefined || subMode === undefined || + mode === GalleryMode.THUMBNAIL || + (mode === GalleryMode.SLIDE && subMode === GallerySubMode.EDIT) || + (mode === GalleryMode.SLIDE && subMode === GallerySubMode.BROWSE && (loading || renaming)); }; /** * Sets current mode of Gallery. - * @param {Gallery.Mode} mode - * @param {Gallery.SubMode} subMode + * @param {GalleryMode} mode + * @param {GallerySubMode} subMode */ DimmableUIController.prototype.setCurrentMode = function(mode, subMode) { if (this.mode_ === mode && this.subMode_ === subMode)
diff --git a/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.html b/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.html index 84009af3..64ba88a 100644 --- a/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.html +++ b/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.html
@@ -22,6 +22,7 @@ <script src="../../file_manager/common/js/async_util.js"></script> <script src="../../file_manager/foreground/js/volume_manager_wrapper.js"></script> <script src="gallery.js"></script> +<script src="gallery_constants.js"></script> <script src="dimmable_ui_controller.js"></script>
diff --git a/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.js b/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.js index c695f7a2..1040026 100644 --- a/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.js +++ b/ui/file_manager/gallery/js/dimmable_ui_controller_unittest.js
@@ -10,31 +10,31 @@ // Disabled in thumbnail mode. assertTrue(DimmableUIController.shouldBeDisabled( - Gallery.Mode.THUMBNAIL, Gallery.SubMode.BROWSE, false /* loading */, + GalleryMode.THUMBNAIL, GallerySubMode.BROWSE, false /* loading */, false /* spokenFeedbackEnabled */, false /* renaming */)); // Disabled in edit mode. assertTrue(DimmableUIController.shouldBeDisabled( - Gallery.Mode.SLIDE, Gallery.SubMode.EDIT, false /* loading*/, + GalleryMode.SLIDE, GallerySubMode.EDIT, false /* loading*/, false /* spokenFeedbackEnabled */, false /* renaming */)); // Shouldn't be disabled while browsing in slide mode. assertFalse(DimmableUIController.shouldBeDisabled( - Gallery.Mode.SLIDE, Gallery.SubMode.BROWSE, false /* loading */, + GalleryMode.SLIDE, GallerySubMode.BROWSE, false /* loading */, false /* spokenFeedbackEnabled */, false /* renaming */)); // Disabled while loading an image in slide mode. assertTrue(DimmableUIController.shouldBeDisabled( - Gallery.Mode.SLIDE, Gallery.SubMode.BROWSE, true /* loading */, + GalleryMode.SLIDE, GallerySubMode.BROWSE, true /* loading */, false /* spokenFeedbackEnabled */, false /* renaming */)); // Disabled when spoken feedback is enabled. assertTrue(DimmableUIController.shouldBeDisabled( - Gallery.Mode.SLIDE, Gallery.SubMode.BROWSE, false /* loading */, + GalleryMode.SLIDE, GallerySubMode.BROWSE, false /* loading */, true /* spokenFeedbackEnabled */, false /* renaming */)); // Disabled when user is renaming an image. assertTrue(DimmableUIController.shouldBeDisabled( - Gallery.Mode.SLIDE, Gallery.SubMode.BROWSE, false /* loading */, + GalleryMode.SLIDE, GallerySubMode.BROWSE, false /* loading */, false /* spokenFeedbackEnabled */, true /* renaming */)) }
diff --git a/ui/file_manager/gallery/js/gallery.js b/ui/file_manager/gallery/js/gallery.js index 71aaac3f..cd07d9a3 100644 --- a/ui/file_manager/gallery/js/gallery.js +++ b/ui/file_manager/gallery/js/gallery.js
@@ -229,38 +229,18 @@ /** * First time tools fade-out timeout in milliseconds. - * @const - * @type {number} + * @const {number} + * @private */ -Gallery.FIRST_FADE_TIMEOUT = 1000; +Gallery.FIRST_FADE_TIMEOUT_ = 1000; /** * Time until mosaic is initialized in the background. Used to make gallery * in the slide mode load faster. In milliseconds. - * @const - * @type {number} + * @const {number} + * @private */ -Gallery.MOSAIC_BACKGROUND_INIT_DELAY = 1000; - -/** - * Modes in Gallery. - * @enum {string} - */ -Gallery.Mode = { - SLIDE: 'slide', - THUMBNAIL: 'thumbnail' -}; - -/** - * Sub modes in Gallery. - * @enum {string} - * TODO(yawano): Remove sub modes by extracting them as modes. - */ -Gallery.SubMode = { - BROWSE: 'browse', - EDIT: 'edit', - SLIDESHOW: 'slideshow' -}; +Gallery.MOSAIC_BACKGROUND_INIT_DELAY_ = 1000; /** * Updates attributes of container element when accessibility configuration has @@ -416,7 +396,7 @@ null, function() { // Flash the toolbar briefly to show it is there. - self.dimmableUIController_.kick(Gallery.FIRST_FADE_TIMEOUT); + self.dimmableUIController_.kick(Gallery.FIRST_FADE_TIMEOUT_); }, function() {}); } @@ -446,14 +426,14 @@ /** * Returns the current mode. - * @return {Gallery.Mode} + * @return {GalleryMode} */ Gallery.prototype.getCurrentMode = function() { switch (/** @type {(SlideMode|ThumbnailMode)} */ (this.currentMode_)) { case this.slideMode_: - return Gallery.Mode.SLIDE; + return GalleryMode.SLIDE; case this.thumbnailMode_: - return Gallery.Mode.THUMBNAIL; + return GalleryMode.THUMBNAIL; default: assertNotReached(); } @@ -462,7 +442,7 @@ /** * Returns sub mode of current mode. If current mode is not set yet, null is * returned. - * @return {Gallery.SubMode} + * @return {GallerySubMode} */ Gallery.prototype.getCurrentSubMode = function() { assert(this.currentMode_); @@ -935,14 +915,16 @@ /** * Minimum width of rename field. * @const {number} + * @private */ -Gallery.MIN_WIDTH_RENAME_FIELD = 160; // px +Gallery.MIN_WIDTH_RENAME_FIELD_ = 160; // px /** * End padding for rename field. * @const {number} + * @private */ -Gallery.END_PADDING_RENAME_FIELD = 20; // px +Gallery.END_PADDING_RENAME_FIELD_ = 20; // px /** * Resize rename field depending on its content. @@ -951,9 +933,11 @@ Gallery.prototype.resizeRenameField_ = function() { var size = this.filenameCanvasContext_.measureText(this.filenameEdit_.value); - var width = Math.min(Math.max( - size.width + Gallery.END_PADDING_RENAME_FIELD, - Gallery.MIN_WIDTH_RENAME_FIELD), window.innerWidth / 2); + var width = Math.min( + Math.max( + size.width + Gallery.END_PADDING_RENAME_FIELD_, + Gallery.MIN_WIDTH_RENAME_FIELD_), + window.innerWidth / 2); this.filenameEdit_.style.width = width + 'px'; };
diff --git a/ui/file_manager/gallery/js/gallery_constants.js b/ui/file_manager/gallery/js/gallery_constants.js new file mode 100644 index 0000000..a57813f --- /dev/null +++ b/ui/file_manager/gallery/js/gallery_constants.js
@@ -0,0 +1,16 @@ +// 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. + +/** + * Modes in Gallery. + * @enum {string} + */ +var GalleryMode = {SLIDE: 'slide', THUMBNAIL: 'thumbnail'}; + +/** + * Sub modes in Gallery. + * @enum {string} + * TODO(yawano): Remove sub modes by extracting them as modes. + */ +var GallerySubMode = {BROWSE: 'browse', EDIT: 'edit', SLIDESHOW: 'slideshow'};
diff --git a/ui/file_manager/gallery/js/gallery_scripts.js b/ui/file_manager/gallery/js/gallery_scripts.js index 98fa45b..d168069 100644 --- a/ui/file_manager/gallery/js/gallery_scripts.js +++ b/ui/file_manager/gallery/js/gallery_scripts.js
@@ -79,6 +79,7 @@ // <include src="dimmable_ui_controller.js"> // <include src="entry_list_watcher.js"> // <include src="error_banner.js"> +// <include src="gallery_constants.js"> // <include src="gallery_data_model.js"> // <include src="gallery_item.js"> // <include src="gallery_util.js">
diff --git a/ui/file_manager/gallery/js/image_editor/compiled_resources2.gyp b/ui/file_manager/gallery/js/image_editor/compiled_resources2.gyp index d681fa1..8e8d8ab 100644 --- a/ui/file_manager/gallery/js/image_editor/compiled_resources2.gyp +++ b/ui/file_manager/gallery/js/image_editor/compiled_resources2.gyp
@@ -7,6 +7,9 @@ # { # 'target_name': 'commands', # 'dependencies': [ +# 'filter', +# 'image_view', +# 'viewport', # 'image_util', # '../../../file_manager/foreground/elements/compiled_resources2.gyp:files_toast', # 'image_editor', @@ -83,6 +86,12 @@ }, # { # 'target_name': 'image_transform', +# 'dependencies': [ +# 'commands', +# 'viewport', +# 'image_buffer', +# 'image_util', +# ], # 'includes': ['../../../compile_js2.gypi'], # }, { @@ -106,10 +115,10 @@ ], 'includes': ['../../../compile_js2.gypi'], }, -# { -# 'target_name': 'test_util', -# 'includes': ['../../../compile_js2.gypi'], -# }, + { + 'target_name': 'test_util', + 'includes': ['../../../compile_js2.gypi'], + }, { 'target_name': 'viewport', 'dependencies': [
diff --git a/ui/file_manager/gallery/js/image_editor/test_util.js b/ui/file_manager/gallery/js/image_editor/test_util.js index 8158e00..1cf706c3 100644 --- a/ui/file_manager/gallery/js/image_editor/test_util.js +++ b/ui/file_manager/gallery/js/image_editor/test_util.js
@@ -8,7 +8,8 @@ * @return {HTMLCanvasElement} */ function getSampleCanvas() { - var canvas = document.createElement('canvas'); + var canvas = + /** @type {HTMLCanvasElement} */ (document.createElement('canvas')); canvas.width = 1920; canvas.height = 1080;
diff --git a/ui/file_manager/gallery/js/slide_mode.js b/ui/file_manager/gallery/js/slide_mode.js index 75df0b37..ef11a6a 100644 --- a/ui/file_manager/gallery/js/slide_mode.js +++ b/ui/file_manager/gallery/js/slide_mode.js
@@ -187,9 +187,9 @@ this.active_ = false; /** - * @private {Gallery.SubMode} + * @private {GallerySubMode} */ - this.subMode_ = Gallery.SubMode.BROWSE; + this.subMode_ = GallerySubMode.BROWSE; /** * @type {boolean} @@ -1466,7 +1466,7 @@ this.resumeSlideshow_(opt_interval); - this.setSubMode_(Gallery.SubMode.SLIDESHOW); + this.setSubMode_(GallerySubMode.SLIDESHOW); }; /** @@ -1499,7 +1499,7 @@ // Re-enable touch operation. this.touchHandlers_.enabled = true; - this.setSubMode_(Gallery.SubMode.BROWSE); + this.setSubMode_(GallerySubMode.BROWSE); }; /** @@ -1579,7 +1579,7 @@ /** * Sets current sub mode. - * @param {Gallery.SubMode} subMode + * @param {GallerySubMode} subMode * @private */ SlideMode.prototype.setSubMode_ = function(subMode) { @@ -1595,7 +1595,7 @@ /** * Returns current sub mode. - * @return {Gallery.SubMode} + * @return {GallerySubMode} */ SlideMode.prototype.getSubMode = function() { return this.subMode_; @@ -1652,7 +1652,7 @@ this.bubble_.hidden = false; }.bind(this)); - this.setSubMode_(Gallery.SubMode.EDIT); + this.setSubMode_(GallerySubMode.EDIT); this.editor_.onStartEditing(); } else { this.editor_.getPrompt().hide(); @@ -1666,7 +1666,7 @@ this.touchHandlers_.enabled = true; - this.setSubMode_(Gallery.SubMode.BROWSE); + this.setSubMode_(GallerySubMode.BROWSE); } };
diff --git a/ui/file_manager/gallery/js/thumbnail_mode.js b/ui/file_manager/gallery/js/thumbnail_mode.js index 6b0b208..a2a2d3c 100644 --- a/ui/file_manager/gallery/js/thumbnail_mode.js +++ b/ui/file_manager/gallery/js/thumbnail_mode.js
@@ -60,10 +60,10 @@ /** * Returns current sub mode. - * @return {Gallery.SubMode} + * @return {GallerySubMode} */ ThumbnailMode.prototype.getSubMode = function() { - return Gallery.SubMode.BROWSE; + return GallerySubMode.BROWSE; }; /**