diff --git a/DEPS b/DEPS index 50c35b1..956ce76 100644 --- a/DEPS +++ b/DEPS
@@ -78,7 +78,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '16c81a1ee9e2b90b97d73a1f08b03bebfadfbc81', + 'skia_revision': '0dec3af001ac443447f1f90c522f74feb0be850a', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -327,7 +327,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '72572b8c8d21b9e36fc1839f0ed239f0bce249c1', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'de8ce79f79ef9a20cfe4835d44269881f0bf51b7', # DevTools node modules. Used on Linux buildbots only. 'src/third_party/devtools-node-modules': {
diff --git a/ash/wallpaper/wallpaper_controller.cc b/ash/wallpaper/wallpaper_controller.cc index 5879694..3894d5f 100644 --- a/ash/wallpaper/wallpaper_controller.cc +++ b/ash/wallpaper/wallpaper_controller.cc
@@ -26,6 +26,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/memory/ref_counted_memory.h" #include "base/path_service.h" #include "base/sequenced_task_runner.h" #include "base/strings/string_number_conversions.h" @@ -38,6 +39,7 @@ #include "components/user_manager/user_image/user_image.h" #include "components/wallpaper/wallpaper_color_calculator.h" #include "components/wallpaper/wallpaper_color_profile.h" +#include "components/wallpaper/wallpaper_files_id.h" #include "components/wallpaper/wallpaper_resizer.h" #include "ui/display/manager/display_manager.h" #include "ui/display/manager/managed_display_info.h" @@ -45,6 +47,7 @@ #include "ui/gfx/codec/jpeg_codec.h" #include "ui/gfx/color_analysis.h" #include "ui/gfx/image/image_skia.h" +#include "ui/gfx/image/image_skia_operations.h" #include "ui/views/widget/widget.h" using color_utils::ColorProfile; @@ -74,6 +77,9 @@ // How long to wait for resizing of the the wallpaper. constexpr int kCompositorLockTimeoutMs = 750; +// Default quality for encoding wallpaper. +const int kDefaultEncodingQuality = 90; + // Caches color calculation results in local state pref service. void CacheProminentColors(const std::vector<SkColor>& colors, const std::string& current_location) { @@ -180,6 +186,102 @@ } } +// Saves wallpaper image raw |data| to |path| (absolute path) in file system. +// Returns true on success. +bool SaveWallpaperInternal(const base::FilePath& path, + const char* data, + int size) { + int written_bytes = base::WriteFile(path, data, size); + return written_bytes == size; +} + +// Creates all new custom wallpaper directories for |wallpaper_files_id| if they +// don't exist. +void EnsureCustomWallpaperDirectories(const std::string& wallpaper_files_id) { + base::FilePath dir = WallpaperController::GetCustomWallpaperDir( + ash::WallpaperController::kSmallWallpaperSubDir) + .Append(wallpaper_files_id); + if (!base::PathExists(dir)) + base::CreateDirectory(dir); + + dir = WallpaperController::GetCustomWallpaperDir( + ash::WallpaperController::kLargeWallpaperSubDir) + .Append(wallpaper_files_id); + + if (!base::PathExists(dir)) + base::CreateDirectory(dir); + + dir = WallpaperController::GetCustomWallpaperDir( + ash::WallpaperController::kOriginalWallpaperSubDir) + .Append(wallpaper_files_id); + if (!base::PathExists(dir)) + base::CreateDirectory(dir); + + dir = WallpaperController::GetCustomWallpaperDir( + ash::WallpaperController::kThumbnailWallpaperSubDir) + .Append(wallpaper_files_id); + if (!base::PathExists(dir)) + base::CreateDirectory(dir); +} + +// Saves original custom wallpaper to |path| (absolute path) on filesystem +// and starts resizing operation of the custom wallpaper if necessary. +void SaveCustomWallpaper(const std::string& wallpaper_files_id, + const base::FilePath& original_path, + wallpaper::WallpaperLayout layout, + std::unique_ptr<gfx::ImageSkia> image) { + base::DeleteFile(WallpaperController::GetCustomWallpaperDir( + WallpaperController::kOriginalWallpaperSubDir) + .Append(wallpaper_files_id), + true /* recursive */); + base::DeleteFile(WallpaperController::GetCustomWallpaperDir( + WallpaperController::kSmallWallpaperSubDir) + .Append(wallpaper_files_id), + true /* recursive */); + base::DeleteFile(WallpaperController::GetCustomWallpaperDir( + WallpaperController::kLargeWallpaperSubDir) + .Append(wallpaper_files_id), + true /* recursive */); + EnsureCustomWallpaperDirectories(wallpaper_files_id); + const std::string file_name = original_path.BaseName().value(); + const base::FilePath small_wallpaper_path = + WallpaperController::GetCustomWallpaperPath( + WallpaperController::kSmallWallpaperSubDir, wallpaper_files_id, + file_name); + const base::FilePath large_wallpaper_path = + WallpaperController::GetCustomWallpaperPath( + WallpaperController::kLargeWallpaperSubDir, wallpaper_files_id, + file_name); + + // Re-encode orginal file to jpeg format and saves the result in case that + // resized wallpaper is not generated (i.e. chrome shutdown before resized + // wallpaper is saved). + WallpaperController::ResizeAndSaveWallpaper( + *image, original_path, wallpaper::WALLPAPER_LAYOUT_STRETCH, + image->width(), image->height(), nullptr); + WallpaperController::ResizeAndSaveWallpaper( + *image, small_wallpaper_path, layout, + WallpaperController::kSmallWallpaperMaxWidth, + WallpaperController::kSmallWallpaperMaxHeight, nullptr); + WallpaperController::ResizeAndSaveWallpaper( + *image, large_wallpaper_path, layout, + WallpaperController::kLargeWallpaperMaxWidth, + WallpaperController::kLargeWallpaperMaxHeight, nullptr); +} + +// Checks if kiosk app is running. Note: it returns false either when there's +// no active user (e.g. at login screen), or the active user is not kiosk. +bool IsInKioskMode() { + base::Optional<user_manager::UserType> active_user_type = + Shell::Get()->session_controller()->GetUserType(); + // |active_user_type| is empty when there's no active user. + if (active_user_type && + *active_user_type == user_manager::USER_TYPE_KIOSK_APP) { + return true; + } + return false; +} + } // namespace const SkColor WallpaperController::kInvalidColor = SK_ColorTRANSPARENT; @@ -285,6 +387,98 @@ } // static +base::FilePath WallpaperController::GetCustomWallpaperPath( + const std::string& sub_dir, + const std::string& wallpaper_files_id, + const std::string& file_name) { + base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir); + return custom_wallpaper_path.Append(wallpaper_files_id).Append(file_name); +} + +// static +base::FilePath WallpaperController::GetCustomWallpaperDir( + const std::string& sub_dir) { + DCHECK(!dir_chrome_os_custom_wallpapers_path_.empty()); + return dir_chrome_os_custom_wallpapers_path_.Append(sub_dir); +} + +// static +bool WallpaperController::ResizeImage( + const gfx::ImageSkia& image, + wallpaper::WallpaperLayout layout, + int preferred_width, + int preferred_height, + scoped_refptr<base::RefCountedBytes>* output, + gfx::ImageSkia* output_skia) { + int width = image.width(); + int height = image.height(); + int resized_width; + int resized_height; + *output = new base::RefCountedBytes(); + + if (layout == wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED) { + // Do not resize custom wallpaper if it is smaller than preferred size. + if (!(width > preferred_width && height > preferred_height)) + return false; + + double horizontal_ratio = static_cast<double>(preferred_width) / width; + double vertical_ratio = static_cast<double>(preferred_height) / height; + if (vertical_ratio > horizontal_ratio) { + resized_width = + gfx::ToRoundedInt(static_cast<double>(width) * vertical_ratio); + resized_height = preferred_height; + } else { + resized_width = preferred_width; + resized_height = + gfx::ToRoundedInt(static_cast<double>(height) * horizontal_ratio); + } + } else if (layout == wallpaper::WALLPAPER_LAYOUT_STRETCH) { + resized_width = preferred_width; + resized_height = preferred_height; + } else { + resized_width = width; + resized_height = height; + } + + gfx::ImageSkia resized_image = gfx::ImageSkiaOperations::CreateResizedImage( + image, skia::ImageOperations::RESIZE_LANCZOS3, + gfx::Size(resized_width, resized_height)); + + SkBitmap bitmap = *(resized_image.bitmap()); + gfx::JPEGCodec::Encode(bitmap, kDefaultEncodingQuality, &(*output)->data()); + + if (output_skia) { + resized_image.MakeThreadSafe(); + *output_skia = resized_image; + } + + return true; +} + +// static +bool WallpaperController::ResizeAndSaveWallpaper( + const gfx::ImageSkia& image, + const base::FilePath& path, + wallpaper::WallpaperLayout layout, + int preferred_width, + int preferred_height, + gfx::ImageSkia* output_skia) { + if (layout == wallpaper::WALLPAPER_LAYOUT_CENTER) { + // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. + if (base::PathExists(path)) + base::DeleteFile(path, false); + return false; + } + scoped_refptr<base::RefCountedBytes> data; + if (ResizeImage(image, layout, preferred_width, preferred_height, &data, + output_skia)) { + return SaveWallpaperInternal( + path, reinterpret_cast<const char*>(data->front()), data->size()); + } + return false; +} + +// static void WallpaperController::DecodeWallpaperIfApplicable( LoadedCallback callback, std::unique_ptr<std::string> data, @@ -411,13 +605,8 @@ bool show_wallpaper, MovableOnDestroyCallbackHolder on_finish) { // There is no visible wallpaper in kiosk mode. - base::Optional<user_manager::UserType> active_user_type = - Shell::Get()->session_controller()->GetUserType(); - // |active_user_type| is empty when there's no active user. - if (active_user_type && - *active_user_type == user_manager::USER_TYPE_KIOSK_APP) { + if (IsInKioskMode()) return; - } wallpaper_cache_map_.erase(account_id); @@ -428,6 +617,8 @@ : wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::FilePath file_path; + base::Optional<user_manager::UserType> active_user_type = + Shell::Get()->session_controller()->GetUserType(); // The wallpaper is determined in the following order: // Guest wallpaper, child wallpaper, customized default wallpaper, and regular @@ -554,10 +745,24 @@ InstallDesktopControllerForAllWindows(); } -base::FilePath WallpaperController::GetCustomWallpaperDir( - const std::string& sub_dir) { - DCHECK(!dir_chrome_os_custom_wallpapers_path_.empty()); - return dir_chrome_os_custom_wallpapers_path_.Append(sub_dir); +bool WallpaperController::IsPolicyControlled(const AccountId& account_id, + bool is_persistent) const { + WallpaperInfo info; + if (!GetUserWallpaperInfo(account_id, &info, is_persistent)) + return false; + return info.type == wallpaper::POLICY; +} + +bool WallpaperController::CanSetUserWallpaper(const AccountId& account_id, + bool is_persistent) const { + // There is no visible wallpaper in kiosk mode. + if (IsInKioskMode()) + return false; + // Don't allow user wallpapers while policy is in effect. + if (IsPolicyControlled(account_id, is_persistent)) { + return false; + } + return true; } void WallpaperController::PrepareWallpaperForLockScreenChange(bool locking) { @@ -707,7 +912,7 @@ bool WallpaperController::GetUserWallpaperInfo(const AccountId& account_id, WallpaperInfo* info, - bool is_persistent) { + bool is_persistent) const { if (!is_persistent) { // Default to the values cached in memory. *info = current_user_wallpaper_info_; @@ -761,6 +966,29 @@ SetUserWallpaperInfo(account_id, info, is_persistent); } +void WallpaperController::SetArcWallpaper( + const AccountId& account_id, + const user_manager::UserType user_type, + const std::string& wallpaper_files_id, + const std::string& file_name, + const gfx::ImageSkia& image, + wallpaper::WallpaperLayout layout, + bool is_ephemeral, + bool show_wallpaper) { + if (!CanSetUserWallpaper(account_id, !is_ephemeral)) + return; + + ash::mojom::WallpaperUserInfoPtr user_info = + ash::mojom::WallpaperUserInfo::New(); + user_info->account_id = account_id; + user_info->type = user_type; + user_info->is_ephemeral = is_ephemeral; + // |has_gaia_account| is unused. + user_info->has_gaia_account = true; + SaveAndSetWallpaper(std::move(user_info), wallpaper_files_id, file_name, + image, wallpaper::CUSTOMIZED, layout, show_wallpaper); +} + bool WallpaperController::GetWallpaperFromCache(const AccountId& account_id, gfx::ImageSkia* image) { CustomWallpaperMap::const_iterator it = wallpaper_cache_map_.find(account_id); @@ -808,7 +1036,18 @@ wallpaper::WallpaperType type, const SkBitmap& image, bool show_wallpaper) { - NOTIMPLEMENTED(); + // TODO(crbug.com/776464): Currently |SetCustomWallpaper| is used by both + // CUSTOMIZED and POLICY types, but it's better to separate them: a new + // |SetPolicyWallpaper| will be created so that the type parameter can be + // removed, and only a single |CanSetUserWallpaper| check is needed here. + if ((type != wallpaper::POLICY && + IsPolicyControlled(user_info->account_id, !user_info->is_ephemeral)) || + IsInKioskMode()) + return; + + SaveAndSetWallpaper(std::move(user_info), wallpaper_files_id, file_name, + gfx::ImageSkia::CreateFrom1xBitmap(image), type, layout, + show_wallpaper); } void WallpaperController::SetOnlineWallpaper( @@ -819,14 +1058,8 @@ bool show_wallpaper) { DCHECK(Shell::Get()->session_controller()->IsActiveUserSessionStarted()); - // There is no visible wallpaper in kiosk mode. - base::Optional<user_manager::UserType> active_user_type = - Shell::Get()->session_controller()->GetUserType(); - // |active_user_type| is empty when there's no active user. - if (!active_user_type || - *active_user_type == user_manager::USER_TYPE_KIOSK_APP) { + if (!CanSetUserWallpaper(user_info->account_id, !user_info->is_ephemeral)) return; - } WallpaperInfo info = {url, layout, wallpaper::ONLINE, base::Time::Now().LocalMidnight()}; @@ -848,6 +1081,9 @@ mojom::WallpaperUserInfoPtr user_info, const std::string& wallpaper_files_id, bool show_wallpaper) { + if (!CanSetUserWallpaper(user_info->account_id, !user_info->is_ephemeral)) + return; + const AccountId account_id = user_info->account_id; const bool is_persistent = !user_info->is_ephemeral; const user_manager::UserType type = user_info->type; @@ -939,6 +1175,14 @@ SetProminentColors(colors); } +void WallpaperController::InitializePathsForTesting() { + dir_user_data_path_ = base::FilePath(FILE_PATH_LITERAL("user_data")); + dir_chrome_os_wallpapers_path_ = + base::FilePath(FILE_PATH_LITERAL("chrome_os_wallpapers")); + dir_chrome_os_custom_wallpapers_path_ = + base::FilePath(FILE_PATH_LITERAL("chrome_os_custom_wallpapers")); +} + void WallpaperController::ShowDefaultWallpaperForTesting() { default_wallpaper_image_.reset( new user_manager::UserImage(CreateSolidColorWallpaper())); @@ -1126,6 +1370,60 @@ } } +void WallpaperController::SaveAndSetWallpaper( + mojom::WallpaperUserInfoPtr user_info, + const std::string& wallpaper_files_id, + const std::string& file_name, + const gfx::ImageSkia& image, + wallpaper::WallpaperType type, + wallpaper::WallpaperLayout layout, + bool show_wallpaper) { + // Empty image indicates decode failure. Use default wallpaper in this case. + if (image.isNull()) { + SetDefaultWallpaperImpl(user_info->account_id, user_info->type, + show_wallpaper, MovableOnDestroyCallbackHolder()); + return; + } + + base::FilePath wallpaper_path = + GetCustomWallpaperPath(WallpaperController::kOriginalWallpaperSubDir, + wallpaper_files_id, file_name); + + const bool should_save_to_disk = + !user_info->is_ephemeral || + (type == wallpaper::POLICY && + user_info->type == user_manager::USER_TYPE_PUBLIC_ACCOUNT); + + if (should_save_to_disk) { + image.EnsureRepsForSupportedScales(); + std::unique_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); + // Block shutdown on this task. Otherwise, we may lose the custom wallpaper + // that the user selected. + scoped_refptr<base::SequencedTaskRunner> blocking_task_runner = + base::CreateSequencedTaskRunnerWithTraits( + {base::MayBlock(), base::TaskPriority::USER_BLOCKING, + base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); + // TODO(bshe): This may break if RawImage becomes RefCountedMemory. + blocking_task_runner->PostTask( + FROM_HERE, + base::BindOnce(&SaveCustomWallpaper, wallpaper_files_id, wallpaper_path, + layout, base::Passed(std::move(deep_copy)))); + } + + const std::string relative_path = + base::FilePath(wallpaper_files_id).Append(file_name).value(); + // User's custom wallpaper path is determined by relative path and the + // appropriate wallpaper resolution in GetCustomWallpaperInternal. + WallpaperInfo info = {relative_path, layout, type, + base::Time::Now().LocalMidnight()}; + SetUserWallpaperInfo(user_info->account_id, info, !user_info->is_ephemeral); + if (show_wallpaper) + SetWallpaperImage(image, info); + + wallpaper_cache_map_[user_info->account_id] = + CustomWallpaperElement(wallpaper_path, image); +} + void WallpaperController::SetProminentColors( const std::vector<SkColor>& colors) { if (prominent_colors_ == colors)
diff --git a/ash/wallpaper/wallpaper_controller.h b/ash/wallpaper/wallpaper_controller.h index 795833c..dbd31db 100644 --- a/ash/wallpaper/wallpaper_controller.h +++ b/ash/wallpaper/wallpaper_controller.h
@@ -28,6 +28,7 @@ class PrefRegistrySimple; namespace base { +class RefCountedBytes; class SequencedTaskRunner; } // namespace base @@ -85,8 +86,8 @@ static const SkColor kInvalidColor; // The paths of wallpaper directories. - // TODO(crbug.com/776464): Make these private and remove the static qualifier - // after |WallpaperManager::LoadWallpaper| and + // TODO(crbug.com/776464): Move these to anonymous namespace after + // |WallpaperManager::LoadWallpaper| and // |WallpaperManager::GetDeviceWallpaperDir| are migrated. static base::FilePath dir_user_data_path_; static base::FilePath dir_chrome_os_wallpapers_path_; @@ -146,6 +147,37 @@ // Returns the appropriate wallpaper resolution for all root windows. static WallpaperResolution GetAppropriateResolution(); + // Returns custom wallpaper path. Appends |sub_dir|, |wallpaper_files_id| and + // |file_name| to custom wallpaper directory. + static base::FilePath GetCustomWallpaperPath( + const std::string& sub_dir, + const std::string& wallpaper_files_id, + const std::string& file_name); + + // Returns custom wallpaper directory by appending corresponding |sub_dir|. + static base::FilePath GetCustomWallpaperDir(const std::string& sub_dir); + + // Resizes |image| to a resolution which is nearest to |preferred_width| and + // |preferred_height| while respecting the |layout| choice. |output_skia| is + // optional (may be null). Returns true on success. + static bool ResizeImage(const gfx::ImageSkia& image, + wallpaper::WallpaperLayout layout, + int preferred_width, + int preferred_height, + scoped_refptr<base::RefCountedBytes>* output, + gfx::ImageSkia* output_skia); + + // Resizes |image| to a resolution which is nearest to |preferred_width| and + // |preferred_height| while respecting the |layout| choice and saves the + // resized wallpaper to |path|. |output_skia| is optional (may be + // null). Returns true on success. + static bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image, + const base::FilePath& path, + wallpaper::WallpaperLayout layout, + int preferred_width, + int preferred_height, + gfx::ImageSkia* output_skia); + // TODO(crbug.com/776464): Move |DecodeWallpaperIfApplicable| and // |ReadAndDecodeWallpaper| to a separate utility file. // If |data_is_ready| is true, start decoding the image, which will run @@ -235,8 +267,15 @@ // crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe. void CreateEmptyWallpaper(); - // Returns custom wallpaper directory by appending corresponding |sub_dir|. - base::FilePath GetCustomWallpaperDir(const std::string& sub_dir); + // Returns whether a wallpaper policy is enforced for |account_id| (not + // including device policy). + bool IsPolicyControlled(const AccountId& account_id, + bool is_persistent) const; + + // When kiosk app is running or policy is enforced, setting a user wallpaper + // is not allowed. + bool CanSetUserWallpaper(const AccountId& account_id, + bool is_persistent) const; // Prepares wallpaper to lock screen transition. Will apply blur if // |locking| is true and remove it otherwise. @@ -289,13 +328,27 @@ // |is_persistent| is false. Returns false if wallpaper info is not found. bool GetUserWallpaperInfo(const AccountId& account_id, wallpaper::WallpaperInfo* info, - bool is_persistent); + bool is_persistent) const; // Initializes wallpaper info for the user to default and saves it to local // state if |is_persistent| is true. void InitializeUserWallpaperInfo(const AccountId& account_id, bool is_persistent); + // TODO(crbug.com/776464): This method is a temporary workaround during the + // refactoring. It should be combined with |SetCustomWallpaper|. + // The same with |SetCustomWallpaper|, except that |image| wasn't once + // converted to |SkBitmap|, so that the image id is preserved. + // ArcWallpaperService needs this to track the wallpaper change. + void SetArcWallpaper(const AccountId& account_id, + const user_manager::UserType user_type, + const std::string& wallpaper_files_id, + const std::string& file_name, + const gfx::ImageSkia& image, + wallpaper::WallpaperLayout layout, + bool is_ephemeral, + bool show_wallpaper); + // Gets encoded wallpaper from cache. Returns true if success. bool GetWallpaperFromCache(const AccountId& account_id, gfx::ImageSkia* image); @@ -356,6 +409,9 @@ // WallpaperColorCalculatorObserver: void OnColorCalculationComplete() override; + // Sets dummy values for wallpaper directories. + void InitializePathsForTesting(); + // Shows a solid color wallpaper as the substitute for default wallpapers and // updates |default_wallpaper_image_|. void ShowDefaultWallpaperForTesting(); @@ -406,6 +462,18 @@ MovableOnDestroyCallbackHolder on_finish, std::unique_ptr<user_manager::UserImage> user_image); + // Saves |image| to disk if |user_info->is_ephemeral| is false, or if it is a + // policy wallpaper for public accounts. Shows the wallpaper immediately if + // |show_wallpaper| is true, otherwise only sets the wallpaper info and + // updates the cache. + void SaveAndSetWallpaper(mojom::WallpaperUserInfoPtr user_info, + const std::string& wallpaper_files_id, + const std::string& file_name, + const gfx::ImageSkia& image, + wallpaper::WallpaperType type, + wallpaper::WallpaperLayout layout, + bool show_wallpaper); + // Sets |prominent_colors_| and notifies the observers if there is a change. void SetProminentColors(const std::vector<SkColor>& prominent_colors);
diff --git a/ash/wallpaper/wallpaper_controller_unittest.cc b/ash/wallpaper/wallpaper_controller_unittest.cc index 4e2aad7..ad5a9e5d 100644 --- a/ash/wallpaper/wallpaper_controller_unittest.cc +++ b/ash/wallpaper/wallpaper_controller_unittest.cc
@@ -180,6 +180,7 @@ wallpaper_delegate_ = static_cast<TestWallpaperDelegate*>(Shell::Get()->wallpaper_delegate()); controller_->set_wallpaper_reload_delay_for_test(0); + controller_->InitializePathsForTesting(); } WallpaperView* wallpaper_view() { @@ -270,9 +271,8 @@ } // Helper function to create a new |mojom::WallpaperUserInfoPtr| instance with - // default values. In addition, remove the previous wallpaper info (if any) - // and clear the wallpaper count. May be called multiple times for the - // same |account_id|. + // default values. In addition, clear the wallpaper count. May be called + // multiple times for the same |account_id|. mojom::WallpaperUserInfoPtr InitializeUser(const AccountId& account_id) { mojom::WallpaperUserInfoPtr wallpaper_user_info = mojom::WallpaperUserInfo::New(); @@ -281,8 +281,6 @@ wallpaper_user_info->is_ephemeral = false; wallpaper_user_info->has_gaia_account = true; - controller_->RemoveUserWallpaperInfo(account_id, - !wallpaper_user_info->is_ephemeral); controller_->current_user_wallpaper_info_ = wallpaper::WallpaperInfo(); controller_->wallpaper_count_for_testing_ = 0; @@ -706,6 +704,46 @@ EXPECT_EQ(2, observer.wallpaper_colors_changed_count()); } +TEST_F(WallpaperControllerTest, SetCustomWallpaper) { + gfx::ImageSkia image = CreateImage(640, 480, kWallpaperColor); + const std::string file_name = "dummy_file_name"; + const std::string wallpaper_files_id = "dummy_file_id"; + const std::string user_email = "user@test.com"; + const AccountId account_id = AccountId::FromUserEmail(user_email); + WallpaperLayout layout = WALLPAPER_LAYOUT_CENTER; + wallpaper::WallpaperType type = wallpaper::CUSTOMIZED; + + SimulateUserLogin(user_email); + + // Verify the wallpaper is set successfully and wallpaper info is updated. + controller_->SetCustomWallpaper(InitializeUser(account_id), + wallpaper_files_id, file_name, layout, type, + *image.bitmap(), true /*show_wallpaper=*/); + RunAllTasksUntilIdle(); + EXPECT_EQ(1, GetWallpaperCount()); + wallpaper::WallpaperInfo wallpaper_info; + EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, + true /*is_persistent=*/)); + wallpaper::WallpaperInfo expected_wallpaper_info( + base::FilePath(wallpaper_files_id).Append(file_name).value(), layout, + type, base::Time::Now().LocalMidnight()); + EXPECT_EQ(wallpaper_info, expected_wallpaper_info); + + // Verify that the wallpaper is not set when |show_wallpaper| is false, but + // wallpaper info is updated properly. + controller_->SetCustomWallpaper(InitializeUser(account_id), + wallpaper_files_id, file_name, layout, type, + *image.bitmap(), true /*show_wallpaper=*/); + RunAllTasksUntilIdle(); + EXPECT_EQ(0, GetWallpaperCount()); + EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, + true /*is_persistent=*/)); + EXPECT_EQ(wallpaper_info, expected_wallpaper_info); + // Remove the custom wallpaper directory that may be created. + controller_->RemoveUserWallpaper(InitializeUser(account_id), + wallpaper_files_id); +} + TEST_F(WallpaperControllerTest, SetOnlineWallpaper) { gfx::ImageSkia image = CreateImage(640, 480, kWallpaperColor); const std::string url = "dummy_url"; @@ -903,6 +941,18 @@ session->SwitchActiveUser(AccountId::FromUserEmail(kiosk_app)); session->SetSessionState(SessionState::ACTIVE); + // Verify that |SetCustomWallpaper| doesn't set wallpaper in kiosk mode, and + // |account_id|'s wallpaper info is not updated. + controller_->SetCustomWallpaper( + InitializeUser(account_id), std::string() /* wallpaper_files_id */, + "dummy_file_name", WALLPAPER_LAYOUT_CENTER, wallpaper::CUSTOMIZED, + *image.bitmap(), true /* show_wallpaper */); + RunAllTasksUntilIdle(); + EXPECT_EQ(0, GetWallpaperCount()); + wallpaper::WallpaperInfo wallpaper_info; + EXPECT_FALSE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, + true /* is_persistent */)); + // Verify that |SetOnlineWallpaper| doesn't set wallpaper in kiosk mode, and // |account_id|'s wallpaper info is not updated. controller_->SetOnlineWallpaper(InitializeUser(account_id), *image.bitmap(), @@ -910,27 +960,79 @@ true /*show_wallpaper=*/); RunAllTasksUntilIdle(); EXPECT_EQ(0, GetWallpaperCount()); - wallpaper::WallpaperInfo wallpaper_info; EXPECT_FALSE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, true /*is_persistent=*/)); - // Verify that |SetDefaultWallpaper| doesn't set wallpaper in kiosk mode, but - // the wallpaper info has been reset to the default value. + // Verify that |SetDefaultWallpaper| doesn't set wallpaper in kiosk mode, and + // |account_id|'s wallpaper info is not updated. controller_->SetDefaultWallpaper(InitializeUser(account_id), std::string() /*wallpaper_files_id=*/, true /*show_wallpaper=*/); RunAllTasksUntilIdle(); EXPECT_EQ(0, GetWallpaperCount()); + EXPECT_FALSE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, + true /*is_persistent=*/)); +} + +TEST_F(WallpaperControllerTest, IgnoreWallpaperRequestWhenPolicyIsEnforced) { + gfx::ImageSkia image = CreateImage(640, 480, kWallpaperColor); + const std::string wallpaper_files_id = "dummy_file_id"; + const std::string user_email = "user@test.com"; + const AccountId account_id = AccountId::FromUserEmail("user@test.com"); + SimulateUserLogin(user_email); + + // Simulate setting a policy wallpaper by setting the wallpaper info. + // TODO(crbug.com/776464): Replace this with a real |SetPolicyWallpaper| call. + wallpaper::WallpaperInfo policy_wallpaper_info( + "dummy_file_location", WALLPAPER_LAYOUT_CENTER, wallpaper::POLICY, + base::Time::Now().LocalMidnight()); + controller_->SetUserWallpaperInfo(account_id, policy_wallpaper_info, + true /*is_persistent=*/); + EXPECT_TRUE( + controller_->IsPolicyControlled(account_id, true /*is_persistent=*/)); + + // Verify that |SetCustomWallpaper| doesn't set wallpaper when policy is + // enforced, and |account_id|'s wallpaper info is not updated. + controller_->SetCustomWallpaper( + InitializeUser(account_id), wallpaper_files_id, "dummy_file_name", + WALLPAPER_LAYOUT_CENTER, wallpaper::CUSTOMIZED, *image.bitmap(), + true /* show_wallpaper */); + RunAllTasksUntilIdle(); + EXPECT_EQ(0, GetWallpaperCount()); + wallpaper::WallpaperInfo wallpaper_info; EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, - true /*is_persistent=*/)); - wallpaper::WallpaperInfo default_wallpaper_info( - std::string(), wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, - wallpaper::DEFAULT, base::Time::Now().LocalMidnight()); - EXPECT_EQ(wallpaper_info, default_wallpaper_info); + true /* is_persistent */)); + EXPECT_EQ(wallpaper_info, policy_wallpaper_info); + + // Verify that |SetOnlineWallpaper| doesn't set wallpaper when policy is + // enforced, and |account_id|'s wallpaper info is not updated. + controller_->SetOnlineWallpaper(InitializeUser(account_id), *image.bitmap(), + "dummy_url", WALLPAPER_LAYOUT_CENTER, + true /*show_wallpaper=*/); + RunAllTasksUntilIdle(); + EXPECT_EQ(0, GetWallpaperCount()); + EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, + true /* is_persistent */)); + EXPECT_EQ(wallpaper_info, policy_wallpaper_info); + + // Verify that |SetDefaultWallpaper| doesn't set wallpaper when policy is + // enforced, and |account_id|'s wallpaper info is not updated. + controller_->SetDefaultWallpaper( + InitializeUser(account_id), wallpaper_files_id, true /*show_wallpaper=*/); + RunAllTasksUntilIdle(); + EXPECT_EQ(0, GetWallpaperCount()); + EXPECT_TRUE(controller_->GetUserWallpaperInfo(account_id, &wallpaper_info, + true /* is_persistent */)); + EXPECT_EQ(wallpaper_info, policy_wallpaper_info); + + // Remove the custom wallpaper directory that may be created. + controller_->RemoveUserWallpaper(InitializeUser(account_id), + wallpaper_files_id); } TEST_F(WallpaperControllerTest, VerifyWallpaperCache) { gfx::ImageSkia image = CreateImage(640, 480, kWallpaperColor); + const std::string wallpaper_files_id = "dummy_file_id"; const std::string user1 = "user1@test.com"; const AccountId account_id1 = AccountId::FromUserEmail(user1); @@ -962,24 +1064,25 @@ // Verify |SetDefaultWallpaper| clears wallpaper cache. controller_->SetDefaultWallpaper(InitializeUser(account_id1), - std::string() /*wallpaper_files_id=*/, + wallpaper_files_id, true /*show_wallpaper=*/); EXPECT_FALSE( controller_->GetWallpaperFromCache(account_id1, &cached_wallpaper)); EXPECT_FALSE(controller_->GetPathFromCache(account_id1, &path)); - // Verify |RemoveUserWallpaper| clears wallpaper cache. (Add wallpaper cache - // again first.) - controller_->SetOnlineWallpaper( - InitializeUser(account_id1), *image.bitmap(), "dummy_file_location", - WALLPAPER_LAYOUT_CENTER, true /*show_wallpaper=*/); + // Verify |SetCustomWallpaper| updates wallpaper cache for |user1|. + controller_->SetCustomWallpaper( + InitializeUser(account_id1), wallpaper_files_id, "dummy_file_name", + WALLPAPER_LAYOUT_CENTER, wallpaper::CUSTOMIZED, *image.bitmap(), + true /*show_wallpaper=*/); RunAllTasksUntilIdle(); EXPECT_TRUE( controller_->GetWallpaperFromCache(account_id1, &cached_wallpaper)); EXPECT_TRUE(controller_->GetPathFromCache(account_id1, &path)); + // Verify |RemoveUserWallpaper| clears wallpaper cache. controller_->RemoveUserWallpaper(InitializeUser(account_id1), - std::string() /*wallpaper_files_id=*/); + wallpaper_files_id); EXPECT_FALSE( controller_->GetWallpaperFromCache(account_id1, &cached_wallpaper)); EXPECT_FALSE(controller_->GetPathFromCache(account_id1, &path));
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 9d6179b..1f96bbe 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc
@@ -902,15 +902,17 @@ default_tile_height = MathUtil::UncheckedRoundUp(viewport_height, divisor) / divisor; + // Use half-width GPU tiles when the content width is + // larger than the viewport width. + if (content_bounds.width() > viewport_width) { + // Divide by 2 and round up. + default_tile_width = (default_tile_width + 1) / 2; + } + // Grow default sizes to account for overlapping border texels. default_tile_width += 2 * PictureLayerTiling::kBorderTexels; default_tile_height += 2 * PictureLayerTiling::kBorderTexels; - // Use half-width GPU tiles when the content width is - // larger than the viewport width. - if (content_bounds.width() > viewport_width) - default_tile_width /= 2; - // Round GPU default tile sizes to a multiple of kGpuDefaultTileAlignment. // This helps prevent rounding errors in our CA path. crbug.com/632274 default_tile_width =
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index c1278fd..64fbb171 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -5049,29 +5049,20 @@ host_impl()->SetViewportSize(gfx::Size(2000, 2000)); host_impl()->NotifyReadyToActivate(); + // Basic test. layer->set_gpu_raster_max_texture_size(host_impl()->device_viewport_size()); result = layer->CalculateTileSize(gfx::Size(10000, 10000)); EXPECT_EQ(result.width(), MathUtil::UncheckedRoundUp( - (2000 + 2 * PictureLayerTiling::kBorderTexels) / 2, 32)); + 2000 / 2 + 2 * PictureLayerTiling::kBorderTexels, 32)); EXPECT_EQ(result.height(), 512); - // Clamp and round-up, when smaller than viewport. - // Tile-height doubles to 50% when width shrinks to <= 50%. - host_impl()->SetViewportSize(gfx::Size(1000, 1000)); + // When using odd sized viewport bounds, we should round up. + host_impl()->SetViewportSize(gfx::Size(509, 1000)); layer->set_gpu_raster_max_texture_size(host_impl()->device_viewport_size()); - result = layer->CalculateTileSize(gfx::Size(447, 10000)); - EXPECT_EQ(result.width(), 448); - EXPECT_EQ(result.height(), 512); - - // Largest layer is 50% of viewport width (rounded up), and - // 50% of viewport in height. - result = layer->CalculateTileSize(gfx::Size(447, 400)); - EXPECT_EQ(result.width(), 448); - EXPECT_EQ(result.height(), 448); - result = layer->CalculateTileSize(gfx::Size(500, 499)); - EXPECT_EQ(result.width(), 512); - EXPECT_EQ(result.height(), 512); + result = layer->CalculateTileSize(gfx::Size(10000, 10000)); + EXPECT_EQ(result.width(), 288); + EXPECT_EQ(result.height(), 256); } TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) {
diff --git a/chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.cc b/chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.cc index 0df8213..6606338f 100644 --- a/chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.cc +++ b/chrome/browser/chromeos/arc/wallpaper/arc_wallpaper_service.cc
@@ -42,6 +42,8 @@ struct PrimaryAccount { const AccountId& id; const bool is_active; + const bool is_ephemeral; + const user_manager::UserType type; }; PrimaryAccount GetPrimaryAccount() { @@ -49,8 +51,12 @@ const user_manager::User* const primary_user = user_manager->GetPrimaryUser(); DCHECK(primary_user); const AccountId& account_id = primary_user->GetAccountId(); + const bool is_ephemeral = + user_manager->IsUserNonCryptohomeDataEphemeral(account_id); + const user_manager::UserType type = primary_user->GetType(); return {account_id, - account_id == user_manager->GetActiveUser()->GetAccountId()}; + account_id == user_manager->GetActiveUser()->GetAccountId(), + is_ephemeral, type}; } std::vector<uint8_t> EncodeImagePng(const gfx::ImageSkia image) { @@ -127,23 +133,37 @@ DCHECK_NE(pair.image_id, 0u) << "image_id should not be 0 as we succeeded to decode image here."; - chromeos::WallpaperManager* const wallpaper_manager = - chromeos::WallpaperManager::Get(); const PrimaryAccount& account = GetPrimaryAccount(); wallpaper::WallpaperFilesId wallpaper_files_id = WallpaperControllerClient::Get()->GetFilesId(account.id); - // TODO(crbug.com/618922): Allow specifying layout. - wallpaper_manager->SetCustomWallpaper( - account.id, wallpaper_files_id, kAndroidWallpaperFilename, - wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, wallpaper::CUSTOMIZED, - image, account.is_active /*update_wallpaper*/); - // When kiosk app is running, or wallpaper cannot be changed due to policy, - // or we are running child profile, WallpaperManager don't submit wallpaper - // change requests. - if (wallpaper_manager->IsPendingWallpaper(pair.image_id)) - service_->id_pairs_.push_back(pair); - else + ash::WallpaperController* wallpaper_controller = GetWallpaperController(); + // Decode request is only created when GetWallpaperController() returns + // non-null, so we can get the pointer here. + DCHECK(wallpaper_controller); + + // TODO(crbug.com/776464): Replace |CanSetUserWallpaper| with mojo callback. + if (!wallpaper_controller->CanSetUserWallpaper(account.id, + !account.is_ephemeral)) { + // When kiosk app is running or policy is enforced, WallpaperController + // doesn't process custom wallpaper requests. service_->NotifyWallpaperChangedAndReset(android_id_); + } else { + bool show_wallpaper = account.is_active; + // When |show_wallpaper| is false, WallpaperController still saves custom + // wallpaper for this user, but the wallpaper won't be shown right away. + // |SetArcWallpaper| calls |OnWallpaperDataChanged| synchronously, so the + // id pair should be added to the queue first. + if (show_wallpaper) + service_->id_pairs_.push_back(pair); + else + service_->NotifyWallpaperChangedAndReset(android_id_); + // TODO(crbug.com/618922): Allow specifying layout. + wallpaper_controller->SetArcWallpaper( + account.id, account.type, wallpaper_files_id.id(), + kAndroidWallpaperFilename, image, + wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, account.is_ephemeral, + show_wallpaper); + } // TODO(crbug.com/618922): Register the wallpaper to Chrome OS wallpaper // picker. Currently the new wallpaper does not appear there. The best way @@ -216,6 +236,11 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (wallpaper_id == 0) wallpaper_id = -1; + if (!GetWallpaperController()) { + NotifyWallpaperChangedAndReset(wallpaper_id); + return; + } + // Previous request will be cancelled at destructor of // ImageDecoder::ImageRequest. decode_request_ = std::make_unique<DecodeRequest>(this, wallpaper_id); @@ -254,25 +279,16 @@ const uint32_t current_image_id = wallpaper_controller->GetWallpaperOriginalImageId(); - chromeos::WallpaperManager* const wallpaper_manager = - chromeos::WallpaperManager::Get(); bool current_wallppaer_notified = false; for (auto it = id_pairs_.begin(); it != id_pairs_.end();) { int32_t const android_id = it->android_id; - bool should_notify = false; if (it->image_id == current_image_id) { - should_notify = true; current_wallppaer_notified = true; it = id_pairs_.erase(it); - } else if (!wallpaper_manager->IsPendingWallpaper(it->image_id)) { - should_notify = true; - it = id_pairs_.erase(it); + NotifyWallpaperChanged(android_id); } else { ++it; } - - if (should_notify) - NotifyWallpaperChanged(android_id); } if (!current_wallppaer_notified)
diff --git a/chrome/browser/chromeos/extensions/wallpaper_api.cc b/chrome/browser/chromeos/extensions/wallpaper_api.cc index c4c1903a..669f875d2 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_api.cc
@@ -149,11 +149,10 @@ void WallpaperSetWallpaperFunction::OnWallpaperDecoded( const gfx::ImageSkia& image) { - chromeos::WallpaperManager* wallpaper_manager = - chromeos::WallpaperManager::Get(); - base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( - ash::WallpaperController::kThumbnailWallpaperSubDir, wallpaper_files_id_, - params_->details.filename); + base::FilePath thumbnail_path = + ash::WallpaperController::GetCustomWallpaperPath( + ash::WallpaperController::kThumbnailWallpaperSubDir, + wallpaper_files_id_.id(), params_->details.filename); wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( extensions::api::wallpaper::ToString(params_->details.layout)); @@ -162,7 +161,7 @@ bool update_wallpaper = account_id_ == user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); - wallpaper_manager->SetCustomWallpaper( + WallpaperControllerClient::Get()->SetCustomWallpaper( account_id_, wallpaper_files_id_, params_->details.filename, layout, wallpaper::CUSTOMIZED, image, update_wallpaper); unsafe_wallpaper_decoder_ = NULL; @@ -205,10 +204,10 @@ scoped_refptr<base::RefCountedBytes> original_data; scoped_refptr<base::RefCountedBytes> thumbnail_data; - chromeos::WallpaperManager::Get()->ResizeImage( + ash::WallpaperController::ResizeImage( *image, wallpaper::WALLPAPER_LAYOUT_STRETCH, image->width(), image->height(), &original_data, NULL); - chromeos::WallpaperManager::Get()->ResizeImage( + ash::WallpaperController::ResizeImage( *image, wallpaper::WALLPAPER_LAYOUT_STRETCH, ash::WallpaperController::kWallpaperThumbnailWidth, ash::WallpaperController::kWallpaperThumbnailHeight, &thumbnail_data,
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc index cdf92d1..a2498dab 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
@@ -416,7 +416,7 @@ return; // Generates and saves small resolution wallpaper. Uses CENTER_CROPPED to // maintain the aspect ratio after resize. - chromeos::WallpaperManager::Get()->ResizeAndSaveWallpaper( + ash::WallpaperController::ResizeAndSaveWallpaper( wallpaper_, file_path, wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, ash::WallpaperController::kSmallWallpaperMaxWidth, ash::WallpaperController::kSmallWallpaperMaxHeight, NULL); @@ -499,11 +499,10 @@ void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( const gfx::ImageSkia& image) { - chromeos::WallpaperManager* wallpaper_manager = - chromeos::WallpaperManager::Get(); - base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( - ash::WallpaperController::kThumbnailWallpaperSubDir, wallpaper_files_id_, - params->file_name); + base::FilePath thumbnail_path = + ash::WallpaperController::GetCustomWallpaperPath( + ash::WallpaperController::kThumbnailWallpaperSubDir, + wallpaper_files_id_.id(), params->file_name); wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( wallpaper_base::ToString(params->layout)); @@ -512,7 +511,7 @@ bool update_wallpaper = account_id_ == user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); - wallpaper_manager->SetCustomWallpaper( + WallpaperControllerClient::Get()->SetCustomWallpaper( account_id_, wallpaper_files_id_, params->file_name, layout, wallpaper::CUSTOMIZED, image, update_wallpaper); unsafe_wallpaper_decoder_ = NULL; @@ -546,7 +545,7 @@ base::CreateDirectory(thumbnail_path.DirName()); scoped_refptr<base::RefCountedBytes> data; - chromeos::WallpaperManager::Get()->ResizeImage( + ash::WallpaperController::ResizeImage( *image, wallpaper::WALLPAPER_LAYOUT_STRETCH, ash::WallpaperController::kWallpaperThumbnailWidth, ash::WallpaperController::kWallpaperThumbnailHeight, &data, NULL);
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc index 9d961777..add3bf2 100644 --- a/chrome/browser/chromeos/login/session/user_session_manager.cc +++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -89,7 +89,7 @@ #include "chromeos/cert_loader.h" #include "chromeos/chromeos_switches.h" #include "chromeos/cryptohome/cryptohome_parameters.h" -#include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/cryptohome/tpm_util.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/session_manager_client.h" @@ -1230,7 +1230,7 @@ void UserSessionManager::PrepareTpmDeviceAndFinalizeProfile(Profile* profile) { BootTimesRecorder::Get()->AddLoginTimeMarker("TPMOwn-Start", false); - if (!cryptohome_util::TpmIsEnabled() || cryptohome_util::TpmIsBeingOwned()) { + if (!tpm_util::TpmIsEnabled() || tpm_util::TpmIsBeingOwned()) { FinalizePrepareProfile(profile); return; } @@ -1249,7 +1249,7 @@ base::BindOnce(&UserSessionManager::OnCryptohomeOperationCompleted, AsWeakPtr(), profile); CryptohomeClient* client = DBusThreadManager::Get()->GetCryptohomeClient(); - if (cryptohome_util::TpmIsOwned()) + if (tpm_util::TpmIsOwned()) client->TpmClearStoredPassword(std::move(callback)); else client->TpmCanAttemptOwnership(std::move(callback));
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc index 13c260a..f6ffadc 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc
@@ -89,9 +89,6 @@ const char kDeviceWallpaperDir[] = "device_wallpaper"; const char kDeviceWallpaperFile[] = "device_wallpaper_image.jpg"; -// Default quality for encoding wallpaper. -const int kDefaultEncodingQuality = 90; - // Maximum number of wallpapers cached by CacheUsersWallpapers(). const int kMaxWallpapersToCache = 3; @@ -211,7 +208,8 @@ bool MoveCustomWallpaperDirectory(const char* sub_dir, const std::string& from_name, const std::string& to_name) { - base::FilePath base_path = WallpaperManager::GetCustomWallpaperDir(sub_dir); + base::FilePath base_path = + ash::WallpaperController::GetCustomWallpaperDir(sub_dir); base::FilePath to_path = base_path.Append(to_name); base::FilePath from_path = base_path.Append(from_name); if (base::PathExists(from_path)) @@ -219,42 +217,6 @@ return false; } -// Creates all new custom wallpaper directories for |wallpaper_files_id| if not -// exist. -void EnsureCustomWallpaperDirectories( - const wallpaper::WallpaperFilesId& wallpaper_files_id) { - base::FilePath dir; - dir = WallpaperManager::GetCustomWallpaperDir( - ash::WallpaperController::kSmallWallpaperSubDir); - dir = dir.Append(wallpaper_files_id.id()); - if (!base::PathExists(dir)) - base::CreateDirectory(dir); - dir = WallpaperManager::GetCustomWallpaperDir( - ash::WallpaperController::kLargeWallpaperSubDir); - dir = dir.Append(wallpaper_files_id.id()); - if (!base::PathExists(dir)) - base::CreateDirectory(dir); - dir = WallpaperManager::GetCustomWallpaperDir( - ash::WallpaperController::kOriginalWallpaperSubDir); - dir = dir.Append(wallpaper_files_id.id()); - if (!base::PathExists(dir)) - base::CreateDirectory(dir); - dir = WallpaperManager::GetCustomWallpaperDir( - ash::WallpaperController::kThumbnailWallpaperSubDir); - dir = dir.Append(wallpaper_files_id.id()); - if (!base::PathExists(dir)) - base::CreateDirectory(dir); -} - -// Saves wallpaper image raw |data| to |path| (absolute path) in file system. -// Returns true on success. -bool SaveWallpaperInternal(const base::FilePath& path, - const char* data, - int size) { - int written_bytes = base::WriteFile(path, data, size); - return written_bytes == size; -} - } // namespace void AssertCalledOnWallpaperSequence(base::SequencedTaskRunner* task_runner) { @@ -312,10 +274,6 @@ true); } - uint32_t GetImageId() const { - return wallpaper::WallpaperResizer::GetImageId(user_wallpaper_); - } - private: // All methods use SetMode() to set object to new state. void SetMode(const AccountId& account_id, @@ -545,171 +503,6 @@ wallpaper_manager = nullptr; } -// static -base::FilePath WallpaperManager::GetCustomWallpaperDir( - const std::string& sub_dir) { - if (!ash::Shell::HasInstance() || ash_util::IsRunningInMash()) { - // Some unit tests come here without a Shell instance. - // TODO(crbug.com/776464): This is intended not to work under mash. Make it - // work again after WallpaperManager is removed. - return base::FilePath(); - } - return ash::Shell::Get()->wallpaper_controller()->GetCustomWallpaperDir( - sub_dir); -} - -// static -bool WallpaperManager::ResizeImage(const gfx::ImageSkia& image, - wallpaper::WallpaperLayout layout, - int preferred_width, - int preferred_height, - scoped_refptr<base::RefCountedBytes>* output, - gfx::ImageSkia* output_skia) { - int width = image.width(); - int height = image.height(); - int resized_width; - int resized_height; - *output = new base::RefCountedBytes(); - - if (layout == wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED) { - // Do not resize custom wallpaper if it is smaller than preferred size. - if (!(width > preferred_width && height > preferred_height)) - return false; - - double horizontal_ratio = static_cast<double>(preferred_width) / width; - double vertical_ratio = static_cast<double>(preferred_height) / height; - if (vertical_ratio > horizontal_ratio) { - resized_width = - gfx::ToRoundedInt(static_cast<double>(width) * vertical_ratio); - resized_height = preferred_height; - } else { - resized_width = preferred_width; - resized_height = - gfx::ToRoundedInt(static_cast<double>(height) * horizontal_ratio); - } - } else if (layout == wallpaper::WALLPAPER_LAYOUT_STRETCH) { - resized_width = preferred_width; - resized_height = preferred_height; - } else { - resized_width = width; - resized_height = height; - } - - gfx::ImageSkia resized_image = gfx::ImageSkiaOperations::CreateResizedImage( - image, skia::ImageOperations::RESIZE_LANCZOS3, - gfx::Size(resized_width, resized_height)); - - SkBitmap bitmap = *(resized_image.bitmap()); - gfx::JPEGCodec::Encode(bitmap, kDefaultEncodingQuality, &(*output)->data()); - - if (output_skia) { - resized_image.MakeThreadSafe(); - *output_skia = resized_image; - } - - return true; -} - -// static -bool WallpaperManager::ResizeAndSaveWallpaper(const gfx::ImageSkia& image, - const base::FilePath& path, - wallpaper::WallpaperLayout layout, - int preferred_width, - int preferred_height, - gfx::ImageSkia* output_skia) { - if (layout == wallpaper::WALLPAPER_LAYOUT_CENTER) { - // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. - if (base::PathExists(path)) - base::DeleteFile(path, false); - return false; - } - scoped_refptr<base::RefCountedBytes> data; - if (ResizeImage(image, layout, preferred_width, preferred_height, &data, - output_skia)) { - return SaveWallpaperInternal( - path, reinterpret_cast<const char*>(data->front()), data->size()); - } - return false; -} - -// static -base::FilePath WallpaperManager::GetCustomWallpaperPath( - const std::string& sub_dir, - const wallpaper::WallpaperFilesId& wallpaper_files_id, - const std::string& file_name) { - base::FilePath custom_wallpaper_path = GetCustomWallpaperDir(sub_dir); - return custom_wallpaper_path.Append(wallpaper_files_id.id()) - .Append(file_name); -} - -void WallpaperManager::SetCustomWallpaper( - const AccountId& account_id, - const wallpaper::WallpaperFilesId& wallpaper_files_id, - const std::string& file_name, - wallpaper::WallpaperLayout layout, - wallpaper::WallpaperType type, - const gfx::ImageSkia& image, - bool show_wallpaper) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - // There is no visible wallpaper in kiosk mode. - if (user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) - return; - - // Don't allow custom wallpapers while policy is in effect. - if (type != wallpaper::POLICY && IsPolicyControlled(account_id)) - return; - - // If decoded wallpaper is empty, we have probably failed to decode the file. - // Use default wallpaper in this case. - if (image.isNull()) { - GetPendingWallpaper()->SetDefaultWallpaper(account_id); - return; - } - - base::FilePath wallpaper_path = - GetCustomWallpaperPath(ash::WallpaperController::kOriginalWallpaperSubDir, - wallpaper_files_id, file_name); - - const user_manager::User* user = - user_manager::UserManager::Get()->FindUser(account_id); - CHECK(user); - const bool is_persistent = - !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( - account_id) || - (type == wallpaper::POLICY && - user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); - - if (is_persistent) { - image.EnsureRepsForSupportedScales(); - std::unique_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); - // Block shutdown on this task. Otherwise, we may lose the custom wallpaper - // that the user selected. - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner = - base::CreateSequencedTaskRunnerWithTraits( - {base::MayBlock(), base::TaskPriority::USER_BLOCKING, - base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); - // TODO(bshe): This may break if RawImage becomes RefCountedMemory. - blocking_task_runner->PostTask( - FROM_HERE, base::BindOnce(&WallpaperManager::SaveCustomWallpaper, - wallpaper_files_id, wallpaper_path, layout, - base::Passed(std::move(deep_copy)))); - } - - std::string relative_path = - base::FilePath(wallpaper_files_id.id()).Append(file_name).value(); - // User's custom wallpaper path is determined by relative path and the - // appropriate wallpaper resolution in GetCustomWallpaperInternal. - WallpaperInfo info = {relative_path, layout, type, - base::Time::Now().LocalMidnight()}; - SetUserWallpaperInfo(account_id, info, is_persistent); - if (show_wallpaper) - GetPendingWallpaper()->SetWallpaperFromImage(account_id, image, info); - - (*GetWallpaperCacheMap())[account_id] = - ash::CustomWallpaperElement(wallpaper_path, image); -} - void WallpaperManager::SetCustomizedDefaultWallpaper( const GURL& wallpaper_url, const base::FilePath& file_path, @@ -813,7 +606,8 @@ // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. if (info.layout == wallpaper::WALLPAPER_LAYOUT_CENTER) sub_dir = ash::WallpaperController::kOriginalWallpaperSubDir; - wallpaper_path = GetCustomWallpaperDir(sub_dir); + wallpaper_path = + ash::WallpaperController::GetCustomWallpaperDir(sub_dir); wallpaper_path = wallpaper_path.Append(info.location); } else { wallpaper_path = GetDeviceWallpaperFilePath(); @@ -922,15 +716,6 @@ ShowUserWallpaper(last_selected_user_); } -bool WallpaperManager::IsPendingWallpaper(uint32_t image_id) { - for (size_t i = 0; i < loading_.size(); ++i) { - if (loading_[i]->GetImageId() == image_id) { - return true; - } - } - return false; -} - bool WallpaperManager::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -998,10 +783,17 @@ } bool WallpaperManager::IsPolicyControlled(const AccountId& account_id) const { - WallpaperInfo info; - if (!GetUserWallpaperInfo(account_id, &info)) + if (!ash::Shell::HasInstance() || ash_util::IsRunningInMash()) { + // Some unit tests come here without a Shell instance. + // TODO(crbug.com/776464): This is intended not to work under mash. Make it + // work again after WallpaperManager is removed. return false; - return info.type == wallpaper::POLICY; + } + bool is_persistent = + !user_manager::UserManager::Get()->IsUserNonCryptohomeDataEphemeral( + account_id); + return ash::Shell::Get()->wallpaper_controller()->IsPolicyControlled( + account_id, is_persistent); } void WallpaperManager::OnPolicySet(const std::string& policy, @@ -1134,49 +926,6 @@ } // static -void WallpaperManager::SaveCustomWallpaper( - const wallpaper::WallpaperFilesId& wallpaper_files_id, - const base::FilePath& original_path, - wallpaper::WallpaperLayout layout, - std::unique_ptr<gfx::ImageSkia> image) { - base::DeleteFile( - GetCustomWallpaperDir(ash::WallpaperController::kOriginalWallpaperSubDir) - .Append(wallpaper_files_id.id()), - true /* recursive */); - base::DeleteFile( - GetCustomWallpaperDir(ash::WallpaperController::kSmallWallpaperSubDir) - .Append(wallpaper_files_id.id()), - true /* recursive */); - base::DeleteFile( - GetCustomWallpaperDir(ash::WallpaperController::kLargeWallpaperSubDir) - .Append(wallpaper_files_id.id()), - true /* recursive */); - EnsureCustomWallpaperDirectories(wallpaper_files_id); - std::string file_name = original_path.BaseName().value(); - base::FilePath small_wallpaper_path = - GetCustomWallpaperPath(ash::WallpaperController::kSmallWallpaperSubDir, - wallpaper_files_id, file_name); - base::FilePath large_wallpaper_path = - GetCustomWallpaperPath(ash::WallpaperController::kLargeWallpaperSubDir, - wallpaper_files_id, file_name); - - // Re-encode orginal file to jpeg format and saves the result in case that - // resized wallpaper is not generated (i.e. chrome shutdown before resized - // wallpaper is saved). - ResizeAndSaveWallpaper(*image, original_path, - wallpaper::WALLPAPER_LAYOUT_STRETCH, image->width(), - image->height(), nullptr); - ResizeAndSaveWallpaper(*image, small_wallpaper_path, layout, - ash::WallpaperController::kSmallWallpaperMaxWidth, - ash::WallpaperController::kSmallWallpaperMaxHeight, - nullptr); - ResizeAndSaveWallpaper(*image, large_wallpaper_path, layout, - ash::WallpaperController::kLargeWallpaperMaxWidth, - ash::WallpaperController::kLargeWallpaperMaxHeight, - nullptr); -} - -// static void WallpaperManager::MoveCustomWallpapersOnWorker( const AccountId& account_id, const wallpaper::WallpaperFilesId& wallpaper_files_id, @@ -1219,7 +968,7 @@ // Falls back on original file if the correct resolution file does not // exist. This may happen when the original custom wallpaper is small or // browser shutdown before resized wallpaper saved. - valid_path = GetCustomWallpaperDir( + valid_path = ash::WallpaperController::GetCustomWallpaperDir( ash::WallpaperController::kOriginalWallpaperSubDir); valid_path = valid_path.Append(info.location); } @@ -1229,9 +978,9 @@ // path. // Note that account id is used instead of wallpaper_files_id here. const std::string& old_path = account_id.GetUserEmail(); // Migrated - valid_path = GetCustomWallpaperPath( - ash::WallpaperController::kOriginalWallpaperSubDir, - wallpaper::WallpaperFilesId::FromString(old_path), info.location); + valid_path = ash::WallpaperController::GetCustomWallpaperPath( + ash::WallpaperController::kOriginalWallpaperSubDir, old_path, + info.location); } if (!base::PathExists(valid_path)) { @@ -1256,19 +1005,19 @@ gfx::ImageSkia* large_wallpaper_image) { *success = true; - *success &= - ResizeAndSaveWallpaper(*image, rescaled_files->path_rescaled_small(), - wallpaper::WALLPAPER_LAYOUT_STRETCH, - ash::WallpaperController::kSmallWallpaperMaxWidth, - ash::WallpaperController::kSmallWallpaperMaxHeight, - small_wallpaper_image); + *success &= ash::WallpaperController::ResizeAndSaveWallpaper( + *image, rescaled_files->path_rescaled_small(), + wallpaper::WALLPAPER_LAYOUT_STRETCH, + ash::WallpaperController::kSmallWallpaperMaxWidth, + ash::WallpaperController::kSmallWallpaperMaxHeight, + small_wallpaper_image); - *success &= - ResizeAndSaveWallpaper(*image, rescaled_files->path_rescaled_large(), - wallpaper::WALLPAPER_LAYOUT_STRETCH, - ash::WallpaperController::kLargeWallpaperMaxWidth, - ash::WallpaperController::kLargeWallpaperMaxHeight, - large_wallpaper_image); + *success &= ash::WallpaperController::ResizeAndSaveWallpaper( + *image, rescaled_files->path_rescaled_large(), + wallpaper::WALLPAPER_LAYOUT_STRETCH, + ash::WallpaperController::kLargeWallpaperMaxWidth, + ash::WallpaperController::kLargeWallpaperMaxHeight, + large_wallpaper_image); } void WallpaperManager::InitializeUserWallpaperInfo( @@ -1367,7 +1116,9 @@ wallpaper_path = GetDeviceWallpaperFilePath(); } else { const char* sub_dir = GetCustomWallpaperSubdirForCurrentResolution(); - wallpaper_path = GetCustomWallpaperDir(sub_dir).Append(info.location); + wallpaper_path = + ash::WallpaperController::GetCustomWallpaperDir(sub_dir).Append( + info.location); } // Set the path to the cache. (*wallpaper_cache_map)[account_id] = @@ -1914,11 +1665,12 @@ // If we're at the login screen, do not change the wallpaper to the user // policy controlled wallpaper but only update the cache. It will be later // updated after the user logs in. - SetCustomWallpaper(account_id, wallpaper_files_id, "policy-controlled.jpeg", - wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, - wallpaper::POLICY, user_image->image(), - user_manager::UserManager::Get() - ->IsUserLoggedIn() /* update wallpaper */); + WallpaperControllerClient::Get()->SetCustomWallpaper( + account_id, wallpaper_files_id, "policy-controlled.jpeg", + wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED, wallpaper::POLICY, + user_image->image(), + user_manager::UserManager::Get() + ->IsUserLoggedIn() /* update wallpaper */); } void WallpaperManager::OnDeviceWallpaperPolicyChanged() {
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h index 4906333c..96071c73 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h
@@ -158,55 +158,6 @@ // WallpaperManager to remove any observers it has registered. static void Shutdown(); - // A wrapper of |WallpaperController::GetCustomWallpaperDir|. - static base::FilePath GetCustomWallpaperDir(const std::string& sub_dir); - - // Resizes |image| to a resolution which is nearest to |preferred_width| and - // |preferred_height| while respecting the |layout| choice. |output_skia| is - // optional (may be NULL). Returns true on success. - static bool ResizeImage(const gfx::ImageSkia& image, - wallpaper::WallpaperLayout layout, - int preferred_width, - int preferred_height, - scoped_refptr<base::RefCountedBytes>* output, - gfx::ImageSkia* output_skia); - - // Resizes |image| to a resolution which is nearest to |preferred_width| and - // |preferred_height| while respecting the |layout| choice and saves the - // resized wallpaper to |path|. |output_skia| is optional (may be - // NULL). Returns true on success. - static bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image, - const base::FilePath& path, - wallpaper::WallpaperLayout layout, - int preferred_width, - int preferred_height, - gfx::ImageSkia* output_skia); - - // Returns custom wallpaper path. Append |sub_dir|, |wallpaper_files_id| and - // |file_name| to custom wallpaper directory. - static base::FilePath GetCustomWallpaperPath( - const std::string& sub_dir, - const wallpaper::WallpaperFilesId& wallpaper_files_id, - const std::string& file_name); - - // Sets wallpaper from policy or from a local file. Saves the custom wallpaper - // to file, posts task to generate thumbnail and updates local state. - // |account_id|: The user's account id. - // |wallpaper_files_id|: The unique id of each wallpaper file. - // |file_name|: The name of the wallpaper file. - // |layout|: The layout of the wallpaper, used for wallpaper resizing. - // |type|: The type of the wallpaper, e.g., default, policy etc. - // |image|: The wallpaper image. - // |show_wallpaper|: If false, don't show the new wallpaper now but only - // update cache. - void SetCustomWallpaper(const AccountId& account_id, - const wallpaper::WallpaperFilesId& wallpaper_files_id, - const std::string& file_name, - wallpaper::WallpaperLayout layout, - wallpaper::WallpaperType type, - const gfx::ImageSkia& image, - bool show_wallpaper); - // Sets a customized default wallpaper to be used wherever a default wallpaper // is needed. Note: it doesn't change the default wallpaper for guest and // child accounts. @@ -244,10 +195,6 @@ // current display's resolution. void UpdateWallpaper(bool clear_cache); - // Returns if the image is in the pending list. |image_id| can be obtained - // from gfx::ImageSkia by using WallpaperResizer::GetImageId(). - bool IsPendingWallpaper(uint32_t image_id); - // Gets wallpaper information of logged in user. bool GetLoggedInUserWallpaperInfo(wallpaper::WallpaperInfo* info); @@ -267,7 +214,7 @@ // Returns queue size. size_t GetPendingListSizeForTesting() const; - // Returns whether a wallpaper policy is enforced for |account_id|. + // A wrapper of |WallpaperController::IsPolicyControlled|. bool IsPolicyControlled(const AccountId& account_id) const; // Called when a wallpaper policy has been set for |account_id|. Blocks user @@ -306,14 +253,6 @@ WallpaperManager(); - // Saves original custom wallpaper to |path| (absolute path) on filesystem - // and starts resizing operation of the custom wallpaper if necessary. - static void SaveCustomWallpaper( - const wallpaper::WallpaperFilesId& wallpaper_files_id, - const base::FilePath& path, - wallpaper::WallpaperLayout layout, - std::unique_ptr<gfx::ImageSkia> image); - // Moves custom wallpapers from user email directory to // |wallpaper_files_id| directory. static void MoveCustomWallpapersOnWorker(
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_browsertest.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_browsertest.cc index a82542e..69d48b6 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_browsertest.cc +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_browsertest.cc
@@ -114,19 +114,19 @@ wallpaper::WallpaperFilesId wallpaper_file_id = GetFilesId(account_id); base::FilePath small_wallpaper_dir = - WallpaperManager::GetCustomWallpaperDir( + ash::WallpaperController::GetCustomWallpaperDir( ash::WallpaperController::kSmallWallpaperSubDir) .Append(wallpaper_file_id.id()); base::FilePath large_wallpaper_dir = - WallpaperManager::GetCustomWallpaperDir( + ash::WallpaperController::GetCustomWallpaperDir( ash::WallpaperController::kLargeWallpaperSubDir) .Append(wallpaper_file_id.id()); base::FilePath original_wallpaper_dir = - WallpaperManager::GetCustomWallpaperDir( + ash::WallpaperController::GetCustomWallpaperDir( ash::WallpaperController::kOriginalWallpaperSubDir) .Append(wallpaper_file_id.id()); base::FilePath thumbnail_wallpaper_dir = - WallpaperManager::GetCustomWallpaperDir( + ash::WallpaperController::GetCustomWallpaperDir( ash::WallpaperController::kThumbnailWallpaperSubDir) .Append(wallpaper_file_id.id()); @@ -145,8 +145,8 @@ const std::string& id) { base::ScopedAllowBlockingForTesting allow_blocking; base::FilePath wallpaper_path = - WallpaperManager::Get()->GetCustomWallpaperPath(sub_dir, - wallpaper_files_id, id); + ash::WallpaperController::GetCustomWallpaperPath( + sub_dir, wallpaper_files_id.id(), id); if (!base::DirectoryExists(wallpaper_path.DirName())) base::CreateDirectory(wallpaper_path.DirName()); @@ -510,101 +510,6 @@ } }; -// Sets test_account_id1_'s wallpaper to a custom wallpaper. -IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, - PRE_VerifyWallpaperCache) { - // Add test_account_id1_ to user list. - // test_account_id1_ is the default login profile. - LogIn(test_account_id1_, kTestUser1Hash); - - std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); - WallpaperManager* wallpaper_manager = WallpaperManager::Get(); - base::FilePath small_wallpaper_path = - GetCustomWallpaperPath(ash::WallpaperController::kSmallWallpaperSubDir, - test_account1_wallpaper_files_id_, id); - base::FilePath large_wallpaper_path = - GetCustomWallpaperPath(ash::WallpaperController::kLargeWallpaperSubDir, - test_account1_wallpaper_files_id_, id); - - // Saves the small/large resolution wallpapers to small/large custom - // wallpaper paths. - ASSERT_TRUE(ash::WallpaperController::WriteJPEGFileForTesting( - small_wallpaper_path, kSmallWallpaperWidth, kSmallWallpaperHeight, - wallpaper_manager_test_utils::kSmallCustomWallpaperColor)); - ASSERT_TRUE(ash::WallpaperController::WriteJPEGFileForTesting( - large_wallpaper_path, kLargeWallpaperWidth, kLargeWallpaperHeight, - wallpaper_manager_test_utils::kLargeCustomWallpaperColor)); - - std::string relative_path = - base::FilePath(test_account1_wallpaper_files_id_.id()).Append(id).value(); - // Saves wallpaper info to local state for user |test_account_id1_|. - WallpaperInfo info = {relative_path, WALLPAPER_LAYOUT_CENTER_CROPPED, - wallpaper::CUSTOMIZED, - base::Time::Now().LocalMidnight()}; - wallpaper_manager->SetUserWallpaperInfo(test_account_id1_, info, true); - wallpaper_manager->ShowUserWallpaper(test_account_id1_); - wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); - std::unique_ptr<WallpaperManager::TestApi> test_api; - test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); - // Verify SetUserWallpaper updates wallpaper cache. - gfx::ImageSkia cached_wallpaper; - EXPECT_TRUE( - test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper)); - base::FilePath path; - EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &path)); - EXPECT_FALSE(path.empty()); -} - -// Tests for crbug.com/339576. Wallpaper cache should be updated in -// multi-profile mode when user chooses a custom wallpaper from wallpaper picker -// (calls SetCustomWallpaper). -// Also, when user login at multi-profile mode, previous logged in users' -// wallpaper cache should not be deleted. -IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, - VerifyWallpaperCache) { - LogIn(test_account_id1_, kTestUser1Hash); - - WallpaperManager* wallpaper_manager = WallpaperManager::Get(); - - // Force load initial wallpaper - // (simulate WallpaperController::UpdateDisplay()). - wallpaper_manager->UpdateWallpaper(true); - wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); - std::unique_ptr<WallpaperManager::TestApi> test_api; - test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); - gfx::ImageSkia cached_wallpaper; - // Previous custom wallpaper should be cached after user login. - EXPECT_TRUE( - test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper)); - base::FilePath original_path; - EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &original_path)); - EXPECT_FALSE(original_path.empty()); - - LogIn(test_account_id2_, kTestUser2Hash); - wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); - // Login another user should not delete logged in user's wallpaper cache. - // Note active user is still test_account_id1_. - EXPECT_TRUE( - test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper)); - base::FilePath path; - EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &path)); - EXPECT_EQ(original_path, path); - - gfx::ImageSkia green_wallpaper = CreateTestImage(SK_ColorGREEN); - wallpaper_manager->SetCustomWallpaper( - test_account_id1_, test_account1_wallpaper_files_id_, - "dummy" /* dummy file name */, WALLPAPER_LAYOUT_CENTER, - wallpaper::CUSTOMIZED, green_wallpaper, true); - wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); - // SetCustomWallpaper should also update wallpaper cache when multi-profile - // is turned on. - EXPECT_TRUE( - test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper)); - EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(green_wallpaper)); - EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &path)); - EXPECT_NE(original_path, path); -} - // ---------------------------------------------------------------------- // Test default wallpapers. @@ -719,30 +624,6 @@ EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); } -IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, IsPendingWallpaper) { - SessionManager::Get()->CreateSession(user_manager::StubAccountId(), - "test_hash", false /* is_child */); - - WallpaperManager* wallpaper_manager = WallpaperManager::Get(); - - // Start loading the default wallpaper (the 1x1 solid color wallpaper). - ash::Shell::Get()->wallpaper_controller()->ShowDefaultWallpaperForTesting(); - - gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( - 640, 480, wallpaper_manager_test_utils::kSmallCustomWallpaperColor); - EXPECT_FALSE(WallpaperManager::Get()->IsPendingWallpaper( - wallpaper::WallpaperResizer::GetImageId(image))); - wallpaper_manager->SetCustomWallpaper( - user_manager::StubAccountId(), - wallpaper::WallpaperFilesId::FromString("test_hash"), "test-nofile.jpeg", - WALLPAPER_LAYOUT_STRETCH, wallpaper::CUSTOMIZED, image, true); - EXPECT_TRUE(wallpaper_manager->IsPendingWallpaper( - wallpaper::WallpaperResizer::GetImageId(image))); - wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); - EXPECT_FALSE(wallpaper_manager->IsPendingWallpaper( - wallpaper::WallpaperResizer::GetImageId(image))); -} - // Tests that if there are multiple users on the device and if one user lost his // wallpaper somehow, the wallpapers should still show correctly on lock/login // screen.
diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc index c2fd62c3..14038a6 100644 --- a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc +++ b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc
@@ -16,7 +16,7 @@ #include "chrome/browser/chromeos/settings/install_attributes.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" -#include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/cryptohome/tpm_util.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cryptohome_client.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h" @@ -111,8 +111,7 @@ void ResetToNonEnterprise() { store_.reset(); - chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", - std::string()); + chromeos::tpm_util::InstallAttributesSet("enterprise.owned", std::string()); install_attributes_.reset( new chromeos::InstallAttributes(fake_cryptohome_client_)); store_.reset(new DeviceCloudPolicyStoreChromeOS(
diff --git a/chrome/browser/chromeos/settings/install_attributes.cc b/chrome/browser/chromeos/settings/install_attributes.cc index d536ec73..eacb38c 100644 --- a/chrome/browser/chromeos/settings/install_attributes.cc +++ b/chrome/browser/chromeos/settings/install_attributes.cc
@@ -19,7 +19,7 @@ #include "base/sys_info.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" -#include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/cryptohome/tpm_util.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "components/policy/proto/install_attributes.pb.h" @@ -28,8 +28,6 @@ namespace chromeos { -namespace cu = cryptohome_util; - namespace { // Number of TPM lock state query retries during consistency check. @@ -143,8 +141,8 @@ base::Optional<bool> is_ready) { if (is_ready.value_or(false)) { registration_mode_ = policy::DEVICE_MODE_NOT_SET; - if (!cu::InstallAttributesIsInvalid() && - !cu::InstallAttributesIsFirstInstall()) { + if (!tpm_util::InstallAttributesIsInvalid() && + !tpm_util::InstallAttributesIsFirstInstall()) { device_locked_ = true; static const char* const kEnterpriseAttributes[] = { @@ -159,7 +157,7 @@ std::map<std::string, std::string> attr_map; for (size_t i = 0; i < arraysize(kEnterpriseAttributes); ++i) { std::string value; - if (cu::InstallAttributesGet(kEnterpriseAttributes[i], &value)) + if (tpm_util::InstallAttributesGet(kEnterpriseAttributes[i], &value)) attr_map[kEnterpriseAttributes[i]] = value; } @@ -261,19 +259,20 @@ } // Clearing the TPM password seems to be always a good deal. - if (cu::TpmIsEnabled() && !cu::TpmIsBeingOwned() && cu::TpmIsOwned()) { + if (tpm_util::TpmIsEnabled() && !tpm_util::TpmIsBeingOwned() && + tpm_util::TpmIsOwned()) { cryptohome_client_->CallTpmClearStoredPasswordAndBlock(); } // Make sure we really have a working InstallAttrs. - if (cu::InstallAttributesIsInvalid()) { + if (tpm_util::InstallAttributesIsInvalid()) { LOG(ERROR) << "Install attributes invalid."; device_lock_running_ = false; callback.Run(LOCK_BACKEND_INVALID); return; } - if (!cu::InstallAttributesIsFirstInstall()) { + if (!tpm_util::InstallAttributesIsFirstInstall()) { LOG(ERROR) << "Install attributes already installed."; device_lock_running_ = false; callback.Run(LOCK_ALREADY_LOCKED); @@ -288,20 +287,21 @@ enterprise_owned = "true"; } std::string mode = GetDeviceModeString(device_mode); - if (!cu::InstallAttributesSet(kAttrConsumerKioskEnabled, kiosk_enabled) || - !cu::InstallAttributesSet(kAttrEnterpriseOwned, enterprise_owned) || - !cu::InstallAttributesSet(kAttrEnterpriseMode, mode) || - !cu::InstallAttributesSet(kAttrEnterpriseDomain, domain) || - !cu::InstallAttributesSet(kAttrEnterpriseRealm, realm) || - !cu::InstallAttributesSet(kAttrEnterpriseDeviceId, device_id)) { + if (!tpm_util::InstallAttributesSet(kAttrConsumerKioskEnabled, + kiosk_enabled) || + !tpm_util::InstallAttributesSet(kAttrEnterpriseOwned, enterprise_owned) || + !tpm_util::InstallAttributesSet(kAttrEnterpriseMode, mode) || + !tpm_util::InstallAttributesSet(kAttrEnterpriseDomain, domain) || + !tpm_util::InstallAttributesSet(kAttrEnterpriseRealm, realm) || + !tpm_util::InstallAttributesSet(kAttrEnterpriseDeviceId, device_id)) { LOG(ERROR) << "Failed writing attributes."; device_lock_running_ = false; callback.Run(LOCK_SET_ERROR); return; } - if (!cu::InstallAttributesFinalize() || - cu::InstallAttributesIsFirstInstall()) { + if (!tpm_util::InstallAttributesFinalize() || + tpm_util::InstallAttributesIsFirstInstall()) { LOG(ERROR) << "Failed locking."; device_lock_running_ = false; callback.Run(LOCK_FINALIZE_ERROR);
diff --git a/chrome/browser/chromeos/settings/install_attributes_unittest.cc b/chrome/browser/chromeos/settings/install_attributes_unittest.cc index 043b629..13687fb 100644 --- a/chrome/browser/chromeos/settings/install_attributes_unittest.cc +++ b/chrome/browser/chromeos/settings/install_attributes_unittest.cc
@@ -15,7 +15,7 @@ #include "base/run_loop.h" #include "base/test/scoped_task_environment.h" #include "chromeos/chromeos_paths.h" -#include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/cryptohome/tpm_util.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -193,12 +193,12 @@ install_attributes_->Init(GetTempPath()); EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode()); // Lock the attributes empty. - ASSERT_TRUE(cryptohome_util::InstallAttributesFinalize()); + ASSERT_TRUE(tpm_util::InstallAttributesFinalize()); base::RunLoop loop; install_attributes_->ReadImmutableAttributes(loop.QuitClosure()); loop.Run(); - ASSERT_FALSE(cryptohome_util::InstallAttributesIsFirstInstall()); + ASSERT_FALSE(tpm_util::InstallAttributesIsFirstInstall()); EXPECT_EQ(policy::DEVICE_MODE_CONSUMER, install_attributes_->GetMode()); EXPECT_EQ(std::string(), install_attributes_->GetDomain()); EXPECT_EQ(std::string(), install_attributes_->GetRealm()); @@ -216,7 +216,7 @@ std::string(), std::string())); - ASSERT_FALSE(cryptohome_util::InstallAttributesIsFirstInstall()); + ASSERT_FALSE(tpm_util::InstallAttributesIsFirstInstall()); EXPECT_EQ(policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, install_attributes_->GetMode()); EXPECT_EQ(std::string(), install_attributes_->GetDomain()); @@ -229,16 +229,16 @@ install_attributes_->Init(GetTempPath()); EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode()); // Lock the attributes as if it was done from older Chrome version. - ASSERT_TRUE(cryptohome_util::InstallAttributesSet( + ASSERT_TRUE(tpm_util::InstallAttributesSet( InstallAttributes::kAttrEnterpriseOwned, "true")); - ASSERT_TRUE(cryptohome_util::InstallAttributesSet( + ASSERT_TRUE(tpm_util::InstallAttributesSet( InstallAttributes::kAttrEnterpriseUser, kTestUserDeprecated)); - ASSERT_TRUE(cryptohome_util::InstallAttributesFinalize()); + ASSERT_TRUE(tpm_util::InstallAttributesFinalize()); base::RunLoop loop; install_attributes_->ReadImmutableAttributes(loop.QuitClosure()); loop.Run(); - ASSERT_FALSE(cryptohome_util::InstallAttributesIsFirstInstall()); + ASSERT_FALSE(tpm_util::InstallAttributesIsFirstInstall()); EXPECT_EQ(policy::DEVICE_MODE_ENTERPRISE, install_attributes_->GetMode()); EXPECT_EQ(kTestDomain, install_attributes_->GetDomain()); EXPECT_EQ(std::string(), install_attributes_->GetRealm()); @@ -285,11 +285,11 @@ EXPECT_EQ(policy::DEVICE_MODE_PENDING, install_attributes_->GetMode()); // Write test values. - ASSERT_TRUE(cryptohome_util::InstallAttributesSet( + ASSERT_TRUE(tpm_util::InstallAttributesSet( InstallAttributes::kAttrEnterpriseOwned, "true")); - ASSERT_TRUE(cryptohome_util::InstallAttributesSet( + ASSERT_TRUE(tpm_util::InstallAttributesSet( InstallAttributes::kAttrEnterpriseUser, kTestUserDeprecated)); - ASSERT_TRUE(cryptohome_util::InstallAttributesFinalize()); + ASSERT_TRUE(tpm_util::InstallAttributesFinalize()); // Verify that InstallAttributes correctly decodes the stub cache file. install_attributes_->Init(GetTempPath());
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html index 09abbf0..cb2bfd5 100644 --- a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html +++ b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html
@@ -14,7 +14,6 @@ <link rel="import" href="../controls/settings_toggle_button.html"> <link rel="import" href="../settings_shared_css.html"> <link rel="import" href="chrome_cleanup_proxy.html"> -<link rel="import" href="items_to_remove_list.html"> <dom-module id="settings-chrome-cleanup-page"> <template> @@ -23,6 +22,20 @@ height: 20px; width: 20px; } + + #files-to-remove-container { + padding: 0 var(--settings-box-row-padding); + /* Use the full available width for file paths to avoid inconsistent + * line breaks when zooming in or out */ + width: calc(var(--settings-card-max-width) - + 2 * var(--settings-box-row-padding)); + } + + #files-to-remove-list { + margin: 0; + word-break: break-all; + } + #learn-more { -webkit-margin-start: 0; } @@ -88,8 +101,7 @@ <div hidden="[[!showExplanation_]]"> <span class="secondary">[[explanation_]]</span> <a id="learn-more" href="$i18n{chromeCleanupLearnMoreUrl}" - on-tap="learnMore_" target="_blank" - hidden="[[!showLearnMore_]]"> + on-tap="learnMore_" target="_blank" hidden="[[!showLearnMore_]]"> $i18n{learnMore} </a> </div> @@ -111,33 +123,22 @@ userInitiatedCleanupsEnabled_)]]" on-settings-boolean-control-change="changeLogsPermission_"> </settings-toggle-button> - <div id="show-items-button" class="settings-box" actionable + <div id="show-files-button" class="settings-box" actionable on-tap="toggleExpandButton_" hidden="[[!showItemsToRemove_]]"> - <div class="start">[[showItemsLinkLabel_]]</div> - <cr-expand-button expanded="{{itemsToRemoveSectionExpanded_}}" - alt="[[showItemsLinkLabel_]]"> + <div class="start"> + $i18n{chromeCleanupLinkShowFiles} + </div> + <cr-expand-button expanded="{{filesToRemoveListExpanded_}}" + alt="$i18n{chromeCleanupLinkShowFiles}"> </cr-expand-button> </div> - <iron-collapse id="iron-collapse-items" - opened="[[itemsToRemoveSectionExpanded_]]"> - <items-to-remove-list - id="files-to-remove-list" - hidden="[[!hasFilesToShow_]]" - title-visible="[[userInitiatedCleanupsEnabled_]]" - title="$i18n{chromeCleanupDetailsFilesAndPrograms}" - initially-expanded="[[!userInitiatedCleanupsEnabled_]]" - items-to-show="[[scannerResults_.files]]"> - </items-to-remove-list> - <items-to-remove-list - id="registry-keys-list" - hidden="[[!hasRegistryKeysToShow_]]" - title="$i18n{chromeCleanupDetailsRegistryEntries}" - items-to-show="[[scannerResults_.registryKeys]]"> - </items-to-remove-list> - <div class="settings-box continuation"> - <div class="secondary"> - $i18nRaw{chromeCleanupDetailsExplanation} - </div> + <iron-collapse opened="[[filesToRemoveListExpanded_]]"> + <div id="files-to-remove-container"> + <ul id="files-to-remove-list" class="secondary"> + <template is="dom-repeat" items="[[filesToRemove_]]" as="fileName"> + <li>[[fileName]]</li> + </template> + </ul> </div> <div id="powered-by-settings-box" class="settings-box continuation"> <div id="powered-by-container" class="secondary"
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js index 09f5631..82a4851 100644 --- a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js +++ b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
@@ -99,14 +99,6 @@ settings.ChromeCleanupCardComponents; /** - * @typedef {{ - * files: Array<string>, - * registryKeys: Array<string>, - * }} - */ -settings.ChromeCleanerScannerResults; - -/** * @fileoverview * 'settings-chrome-cleanup-page' is the settings page containing Chrome * Cleanup settings. @@ -125,12 +117,6 @@ properties: { /** @private */ - userInitiatedCleanupsEnabled_: { - type: Boolean, - value: false, - }, - - /** @private */ title_: { type: String, value: '', @@ -189,43 +175,16 @@ }, /** @private */ - itemsToRemoveSectionExpanded_: { + filesToRemoveListExpanded_: { type: Boolean, value: false, - observer: 'itemsToRemoveSectionExpandedChanged_', + observer: 'filesToRemoveListExpandedChanged_', }, /** @private */ - showItemsLinkLabel_: { - type: String, - value: '', - }, - - /** @private */ - showingAllFiles_: { - type: Boolean, - value: false, - }, - - /** @private {!settings.ChromeCleanerScannerResults} */ - scannerResults_: { + filesToRemove_: { type: Array, - value: function() { - return {'files': [], 'registryKeys': []}; - }, - }, - - /** @private */ - hasFilesToShow_: { - type: Boolean, - computed: 'computeHasFilesToShow_(scannerResults_)', - }, - - /** @private */ - hasRegistryKeysToShow_: { - type: Boolean, - computed: 'computeHasRegistryKeysToShow_(' + - 'userInitiatedCleanupsEnabled_, scannerResults_)', + value: [], }, /** @private */ @@ -258,9 +217,6 @@ }, }, - /** @private {!settings.ChromeCleanerScannerResults} */ - emptyChromeCleanerScannerResults_: {'files': [], 'registryKeys': []}, - /** @private {?settings.ChromeCleanupProxy} */ browserProxy_: null, @@ -274,6 +230,9 @@ /** @private {settings.ChromeCleanupOngoingAction} */ ongoingAction_: settings.ChromeCleanupOngoingAction.NONE, + /** @private {boolean} */ + userInitiatedCleanupsEnabled_: false, + /** * If true, the scan offered view is rendered on state idle, regardless of * the idle reason received from the cleaner controller. The goal is to @@ -353,16 +312,16 @@ }, /** - * Notifies Chrome that the details section was opened or closed. + * Notify Chrome that the details section was opened or closed. * @private */ - itemsToRemoveSectionExpandedChanged_: function(newVal, oldVal) { - if (!oldVal && newVal) - this.browserProxy_.notifyShowDetails(this.itemsToRemoveSectionExpanded_); + filesToRemoveListExpandedChanged_: function() { + if (this.browserProxy_) + this.browserProxy_.notifyShowDetails(this.filesToRemoveListExpanded_); }, /** - * Notifies Chrome that the "learn more" link was clicked. + * Notfies Chrome that the "learn more" link was clicked. * @private */ learnMore_: function() { @@ -374,7 +333,7 @@ * @private */ showPoweredBy_: function() { - return this.itemsToRemoveSectionExpanded_ && this.isPartnerPowered_; + return this.filesToRemoveListExpanded_ && this.isPartnerPowered_; }, /** @@ -387,37 +346,12 @@ }, /** - * Returns true if there are files to show to the user. - * @param {!settings.ChromeCleanerScannerResults} scannerResults The cleanup - * items to be presented to the user. - * @return {boolean} - * @private - */ - computeHasFilesToShow_(scannerResults) { - return scannerResults.files.length > 0; - }, - - /** - * Returns true if user-initiated cleanups are enabled and there are registry - * keys to show to the user. - * @param {!settings.ChromeCleanerScannerResults} scannerResults The cleanup - * items to be presented to the user. - * @return {boolean} - * @private - */ - computeHasRegistryKeysToShow_(userInitiatedCleanupsEnabled, scannerResults) { - return userInitiatedCleanupsEnabled && - scannerResults.registryKeys.length > 0; - }, - - /** * Listener of event 'chrome-cleanup-on-idle'. * @param {string} idleReason * @private */ onIdle_: function(idleReason) { this.ongoingAction_ = settings.ChromeCleanupOngoingAction.NONE; - this.scannerResults_ = this.emptyChromeCleanerScannerResults_; // If user-initiated cleanups are disabled, then the card will be shown at // the top of the settings page. @@ -499,7 +433,6 @@ */ onScanning_: function() { this.ongoingAction_ = settings.ChromeCleanupOngoingAction.SCANNING; - this.scannerResults_ = this.emptyChromeCleanerScannerResults_; this.renderScanOfferedByDefault_ = false; this.renderCleanupCard_( this.userInitiatedCleanupsEnabled_ ? @@ -510,32 +443,27 @@ /** * Listener of event 'chrome-cleanup-on-infected'. * Offers a cleanup to the user and enables presenting files to be removed. - * @param {!settings.ChromeCleanerScannerResults} scannerResults The cleanup - * items to be presented to the user. + * @param {!Array<string>} files The list of files to present to the user. * @private */ - onInfected_: function(scannerResults) { + onInfected_: function(files) { this.ongoingAction_ = settings.ChromeCleanupOngoingAction.NONE; this.renderScanOfferedByDefault_ = false; - this.scannerResults_ = scannerResults; - this.updateShowItemsLinklabel_(); - this.renderCleanupCard_(settings.ChromeCleanerCardState.CLEANUP_OFFERED); + this.renderCleanupCard_( + settings.ChromeCleanerCardState.CLEANUP_OFFERED, files); }, /** * Listener of event 'chrome-cleanup-on-cleaning'. * Shows a spinner indicating that an on-going action and enables presenting * files to be removed. - * @param {!settings.ChromeCleanerScannerResults} scannerResults The cleanup - * items to be presented to the user. + * @param {!Array<string>} files The list of files to present to the user. * @private */ - onCleaning_: function(scannerResults) { + onCleaning_: function(files) { this.ongoingAction_ = settings.ChromeCleanupOngoingAction.CLEANING; this.renderScanOfferedByDefault_ = false; - this.scannerResults_ = scannerResults; - this.updateShowItemsLinklabel_(); - this.renderCleanupCard_(settings.ChromeCleanerCardState.CLEANING); + this.renderCleanupCard_(settings.ChromeCleanerCardState.CLEANING, files); }, /** @@ -546,7 +474,6 @@ */ onRebootRequired_: function() { this.ongoingAction_ = settings.ChromeCleanupOngoingAction.NONE; - this.scannerResults_ = this.emptyChromeCleanerScannerResults_; this.renderScanOfferedByDefault_ = false; this.renderCleanupCard_(settings.ChromeCleanerCardState.REBOOT_REQUIRED); }, @@ -555,12 +482,14 @@ * Renders the cleanup card given the state and list of files. * @param {!settings.ChromeCleanerCardState} state The card state to be * rendered. + * @param {Array<string>=} opt_files The list of files to present to the user. * @private */ - renderCleanupCard_: function(state) { + renderCleanupCard_: function(state, opt_files) { var components = this.cardStateToComponentsMap_.get(state); assert(components); + this.filesToRemove_ = opt_files || []; this.title_ = components.title || ''; this.explanation_ = components.explanation || ''; this.updateIcon_(components.icon); @@ -621,8 +550,8 @@ // Files to remove list should only be expandable if details are being // shown, otherwise it will add extra padding at the bottom of the card. - if (!this.showExplanation_ || !this.showItemsToRemove_) - this.itemsToRemoveSectionExpanded_ = false; + if (!this.showExplanation_) + this.filesToRemoveListExpanded_ = false; }, /** @@ -698,25 +627,6 @@ }, /** - * Updates the label for the collapsed detailed view. If user-initiated - * cleanups are enabled, the string is obtained from the browser proxy, since - * it may require a plural version. Otherwise, use the default value for - * |chromeCleanupLinkShowItems|. - */ - updateShowItemsLinklabel_: function() { - var setShowItemsLabel = text => this.showItemsLinkLabel_ = text; - if (this.userInitiatedCleanupsEnabled_) { - this.browserProxy_ - .getItemsToRemovePluralString( - this.scannerResults_.files.length + - this.scannerResults_.registryKeys.length) - .then(setShowItemsLabel); - } else { - setShowItemsLabel(this.i18n('chromeCleanupLinkShowItems')); - } - }, - - /** * Returns the map of card states to components to be rendered. * @return {!Map<settings.ChromeCleanerCardState, * !settings.ChromeCleanupCardComponents>}
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js index c92b662..76b3158 100644 --- a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js +++ b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js
@@ -50,22 +50,6 @@ * Notifies Chrome that the "learn more" link was clicked. */ notifyLearnMoreClicked() {} - - /** - * Requests the plural string for the "show more" link in the detailed - * view for either files to delete or registry keys. - * @param {number} numHiddenItems - * @return {!Promise<string>} - */ - getMoreItemsPluralString(numHiddenItems) {} - - /** - * Requests the plural string for the "items to remove" link in the detailed - * view. - * @param {number} numItems - * @return {!Promise<string>} - */ - getItemsToRemovePluralString(numItems) {} } /** @@ -111,16 +95,6 @@ notifyLearnMoreClicked() { chrome.send('notifyChromeCleanupLearnMoreClicked'); } - - /** @override */ - getMoreItemsPluralString(numHiddenItems) { - return cr.sendWithPromise('getMoreItemsPluralString', numHiddenItems); - } - - /** @override */ - getItemsToRemovePluralString(numItems) { - return cr.sendWithPromise('getItemsToRemovePluralString', numItems); - } } cr.addSingletonGetter(ChromeCleanupProxyImpl);
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp b/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp index b9927717..34c9d87 100644 --- a/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp +++ b/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp
@@ -25,13 +25,5 @@ ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, - { - 'target_name': 'items_to_remove_list', - 'dependencies': [ - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', - 'chrome_cleanup_proxy', - ], - 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], - }, ], }
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html b/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html deleted file mode 100644 index 6f8b7eb..0000000 --- a/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html +++ /dev/null
@@ -1,37 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="chrome_cleanup_proxy.html"> - -<dom-module id="items-to-remove-list"> - <template> - <style include="settings-shared"> - :host { - display: block; - margin: 0; - padding: 0 var(--settings-box-row-padding); - word-break: break-all; - } - - #more-items-link { - color: var(--google-blue-500); - cursor: pointer; - } - </style> - <div id="title" class="secondary" hidden="[[!titleVisible]]"> - [[title]] - </div> - <ul id="list" class="secondary"> - <template is="dom-repeat" items="[[visibleItems_]]"> - <li class="visible-item">[[item]]</li> - </template> - <li id="more-items-link" hidden="[[expanded_]]" on-tap="expandList_"> - [[moreItemsLinkText_]] - </li> - </ul> - </template> - <script src="items_to_remove_list.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js b/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js deleted file mode 100644 index e628437c5..0000000 --- a/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js +++ /dev/null
@@ -1,142 +0,0 @@ -// 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. - -cr.exportPath('settings'); - -/** - * The default number of items to show for files and registry keys on the - * detailed view when user-initiated cleanups are enabled. - */ -settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW = 4; - -/** - * @fileoverview - * 'items-to-remove-list' represents a list of items to - * be removed or changed to be shown on the Chrome Cleanup page. - * TODO(crbug.com/776538): Update the strings to say that some items are only - * changed and not removed. - * - * Examples: - * - * <!-- Items list initially expanded. --> - * <items-to-remove-list - * title="Files and programs:" - * initially-expanded="true" - * items-to-show="[[filesToShow]]"> - * </items-to-remove-list> - * - * <!-- Items list initially shows |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| - * items. If there are more than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| - * items on the list, then a "show more" link is shown; tapping on it - * expands the list. --> - * <items-to-remove-list - * title="Files and programs:" - * items-to-show="[[filesToShow]]"> - * </items-to-remove-list> - */ -Polymer({ - is: 'items-to-remove-list', - - properties: { - titleVisible: { - type: Boolean, - value: true, - }, - - title: { - type: String, - value: '', - }, - - /** @type {!Array<string>} */ - itemsToShow: Array, - - /** - * If true, all items from |itemsToShow| will be presented on the card - * by default, and the "show more" link will be omitted. - */ - initiallyExpanded: { - type: Boolean, - value: false, - }, - - /** - * If true, all items from |itemsToShow| will be presented on the card, - * and the "show more" link will be omitted. - */ - expanded_: { - type: Boolean, - value: false, - }, - - /** - * The list of items to actually present on the card. If |expanded_|, then - * it's the same as |itemsToShow|. - * @private {?Array<string>} - */ - visibleItems_: Array, - - /** - * The text for the "show more" link available if not all files are visible - * in the card. - * @private - */ - moreItemsLinkText_: { - type: String, - value: '', - }, - }, - - observers: ['updateVisibleState_(itemsToShow, initiallyExpanded)'], - - /** @private */ - expandList_: function() { - this.expanded_ = true; - this.visibleItems_ = this.itemsToShow; - this.moreItemsLinkText_ = ''; - }, - - /** - * Decides which elements will be visible in the card and if the "show more" - * link will be rendered. - * - * Cases handled: - * 1. If |initiallyExpanded|, then all items will be visible. - * 2. Otherwise: - * (A) If size(itemsToShow) < CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW, then - * all items will be visible. - * (B) Otherwise, exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1| will - * be visible and the "show more" link will be rendered. The list - * presented to the user will contain exactly - * |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| elements, and the last one - * will be the "show more" link. - * - * @param {!Array<string>} itemsToShow - * @param {boolean} initiallyExpanded - */ - updateVisibleState_: function(itemsToShow, initiallyExpanded) { - // Start expanded if there are less than - // |settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items to show. - this.expanded_ = this.initiallyExpanded || - this.itemsToShow.length <= - settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW; - - if (this.expanded_) { - this.visibleItems_ = this.itemsToShow; - this.moreItemsLinkText_ = ''; - return; - } - - this.visibleItems_ = this.itemsToShow.slice( - 0, settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1); - - const browserProxy = settings.ChromeCleanupProxyImpl.getInstance(); - browserProxy - .getMoreItemsPluralString( - this.itemsToShow.length - this.visibleItems_.length) - .then(linkText => { - this.moreItemsLinkText_ = linkText; - }); - }, -});
diff --git a/chrome/browser/resources/settings/languages_page/languages_page.html b/chrome/browser/resources/settings/languages_page/languages_page.html index a2a2fcc..608022d 100644 --- a/chrome/browser/resources/settings/languages_page/languages_page.html +++ b/chrome/browser/resources/settings/languages_page/languages_page.html
@@ -214,12 +214,12 @@ </div> <!-- |enable_spellchecking| may be set by policy, but if it's enabled, we shouldn't display the policy indicator. --> - <template is="dom-if" if="[[spellCheckDisabled_]]"> + <template is="dom-if" if="[[spellCheckDisabled_]]" restamp> <cr-policy-pref-indicator pref="[[prefs.browser.enable_spellchecking]]"> </cr-policy-pref-indicator> </template> - <template is="dom-if" if="[[!spellCheckDisabled_]]"> + <template is="dom-if" if="[[!spellCheckDisabled_]]" restamp> <cr-expand-button expanded="{{spellCheckOpened_}}" alt="$i18n{spellCheckExpandA11yLabel}"> </cr-expand-button>
diff --git a/chrome/browser/resources/settings/settings_resources.grd b/chrome/browser/resources/settings/settings_resources.grd index 2a5b9f2..f5cc696 100644 --- a/chrome/browser/resources/settings/settings_resources.grd +++ b/chrome/browser/resources/settings/settings_resources.grd
@@ -318,12 +318,6 @@ file="chrome_cleanup_page/chrome_cleanup_page.js" type="chrome_html" preprocess="true" /> - <structure name="IDR_SETTINGS_CHROME_CLEANUP_ITEMS_TO_REMOVE_LIST_HTML" - file="chrome_cleanup_page/items_to_remove_list.html" - type="chrome_html"/> - <structure name="IDR_SETTINGS_CHROME_CLEANUP_ITEMS_TO_REMOVE_LIST_JS" - file="chrome_cleanup_page/items_to_remove_list.js" - type="chrome_html"/> </if> <structure name="IDR_SETTINGS_CLEAR_BROWSING_DATA_BROWSER_PROXY_HTML" file="clear_browsing_data_dialog/clear_browsing_data_browser_proxy.html"
diff --git a/chrome/browser/ui/ash/test_wallpaper_controller.cc b/chrome/browser/ui/ash/test_wallpaper_controller.cc index 4c8adb3..50a901c 100644 --- a/chrome/browser/ui/ash/test_wallpaper_controller.cc +++ b/chrome/browser/ui/ash/test_wallpaper_controller.cc
@@ -35,7 +35,7 @@ wallpaper::WallpaperType type, const SkBitmap& image, bool show_wallpaper) { - NOTIMPLEMENTED(); + set_custom_wallpaper_count_++; } void TestWallpaperController::SetOnlineWallpaper(
diff --git a/chrome/browser/ui/ash/test_wallpaper_controller.h b/chrome/browser/ui/ash/test_wallpaper_controller.h index c7e22ec..77bb6d2 100644 --- a/chrome/browser/ui/ash/test_wallpaper_controller.h +++ b/chrome/browser/ui/ash/test_wallpaper_controller.h
@@ -26,6 +26,7 @@ int set_default_wallpaper_count() const { return set_default_wallpaper_count_; } + int set_custom_wallpaper_count() const { return set_custom_wallpaper_count_; } // Returns a mojo interface pointer bound to this object. ash::mojom::WallpaperControllerPtr CreateInterfacePtr(); @@ -72,6 +73,7 @@ bool was_client_set_ = false; int remove_user_wallpaper_count_ = 0; int set_default_wallpaper_count_ = 0; + int set_custom_wallpaper_count_ = 0; DISALLOW_COPY_AND_ASSIGN(TestWallpaperController); };
diff --git a/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc b/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc index 298c58d2..e01769d 100644 --- a/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc +++ b/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc
@@ -13,17 +13,13 @@ #include "base/metrics/user_metrics_action.h" #include "base/synchronization/lock.h" #include "base/values.h" -#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/component_updater/sw_reporter_installer_win.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" -#include "chrome/grit/generated_resources.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_message_handler.h" -#include "ui/base/l10n/l10n_util.h" using safe_browsing::ChromeCleanerController; @@ -41,36 +37,14 @@ }; // Returns a ListValue containing a copy of the file paths stored in |files|. -std::unique_ptr<base::ListValue> GetFilesAsListStorage( - const std::set<base::FilePath>& files) { - auto value = base::MakeUnique<base::ListValue>(); +base::ListValue GetFilesAsListStorage(const std::set<base::FilePath>& files) { + base::ListValue value; for (const base::FilePath& path : files) - value->AppendString(path.value()); + value.AppendString(path.value()); return value; } -// Returns a ListValue containing a copy of the registry keys stored in -// |registry_keys|. -std::unique_ptr<base::ListValue> GetRegistryKeysAsListStorage( - const std::set<base::string16>& registry_keys) { - auto value = base::MakeUnique<base::ListValue>(); - for (const base::string16& key : registry_keys) - value->AppendString(key); - - return value; -} - -base::DictionaryValue GetScannerResultsAsDictionary( - const safe_browsing::ChromeCleanerScannerResults& scanner_results) { - base::DictionaryValue value; - value.SetList("files", - GetFilesAsListStorage(scanner_results.files_to_delete())); - value.SetList("registryKeys", - GetRegistryKeysAsListStorage(scanner_results.registry_keys())); - return value; -} - std::string IdleReasonToString( ChromeCleanerController::IdleReason idle_reason) { switch (idle_reason) { @@ -141,15 +115,6 @@ base::BindRepeating( &ChromeCleanupHandler::HandleNotifyChromeCleanupLearnMoreClicked, base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getMoreItemsPluralString", - base::BindRepeating(&ChromeCleanupHandler::HandleGetMoreItemsPluralString, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getItemsToRemovePluralString", - base::BindRepeating( - &ChromeCleanupHandler::HandleGetItemsToRemovePluralString, - base::Unretained(this))); } void ChromeCleanupHandler::OnJavascriptAllowed() { @@ -177,13 +142,13 @@ void ChromeCleanupHandler::OnInfected( const safe_browsing::ChromeCleanerScannerResults& scanner_results) { FireWebUIListener("chrome-cleanup-on-infected", - GetScannerResultsAsDictionary(scanner_results)); + GetFilesAsListStorage(scanner_results.files_to_delete())); } void ChromeCleanupHandler::OnCleaning( const safe_browsing::ChromeCleanerScannerResults& scanner_results) { FireWebUIListener("chrome-cleanup-on-cleaning", - GetScannerResultsAsDictionary(scanner_results)); + GetFilesAsListStorage(scanner_results.files_to_delete())); } void ChromeCleanupHandler::OnRebootRequired() { @@ -324,34 +289,4 @@ base::UserMetricsAction("SoftwareReporter.CleanupWebui_LearnMore")); } -void ChromeCleanupHandler::HandleGetMoreItemsPluralString( - const base::ListValue* args) { -#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) - GetPluralString(IDS_SETTINGS_RESET_CLEANUP_DETAILS_MORE, args); -#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) -} - -void ChromeCleanupHandler::HandleGetItemsToRemovePluralString( - const base::ListValue* args) { -#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) - GetPluralString(IDS_SETTINGS_RESET_CLEANUP_DETAILS_ITEMS_TO_BE_REMOVED, args); -#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) -} - -void ChromeCleanupHandler::GetPluralString(int id, - const base::ListValue* args) { - CHECK_EQ(2U, args->GetSize()); - - std::string callback_id; - CHECK(args->GetString(0, &callback_id)); - - int num_items = 0; - args->GetInteger(1, &num_items); - DCHECK_GT(0, num_items); - - ResolveJavascriptCallback( - base::Value(callback_id), - base::Value(l10n_util::GetPluralStringFUTF16(id, num_items))); -} - } // namespace settings
diff --git a/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h b/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h index c0d2a83..c0d61a2 100644 --- a/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h +++ b/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h
@@ -76,16 +76,6 @@ // the "learn more" link was clicked. void HandleNotifyChromeCleanupLearnMoreClicked(const base::ListValue* args); - // Callback for the "getMoreItemsPluralString" message, that obtains the text - // string for the "show more" items on the detailed view. - void HandleGetMoreItemsPluralString(const base::ListValue* args); - - // Callback for the "getItemsToRemovePluralString" message, that obtains the - // text string for the detailed view when user-initiated cleanups are enabled. - void HandleGetItemsToRemovePluralString(const base::ListValue* args); - - void GetPluralString(int id, const base::ListValue* args); - // Raw pointer to a singleton. Must outlive this object. safe_browsing::ChromeCleanerController* controller_;
diff --git a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc index 4767004..8243e46 100644 --- a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
@@ -763,7 +763,7 @@ IDS_SETTINGS_RESET_CLEANUP_EXPLANATION_SCAN_ERROR}, {"chromeCleanupFindButtonLable", IDS_SETTINGS_RESET_CLEANUP_FIND_BUTTON_LABEL}, - {"chromeCleanupLinkShowItems", + {"chromeCleanupLinkShowFiles", IDS_SETTINGS_RESET_CLEANUP_LINK_SHOW_FILES}, {"chromeCleanupLogsUploadPermission", IDS_CHROME_CLEANUP_LOGS_PERMISSION}, {"chromeCleanupRemoveButtonLabel",
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py index e4fb129..25e3861 100755 --- a/chrome/test/chromedriver/test/run_py_tests.py +++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -90,17 +90,26 @@ ] _VERSION_SPECIFIC_FILTER['64'] = [ + # These tests are implemented to run on the latest versions of Chrome > 64 + 'HeadlessInvalidCertificateTest.*', # https://bugs.chromium.org/p/chromedriver/issues/detail?id=2025 'ChromeDriverTest.testDoesntHangOnFragmentNavigation', ] _VERSION_SPECIFIC_FILTER['63'] = [ + # These tests are implemented to run on the latest versions of Chrome > 64 + 'HeadlessInvalidCertificateTest.*', # https://bugs.chromium.org/p/chromedriver/issues/detail?id=2025 'ChromeDriverTest.testDoesntHangOnFragmentNavigation', 'ChromeDriverPageLoadTimeoutTest.testHistoryNavigationWithPageLoadTimeout', 'ChromeDriverPageLoadTimeoutTest.testRefreshWithPageLoadTimeout', ] +_VERSION_SPECIFIC_FILTER['62'] = [ + # These tests are implemented to run on the latest versions of Chrome > 64 + 'HeadlessInvalidCertificateTest.*', +] + _OS_SPECIFIC_FILTER = {} _OS_SPECIFIC_FILTER['win'] = [ # https://bugs.chromium.org/p/chromedriver/issues/detail?id=299 @@ -206,6 +215,9 @@ ) _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = ( _ANDROID_NEGATIVE_FILTER['chrome'] + [ + # Tests in HeadlessInvalidCertificateTest class can't be run + # on chromedriver_webview_shell + 'HeadlessInvalidCertificateTest.*', 'ChromeLoggingCapabilityTest.testPerformanceLogger', 'ChromeDriverTest.testShadowDom*', # WebView doesn't support emulating network conditions.
diff --git a/chrome/test/data/webui/settings/chrome_cleanup_page_test.js b/chrome/test/data/webui/settings/chrome_cleanup_page_test.js index 5b14b74..7f3c7a7 100644 --- a/chrome/test/data/webui/settings/chrome_cleanup_page_test.js +++ b/chrome/test/data/webui/settings/chrome_cleanup_page_test.js
@@ -14,8 +14,6 @@ 'startScanning', 'notifyShowDetails', 'notifyLearnMoreClicked', - 'getMoreItemsPluralString', - 'getItemsToRemovePluralString', ]); } @@ -58,18 +56,6 @@ notifyLearnMoreClicked() { this.methodCalled('notifyLearnMoreClicked'); } - - /** @override */ - getMoreItemsPluralString(numHiddenItems) { - this.methodCalled('getMoreItemsPluralString', numHiddenItems); - return Promise.resolve(''); - } - - /** @override */ - getItemsToRemovePluralString(numItems) { - this.methodCalled('getItemsToRemovePluralString', numItems); - return Promise.resolve(''); - } } var chromeCleanupPage = null; @@ -77,23 +63,6 @@ /** @type {?TestDownloadsBrowserProxy} */ var ChromeCleanupProxy = null; -var shortFileList = ['file 1', 'file 2', 'file 3']; -var exactSizeFileList = ['file 1', 'file 2', 'file 3', 'file 4']; -var longFileList = ['file 1', 'file 2', 'file 3', 'file 4', 'file 5']; -var shortRegistryKeysList = ['key 1', 'key 2']; -var exactSizeRegistryKeysList = ['key 1', 'key 2', 'key 3', 'key 4']; -var longRegistryKeysList = - ['key 1', 'key 2', 'key 3', 'key 4', 'key 5', 'key 6']; - -var defaultScannerResults = { - 'files': shortFileList, - 'registryKeys': shortRegistryKeysList, -}; - -/** - * @param {boolean} userInitiatedCleanupsEnabled Whether the user initiated - * cleanup feature is enabled. - */ function initParametrizedTest(userInitiatedCleanupsEnabled) { ChromeCleanupProxy = new TestChromeCleanupProxy(); settings.ChromeCleanupProxyImpl.instance_ = ChromeCleanupProxy; @@ -108,74 +77,18 @@ document.body.appendChild(chromeCleanupPage); } -/** - * @param {!Array} originalItems - * @param {!Array} visibleItems - * @param {boolean} listCanBeShortened - */ -function validateVisibleItemsList( - originalItems, visibleItems, listCanBeShortened) { - var visibleItemsList = visibleItems.querySelectorAll('.visible-item'); - var showMoreItems = visibleItems.querySelector('#show-more-items'); - - if (!listCanBeShortened || - originalItems.length <= settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW) { - assertEquals(visibleItemsList.length, originalItems.length); - assertTrue(showMoreItems.hidden); - } else { - assertEquals( - visibleItemsList.length, - settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1); - assertFalse(showMoreItems.hidden); - - // Tapping on the "show more" link should expand the list. - var link = showMoreItems.querySelector('a'); - MockInteractions.tap(link); - Polymer.dom.flush(); - - visibleItemsList = visibleItems.querySelectorAll('.visible-item'); - assertEquals(visibleItemsList.length, originalItems.length); - assertTrue(showMoreItems.hidden); - } -} - -/** - * @param {boolean} userInitiatedCleanupsEnabled Whether the user initiated - * cleanup feature is enabled. - * @param {!Array} files The list of files to be cleaned - * @param {!Array} registryKeys The list of registry entires to be cleaned. - */ -function startCleanupFromInfected( - userInitiatedCleanupsEnabled, files, registryKeys) { - var scannerResults = {'files': files, 'registryKeys': registryKeys}; - +function startCleanupFromInfected() { cr.webUIListenerCallback('chrome-cleanup-upload-permission-change', false); - cr.webUIListenerCallback('chrome-cleanup-on-infected', scannerResults); + cr.webUIListenerCallback( + 'chrome-cleanup-on-infected', ['file 1', 'file 2', 'file 3']); Polymer.dom.flush(); - var showItemsButton = chromeCleanupPage.$$('#show-items-button'); - assertTrue(!!showItemsButton); - MockInteractions.tap(showItemsButton); - - var filesToRemoveList = - chromeCleanupPage.$$('#files-to-remove-list').$$('#list'); - assertTrue(!!filesToRemoveList); - validateVisibleItemsList( - files, filesToRemoveList, - userInitiatedCleanupsEnabled /* listCanBeShortened */); - - var registryKeysListContainer = chromeCleanupPage.$$('#registry-keys-list'); - assertTrue(!!registryKeysListContainer); - if (userInitiatedCleanupsEnabled && registryKeys.length > 0) { - assertFalse(registryKeysListContainer.hidden); - var registryKeysList = registryKeysListContainer.$$('#list'); - assertTrue(!!registryKeysList); - validateVisibleItemsList( - registryKeys, registryKeysList, - true /* listCanBeShortened */); - } else { - assertTrue(registryKeysListContainer.hidden); - } + var showFilesButton = chromeCleanupPage.$$('#show-files-button'); + assertTrue(!!showFilesButton); + MockInteractions.tap(showFilesButton); + filesToRemove = chromeCleanupPage.$$('#files-to-remove-list'); + assertTrue(!!filesToRemove); + assertEquals(filesToRemove.getElementsByTagName('li').length, 3); var actionButton = chromeCleanupPage.$$('#action-button'); assertTrue(!!actionButton); @@ -183,8 +96,7 @@ return ChromeCleanupProxy.whenCalled('startCleanup') .then(function(logsUploadEnabled) { assertFalse(logsUploadEnabled); - cr.webUIListenerCallback( - 'chrome-cleanup-on-cleaning', defaultScannerResults); + cr.webUIListenerCallback('chrome-cleanup-on-cleaning', false); Polymer.dom.flush(); var spinner = chromeCleanupPage.$$('#waiting-spinner'); @@ -202,13 +114,9 @@ return ChromeCleanupProxy.whenCalled('restartComputer'); } -/** - * @param {boolean} userInitiatedCleanupsEnabled Whether the user initiated - * cleanup feature is enabled. - */ function cleanupFailure(userInitiatedCleanupsEnabled) { cr.webUIListenerCallback('chrome-cleanup-upload-permission-change', false); - cr.webUIListenerCallback('chrome-cleanup-on-cleaning', defaultScannerResults); + cr.webUIListenerCallback('chrome-cleanup-on-cleaning', false); cr.webUIListenerCallback( 'chrome-cleanup-on-idle', settings.ChromeCleanupIdleReason.CLEANING_FAILED); @@ -224,12 +132,8 @@ } } -/** - * @param {boolean} userInitiatedCleanupsEnabled Whether the user initiated - * cleanup feature is enabled. - */ function cleanupSuccess(userInitiatedCleanupsEnabled) { - cr.webUIListenerCallback('chrome-cleanup-on-cleaning', defaultScannerResults); + cr.webUIListenerCallback('chrome-cleanup-on-cleaning', false); cr.webUIListenerCallback( 'chrome-cleanup-on-idle', settings.ChromeCleanupIdleReason.CLEANING_SUCCEEDED); @@ -245,14 +149,10 @@ } } -/** - * @param {boolean} testingScanOffered Whether to test the case where scanning - * is offered to the user. - */ function testLogsUploading(testingScanOffered) { if (testingScanOffered) { cr.webUIListenerCallback( - 'chrome-cleanup-on-infected', defaultScannerResults); + 'chrome-cleanup-on-infected', ['file 1', 'file 2', 'file 3']); } else { cr.webUIListenerCallback( 'chrome-cleanup-on-idle', settings.ChromeCleanupIdleReason.INITIAL); @@ -279,78 +179,11 @@ suite('ChromeCleanupHandler_UserInitiatedCleanupsDisabled', function() { setup(function() { - initParametrizedTest(false /* userInitiatedCleanupsEnabled */); + initParametrizedTest(false); }); - test('startCleanupFromInfected_FewFilesNoRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, shortFileList, []); - }); - - test('startCleanupFromInfected_FewFilesFewRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, shortFileList, - shortRegistryKeysList); - }); - - test('startCleanupFromInfected_FewFilesExactSizeRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, shortFileList, - exactSizeRegistryKeysList); - }); - - test('startCleanupFromInfected_FewFilesManyRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, shortFileList, - longRegistryKeysList); - }); - - test('startCleanupFromInfected_ExactSizeFilesNoRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, exactSizeFileList, []); - }); - - test('startCleanupFromInfected_ExactSizeFilesFewRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, exactSizeFileList, - shortRegistryKeysList); - }); - - test( - 'startCleanupFromInfected_ExactSizeFilesExactSizeRegistryKeys', - function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, exactSizeFileList, - exactSizeRegistryKeysList); - }); - - test('startCleanupFromInfected_ExactSizeFilesManyRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, exactSizeFileList, - longRegistryKeysList); - }); - - test('startCleanupFromInfected_ManyFilesNoRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, longFileList, []); - }); - - test('startCleanupFromInfected_ManyFilesFewRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, longFileList, - shortRegistryKeysList); - }); - - test('startCleanupFromInfected_ManyFilesExactSizeRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, longFileList, - exactSizeRegistryKeysList); - }); - - test('startCleanupFromInfected_ManyFilesManyRegistryKeys', function() { - return startCleanupFromInfected( - false /* userInitiatedCleanupsEnabled */, longFileList, - longRegistryKeysList); + test('startCleanupFromInfected', function() { + return startCleanupFromInfected(); }); test('rebootFromRebootRequired', function() { @@ -358,21 +191,21 @@ }); test('cleanupFailure', function() { - return cleanupFailure(false /* userInitiatedCleanupsEnabled */); + return cleanupFailure(false); }); test('cleanupSuccess', function() { - return cleanupSuccess(false /* userInitiatedCleanupsEnabled */); + return cleanupSuccess(false); }); test('logsUploadingOnInfected', function() { - return testLogsUploading(false /* testingScanOffered */); + return testLogsUploading(false); }); }); suite('ChromeCleanupHandler_UserInitiatedCleanupsEnabled', function() { setup(function() { - initParametrizedTest(true /* userInitiatedCleanupsEnabled */); + initParametrizedTest(true); }); function scanOfferedOnInitiallyIdle(idleReason) { @@ -487,75 +320,8 @@ assertFalse(!!actionButton); }); - test('startCleanupFromInfected_FewFilesNoRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, shortFileList, []); - }); - - test('startCleanupFromInfected_FewFilesFewRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, shortFileList, - shortRegistryKeysList); - }); - - test('startCleanupFromInfected_FewFilesExactSizeRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, shortFileList, - exactSizeRegistryKeysList); - }); - - test('startCleanupFromInfected_FewFilesManyRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, shortFileList, - longRegistryKeysList); - }); - - test('startCleanupFromInfected_ExactSizeFilesNoRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, exactSizeFileList, []); - }); - - test('startCleanupFromInfected_ExactSizeFilesFewRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, exactSizeFileList, - shortRegistryKeysList); - }); - - test( - 'startCleanupFromInfected_ExactSizeFilesExactSizeRegistryKeys', - function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, exactSizeFileList, - exactSizeRegistryKeysList); - }); - - test('startCleanupFromInfected_ExactSizeFilesManyRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, exactSizeFileList, - longRegistryKeysList); - }); - - test('startCleanupFromInfected_ManyFilesNoRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, longFileList, []); - }); - - test('startCleanupFromInfected_ManyFilesFewRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, longFileList, - shortRegistryKeysList); - }); - - test('startCleanupFromInfected_ManyFilesExactSizeRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, longFileList, - exactSizeRegistryKeysList); - }); - - test('startCleanupFromInfected_ManyFilesManyRegistryKeys', function() { - return startCleanupFromInfected( - true /* userInitiatedCleanupsEnabled */, longFileList, - longRegistryKeysList); + test('startCleanupFromInfected', function() { + return startCleanupFromInfected(); }); test('rebootFromRebootRequired', function() { @@ -563,18 +329,18 @@ }); test('cleanupFailure', function() { - return cleanupFailure(true /* userInitiatedCleanupsEnabled */); + return cleanupFailure(true); }); test('cleanupSuccess', function() { - return cleanupSuccess(true /* userInitiatedCleanupsEnabled */); + return cleanupSuccess(true); }); test('logsUploadingOnScanOffered', function() { - return testLogsUploading(true /* testingScanOffered */); + return testLogsUploading(true); }); test('logsUploadingOnInfected', function() { - return testLogsUploading(false /* testingScanOffered */); + return testLogsUploading(false); }); });
diff --git a/chrome/test/data/webui/settings/languages_page_tests.js b/chrome/test/data/webui/settings/languages_page_tests.js index 4c0fe197..df11e26 100644 --- a/chrome/test/data/webui/settings/languages_page_tests.js +++ b/chrome/test/data/webui/settings/languages_page_tests.js
@@ -459,6 +459,13 @@ // The policy indicator should be present. assertTrue(!!triggerRow.querySelector('cr-policy-pref-indicator')); + + // Force-enable spellchecking via policy, and ensure that the policy + // indicator is not present. |enable_spellchecking| can be forced to + // true by policy, but no indicator should be shown in that case. + languageHelper.setPrefValue('browser.enable_spellchecking', true); + Polymer.dom.flush(); + assertFalse(!!triggerRow.querySelector('cr-policy-pref-indicator')); } }); });
diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn index 93b7d8d..661b58a 100644 --- a/chromeos/BUILD.gn +++ b/chromeos/BUILD.gn
@@ -120,12 +120,12 @@ "cryptohome/async_method_caller.h", "cryptohome/cryptohome_parameters.cc", "cryptohome/cryptohome_parameters.h", - "cryptohome/cryptohome_util.cc", - "cryptohome/cryptohome_util.h", "cryptohome/homedir_methods.cc", "cryptohome/homedir_methods.h", "cryptohome/system_salt_getter.cc", "cryptohome/system_salt_getter.h", + "cryptohome/tpm_util.cc", + "cryptohome/tpm_util.h", "dbus/arc_midis_client.cc", "dbus/arc_midis_client.h", "dbus/arc_obb_mounter_client.cc",
diff --git a/chromeos/cryptohome/cryptohome_util.cc b/chromeos/cryptohome/tpm_util.cc similarity index 61% rename from chromeos/cryptohome/cryptohome_util.cc rename to chromeos/cryptohome/tpm_util.cc index 7d057b1..5a9881f 100644 --- a/chromeos/cryptohome/cryptohome_util.cc +++ b/chromeos/cryptohome/tpm_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/cryptohome/tpm_util.h" #include <stdint.h> @@ -11,7 +11,7 @@ #include "chromeos/dbus/dbus_thread_manager.h" namespace chromeos { -namespace cryptohome_util { +namespace tpm_util { bool TpmIsEnabled() { bool result = false; @@ -29,17 +29,16 @@ bool TpmIsBeingOwned() { bool result = false; - DBusThreadManager::Get()->GetCryptohomeClient()-> - CallTpmIsBeingOwnedAndBlock(&result); + DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsBeingOwnedAndBlock( + &result); return result; } -bool InstallAttributesGet( - const std::string& name, std::string* value) { +bool InstallAttributesGet(const std::string& name, std::string* value) { std::vector<uint8_t> buf; bool success = false; - DBusThreadManager::Get()->GetCryptohomeClient()-> - InstallAttributesGet(name, &buf, &success); + DBusThreadManager::Get()->GetCryptohomeClient()->InstallAttributesGet( + name, &buf, &success); if (success) { // Cryptohome returns 'buf' with a terminating '\0' character. DCHECK(!buf.empty()); @@ -49,35 +48,35 @@ return success; } -bool InstallAttributesSet( - const std::string& name, const std::string& value) { +bool InstallAttributesSet(const std::string& name, const std::string& value) { std::vector<uint8_t> buf(value.c_str(), value.c_str() + value.size() + 1); bool success = false; - DBusThreadManager::Get()->GetCryptohomeClient()-> - InstallAttributesSet(name, buf, &success); + DBusThreadManager::Get()->GetCryptohomeClient()->InstallAttributesSet( + name, buf, &success); return success; } bool InstallAttributesFinalize() { bool success = false; - DBusThreadManager::Get()->GetCryptohomeClient()-> - InstallAttributesFinalize(&success); + DBusThreadManager::Get()->GetCryptohomeClient()->InstallAttributesFinalize( + &success); return success; } bool InstallAttributesIsInvalid() { bool result = false; - DBusThreadManager::Get()->GetCryptohomeClient()-> - InstallAttributesIsInvalid(&result); + DBusThreadManager::Get()->GetCryptohomeClient()->InstallAttributesIsInvalid( + &result); return result; } bool InstallAttributesIsFirstInstall() { bool result = false; - DBusThreadManager::Get()->GetCryptohomeClient()-> - InstallAttributesIsFirstInstall(&result); + DBusThreadManager::Get() + ->GetCryptohomeClient() + ->InstallAttributesIsFirstInstall(&result); return result; } -} // namespace cryptohome_util +} // namespace tpm_util } // namespace chromeos
diff --git a/chromeos/cryptohome/cryptohome_util.h b/chromeos/cryptohome/tpm_util.h similarity index 84% rename from chromeos/cryptohome/cryptohome_util.h rename to chromeos/cryptohome/tpm_util.h index bc47625..d3b7d58 100644 --- a/chromeos/cryptohome/cryptohome_util.h +++ b/chromeos/cryptohome/tpm_util.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_UTIL_H_ -#define CHROMEOS_CRYPTOHOME_CRYPTOHOME_UTIL_H_ +#ifndef CHROMEOS_CRYPTOHOME_TPM_UTIL_H_ +#define CHROMEOS_CRYPTOHOME_TPM_UTIL_H_ #include <string> @@ -13,7 +13,7 @@ // Wrappers of the D-Bus method calls for working with Tpm. Note that all of // these are blocking and thus must not be called on the UI thread! -namespace cryptohome_util { +namespace tpm_util { // Returns whether Tpm is presented and enabled. CHROMEOS_EXPORT bool TpmIsEnabled(); @@ -32,7 +32,7 @@ CHROMEOS_EXPORT bool InstallAttributesIsInvalid(); CHROMEOS_EXPORT bool InstallAttributesIsFirstInstall(); -} // namespace cryptohome_util +} // namespace tpm_util } // namespace chromeos -#endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_UTIL_H_ +#endif // CHROMEOS_CRYPTOHOME_TPM_UTIL_H_
diff --git a/chromeos/dbus/fake_auth_policy_client.cc b/chromeos/dbus/fake_auth_policy_client.cc index fc0a1e1a..97f890b 100644 --- a/chromeos/dbus/fake_auth_policy_client.cc +++ b/chromeos/dbus/fake_auth_policy_client.cc
@@ -19,7 +19,6 @@ #include "base/threading/thread_task_runner_handle.h" #include "chromeos/chromeos_paths.h" #include "chromeos/cryptohome/cryptohome_parameters.h" -#include "chromeos/cryptohome/cryptohome_util.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/session_manager_client.h"
diff --git a/chromeos/login/auth/authpolicy_login_helper.cc b/chromeos/login/auth/authpolicy_login_helper.cc index cd17676..1d28b2cc 100644 --- a/chromeos/login/auth/authpolicy_login_helper.cc +++ b/chromeos/login/auth/authpolicy_login_helper.cc
@@ -8,14 +8,13 @@ #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/task_scheduler/post_task.h" -#include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/cryptohome/tpm_util.h" #include "chromeos/dbus/auth_policy_client.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/upstart_client.h" namespace chromeos { -namespace cu = cryptohome_util; namespace { @@ -96,17 +95,17 @@ bool AuthPolicyLoginHelper::IsAdLocked() { std::string mode; - return chromeos::cryptohome_util::InstallAttributesGet(kAttrMode, &mode) && + return chromeos::tpm_util::InstallAttributesGet(kAttrMode, &mode) && mode == kDeviceModeEnterpriseAD; } // static bool AuthPolicyLoginHelper::LockDeviceActiveDirectoryForTesting( const std::string& realm) { - return cu::InstallAttributesSet("enterprise.owned", "true") && - cu::InstallAttributesSet(kAttrMode, kDeviceModeEnterpriseAD) && - cu::InstallAttributesSet("enterprise.realm", realm) && - cu::InstallAttributesFinalize(); + return tpm_util::InstallAttributesSet("enterprise.owned", "true") && + tpm_util::InstallAttributesSet(kAttrMode, kDeviceModeEnterpriseAD) && + tpm_util::InstallAttributesSet("enterprise.realm", realm) && + tpm_util::InstallAttributesFinalize(); } void AuthPolicyLoginHelper::JoinAdDomain(const std::string& machine_name,
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 75ddcc2..9dd62bae6 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc
@@ -380,8 +380,10 @@ // Don't grant further access to GPU if it is not allowed. GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); DCHECK(gpu_data_manager); - if (!gpu_data_manager->GpuAccessAllowed(nullptr)) + if (!gpu_data_manager->GpuAccessAllowed(nullptr)) { + DLOG(ERROR) << "!GpuDataManagerImpl::GpuAccessAllowed()"; return nullptr; + } if (g_gpu_process_hosts[kind] && ValidateHost(g_gpu_process_hosts[kind])) return g_gpu_process_hosts[kind]; @@ -390,8 +392,10 @@ return nullptr; // Do not create a new process if browser is shutting down. - if (BrowserMainRunner::ExitedMainMessageLoop()) + if (BrowserMainRunner::ExitedMainMessageLoop()) { + DLOG(ERROR) << "BrowserMainRunner::ExitedMainMessageLoop()"; return nullptr; + } static int last_host_id = 0; int host_id; @@ -406,6 +410,7 @@ host->RecordProcessCrash(); delete host; + DLOG(ERROR) << "GpuProcessHost::Init() failed"; return nullptr; }
diff --git a/content/browser/webauth/cbor/cbor_reader.cc b/content/browser/webauth/cbor/cbor_reader.cc index fa4e0576..f0abecb 100644 --- a/content/browser/webauth/cbor/cbor_reader.cc +++ b/content/browser/webauth/cbor/cbor_reader.cc
@@ -5,6 +5,8 @@ #include "content/browser/webauth/cbor/cbor_reader.h" #include <math.h> +#include <utility> + #include "base/numerics/safe_conversions.h" #include "base/stl_util.h" #include "base/strings/string_util.h" @@ -41,6 +43,10 @@ "order."; const char kNonMinimalCBOREncoding[] = "Unsigned integers must be encoded with minimum number of bytes."; +const char kUnsupportedSimpleValue[] = + "Unsupported or unassigned simple value."; +const char kUnsupportedFloatingPointValue[] = + "Floating point numbers are not supported."; } // namespace @@ -95,6 +101,8 @@ return ReadCBORArray(length, max_nesting_level); case CBORValue::Type::MAP: return ReadCBORMap(length, max_nesting_level); + case CBORValue::Type::SIMPLE_VALUE: + return ReadSimpleValue(additional_info, length); case CBORValue::Type::NONE: break; } @@ -103,10 +111,10 @@ return base::nullopt; } -bool CBORReader::ReadUnsignedInt(int additional_info, uint64_t* length) { +bool CBORReader::ReadUnsignedInt(uint8_t additional_info, uint64_t* value) { uint8_t additional_bytes = 0; if (additional_info < 24) { - *length = additional_info; + *value = additional_info; return true; } else if (additional_info == 24) { additional_bytes = 1; @@ -132,10 +140,33 @@ int_data |= *it_++; } - *length = int_data; + *value = int_data; return CheckUintEncodedByteLength(additional_bytes, int_data); } +base::Optional<CBORValue> CBORReader::ReadSimpleValue(uint8_t additional_info, + uint64_t value) { + // Floating point numbers are not supported. + if (additional_info > 24 && additional_info < 28) { + error_code_ = DecoderError::UNSUPPORTED_FLOATING_POINT_VALUE; + return base::nullopt; + } + + CHECK_LE(value, 255u); + CBORValue::SimpleValue possibly_unsupported_simple_value = + static_cast<CBORValue::SimpleValue>(static_cast<int>(value)); + switch (possibly_unsupported_simple_value) { + case CBORValue::SimpleValue::FALSE_VALUE: + case CBORValue::SimpleValue::TRUE_VALUE: + case CBORValue::SimpleValue::NULL_VALUE: + case CBORValue::SimpleValue::UNDEFINED: + return CBORValue(possibly_unsupported_simple_value); + } + + error_code_ = DecoderError::UNSUPPORTED_SIMPLE_VALUE; + return base::nullopt; +} + base::Optional<CBORValue> CBORReader::ReadString(uint64_t num_bytes) { if (!CanConsume(num_bytes)) { error_code_ = DecoderError::INCOMPLETE_CBOR_DATA; @@ -278,6 +309,10 @@ return kMapKeyOutOfOrder; case DecoderError::NON_MINIMAL_CBOR_ENCODING: return kNonMinimalCBOREncoding; + case DecoderError::UNSUPPORTED_SIMPLE_VALUE: + return kUnsupportedSimpleValue; + case DecoderError::UNSUPPORTED_FLOATING_POINT_VALUE: + return kUnsupportedFloatingPointValue; default: NOTREACHED(); return "Unknown error code.";
diff --git a/content/browser/webauth/cbor/cbor_reader.h b/content/browser/webauth/cbor/cbor_reader.h index d7b827b..e831676 100644 --- a/content/browser/webauth/cbor/cbor_reader.h +++ b/content/browser/webauth/cbor/cbor_reader.h
@@ -23,6 +23,7 @@ // * 3: UTF-8 strings. // * 4: Definite-length arrays. // * 5: Definite-length maps. +// * 7: Simple values. // // Requirements for canonical CBOR representation: // - Duplicate keys for map are not allowed. @@ -30,8 +31,9 @@ // lexical order. // // Known limitations and interpretations of the RFC: -// - Does not support negative integers, floating point numbers, indefinite -// data streams and tagging. +// - Does not support negative integers, indefinite data streams and tagging. +// - Floating point representations and BREAK stop code in major +// type 7 are not supported. // - Non-character codepoint are not supported for Major type 3. // - Incomplete CBOR data items are treated as syntax errors. // - Trailing data bytes are treated as errors. @@ -41,6 +43,8 @@ // by setting |max_nesting_level|. // - Only CBOR maps with integer or string type keys are supported due to the // cost of serialization when sorting map keys. +// - Simple values that are unassigned/reserved as per RFC 7049 are not +// supported and treated as errors. namespace content { @@ -60,6 +64,8 @@ DUPLICATE_KEY, OUT_OF_ORDER_KEY, NON_MINIMAL_CBOR_ENCODING, + UNSUPPORTED_SIMPLE_VALUE, + UNSUPPORTED_FLOATING_POINT_VALUE, }; // CBOR nested depth sufficient for most use cases. @@ -82,7 +88,9 @@ private: CBORReader(Bytes::const_iterator it, const Bytes::const_iterator end); base::Optional<CBORValue> DecodeCBOR(int max_nesting_level); - bool ReadUnsignedInt(int additional_info, uint64_t* length); + bool ReadUnsignedInt(uint8_t additional_info, uint64_t* length); + base::Optional<CBORValue> ReadSimpleValue(uint8_t additional_info, + uint64_t value); base::Optional<CBORValue> ReadBytes(uint64_t num_bytes); base::Optional<CBORValue> ReadString(uint64_t num_bytes); base::Optional<CBORValue> ReadCBORArray(uint64_t length,
diff --git a/content/browser/webauth/cbor/cbor_reader_unittest.cc b/content/browser/webauth/cbor/cbor_reader_unittest.cc index 38663681..396d76f 100644 --- a/content/browser/webauth/cbor/cbor_reader_unittest.cc +++ b/content/browser/webauth/cbor/cbor_reader_unittest.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <utility> + #include "content/browser/webauth/cbor/cbor_reader.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -102,7 +104,7 @@ static const ByteTestCase kByteStringTestCases[] = { // clang-format off {{}, {0x40}}, - {{0x01, 0x02, 0x03, 0x04},{0x44, 0x01, 0x02, 0x03, 0x04}}, + {{0x01, 0x02, 0x03, 0x04}, {0x44, 0x01, 0x02, 0x03, 0x04}}, // clang-format on }; @@ -224,7 +226,7 @@ // clang-format off 0xa4, // map with 4 key value pairs: 0x18, 0x18, // 24 - 0x63, 0x61, 0x62, 0x63, // "abc" + 0x63, 0x61, 0x62, 0x63, // "abc" 0x60, // "" 0x61, 0x2e, // "." @@ -405,6 +407,51 @@ EXPECT_EQ(nested_map.GetMap().find(key_d)->second.GetUnsigned(), 3u); } +TEST(CBORReaderTest, TestReadSimpleValue) { + static const struct { + const CBORValue::SimpleValue value; + const std::vector<uint8_t> cbor_data; + } kSimpleValueTestCases[] = { + {CBORValue::SimpleValue::FALSE_VALUE, {0xf4}}, + {CBORValue::SimpleValue::TRUE_VALUE, {0xf5}}, + {CBORValue::SimpleValue::NULL_VALUE, {0xf6}}, + {CBORValue::SimpleValue::UNDEFINED, {0xf7}}, + }; + + int test_element_index = 0; + for (const auto& test_case : kSimpleValueTestCases) { + SCOPED_TRACE(testing::Message() + << "testing simple value at index : " << test_element_index++); + + base::Optional<CBORValue> cbor = CBORReader::Read(test_case.cbor_data); + ASSERT_TRUE(cbor.has_value()); + ASSERT_EQ(cbor.value().type(), CBORValue::Type::SIMPLE_VALUE); + EXPECT_EQ(cbor.value().GetSimpleValue(), test_case.value); + } +} + +TEST(CBORReaderTest, TestReadUnsupportedFloatingPointNumbers) { + static const std::vector<uint8_t> floating_point_cbors[] = { + // 16 bit floating point value. + {0xf9, 0x10, 0x00}, + // 32 bit floating point value. + {0xfa, 0x10, 0x00, 0x00, 0x00}, + // 64 bit floating point value. + {0xfb, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + + for (const auto& unsupported_floating_point : floating_point_cbors) { + SCOPED_TRACE(testing::Message() + << "testing unsupported floating point : " + << testing::PrintToString(unsupported_floating_point)); + CBORReader::DecoderError error_code; + base::Optional<CBORValue> cbor = + CBORReader::Read(unsupported_floating_point, &error_code); + EXPECT_FALSE(cbor.has_value()); + EXPECT_EQ(error_code, + CBORReader::DecoderError::UNSUPPORTED_FLOATING_POINT_VALUE); + } +} + TEST(CBORReaderTest, TestIncompleteCBORDataError) { static const std::vector<uint8_t> incomplete_cbor_list[] = { // Additional info byte corresponds to unsigned int that corresponds @@ -468,7 +515,17 @@ // "\xc3\xbc" encoded with major type 3 and additional info of 30. {0x7E, 0xc3, 0xbc}, // "\xe6\xb0\xb4" encoded with major type 3 and additional info of 31. - {0x7F, 0xe6, 0xb0, 0xb4}}; + {0x7F, 0xe6, 0xb0, 0xb4}, + // Major type 7, additional information 28: unassigned. + {0xFC}, + // Major type 7, additional information 29: unassigned. + {0xFD}, + // Major type 7, additional information 30: unassigned. + {0xFE}, + // Major type 7, additional information 31: "break" stop code for + // indefinite-length items. + {0xFF}, + }; int test_element_index = 0; for (const auto& incorrect_cbor : kUnknownAdditionalInfoList) { @@ -674,4 +731,39 @@ } } +TEST(CBORReaderTest, TestUnsupportedSimplevalue) { + static const std::vector<uint8_t> unsupported_simple_values[] = { + // Simple value (0, unassigned) + {0xE0}, + // Simple value (19, unassigned) + {0xF3}, + // Simple value (24, reserved) + {0xF8, 0x18}, + // Simple value (28, reserved) + {0xF8, 0x1C}, + // Simple value (29, reserved) + {0xF8, 0x1D}, + // Simple value (30, reserved) + {0xF8, 0x1E}, + // Simple value (31, reserved) + {0xF8, 0x1F}, + // Simple value (32, unassigned) + {0xF8, 0x20}, + // Simple value (255, unassigned) + {0xF8, 0xFF}, + }; + + for (const auto& unsupported_simple_val : unsupported_simple_values) { + SCOPED_TRACE(testing::Message() + << "testing unsupported cbor simple value : " + << ::testing::PrintToString(unsupported_simple_val)); + + CBORReader::DecoderError error_code; + base::Optional<CBORValue> cbor = + CBORReader::Read(unsupported_simple_val, &error_code); + EXPECT_FALSE(cbor.has_value()); + EXPECT_EQ(error_code, CBORReader::DecoderError::UNSUPPORTED_SIMPLE_VALUE); + } +} + } // namespace content
diff --git a/content/browser/webauth/cbor/cbor_values.cc b/content/browser/webauth/cbor/cbor_values.cc index 2e64ac0..bd0f1e9 100644 --- a/content/browser/webauth/cbor/cbor_values.cc +++ b/content/browser/webauth/cbor/cbor_values.cc
@@ -35,6 +35,9 @@ case Type::MAP: new (&map_value_) MapValue(); return; + case Type::SIMPLE_VALUE: + simple_value_ = CBORValue::SimpleValue::UNDEFINED; + return; case Type::NONE: return; } @@ -81,6 +84,11 @@ CBORValue::CBORValue(MapValue&& in_map) noexcept : type_(Type::MAP), map_value_(std::move(in_map)) {} +CBORValue::CBORValue(SimpleValue in_simple) + : type_(Type::SIMPLE_VALUE), simple_value_(in_simple) { + CHECK(static_cast<int>(in_simple) >= 20 && static_cast<int>(in_simple) <= 23); +} + CBORValue& CBORValue::operator=(CBORValue&& that) noexcept { InternalCleanup(); InternalMoveConstructFrom(std::move(that)); @@ -106,6 +114,8 @@ return CBORValue(array_value_); case Type::MAP: return CBORValue(map_value_); + case Type::SIMPLE_VALUE: + return CBORValue(simple_value_); } NOTREACHED(); @@ -137,6 +147,11 @@ return map_value_; } +CBORValue::SimpleValue CBORValue::GetSimpleValue() const { + CHECK(is_simple()); + return simple_value_; +} + void CBORValue::InternalMoveConstructFrom(CBORValue&& that) { type_ = that.type_; @@ -156,6 +171,9 @@ case Type::MAP: new (&map_value_) MapValue(std::move(that.map_value_)); return; + case Type::SIMPLE_VALUE: + simple_value_ = that.simple_value_; + return; case Type::NONE: return; } @@ -178,6 +196,7 @@ break; case Type::NONE: case Type::UNSIGNED: + case Type::SIMPLE_VALUE: break; } type_ = Type::NONE;
diff --git a/content/browser/webauth/cbor/cbor_values.h b/content/browser/webauth/cbor/cbor_values.h index bea7b38c..9b35fda 100644 --- a/content/browser/webauth/cbor/cbor_values.h +++ b/content/browser/webauth/cbor/cbor_values.h
@@ -78,9 +78,17 @@ STRING = 3, ARRAY = 4, MAP = 5, + SIMPLE_VALUE = 7, NONE = -1, }; + enum class SimpleValue { + FALSE_VALUE = 20, + TRUE_VALUE = 21, + NULL_VALUE = 22, + UNDEFINED = 23, + }; + CBORValue(CBORValue&& that) noexcept; CBORValue() noexcept; // A NONE value. @@ -100,6 +108,8 @@ explicit CBORValue(const MapValue& in_map); explicit CBORValue(MapValue&& in_map) noexcept; + explicit CBORValue(SimpleValue in_simple); + CBORValue& operator=(CBORValue&& that) noexcept; ~CBORValue(); @@ -119,9 +129,11 @@ bool is_string() const { return type() == Type::STRING; } bool is_array() const { return type() == Type::ARRAY; } bool is_map() const { return type() == Type::MAP; } + bool is_simple() const { return type() == Type::SIMPLE_VALUE; } // These will all fatally assert if the type doesn't match. const uint64_t& GetUnsigned() const; + SimpleValue GetSimpleValue() const; const BinaryValue& GetBytestring() const; // Returned string may contain NUL characters. const std::string& GetString() const; @@ -132,6 +144,7 @@ Type type_; union { + SimpleValue simple_value_; uint64_t unsigned_value_; BinaryValue bytestring_value_; std::string string_value_;
diff --git a/content/browser/webauth/cbor/cbor_values_unittest.cc b/content/browser/webauth/cbor/cbor_values_unittest.cc index 6894896..4ef956a 100644 --- a/content/browser/webauth/cbor/cbor_values_unittest.cc +++ b/content/browser/webauth/cbor/cbor_values_unittest.cc
@@ -109,6 +109,25 @@ } } +TEST(CBORValuesTest, ConstructSimpleValue) { + CBORValue false_value(CBORValue::SimpleValue::FALSE_VALUE); + ASSERT_EQ(CBORValue::Type::SIMPLE_VALUE, false_value.type()); + EXPECT_EQ(CBORValue::SimpleValue::FALSE_VALUE, false_value.GetSimpleValue()); + + CBORValue true_value(CBORValue::SimpleValue::TRUE_VALUE); + ASSERT_EQ(CBORValue::Type::SIMPLE_VALUE, true_value.type()); + EXPECT_EQ(CBORValue::SimpleValue::TRUE_VALUE, true_value.GetSimpleValue()); + + CBORValue null_value(CBORValue::SimpleValue::NULL_VALUE); + ASSERT_EQ(CBORValue::Type::SIMPLE_VALUE, null_value.type()); + EXPECT_EQ(CBORValue::SimpleValue::NULL_VALUE, null_value.GetSimpleValue()); + + CBORValue undefined_value(CBORValue::SimpleValue::UNDEFINED); + ASSERT_EQ(CBORValue::Type::SIMPLE_VALUE, undefined_value.type()); + EXPECT_EQ(CBORValue::SimpleValue::UNDEFINED, + undefined_value.GetSimpleValue()); +} + // Test copy constructors TEST(CBORValuesTest, CopyUnsigned) { CBORValue value(74); @@ -187,6 +206,19 @@ blank.GetMap().find(key_a)->second.GetUnsigned()); } +TEST(CBORValuesTest, CopySimpleValue) { + CBORValue value(CBORValue::SimpleValue::TRUE_VALUE); + CBORValue copied_value(value.Clone()); + EXPECT_EQ(value.type(), copied_value.type()); + EXPECT_EQ(value.GetSimpleValue(), copied_value.GetSimpleValue()); + + CBORValue blank; + + blank = value.Clone(); + EXPECT_EQ(value.type(), blank.type()); + EXPECT_EQ(value.GetSimpleValue(), blank.GetSimpleValue()); +} + // Test move constructors and move-assignment TEST(CBORValuesTest, MoveUnsigned) { CBORValue value(74); @@ -271,7 +303,20 @@ TEST(CBORValuesTest, SelfSwap) { CBORValue test(1); std::swap(test, test); - EXPECT_TRUE(test.GetUnsigned() == 1); + EXPECT_EQ(test.GetUnsigned(), 1u); +} + +TEST(CBORValuesTest, MoveSimpleValue) { + CBORValue value(CBORValue::SimpleValue::UNDEFINED); + CBORValue moved_value(std::move(value)); + EXPECT_EQ(CBORValue::Type::SIMPLE_VALUE, moved_value.type()); + EXPECT_EQ(CBORValue::SimpleValue::UNDEFINED, moved_value.GetSimpleValue()); + + CBORValue blank; + + blank = CBORValue(CBORValue::SimpleValue::UNDEFINED); + EXPECT_EQ(CBORValue::Type::SIMPLE_VALUE, blank.type()); + EXPECT_EQ(CBORValue::SimpleValue::UNDEFINED, blank.GetSimpleValue()); } } // namespace content
diff --git a/content/browser/webauth/cbor/cbor_writer.cc b/content/browser/webauth/cbor/cbor_writer.cc index 88faaf89..0206cee1 100644 --- a/content/browser/webauth/cbor/cbor_writer.cc +++ b/content/browser/webauth/cbor/cbor_writer.cc
@@ -88,6 +88,15 @@ } return true; } + + // Represents a simple value. + case CBORValue::Type::SIMPLE_VALUE: { + const CBORValue::SimpleValue simple_value = node.GetSimpleValue(); + StartItem(CBORValue::Type::SIMPLE_VALUE, + base::checked_cast<uint64_t>(simple_value)); + return true; + } + default: break; }
diff --git a/content/browser/webauth/cbor/cbor_writer.h b/content/browser/webauth/cbor/cbor_writer.h index 8ea9651b..32dd602 100644 --- a/content/browser/webauth/cbor/cbor_writer.h +++ b/content/browser/webauth/cbor/cbor_writer.h
@@ -25,6 +25,8 @@ // * 4: Arrays, with the number of elements known at the start. // * 5: Maps, with the number of elements known at the start // of the container. +// * 7: Simple values. +// // Unsupported: // * Negative integers. // * Floating-point numbers. @@ -68,7 +70,7 @@ size_t max_nesting_level = kDefaultMaxNestingDepth); private: - CBORWriter(std::vector<uint8_t>* cbor); + explicit CBORWriter(std::vector<uint8_t>* cbor); // Called recursively to build the CBOR bytestring. When completed, // |encoded_cbor_| will contain the CBOR.
diff --git a/content/browser/webauth/cbor/cbor_writer_unittest.cc b/content/browser/webauth/cbor/cbor_writer_unittest.cc index 54595b1..2de0c7c9 100644 --- a/content/browser/webauth/cbor/cbor_writer_unittest.cc +++ b/content/browser/webauth/cbor/cbor_writer_unittest.cc
@@ -238,6 +238,23 @@ arraysize(kNestedMapTestCase))); } +TEST(CBORWriterTest, TestWriteSimpleValue) { + static const struct { + CBORValue::SimpleValue simple_value; + const base::StringPiece cbor; + } kSimpleTestCase[] = { + {CBORValue::SimpleValue::FALSE_VALUE, base::StringPiece("\xf4")}, + {CBORValue::SimpleValue::TRUE_VALUE, base::StringPiece("\xf5")}, + {CBORValue::SimpleValue::NULL_VALUE, base::StringPiece("\xf6")}, + {CBORValue::SimpleValue::UNDEFINED, base::StringPiece("\xf7")}}; + + for (const auto& test_case : kSimpleTestCase) { + auto cbor = CBORWriter::Write(CBORValue(test_case.simple_value)); + ASSERT_TRUE(cbor.has_value()); + EXPECT_THAT(cbor.value(), testing::ElementsAreArray(test_case.cbor)); + } +} + // For major type 0, 2, 3, empty CBOR array, and empty CBOR map, the nesting // depth is expected to be 0 since the CBOR decoder does not need to parse // any nested CBOR value elements.
diff --git a/testing/buildbot/OWNERS b/testing/buildbot/OWNERS index f7607e4c..ad0ef62d 100644 --- a/testing/buildbot/OWNERS +++ b/testing/buildbot/OWNERS
@@ -12,44 +12,6 @@ tansell@chromium.org thakis@chromium.org -# TODO(crbug.com/662541): -# These files are auto-generated and are being converted to the -# new format using ./generate_buildbot_json.py. Until everything -# is converted these files are locked down; make sure that one of the -# people working on that process is approving things. -# -# Not planned for conversion yet: -# chromium.clang -# chromium.goma -# chromium.fyi -# chromium.perf* -# chromium.webrtc* -# client.v8* -per-file chromium.json=set noparent -per-file chromium.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.android*.json=set noparent -per-file chromium.android*.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.angle*.json=set noparent -per-file chromium.angle*.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.chrome.json=set noparent -per-file chromium.chrome.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.linux.json=set noparent -per-file chromium.linux.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.mac.json=set noparent -per-file chromium.mac.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.memory.json=set noparent -per-file chromium.memory.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.sandbox.json=set noparent -per-file chromium.sandbox.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.swarm.json=set noparent -per-file chromium.swarm.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.memory.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.webkit.json=set noparent -per-file chromium.webkit.json=file://testing/buildbot/GENERATION_OWNERS -per-file chromium.win.json=set noparent -per-file chromium.win.json=file://testing/buildbot/GENERATION_OWNERS - - # For Site Isolation FYI tests: per-file chromium.fyi.json=creis@chromium.org per-file chromium.fyi.json=nick@chromium.org
diff --git a/third_party/WebKit/LayoutTests/ImageFirstTests b/third_party/WebKit/LayoutTests/ImageFirstTests index ae3d3065..2e5391f 100644 --- a/third_party/WebKit/LayoutTests/ImageFirstTests +++ b/third_party/WebKit/LayoutTests/ImageFirstTests
@@ -80,3 +80,4 @@ virtual/layout_ng/external/wpt/css/CSS2/linebox virtual/mojo-loading/fast/table virtual/spv175/fast/borders +virtual/spv175/fast/multicol
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index 50c8833..b40c1f9 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -83,9 +83,11 @@ crbug.com/771643 virtual/spv175/fast/borders/inline-mask-overlay-image-outset-vertical-rl.html [ Failure ] crbug.com/771643 virtual/spv175/fast/borders/inline-mask-overlay-image-outset.html [ Failure ] crbug.com/771643 virtual/spv175/fast/borders/inline-mask-overlay-image.html [ Failure ] +crbug.com/771643 virtual/spv175/fast/multicol/border-radius-clipped-layer.html [ Failure ] +crbug.com/771643 virtual/spv175/fast/multicol/layers-split-across-columns.html [ Failure ] +crbug.com/771643 virtual/spv175/fast/multicol/mixed-opacity-test.html [ Failure ] +crbug.com/771643 virtual/spv175/fast/multicol/overflow-across-columns.html [ Failure ] crbug.com/771643 virtual/spv175/paint/invalidation/forms/select-option-background-color.html [ Failure ] -crbug.com/771643 virtual/spv175/paint/invalidation/multicol/multicol-with-overflowing-block-rl.html [ Failure ] -crbug.com/771643 virtual/spv175/paint/invalidation/overflow/paged-with-overflowing-block-rl.html [ Failure ] crbug.com/771643 virtual/spv175/paint/invalidation/position/position-change-keeping-geometry.html [ Failure ] crbug.com/771643 virtual/spv175/paint/invalidation/svg/absolute-sized-content-with-resources.xhtml [ Failure ] crbug.com/771643 virtual/spv175/paint/invalidation/svg/deep-dynamic-updates.svg [ Failure ] @@ -148,6 +150,12 @@ # Fails because of an 8bit precision error in the YUV -> RGB conversion matrix crbug.com/774567 [ Win Linux ] external/wpt/webvtt/rendering/cues-with-video/processing-model/dom_override_remove_cue_while_paused.html [ Failure ] +# Failing after the Skia roll https://chromium.googlesource.com/chromium/src/+/dc8531cb84f4d3334fc520c2c9269935a90d0c30 +crbug.com/796766 [ Mac Win Linux ] fast/webgl/texImage-imageBitmap-from-canvas-resize.html [ Failure Pass ] +crbug.com/796766 [ Mac Win Linux ] fast/webgl/texImage-imageBitmap-from-image-resize.html [ Failure Pass ] +crbug.com/796766 [ Mac Win Linux ] fast/webgl/texImage-imageBitmap-from-imageData-resize.html [ Failure Pass ] +crbug.com/796766 [ Mac Win Linux ] fast/webgl/texImage-imageBitmap-from-offscreen-canvas-resize.html [ Failure Pass ] + # Fails because the manual test hasn't been automated yet crbug.com/762054 external/wpt/css/cssom-view/overscrollBehavior-manual.html [ Skip ] @@ -1403,6 +1411,7 @@ crbug.com/306222 fast/hidpi/image-srcset-relative-svg-canvas-2x.html [ Skip ] crbug.com/467477 fast/multicol/vertical-rl/nested-columns.html [ Failure ] +crbug.com/467477 virtual/spv175/fast/multicol/vertical-rl/nested-columns.html [ Skip ] crbug.com/674225 [ Mac ] fast/replaced/input-radio-height-inside-auto-container.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/VirtualTestSuites b/third_party/WebKit/LayoutTests/VirtualTestSuites index d145741d2..b1c5547 100644 --- a/third_party/WebKit/LayoutTests/VirtualTestSuites +++ b/third_party/WebKit/LayoutTests/VirtualTestSuites
@@ -282,6 +282,12 @@ "references_use_default_args": true }, { + "prefix": "spv175", + "base": "fast/multicol", + "args": ["--enable-slimming-paint-v175", "--root-layer-scrolls"], + "references_use_default_args": true + }, + { "prefix": "scalefactor200", "base": "fast/hidpi/static", "args": ["--force-device-scale-factor=2"]
diff --git a/third_party/WebKit/LayoutTests/http/tests/sendbeacon/beacon-allowance-no-limit.html b/third_party/WebKit/LayoutTests/http/tests/sendbeacon/beacon-allowance-no-limit.html deleted file mode 100644 index bd4fdf36..0000000 --- a/third_party/WebKit/LayoutTests/http/tests/sendbeacon/beacon-allowance-no-limit.html +++ /dev/null
@@ -1,18 +0,0 @@ -<!DOCTYPE HTML> -<script src="/js-test-resources/testharness.js"></script> -<script src="/js-test-resources/testharnessreport.js"></script> -<script> -test(() => { - if (!window.internals) - return; - - // Any negative value will do to disable limit checks. - internals.settings.setMaxBeaconTransmission(-2); - - let payload = new Uint8Array(128 * 1024); - assert_true(navigator.sendBeacon("resources/blank.txt", payload)); - assert_true(navigator.sendBeacon("resources/blank.txt", payload)); -}, "If no beacon transmission limit is in effect, then navigator.sendBeacon()" + - " should succeed."); -</script> -</html>
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.html b/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.html index 6c9a855d..f4262869 100644 --- a/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.html +++ b/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.html
@@ -1,8 +1,4 @@ <!DOCTYPE html> -<div id="container" style="-webkit-columns:3; -webkit-column-gap:0; column-fill:auto; width:500px; height:500px; -webkit-writing-mode:vertical-rl;"> - <div style="width:100px;"> - <div id="elm" style="width:1500px; background:green;"></div> - </div> -</div> +<div style="width: 500px; height: 500px; background: green"></div> <p>Test changing the background color of a big block that overflows the flow thread.</p> -<p>A green square should be seen above (if tested manually, you need to click first).</p> +<p>A green square should be seen above.</p>
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl.html b/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl.html index 7412576..24066bf 100644 --- a/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl.html +++ b/third_party/WebKit/LayoutTests/paint/invalidation/multicol/multicol-with-overflowing-block-rl.html
@@ -1,18 +1,15 @@ <!DOCTYPE html> <script src="../resources/text-based-repaint.js"></script> <script> - if (window.internals) - onload = runRepaintAndPixelTest; - else - onclick = repaintTest; + onload = runRepaintAndPixelTest; function repaintTest() { document.getElementById('elm').style.background = 'green'; } </script> -<div id="container" style="-webkit-columns:3; -webkit-column-gap:0; column-fill:auto; width:500px; height:500px; -webkit-writing-mode:vertical-rl;"> +<div id="container" style="columns:3; column-gap:0; column-fill:auto; width:500px; height:500px; writing-mode:vertical-rl;"> <div style="width:100px;"> <div id="elm" style="width:1500px; background:yellow;"></div> </div> </div> <p>Test changing the background color of a big block that overflows the flow thread.</p> -<p>A green square should be seen above (if tested manually, you need to click first).</p> +<p>A green square should be seen above.</p>
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png b/third_party/WebKit/LayoutTests/platform/linux/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png index a403517e..e56f58a 100644 --- a/third_party/WebKit/LayoutTests/platform/linux/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png +++ b/third_party/WebKit/LayoutTests/platform/linux/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png b/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png index 9e07322..6859ade 100644 --- a/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-mac10.11/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png b/third_party/WebKit/LayoutTests/platform/mac-mac10.11/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png index c67c741..7e0fdd2 100644 --- a/third_party/WebKit/LayoutTests/platform/mac-mac10.11/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac-mac10.11/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png b/third_party/WebKit/LayoutTests/platform/mac/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png index ec944803..dc0798b 100644 --- a/third_party/WebKit/LayoutTests/platform/mac/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png +++ b/third_party/WebKit/LayoutTests/platform/mac/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/win/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png b/third_party/WebKit/LayoutTests/platform/win/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png index f250df31..3a2325f 100644 --- a/third_party/WebKit/LayoutTests/platform/win/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png +++ b/third_party/WebKit/LayoutTests/platform/win/fast/multicol/multicol-with-child-renderLayer-for-input-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/fast/borders/border-antialiasing-expected.png b/third_party/WebKit/LayoutTests/virtual/spv175/fast/borders/border-antialiasing-expected.png index 2b5d56eb..10f5769 100644 --- a/third_party/WebKit/LayoutTests/virtual/spv175/fast/borders/border-antialiasing-expected.png +++ b/third_party/WebKit/LayoutTests/virtual/spv175/fast/borders/border-antialiasing-expected.png Binary files differ
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/fast/multicol/README.txt b/third_party/WebKit/LayoutTests/virtual/spv175/fast/multicol/README.txt new file mode 100644 index 0000000..c68ac05 --- /dev/null +++ b/third_party/WebKit/LayoutTests/virtual/spv175/fast/multicol/README.txt
@@ -0,0 +1 @@ +# This suite runs tests with --enable-slimming-paint-v175
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/fast/multicol/composited-layer-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/fast/multicol/composited-layer-expected.txt new file mode 100644 index 0000000..acde760e --- /dev/null +++ b/third_party/WebKit/LayoutTests/virtual/spv175/fast/multicol/composited-layer-expected.txt
@@ -0,0 +1,37 @@ +{ +"layers": [ +{ +"name": "LayoutView #document", +"bounds": [800, 600], +"backgroundColor": "#FFFFFF" +}, +{ +"name": "Scrolling Layer", +"bounds": [800, 600], +"drawsContent": false +}, +{ +"name": "Scrolling Contents Layer", +"bounds": [800, 600], +"contentsOpaque": true, +"backgroundColor": "#FFFFFF" +}, +{ +"name": "LayoutBlockFlow DIV id='multicol'", +"bounds": [200, 100], +"transform": 1 +} +], +"transforms": [ +{ +"id": 1, +"transform": [ +[1, 0, 0, 0], +[0, 1, 0, 0], +[0, 0, 1, 0], +[8, 8, 0, 1] +] +} +] +} +
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.txt new file mode 100644 index 0000000..ceb628e --- /dev/null +++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/multicol/multicol-with-overflowing-block-rl-expected.txt
@@ -0,0 +1,67 @@ +{ + "layers": [ + { + "name": "LayoutView #document", + "bounds": [800, 600], + "backgroundColor": "#FFFFFF" + }, + { + "name": "Scrolling Layer", + "bounds": [800, 600], + "drawsContent": false + }, + { + "name": "Scrolling Contents Layer", + "bounds": [800, 600], + "contentsOpaque": true, + "backgroundColor": "#FFFFFF", + "paintInvalidations": [ + { + "object": "LayoutMultiColumnFlowThread (anonymous)", + "rect": [8, 8, 792, 167], + "reason": "chunk uncacheable" + }, + { + "object": "LayoutMultiColumnFlowThread (anonymous)", + "rect": [8, 8, 792, 167], + "reason": "chunk uncacheable" + }, + { + "object": "LayoutMultiColumnFlowThread (anonymous)", + "rect": [0, 341, 508, 167], + "reason": "chunk uncacheable" + }, + { + "object": "LayoutMultiColumnFlowThread (anonymous)", + "rect": [0, 341, 508, 167], + "reason": "chunk uncacheable" + }, + { + "object": "LayoutMultiColumnFlowThread (anonymous)", + "rect": [8, 174, 500, 168], + "reason": "chunk uncacheable" + }, + { + "object": "LayoutMultiColumnFlowThread (anonymous)", + "rect": [8, 174, 500, 168], + "reason": "chunk uncacheable" + } + ] + } + ], + "objectPaintInvalidations": [ + { + "object": "LayoutBlockFlow DIV id='elm'", + "reason": "style change" + }, + { + "object": "LayoutBlockFlow DIV id='elm'", + "reason": "style change" + }, + { + "object": "LayoutBlockFlow DIV id='elm'", + "reason": "style change" + } + ] +} +
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/overflow/paged-with-overflowing-block-rl-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/overflow/paged-with-overflowing-block-rl-expected.txt new file mode 100644 index 0000000..6d86ac9e --- /dev/null +++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/overflow/paged-with-overflowing-block-rl-expected.txt
@@ -0,0 +1,43 @@ +{ + "layers": [ + { + "name": "LayoutView #document", + "bounds": [800, 600], + "backgroundColor": "#FFFFFF" + }, + { + "name": "Scrolling Layer", + "bounds": [800, 600], + "drawsContent": false + }, + { + "name": "Scrolling Contents Layer", + "bounds": [800, 600], + "contentsOpaque": true, + "backgroundColor": "#FFFFFF", + "paintInvalidations": [ + { + "object": "LayoutPagedFlowThread (anonymous)", + "rect": [8, 8, 500, 485], + "reason": "chunk uncacheable" + }, + { + "object": "LayoutPagedFlowThread (anonymous)", + "rect": [8, 8, 500, 485], + "reason": "chunk uncacheable" + } + ] + } + ], + "objectPaintInvalidations": [ + { + "object": "LayoutBlockFlow DIV id='elm'", + "reason": "style change" + }, + { + "object": "LayoutBlockFlow DIV id='elm'", + "reason": "style change" + } + ] +} +
diff --git a/third_party/WebKit/Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl index 149cced..34a794e 100644 --- a/third_party/WebKit/Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl +++ b/third_party/WebKit/Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl
@@ -279,8 +279,8 @@ {{apply_fill_layer('CSSPropertyBackgroundClip', 'Clip')}} {{apply_fill_layer('CSSPropertyBackgroundImage', 'Image', 'GetImage')}} {{apply_fill_layer('CSSPropertyBackgroundOrigin', 'Origin')}} -{{apply_fill_layer('CSSPropertyBackgroundPositionX', 'XPosition')}} -{{apply_fill_layer('CSSPropertyBackgroundPositionY', 'YPosition')}} +{{apply_fill_layer('CSSPropertyBackgroundPositionX', 'PositionX')}} +{{apply_fill_layer('CSSPropertyBackgroundPositionY', 'PositionY')}} {{apply_fill_layer('CSSPropertyBackgroundRepeatX', 'RepeatX')}} {{apply_fill_layer('CSSPropertyBackgroundRepeatY', 'RepeatY')}} {{apply_fill_layer('CSSPropertyBackgroundSize', 'Size', 'Size')}} @@ -289,8 +289,8 @@ {{apply_fill_layer('CSSPropertyWebkitMaskComposite', 'Composite')}} {{apply_fill_layer('CSSPropertyWebkitMaskImage', 'Image', 'GetImage')}} {{apply_fill_layer('CSSPropertyWebkitMaskOrigin', 'Origin')}} -{{apply_fill_layer('CSSPropertyWebkitMaskPositionX', 'XPosition')}} -{{apply_fill_layer('CSSPropertyWebkitMaskPositionY', 'YPosition')}} +{{apply_fill_layer('CSSPropertyWebkitMaskPositionX', 'PositionX')}} +{{apply_fill_layer('CSSPropertyWebkitMaskPositionY', 'PositionY')}} {{apply_fill_layer('CSSPropertyWebkitMaskRepeatX', 'RepeatX')}} {{apply_fill_layer('CSSPropertyWebkitMaskRepeatY', 'RepeatY')}} {{apply_fill_layer('CSSPropertyWebkitMaskSize', 'Size', 'Size')}}
diff --git a/third_party/WebKit/Source/core/animation/LengthListPropertyFunctions.cpp b/third_party/WebKit/Source/core/animation/LengthListPropertyFunctions.cpp index 7829245..ec10cef0 100644 --- a/third_party/WebKit/Source/core/animation/LengthListPropertyFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/LengthListPropertyFunctions.cpp
@@ -45,19 +45,19 @@ switch (property) { case CSSPropertyBackgroundPositionX: case CSSPropertyWebkitMaskPositionX: - is_set = &FillLayer::IsXPositionSet; - get_length = &FillLayer::XPosition; + is_set = &FillLayer::IsPositionXSet; + get_length = &FillLayer::PositionX; get_edge = &FillLayer::BackgroundXOrigin; - set_length = &FillLayer::SetXPosition; - clear = &FillLayer::ClearXPosition; + set_length = &FillLayer::SetPositionX; + clear = &FillLayer::ClearPositionX; break; case CSSPropertyBackgroundPositionY: case CSSPropertyWebkitMaskPositionY: - is_set = &FillLayer::IsYPositionSet; - get_length = &FillLayer::YPosition; + is_set = &FillLayer::IsPositionYSet; + get_length = &FillLayer::PositionY; get_edge = &FillLayer::BackgroundYOrigin; - set_length = &FillLayer::SetYPosition; - clear = &FillLayer::ClearYPosition; + set_length = &FillLayer::SetPositionY; + clear = &FillLayer::ClearPositionY; break; default: NOTREACHED();
diff --git a/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp b/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp index 208e4a8..7ed30206 100644 --- a/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp +++ b/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp
@@ -24,12 +24,12 @@ switch (property) { case CSSPropertyBackgroundPositionX: case CSSPropertyWebkitMaskPositionX: - if (a_layer->XPosition() != b_layer->XPosition()) + if (a_layer->PositionX() != b_layer->PositionX()) return false; break; case CSSPropertyBackgroundPositionY: case CSSPropertyWebkitMaskPositionY: - if (a_layer->YPosition() != b_layer->YPosition()) + if (a_layer->PositionY() != b_layer->PositionY()) return false; break; case CSSPropertyBackgroundSize:
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp index d415977..7241d90e 100644 --- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp +++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -117,7 +117,7 @@ *CSSIdentifierValue::Create(layer.BackgroundXOrigin())); } position_list->Append( - *ZoomAdjustedPixelValueForLength(layer.XPosition(), style)); + *ZoomAdjustedPixelValueForLength(layer.PositionX(), style)); if (layer.IsBackgroundYOriginSet()) { DCHECK(property.IDEquals(CSSPropertyBackgroundPosition) || property.IDEquals(CSSPropertyWebkitMaskPosition)); @@ -125,7 +125,7 @@ *CSSIdentifierValue::Create(layer.BackgroundYOrigin())); } position_list->Append( - *ZoomAdjustedPixelValueForLength(layer.YPosition(), style)); + *ZoomAdjustedPixelValueForLength(layer.PositionY(), style)); return position_list; } @@ -2339,9 +2339,10 @@ resolved_property.IDEquals(CSSPropertyWebkitMaskPositionX) ? &style.MaskLayers() : &style.BackgroundLayers(); - for (; curr_layer; curr_layer = curr_layer->Next()) + for (; curr_layer; curr_layer = curr_layer->Next()) { list->Append( - *ZoomAdjustedPixelValueForLength(curr_layer->XPosition(), style)); + *ZoomAdjustedPixelValueForLength(curr_layer->PositionX(), style)); + } return list; } case CSSPropertyBackgroundPositionY: @@ -2351,9 +2352,10 @@ resolved_property.IDEquals(CSSPropertyWebkitMaskPositionY) ? &style.MaskLayers() : &style.BackgroundLayers(); - for (; curr_layer; curr_layer = curr_layer->Next()) + for (; curr_layer; curr_layer = curr_layer->Next()) { list->Append( - *ZoomAdjustedPixelValueForLength(curr_layer->YPosition(), style)); + *ZoomAdjustedPixelValueForLength(curr_layer->PositionY(), style)); + } return list; } case CSSPropertyBorderCollapse:
diff --git a/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp b/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp index 3f023f0..a39a7a0 100644 --- a/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp +++ b/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp
@@ -229,11 +229,11 @@ layer->SetSizeLength(b); } -void CSSToStyleMap::MapFillXPosition(StyleResolverState& state, +void CSSToStyleMap::MapFillPositionX(StyleResolverState& state, FillLayer* layer, const CSSValue& value) { if (value.IsInitialValue()) { - layer->SetXPosition(FillLayer::InitialFillXPosition(layer->GetType())); + layer->SetPositionX(FillLayer::InitialFillPositionX(layer->GetType())); return; } @@ -250,18 +250,18 @@ CSSValueRight>(state, value); - layer->SetXPosition(length); + layer->SetPositionX(length); if (value.IsValuePair()) layer->SetBackgroundXOrigin( ToCSSIdentifierValue(ToCSSValuePair(value).First()) .ConvertTo<BackgroundEdgeOrigin>()); } -void CSSToStyleMap::MapFillYPosition(StyleResolverState& state, +void CSSToStyleMap::MapFillPositionY(StyleResolverState& state, FillLayer* layer, const CSSValue& value) { if (value.IsInitialValue()) { - layer->SetYPosition(FillLayer::InitialFillYPosition(layer->GetType())); + layer->SetPositionY(FillLayer::InitialFillPositionY(layer->GetType())); return; } @@ -278,7 +278,7 @@ CSSValueBottom>( state, value); - layer->SetYPosition(length); + layer->SetPositionY(length); if (value.IsValuePair()) layer->SetBackgroundYOrigin( ToCSSIdentifierValue(ToCSSValuePair(value).First())
diff --git a/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.h b/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.h index 63eeb17..5d86fbc0 100644 --- a/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.h +++ b/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.h
@@ -58,10 +58,10 @@ static void MapFillRepeatX(StyleResolverState&, FillLayer*, const CSSValue&); static void MapFillRepeatY(StyleResolverState&, FillLayer*, const CSSValue&); static void MapFillSize(StyleResolverState&, FillLayer*, const CSSValue&); - static void MapFillXPosition(StyleResolverState&, + static void MapFillPositionX(StyleResolverState&, FillLayer*, const CSSValue&); - static void MapFillYPosition(StyleResolverState&, + static void MapFillPositionY(StyleResolverState&, FillLayer*, const CSSValue&); static void MapFillMaskSourceType(StyleResolverState&,
diff --git a/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp b/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp index 64c5618e..ddcac94 100644 --- a/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp +++ b/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp
@@ -124,7 +124,7 @@ // background X or Y position will probably be specified. const FillLayer& background = style.BackgroundLayers(); return style.HasBackgroundImage() && - (background.XPosition().IsFixed() || background.YPosition().IsFixed()); + (background.PositionX().IsFixed() || background.PositionY().IsFixed()); } StyleImage* ElementStyleResources::LoadPendingImage(
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextNodeHandler.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextNodeHandler.cpp index 5280cfc..ece1a1d 100644 --- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextNodeHandler.cpp +++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextNodeHandler.cpp
@@ -36,22 +36,27 @@ return layout_object->Style()->Visibility() != EVisibility::kVisible; } -// TODO(xiaochengh): Use a return type with better clarity -std::pair<String, std::pair<unsigned, unsigned>> -ComputeTextAndOffsetsForEmission(const NGOffsetMapping& mapping, - const NGOffsetMappingUnit& unit, - unsigned run_start, - unsigned run_end, - const TextIteratorBehavior& behavior) { +struct StringAndOffsetRange { + String string; + unsigned start; + unsigned end; +}; + +StringAndOffsetRange ComputeTextAndOffsetsForEmission( + const NGOffsetMapping& mapping, + const NGOffsetMappingUnit& unit, + unsigned run_start, + unsigned run_end, + const TextIteratorBehavior& behavior) { // TODO(xiaochengh): Handle EmitsOriginalText. unsigned text_content_start = unit.ConvertDOMOffsetToTextContent(run_start); unsigned text_content_end = unit.ConvertDOMOffsetToTextContent(run_end); unsigned length = text_content_end - text_content_start; if (behavior.EmitsSpaceForNbsp()) { String string = mapping.GetText().Substring(text_content_start, length); - return {string, {0u, 0u}}; + return {string, 0, 0}; } - return {mapping.GetText(), {text_content_start, text_content_end}}; + return {mapping.GetText(), text_content_start, text_content_end}; } } // namespace @@ -117,9 +122,9 @@ auto string_and_offsets = ComputeTextAndOffsetsForEmission( *mapping, unit, run_start, run_end, behavior_); - const String& string = string_and_offsets.first; - const unsigned text_content_start = string_and_offsets.second.first; - const unsigned text_content_end = string_and_offsets.second.second; + const String& string = string_and_offsets.string; + const unsigned text_content_start = string_and_offsets.start; + const unsigned text_content_end = string_and_offsets.end; text_state_.EmitText(text_node_, run_start, run_end, string, text_content_start, text_content_end); offset_ = run_end;
diff --git a/third_party/WebKit/Source/core/frame/Settings.json5 b/third_party/WebKit/Source/core/frame/Settings.json5 index 95809540..cfb30eb 100644 --- a/third_party/WebKit/Source/core/frame/Settings.json5 +++ b/third_party/WebKit/Source/core/frame/Settings.json5
@@ -612,19 +612,6 @@ type: "double", }, - // This value indicates the maximum number of bytes a document is allowed to - // transmit in Beacons (via navigator.sendBeacon()) -- Beacons are intended to be - // smaller payloads transmitted as a page is unloading, not a general (one-way) - // network transmission API. The spec <https://w3c.github.io/beacon/> does not - // proscribe an upper limit, but allows for it -- the underlying API will return - // 'false' in that case. If the value is set to a negative value, no limit - // will be imposed. - { - name: "maxBeaconTransmission", - initial: 65536, - type: "int", - }, - // This value is set to false if the platform does not support fullscreen. // When set to false all the requests to enter fullscreen will return an error // (fullscreenerror or webkitfullscreenerror) as specified in the standard:
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp index f608f0a8..7d86d45 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -5736,7 +5736,7 @@ return true; // TODO(alancutter): Make this work correctly for calc lengths. - if (layer.YPosition().IsPercentOrCalc() && !layer.YPosition().IsZero()) + if (layer.PositionY().IsPercentOrCalc() && !layer.PositionY().IsZero()) return true; if (layer.BackgroundYOrigin() != BackgroundEdgeOrigin::kTop) @@ -5778,7 +5778,7 @@ return true; // TODO(alancutter): Make this work correctly for calc lengths. - if (layer.XPosition().IsPercentOrCalc() && !layer.XPosition().IsZero()) + if (layer.PositionX().IsPercentOrCalc() && !layer.PositionX().IsZero()) return true; if (layer.BackgroundXOrigin() != BackgroundEdgeOrigin::kLeft)
diff --git a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp index be69fc4..56302d5 100644 --- a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp +++ b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
@@ -227,7 +227,7 @@ // handle large positions. if (unsnapped_tile_width) { LayoutUnit computed_x_position = - RoundedMinimumValueForLength(fill_layer.XPosition(), + RoundedMinimumValueForLength(fill_layer.PositionX(), unsnapped_available_width) - offset_for_cell; float number_of_tiles_in_position; @@ -263,7 +263,7 @@ // handle large positions. if (unsnapped_tile_height) { LayoutUnit computed_y_position = - RoundedMinimumValueForLength(fill_layer.YPosition(), + RoundedMinimumValueForLength(fill_layer.PositionY(), unsnapped_available_height) - offset_for_cell; float number_of_tiles_in_position; @@ -623,7 +623,7 @@ positioning_area_size.Height() - TileSize().Height(); LayoutUnit computed_x_position = - RoundedMinimumValueForLength(fill_layer.XPosition(), available_width) - + RoundedMinimumValueForLength(fill_layer.PositionX(), available_width) - offset_in_background_.X(); if (background_repeat_x == EFillRepeat::kRoundFill && positioning_area_size.Width() > LayoutUnit() && @@ -652,7 +652,7 @@ } LayoutUnit computed_y_position = - RoundedMinimumValueForLength(fill_layer.YPosition(), available_height) - + RoundedMinimumValueForLength(fill_layer.PositionY(), available_height) - offset_in_background_.Y(); if (background_repeat_y == EFillRepeat::kRoundFill && positioning_area_size.Height() > LayoutUnit() &&
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp index 9594893..265e46bb 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -1310,23 +1310,36 @@ return object_bounding_box_in_flow_thread; } +static LayoutPoint PaintOffsetInPaginationContainer( + const LayoutObject& object, + const PaintLayer& enclosing_pagination_layer) { + // Non-boxes use their containing blocks' paint offset. + if (!object.IsBox() && !object.HasLayer()) { + return PaintOffsetInPaginationContainer(*object.ContainingBlock(), + enclosing_pagination_layer); + } + + TransformState transform_state(TransformState::kApplyTransformDirection, + FloatPoint()); + object.MapLocalToAncestor(&enclosing_pagination_layer.GetLayoutObject(), + transform_state, kApplyContainerFlip); + transform_state.Flatten(); + return LayoutPoint(transform_state.LastPlanarPoint()); +} + void FragmentPaintPropertyTreeBuilder::UpdatePaintOffset() { // Paint offsets for fragmented content are computed from scratch. - if (context_.fragment_clip && + const auto* enclosing_pagination_layer = + full_context_.painting_layer->EnclosingPaginationLayer(); + if (enclosing_pagination_layer && // Except if the paint_offset_root is below the pagination container, // in which case fragmentation offsets are already baked into the paint // offset transform for paint_offset_root. !context_.current.paint_offset_root->PaintingLayer() ->EnclosingPaginationLayer()) { - PaintLayer* paint_layer = object_.PaintingLayer(); - PaintLayer* enclosing_pagination_layer = - paint_layer->EnclosingPaginationLayer(); - DCHECK(enclosing_pagination_layer); - // Set fragment visual paint offset. LayoutPoint paint_offset = - BoundingBoxInPaginationContainer(object_, *enclosing_pagination_layer) - .Location(); + PaintOffsetInPaginationContainer(object_, *enclosing_pagination_layer); paint_offset.MoveBy(fragment_data_.PaginationOffset()); paint_offset.MoveBy( @@ -1598,6 +1611,47 @@ } } +void ObjectPaintPropertyTreeBuilder::UpdateCompositedLayerPaginationOffset() { + if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) + return; + + const auto* enclosing_pagination_layer = + context_.painting_layer->EnclosingPaginationLayer(); + if (!enclosing_pagination_layer) + return; + + // We reach here because context_.painting_layer is in a composited layer + // under the pagination layer. SPv1* doesn't fragment composited layers, + // but we still need to set correct pagination offset for correct paint + // offset calculation. + FragmentData& first_fragment = + object_.GetMutableForPainting().FirstFragment(); + bool is_paint_invalidation_container = object_.IsPaintInvalidationContainer(); + const auto* parent_composited_layer = + context_.painting_layer->EnclosingLayerWithCompositedLayerMapping( + is_paint_invalidation_container ? kExcludeSelf : kIncludeSelf); + if (is_paint_invalidation_container && + (!parent_composited_layer || + !parent_composited_layer->EnclosingPaginationLayer())) { + // |object_| establishes the top level composited layer under the + // pagination layer. + FragmentainerIterator iterator( + ToLayoutFlowThread(enclosing_pagination_layer->GetLayoutObject()), + BoundingBoxInPaginationContainer(object_, *enclosing_pagination_layer)); + if (!iterator.AtEnd()) { + first_fragment.SetPaginationOffset( + ToLayoutPoint(iterator.PaginationOffset())); + } + } else { + DCHECK(parent_composited_layer); + // All objects under the composited layer use the same pagination offset. + first_fragment.SetPaginationOffset( + parent_composited_layer->GetLayoutObject() + .FirstFragment() + .PaginationOffset()); + } +} + // Limit the maximum number of fragments, to avoid pathological situations. static const int kMaxNumFragments = 2000; @@ -1613,11 +1667,12 @@ if (!NeedsFragmentation(object_, *context_.painting_layer)) { InitSingleFragmentFromParent(needs_paint_properties); + UpdateCompositedLayerPaginationOffset(); } else { // We need at least the fragments for all fragmented objects, which store // their local border box properties and paint invalidation data (such // as paint offset and visual rect) on each fragment. - PaintLayer* paint_layer = object_.PaintingLayer(); + PaintLayer* paint_layer = context_.painting_layer; PaintLayer* enclosing_pagination_layer = paint_layer->EnclosingPaginationLayer();
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h index 708ddf3..d9aff961 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.h
@@ -159,6 +159,7 @@ ALWAYS_INLINE void InitFragmentPaintProperties(FragmentData&, bool needs_paint_properties); ALWAYS_INLINE void InitSingleFragmentFromParent(bool needs_paint_properties); + ALWAYS_INLINE void UpdateCompositedLayerPaginationOffset(); ALWAYS_INLINE void UpdateFragments(); ALWAYS_INLINE void UpdatePaintingLayer();
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp index 19111c9..3d52a94 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -3404,7 +3404,7 @@ LayoutObject* target2 = GetLayoutObjectByElementId("target2"); EXPECT_EQ(LayoutPoint(LayoutUnit(400.5f), LayoutUnit(8.0f)), target2->FirstFragment().PaintOffset()); - // |target1| is only in the second column. + // |target2| is only in the second column. EXPECT_FALSE(target2->FirstFragment().NextFragment()); } @@ -3576,6 +3576,107 @@ .PaintOffset()); } +TEST_P(PaintPropertyTreeBuilderTest, + PaintOffsetsUnderMultiColumnVerticalRLWithOverflow) { + SetBodyInnerHTML(R"HTML( + <style>body { margin: 0; }</style> + <div id='multicol' style='columns:2; column-fill:auto; column-gap: 0; + width: 200px; height: 200px; writing-mode: vertical-rl'> + <div style='width: 100px'> + <div id='content' style='width: 400px'></div> + </div> + </div> + )HTML"); + + LayoutObject* thread = + GetLayoutObjectByElementId("multicol")->SlowFirstChild(); + EXPECT_TRUE(thread->IsLayoutFlowThread()); + EXPECT_EQ(2u, NumFragments(thread)); + EXPECT_EQ(LayoutPoint(100, 0), FragmentAt(thread, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(thread, 0).PaginationOffset()); + EXPECT_EQ(LayoutPoint(300, 100), FragmentAt(thread, 1).PaintOffset()); + EXPECT_EQ(LayoutPoint(200, 100), FragmentAt(thread, 1).PaginationOffset()); + + LayoutObject* content = GetLayoutObjectByElementId("content"); + EXPECT_EQ(2u, NumFragments(content)); + EXPECT_EQ(LayoutPoint(-200, 0), FragmentAt(content, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(content, 0).PaginationOffset()); + EXPECT_EQ(LayoutPoint(0, 100), FragmentAt(content, 1).PaintOffset()); + EXPECT_EQ(LayoutPoint(200, 100), FragmentAt(content, 1).PaginationOffset()); +} + +TEST_P(PaintPropertyTreeBuilderTest, CompositedUnderMultiColumn) { + SetBodyInnerHTML(R"HTML( + <style>body { margin: 0; }</style> + <div id='multicol' style='columns:3; column-fill:auto; column-gap: 0; + width: 300px; height: 200px'> + <div style='height: 300px'></div> + <div id='composited' style='will-change: transform; height: 300px'> + <div id='non-composited-child' style='height: 150px'></div> + <div id='composited-child' + style='will-change: transform; height: 150px'></div> + </div> + </div> + )HTML"); + + LayoutObject* thread = + GetLayoutObjectByElementId("multicol")->SlowFirstChild(); + EXPECT_TRUE(thread->IsLayoutFlowThread()); + EXPECT_EQ(3u, NumFragments(thread)); + EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(thread, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(thread, 0).PaginationOffset()); + EXPECT_EQ(LayoutPoint(100, -200), FragmentAt(thread, 1).PaintOffset()); + EXPECT_EQ(LayoutPoint(100, -200), FragmentAt(thread, 1).PaginationOffset()); + EXPECT_EQ(LayoutPoint(200, -400), FragmentAt(thread, 2).PaintOffset()); + EXPECT_EQ(LayoutPoint(200, -400), FragmentAt(thread, 2).PaginationOffset()); + + LayoutObject* composited = GetLayoutObjectByElementId("composited"); + LayoutObject* non_composited_child = + GetLayoutObjectByElementId("non-composited-child"); + LayoutObject* composited_child = + GetLayoutObjectByElementId("composited-child"); + if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { + // Compositing doesn't affect SPv2 fragmentation. + EXPECT_EQ(2u, NumFragments(composited)); + EXPECT_EQ(LayoutPoint(100, 100), FragmentAt(composited, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(100, -200), + FragmentAt(composited, 0).PaginationOffset()); + EXPECT_EQ(LayoutPoint(200, -100), FragmentAt(composited, 1).PaintOffset()); + EXPECT_EQ(LayoutPoint(200, -400), + FragmentAt(composited, 1).PaginationOffset()); + EXPECT_EQ(2u, NumFragments(non_composited_child)); + EXPECT_EQ(LayoutPoint(100, 100), + FragmentAt(non_composited_child, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(100, -200), + FragmentAt(non_composited_child, 0).PaginationOffset()); + EXPECT_EQ(LayoutPoint(200, -100), + FragmentAt(non_composited_child, 1).PaintOffset()); + EXPECT_EQ(LayoutPoint(200, -400), + FragmentAt(non_composited_child, 1).PaginationOffset()); + EXPECT_EQ(1u, NumFragments(composited_child)); + EXPECT_EQ(LayoutPoint(200, 50), + FragmentAt(composited_child, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(200, -400), + FragmentAt(composited_child, 0).PaginationOffset()); + } else { + // SPv1* forces single fragment for composited layers. + EXPECT_EQ(1u, NumFragments(composited)); + EXPECT_EQ(LayoutPoint(100, 100), FragmentAt(composited, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(100, -200), + FragmentAt(composited, 0).PaginationOffset()); + EXPECT_EQ(1u, NumFragments(non_composited_child)); + EXPECT_EQ(LayoutPoint(100, 100), + FragmentAt(non_composited_child, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(100, -200), + FragmentAt(non_composited_child, 0).PaginationOffset()); + EXPECT_EQ(1u, NumFragments(composited_child)); + EXPECT_EQ(LayoutPoint(100, 250), + FragmentAt(composited_child, 0).PaintOffset()); + EXPECT_EQ(LayoutPoint(100, -200), + FragmentAt(composited_child, 0).PaginationOffset()); + } +} + // Ensures no crash with multi-column containing relative-position inline with // spanner with absolute-position children. TEST_P(PaintPropertyTreeBuilderTest,
diff --git a/third_party/WebKit/Source/core/paint/compositing/CompositingInputsUpdater.cpp b/third_party/WebKit/Source/core/paint/compositing/CompositingInputsUpdater.cpp index b94d8f3..1499bc50 100644 --- a/third_party/WebKit/Source/core/paint/compositing/CompositingInputsUpdater.cpp +++ b/third_party/WebKit/Source/core/paint/compositing/CompositingInputsUpdater.cpp
@@ -181,12 +181,6 @@ bool layer_is_fixed_position = layer->GetLayoutObject().Style()->GetPosition() == EPosition::kFixed; - if (layer_is_fixed_position && properties.filter_ancestor && - layer->FixedToViewport()) { - UseCounter::Count(layer->GetLayoutObject().GetDocument(), - WebFeature::kViewportFixedPositionUnderFilter); - } - properties.nearest_fixed_position_layer = layer_is_fixed_position ? layer : parent->NearestFixedPositionLayer();
diff --git a/third_party/WebKit/Source/core/style/FillLayer.cpp b/third_party/WebKit/Source/core/style/FillLayer.cpp index f4c8b35..55a02d3 100644 --- a/third_party/WebKit/Source/core/style/FillLayer.cpp +++ b/third_party/WebKit/Source/core/style/FillLayer.cpp
@@ -31,8 +31,8 @@ Persistent<StyleImage> image_; - Length x_position_; - Length y_position_; + Length position_x_; + Length position_y_; LengthSize size_length_; @@ -46,8 +46,8 @@ FillLayer::FillLayer(EFillLayerType type, bool use_initial_values) : next_(nullptr), image_(FillLayer::InitialFillImage(type)), - x_position_(FillLayer::InitialFillXPosition(type)), - y_position_(FillLayer::InitialFillYPosition(type)), + position_x_(FillLayer::InitialFillPositionX(type)), + position_y_(FillLayer::InitialFillPositionY(type)), size_length_(FillLayer::InitialFillSizeLength(type)), attachment_( static_cast<unsigned>(FillLayer::InitialFillAttachment(type))), @@ -70,8 +70,8 @@ origin_set_(use_initial_values), repeat_x_set_(use_initial_values), repeat_y_set_(use_initial_values), - x_pos_set_(use_initial_values), - y_pos_set_(use_initial_values), + pos_x_set_(use_initial_values), + pos_y_set_(use_initial_values), background_x_origin_set_(false), background_y_origin_set_(false), composite_set_(use_initial_values || type == EFillLayerType::kMask), @@ -86,8 +86,8 @@ FillLayer::FillLayer(const FillLayer& o) : next_(o.next_ ? new FillLayer(*o.next_) : nullptr), image_(o.image_), - x_position_(o.x_position_), - y_position_(o.y_position_), + position_x_(o.position_x_), + position_y_(o.position_y_), size_length_(o.size_length_), attachment_(o.attachment_), clip_(o.clip_), @@ -106,8 +106,8 @@ origin_set_(o.origin_set_), repeat_x_set_(o.repeat_x_set_), repeat_y_set_(o.repeat_y_set_), - x_pos_set_(o.x_pos_set_), - y_pos_set_(o.y_pos_set_), + pos_x_set_(o.pos_x_set_), + pos_y_set_(o.pos_y_set_), background_x_origin_set_(o.background_x_origin_set_), background_y_origin_set_(o.background_y_origin_set_), composite_set_(o.composite_set_), @@ -130,8 +130,8 @@ } image_ = o.image_; - x_position_ = o.x_position_; - y_position_ = o.y_position_; + position_x_ = o.position_x_; + position_y_ = o.position_y_; background_x_origin_ = o.background_x_origin_; background_y_origin_ = o.background_y_origin_; background_x_origin_set_ = o.background_x_origin_set_; @@ -155,8 +155,8 @@ origin_set_ = o.origin_set_; repeat_x_set_ = o.repeat_x_set_; repeat_y_set_ = o.repeat_y_set_; - x_pos_set_ = o.x_pos_set_; - y_pos_set_ = o.y_pos_set_; + pos_x_set_ = o.pos_x_set_; + pos_y_set_ = o.pos_y_set_; mask_source_type_set_ = o.mask_source_type_set_; type_ = o.type_; @@ -167,8 +167,8 @@ } bool FillLayer::LayerPropertiesEqual(const FillLayer& o) const { - return DataEquivalent(image_, o.image_) && x_position_ == o.x_position_ && - y_position_ == o.y_position_ && + return DataEquivalent(image_, o.image_) && position_x_ == o.position_x_ && + position_y_ == o.position_y_ && background_x_origin_ == o.background_x_origin_ && background_y_origin_ == o.background_y_origin_ && attachment_ == o.attachment_ && clip_ == o.clip_ && @@ -196,12 +196,12 @@ void FillLayer::FillUnsetProperties() { FillLayer* curr; - for (curr = this; curr && curr->IsXPositionSet(); curr = curr->Next()) { + for (curr = this; curr && curr->IsPositionXSet(); curr = curr->Next()) { } if (curr && curr != this) { // We need to fill in the remaining values with the pattern specified. for (FillLayer* pattern = this; curr; curr = curr->Next()) { - curr->x_position_ = pattern->x_position_; + curr->position_x_ = pattern->position_x_; if (pattern->IsBackgroundXOriginSet()) curr->background_x_origin_ = pattern->background_x_origin_; if (pattern->IsBackgroundYOriginSet()) @@ -212,12 +212,12 @@ } } - for (curr = this; curr && curr->IsYPositionSet(); curr = curr->Next()) { + for (curr = this; curr && curr->IsPositionYSet(); curr = curr->Next()) { } if (curr && curr != this) { // We need to fill in the remaining values with the pattern specified. for (FillLayer* pattern = this; curr; curr = curr->Next()) { - curr->y_position_ = pattern->y_position_; + curr->position_y_ = pattern->position_y_; if (pattern->IsBackgroundXOriginSet()) curr->background_x_origin_ = pattern->background_x_origin_; if (pattern->IsBackgroundYOriginSet())
diff --git a/third_party/WebKit/Source/core/style/FillLayer.h b/third_party/WebKit/Source/core/style/FillLayer.h index 98dadb9..29e2cf4 100644 --- a/third_party/WebKit/Source/core/style/FillLayer.h +++ b/third_party/WebKit/Source/core/style/FillLayer.h
@@ -60,8 +60,8 @@ ~FillLayer(); StyleImage* GetImage() const { return image_.Get(); } - const Length& XPosition() const { return x_position_; } - const Length& YPosition() const { return y_position_; } + const Length& PositionX() const { return position_x_; } + const Length& PositionY() const { return position_y_; } BackgroundEdgeOrigin BackgroundXOrigin() const { return static_cast<BackgroundEdgeOrigin>(background_x_origin_); } @@ -101,8 +101,8 @@ } bool IsImageSet() const { return image_set_; } - bool IsXPositionSet() const { return x_pos_set_; } - bool IsYPositionSet() const { return y_pos_set_; } + bool IsPositionXSet() const { return pos_x_set_; } + bool IsPositionYSet() const { return pos_y_set_; } bool IsBackgroundXOriginSet() const { return background_x_origin_set_; } bool IsBackgroundYOriginSet() const { return background_y_origin_set_; } bool IsAttachmentSet() const { return attachment_set_; } @@ -121,15 +121,15 @@ image_ = i; image_set_ = true; } - void SetXPosition(const Length& position) { - x_position_ = position; - x_pos_set_ = true; + void SetPositionX(const Length& position) { + position_x_ = position; + pos_x_set_ = true; background_x_origin_set_ = false; background_x_origin_ = static_cast<unsigned>(BackgroundEdgeOrigin::kLeft); } - void SetYPosition(const Length& position) { - y_position_ = position; - y_pos_set_ = true; + void SetPositionY(const Length& position) { + position_y_ = position; + pos_y_set_ = true; background_y_origin_set_ = false; background_y_origin_ = static_cast<unsigned>(BackgroundEdgeOrigin::kTop); } @@ -187,12 +187,12 @@ image_.Clear(); image_set_ = false; } - void ClearXPosition() { - x_pos_set_ = false; + void ClearPositionX() { + pos_x_set_ = false; background_x_origin_set_ = false; } - void ClearYPosition() { - y_pos_set_ = false; + void ClearPositionY() { + pos_y_set_ = false; background_y_origin_set_ = false; } @@ -286,10 +286,10 @@ static FillSize InitialFillSize(EFillLayerType type) { return FillSize(InitialFillSizeType(type), InitialFillSizeLength(type)); } - static Length InitialFillXPosition(EFillLayerType) { + static Length InitialFillPositionX(EFillLayerType) { return Length(0.0, kPercent); } - static Length InitialFillYPosition(EFillLayerType) { + static Length InitialFillPositionY(EFillLayerType) { return Length(0.0, kPercent); } static StyleImage* InitialFillImage(EFillLayerType) { return nullptr; } @@ -310,8 +310,8 @@ Persistent<StyleImage> image_; - Length x_position_; - Length y_position_; + Length position_x_; + Length position_y_; LengthSize size_length_; @@ -333,8 +333,8 @@ unsigned origin_set_ : 1; unsigned repeat_x_set_ : 1; unsigned repeat_y_set_ : 1; - unsigned x_pos_set_ : 1; - unsigned y_pos_set_ : 1; + unsigned pos_x_set_ : 1; + unsigned pos_y_set_ : 1; unsigned background_x_origin_set_ : 1; unsigned background_y_origin_set_ : 1; unsigned composite_set_ : 1;
diff --git a/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.cpp b/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.cpp index 324d4ed..e5d67d0d 100644 --- a/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.cpp +++ b/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.cpp
@@ -20,6 +20,8 @@ namespace blink { +constexpr size_t NavigatorBeacon::kMaxAllowance; + NavigatorBeacon::NavigatorBeacon(Navigator& navigator) : Supplement<Navigator>(navigator), transmitted_bytes_(0) {} @@ -64,28 +66,6 @@ return true; } -// Determine the remaining size allowance for Beacon transmissions. -// If (-1) is returned, a no limit policy is in place, otherwise -// it is the max size (in bytes) of a beacon request. -// -// The loader takes the allowance into account once the Beacon -// payload size has been determined, deciding if the transmission -// will be allowed to go ahead or not. -int NavigatorBeacon::MaxAllowance() const { - DCHECK(GetSupplementable()->GetFrame()); - const Settings* settings = GetSupplementable()->GetFrame()->GetSettings(); - if (settings) { - int max_allowed = settings->GetMaxBeaconTransmission(); - // Any negative value represent no max limit. - if (max_allowed < 0) - return -1; - if (static_cast<size_t>(max_allowed) <= transmitted_bytes_) - return 0; - return max_allowed - static_cast<int>(transmitted_bytes_); - } - return -1; -} - void NavigatorBeacon::AddTransmittedBytes(size_t sent_bytes) { transmitted_bytes_ += sent_bytes; } @@ -110,7 +90,8 @@ if (!CanSendBeacon(context, url, exception_state)) return false; - int allowance = MaxAllowance(); + size_t allowance = + kMaxAllowance - std::min(kMaxAllowance, transmitted_bytes_); size_t beacon_size = 0; bool allowed; @@ -150,9 +131,7 @@ return false; } - // Only accumulate transmission size if a limit is imposed. - if (allowance >= 0) - AddTransmittedBytes(beacon_size); + AddTransmittedBytes(beacon_size); return true; }
diff --git a/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.h b/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.h index 16763ba..32e4199 100644 --- a/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.h +++ b/third_party/WebKit/Source/modules/beacon/NavigatorBeacon.h
@@ -46,6 +46,8 @@ void AddTransmittedBytes(size_t sent_bytes); size_t transmitted_bytes_; + + static constexpr size_t kMaxAllowance = 65536; }; } // namespace blink
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 2de9a72..5cc96d7 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -16948,7 +16948,7 @@ <int value="1958" label="MediaStreamConstraintsGoogDAEchoCancellation"/> <int value="1959" label="MediaStreamConstraintsGoogNoiseReduction"/> <int value="1960" label="MediaStreamConstraintsGoogPowerLineFrequency"/> - <int value="1961" label="ViewportFixedPositionUnderFilter"/> + <int value="1961" label="ViewportFixedPositionUnderFilter (obsolete)"/> <int value="1962" label="RequestMIDIAccessWithSysExOption_ObscuredByFootprinting"/> <int value="1963"