diff --git a/base/values.cc b/base/values.cc index 012410bd..d0058359 100644 --- a/base/values.cc +++ b/base/values.cc
@@ -1233,7 +1233,7 @@ list_->push_back(std::move(*in_value)); } -#if !defined(OS_LINUX) +#if !defined(OS_LINUX) && !defined(OS_MACOSX) void ListValue::Append(Value* in_value) { DCHECK(in_value); Append(WrapUnique(in_value));
diff --git a/base/values.h b/base/values.h index 5e5e4b6..a18f11f 100644 --- a/base/values.h +++ b/base/values.h
@@ -450,7 +450,7 @@ // Appends a Value to the end of the list. void Append(std::unique_ptr<Value> in_value); -#if !defined(OS_LINUX) +#if !defined(OS_LINUX) && !defined(OS_MACOSX) // Deprecated version of the above. TODO(estade): remove. void Append(Value* in_value); #endif
diff --git a/chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc b/chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc index 2c5781d..dde2aa4 100644 --- a/chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc +++ b/chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc
@@ -13,11 +13,11 @@ #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h" -#include "content/public/test/mock_storage_client.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread_bundle.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_manager_proxy.h" +#include "storage/browser/test/mock_storage_client.h" using content::BrowserThread; using content::MockOriginData;
diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc index 8e86338..82ab680f 100644 --- a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc +++ b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
@@ -146,6 +146,12 @@ namespace chromeos { +QueryResult::QueryResult() = default; + +QueryResult::QueryResult(const QueryResult& other) = default; + +QueryResult::~QueryResult() = default; + CupsPrintJobManagerImpl::CupsPrintJobManagerImpl(Profile* profile) : CupsPrintJobManager(profile), cups_connection_(GURL(), HTTP_ENCRYPT_NEVER, false),
diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h index a26392f..cdf72369 100644 --- a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h +++ b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.h
@@ -24,6 +24,10 @@ namespace chromeos { struct QueryResult { + QueryResult(); + QueryResult(const QueryResult& other); + ~QueryResult(); + bool success; std::vector<::printing::QueueStatus> queues; };
diff --git a/chrome/browser/chromeos/proxy_cros_settings_parser.cc b/chrome/browser/chromeos/proxy_cros_settings_parser.cc index be6d08fe..baee7de 100644 --- a/chrome/browser/chromeos/proxy_cros_settings_parser.cc +++ b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
@@ -282,12 +282,10 @@ config_service->SetProxyConfig(network_guid, config); } -// TODO(crbug.com/697817): Change |out_value| to be -// std::unique_ptr<base::Value>*. bool GetProxyPrefValue(const std::string& network_guid, const std::string& path, UIProxyConfigService* config_service, - base::Value** out_value) { + std::unique_ptr<base::Value>* out_value) { std::string controlled_by; std::unique_ptr<base::Value> data; UIProxyConfig config; @@ -358,12 +356,12 @@ list->AppendString(rule->ToString()); data = std::move(list); } else { - *out_value = NULL; + out_value->reset(); return false; } // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. - base::DictionaryValue* dict = new base::DictionaryValue; + auto dict = base::MakeUnique<base::DictionaryValue>(); if (!data) data = base::MakeUnique<base::Value>(base::Value::Type::STRING); dict->Set("value", std::move(data)); @@ -374,7 +372,7 @@ } else { dict->SetBoolean("disabled", false); } - *out_value = dict; + *out_value = std::move(dict); return true; }
diff --git a/chrome/browser/chromeos/proxy_cros_settings_parser.h b/chrome/browser/chromeos/proxy_cros_settings_parser.h index 7d79156f..7d427fb4 100644 --- a/chrome/browser/chromeos/proxy_cros_settings_parser.h +++ b/chrome/browser/chromeos/proxy_cros_settings_parser.h
@@ -7,6 +7,7 @@ #include <stddef.h> +#include <memory> #include <string> namespace base { @@ -55,7 +56,7 @@ bool GetProxyPrefValue(const std::string& network_guid, const std::string& path, UIProxyConfigService* config_service, - base::Value** out_value); + std::unique_ptr<base::Value>* out_value); } // namespace proxy_cros_settings_parser
diff --git a/chrome/browser/ui/app_list/search/common/webservice_cache.cc b/chrome/browser/ui/app_list/search/common/webservice_cache.cc index 40b116ac..b1f103c 100644 --- a/chrome/browser/ui/app_list/search/common/webservice_cache.cc +++ b/chrome/browser/ui/app_list/search/common/webservice_cache.cc
@@ -128,15 +128,15 @@ return true; } -base::DictionaryValue* WebserviceCache::DictFromPayload( +std::unique_ptr<base::DictionaryValue> WebserviceCache::DictFromPayload( const Payload& payload) { - base::DictionaryValue* dict = new base::DictionaryValue(); + auto dict = base::MakeUnique<base::DictionaryValue>(); dict->SetString(kKeyResultTime, base::Int64ToString( payload.time.ToInternalValue())); // The payload will still keep ownership of it's result dict, hence put a // a copy of the result dictionary here. This dictionary will be owned by // data_store_->cached_dict(). - dict->Set(kKeyResult, payload.result->DeepCopy()); + dict->Set(kKeyResult, base::MakeUnique<base::Value>(*payload.result)); return dict; }
diff --git a/chrome/browser/ui/app_list/search/common/webservice_cache.h b/chrome/browser/ui/app_list/search/common/webservice_cache.h index d9f67ca..425c38a4 100644 --- a/chrome/browser/ui/app_list/search/common/webservice_cache.h +++ b/chrome/browser/ui/app_list/search/common/webservice_cache.h
@@ -88,7 +88,8 @@ // Returns a dictionary value for a given payload. The returned dictionary // will be owned by the data_store_ cached_dict, and freed on the destruction // of our dictionary datastore. - base::DictionaryValue* DictFromPayload(const Payload& payload); + std::unique_ptr<base::DictionaryValue> DictFromPayload( + const Payload& payload); // Trims our MRU cache, making sure that any element that is removed is also // removed from the dictionary data store.
diff --git a/chrome/browser/ui/ash/chrome_launcher_prefs.cc b/chrome/browser/ui/ash/chrome_launcher_prefs.cc index 5d60fb7a..598556a0 100644 --- a/chrome/browser/ui/ash/chrome_launcher_prefs.cc +++ b/chrome/browser/ui/ash/chrome_launcher_prefs.cc
@@ -6,7 +6,9 @@ #include <stddef.h> +#include <memory> #include <set> +#include <utility> #include "ash/public/cpp/app_launch_id.h" #include "base/macros.h" @@ -137,12 +139,13 @@ DictionaryPrefUpdate update(prefs, prefs::kShelfPreferences); base::DictionaryValue* shelf_prefs = update.Get(); - base::DictionaryValue* display_prefs = nullptr; - if (!shelf_prefs->GetDictionary(display_key, &display_prefs)) { - display_prefs = new base::DictionaryValue(); - shelf_prefs->Set(display_key, display_prefs); + base::DictionaryValue* display_prefs_weak = nullptr; + if (!shelf_prefs->GetDictionary(display_key, &display_prefs_weak)) { + auto display_prefs = base::MakeUnique<base::DictionaryValue>(); + display_prefs_weak = display_prefs.get(); + shelf_prefs->Set(display_key, std::move(display_prefs)); } - display_prefs->SetStringWithoutPathExpansion(pref_key, value); + display_prefs_weak->SetStringWithoutPathExpansion(pref_key, value); } ShelfAlignment AlignmentFromPref(const std::string& value) {
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc index 8b0ef3b..1c3b07e0 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
@@ -327,11 +327,12 @@ "for testing pinned platform apps"); manifest_platform_app.SetString(extensions::manifest_keys::kApp, "true"); manifest_platform_app.Set(extensions::manifest_keys::kPlatformAppBackground, - new base::DictionaryValue()); - base::ListValue* scripts = new base::ListValue(); + base::MakeUnique<base::DictionaryValue>()); + auto scripts = base::MakeUnique<base::ListValue>(); scripts->AppendString("main.js"); manifest_platform_app.Set( - extensions::manifest_keys::kPlatformAppBackgroundScripts, scripts); + extensions::manifest_keys::kPlatformAppBackgroundScripts, + std::move(scripts)); extensions::TestExtensionSystem* extension_system( static_cast<extensions::TestExtensionSystem*>( @@ -371,9 +372,9 @@ "for testing pinned Gmail"); manifest_gmail.SetString(extensions::manifest_keys::kLaunchWebURL, kGmailLaunchURL); - base::ListValue* list = new base::ListValue(); + auto list = base::MakeUnique<base::ListValue>(); list->AppendString("*://mail.google.com/mail/ca"); - manifest_gmail.Set(extensions::manifest_keys::kWebURLs, list); + manifest_gmail.Set(extensions::manifest_keys::kWebURLs, std::move(list)); extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, manifest_gmail, Extension::NO_FLAGS,
diff --git a/chrome/browser/ui/browser_window_state.cc b/chrome/browser/ui/browser_window_state.cc index e7eb1923..54f3544c 100644 --- a/chrome/browser/ui/browser_window_state.cc +++ b/chrome/browser/ui/browser_window_state.cc
@@ -6,6 +6,8 @@ #include <stddef.h> +#include <utility> + #include "base/command_line.h" #include "base/macros.h" #include "base/memory/ptr_util.h" @@ -56,12 +58,13 @@ base::DictionaryValue* Get() override { base::DictionaryValue* all_apps_dict = DictionaryPrefUpdate::Get(); - base::DictionaryValue* this_app_dict = NULL; - if (!all_apps_dict->GetDictionary(window_name_, &this_app_dict)) { - this_app_dict = new base::DictionaryValue; - all_apps_dict->Set(window_name_, this_app_dict); + base::DictionaryValue* this_app_dict_weak = NULL; + if (!all_apps_dict->GetDictionary(window_name_, &this_app_dict_weak)) { + auto this_app_dict = base::MakeUnique<base::DictionaryValue>(); + this_app_dict_weak = this_app_dict.get(); + all_apps_dict->Set(window_name_, std::move(this_app_dict)); } - return this_app_dict; + return this_app_dict_weak; } private:
diff --git a/chrome/browser/ui/webui/browsing_history_handler.cc b/chrome/browser/ui/webui/browsing_history_handler.cc index 046516d..34947f1 100644 --- a/chrome/browser/ui/webui/browsing_history_handler.cc +++ b/chrome/browser/ui/webui/browsing_history_handler.cc
@@ -194,7 +194,7 @@ it != entry->all_timestamps.end(); ++it) { timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime()); } - result->Set("allTimestamps", timestamps.release()); + result->Set("allTimestamps", std::move(timestamps)); // Always pass the short date since it is needed both in the search and in // the monthly view.
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index 37156b8..ac624b6 100644 --- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -352,7 +352,7 @@ base::DictionaryValue app_list; app_list.SetString("etag", parsed_app_list->etag()); - base::ListValue* items = new base::ListValue(); + auto items = base::MakeUnique<base::ListValue>(); for (size_t i = 0; i < parsed_app_list->items().size(); ++i) { const google_apis::AppResource* app = parsed_app_list->items()[i].get(); auto app_data = base::MakeUnique<base::DictionaryValue>(); @@ -363,7 +363,7 @@ items->Append(std::move(app_data)); } - app_list.Set("items", items); + app_list.Set("items", std::move(items)); web_ui()->CallJavascriptFunctionUnsafe("updateAppList", app_list); }
diff --git a/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc index 865ceac..3933864 100644 --- a/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
@@ -4,6 +4,10 @@ #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h" +#include <utility> + +#include "base/memory/ptr_util.h" +#include "base/values.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/screens/network_error.h" @@ -85,10 +89,9 @@ data.SetBoolean("shortcutEnabled", !KioskAppManager::Get()->GetDisableBailoutShortcut()); - // |data| will take ownership of |app_info|. - base::DictionaryValue *app_info = new base::DictionaryValue(); - PopulateAppInfo(app_info); - data.Set("appInfo", app_info); + auto app_info = base::MakeUnique<base::DictionaryValue>(); + PopulateAppInfo(app_info.get()); + data.Set("appInfo", std::move(app_info)); SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); ShowScreenWithData(kScreenId, &data);
diff --git a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc index 231dc669..deb6689 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc
@@ -48,7 +48,7 @@ private: // Converts menu model into the ListValue, ready for passing to WebUI. - base::ListValue* ConvertMenuModel(ui::MenuModel* model); + std::unique_ptr<base::ListValue> ConvertMenuModel(ui::MenuModel* model); // WebUI where network menu is located. content::WebUI* web_ui_; @@ -81,8 +81,9 @@ model->ActivatedAt(index); } -base::ListValue* NetworkMenuWebUI::ConvertMenuModel(ui::MenuModel* model) { - base::ListValue* list = new base::ListValue(); +std::unique_ptr<base::ListValue> NetworkMenuWebUI::ConvertMenuModel( + ui::MenuModel* model) { + auto list = base::MakeUnique<base::ListValue>(); for (int i = 0; i < model->GetItemCount(); ++i) { ui::MenuModel::ItemType type = model->GetTypeAt(i); int id;
diff --git a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc index e20720e8..336d10c6 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
@@ -246,11 +246,10 @@ const bool enable_layouts = !user_manager::UserManager::Get()->IsUserLoggedIn() && !is_slave; - dict->Set("languageList", language_list.release()); - dict->Set( - "inputMethodsList", - GetAndActivateLoginKeyboardLayouts( - application_locale, selected_input_method, enable_layouts).release()); + dict->Set("languageList", std::move(language_list)); + dict->Set("inputMethodsList", + GetAndActivateLoginKeyboardLayouts( + application_locale, selected_input_method, enable_layouts)); dict->Set("timezoneList", GetTimezoneList()); } @@ -268,7 +267,7 @@ // NetworkScreenHandler, private: ---------------------------------------------- // static -base::ListValue* NetworkScreenHandler::GetTimezoneList() { +std::unique_ptr<base::ListValue> NetworkScreenHandler::GetTimezoneList() { std::string current_timezone_id; CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); @@ -292,7 +291,7 @@ timezone_list->Append(std::move(timezone_option)); } - return timezone_list.release(); + return timezone_list; } } // namespace chromeos
diff --git a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h index a181032..cbf4f712 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h
@@ -17,6 +17,10 @@ #include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/gfx/geometry/point.h" +namespace base { +class ListValue; +} + namespace chromeos { class CoreOobeView; @@ -48,7 +52,7 @@ void Initialize() override; // Returns available timezones. Caller gets the ownership. - static base::ListValue* GetTimezoneList(); + static std::unique_ptr<base::ListValue> GetTimezoneList(); CoreOobeView* core_oobe_view_ = nullptr; NetworkScreen* screen_ = nullptr;
diff --git a/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc index 0ac53b7..840bb5a 100644 --- a/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc
@@ -239,7 +239,7 @@ user_dict.get()); users_list->Append(std::move(user_dict)); } - data->Set("managers", users_list.release()); + data->Set("managers", std::move(users_list)); ShowScreenWithData(OobeScreen::SCREEN_CREATE_SUPERVISED_USER_FLOW, data.get());
diff --git a/chrome/browser/ui/webui/chromeos/network_ui.cc b/chrome/browser/ui/webui/chromeos/network_ui.cc index f8ca248..ac5352e 100644 --- a/chrome/browser/ui/webui/chromeos/network_ui.cc +++ b/chrome/browser/ui/webui/chromeos/network_ui.cc
@@ -67,7 +67,7 @@ ip_configs.release()); } if (!device_dictionary->empty()) - dictionary->Set(shill::kDeviceProperty, device_dictionary.release()); + dictionary->Set(shill::kDeviceProperty, std::move(device_dictionary)); } class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
diff --git a/chrome/browser/ui/webui/chromeos/power_ui.cc b/chrome/browser/ui/webui/chromeos/power_ui.cc index 70cfa00..0a354f9 100644 --- a/chrome/browser/ui/webui/chromeos/power_ui.cc +++ b/chrome/browser/ui/webui/chromeos/power_ui.cc
@@ -6,6 +6,7 @@ #include <stddef.h> +#include <memory> #include <utility> #include "base/bind.h" @@ -177,7 +178,7 @@ state_dict->SetDouble(state_names[index], static_cast<double>(sample.time_in_state[index])); } - js_sample->Set("timeInState", state_dict.release()); + js_sample->Set("timeInState", std::move(state_dict)); js_sample_list->Append(std::move(js_sample)); }
diff --git a/chrome/browser/ui/webui/chromeos/set_time_ui.cc b/chrome/browser/ui/webui/chromeos/set_time_ui.cc index 154c9ed8..98871678 100644 --- a/chrome/browser/ui/webui/chromeos/set_time_ui.cc +++ b/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -118,7 +118,7 @@ source->AddLocalizedString("timeLabel", IDS_SET_TIME_TIME_LABEL); base::DictionaryValue values; - values.Set("timezoneList", chromeos::system::GetTimezoneList().release()); + values.Set("timezoneList", chromeos::system::GetTimezoneList()); // If we are not logged in, we need to show the time zone dropdown. // Otherwise, we can leave |currentTimezoneId| blank.
diff --git a/chrome/browser/ui/webui/components_ui.cc b/chrome/browser/ui/webui/components_ui.cc index 2b716f5d..d815653 100644 --- a/chrome/browser/ui/webui/components_ui.cc +++ b/chrome/browser/ui/webui/components_ui.cc
@@ -104,9 +104,8 @@ void ComponentsDOMHandler::HandleRequestComponentsData( const base::ListValue* args) { - base::ListValue* list = ComponentsUI::LoadComponents(); base::DictionaryValue result; - result.Set("components", list); + result.Set("components", ComponentsUI::LoadComponents()); web_ui()->CallJavascriptFunctionUnsafe("returnComponentsData", result); } @@ -164,14 +163,14 @@ } // static -base::ListValue* ComponentsUI::LoadComponents() { +std::unique_ptr<base::ListValue> ComponentsUI::LoadComponents() { component_updater::ComponentUpdateService* cus = g_browser_process->component_updater(); std::vector<std::string> component_ids; component_ids = cus->GetComponentIDs(); // Construct DictionaryValues to return to UI. - base::ListValue* component_list = new base::ListValue(); + auto component_list = base::MakeUnique<base::ListValue>(); for (size_t j = 0; j < component_ids.size(); ++j) { update_client::CrxUpdateItem item; if (cus->GetComponentDetails(component_ids[j], &item)) {
diff --git a/chrome/browser/ui/webui/components_ui.h b/chrome/browser/ui/webui/components_ui.h index b12052bf..4a4584e2 100644 --- a/chrome/browser/ui/webui/components_ui.h +++ b/chrome/browser/ui/webui/components_ui.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_UI_WEBUI_COMPONENTS_UI_H_ #define CHROME_BROWSER_UI_WEBUI_COMPONENTS_UI_H_ +#include <memory> #include <string> #include "base/macros.h" @@ -14,6 +15,7 @@ #include "ui/base/layout.h" namespace base { +class ListValue; class RefCountedMemory; } @@ -25,7 +27,7 @@ static void OnDemandUpdate(const std::string& component_id); - static base::ListValue* LoadComponents(); + static std::unique_ptr<base::ListValue> LoadComponents(); static base::RefCountedMemory* GetFaviconResourceBytes( ui::ScaleFactor scale_factor);
diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chrome/browser/ui/webui/cookies_tree_model_util.cc index 6141403..0d9e80a 100644 --- a/chrome/browser/ui/webui/cookies_tree_model_util.cc +++ b/chrome/browser/ui/webui/cookies_tree_model_util.cc
@@ -9,6 +9,7 @@ #include <vector> #include "base/i18n/time_formatting.h" +#include "base/memory/ptr_util.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" @@ -255,14 +256,14 @@ dict->SetString(kKeyOrigin, service_worker_info.origin.spec()); dict->SetString(kKeySize, ui::FormatBytes(service_worker_info.total_size_bytes)); - base::ListValue* scopes = new base::ListValue; + auto scopes = base::MakeUnique<base::ListValue>(); for (std::vector<GURL>::const_iterator it = service_worker_info.scopes.begin(); it != service_worker_info.scopes.end(); ++it) { scopes->AppendString(it->spec()); } - dict->Set(kKeyScopes, scopes); + dict->Set(kKeyScopes, std::move(scopes)); break; } case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE: { @@ -305,7 +306,7 @@ const extensions::ExtensionSet* protecting_apps = node.GetModel()->ExtensionsProtectingNode(node); if (protecting_apps && !protecting_apps->is_empty()) { - base::ListValue* app_infos = new base::ListValue; + auto app_infos = base::MakeUnique<base::ListValue>(); for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); it != protecting_apps->end(); ++it) { std::unique_ptr<base::DictionaryValue> app_info( @@ -314,7 +315,7 @@ app_info->SetString(kKeyName, (*it)->name()); app_infos->Append(std::move(app_info)); } - dict->Set(kKeyAppsProtectingThis, app_infos); + dict->Set(kKeyAppsProtectingThis, std::move(app_infos)); } #endif
diff --git a/chrome/browser/ui/webui/extensions/extension_loader_handler.cc b/chrome/browser/ui/webui/extensions/extension_loader_handler.cc index f85d09d..846123f 100644 --- a/chrome/browser/ui/webui/extensions/extension_loader_handler.cc +++ b/chrome/browser/ui/webui/extensions/extension_loader_handler.cc
@@ -4,17 +4,20 @@ #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h" +#include <memory> #include <utility> #include "base/bind.h" #include "base/files/file_util.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/task_scheduler/post_task.h" +#include "base/values.h" #include "chrome/browser/extensions/path_util.h" #include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/profiles/profile.h" @@ -205,9 +208,9 @@ highlighter.SetHighlightedRegions(manifest_value.get()); std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); - failure->Set("path", new base::Value(prettified_path.LossyDisplayName())); - failure->Set("error", new base::Value(base::UTF8ToUTF16(error))); - failure->Set("manifest", manifest_value.release()); + failure->SetString("path", prettified_path.LossyDisplayName()); + failure->SetString("error", error); + failure->Set("manifest", std::move(manifest_value)); failures_.Append(std::move(failure)); // Only notify the frontend if the frontend UI is ready.
diff --git a/chrome/browser/ui/webui/flags_ui.cc b/chrome/browser/ui/webui/flags_ui.cc index 5a892e3..75db6452 100644 --- a/chrome/browser/ui/webui/flags_ui.cc +++ b/chrome/browser/ui/webui/flags_ui.cc
@@ -4,7 +4,9 @@ #include "chrome/browser/ui/webui/flags_ui.h" +#include <memory> #include <string> +#include <utility> #include "base/bind.h" #include "base/bind_helpers.h" @@ -192,8 +194,8 @@ access_, supported_features.get(), unsupported_features.get()); - results.Set(flags_ui::kSupportedFeatures, supported_features.release()); - results.Set(flags_ui::kUnsupportedFeatures, unsupported_features.release()); + results.Set(flags_ui::kSupportedFeatures, std::move(supported_features)); + results.Set(flags_ui::kUnsupportedFeatures, std::move(unsupported_features)); results.SetBoolean(flags_ui::kNeedsRestart, about_flags::IsRestartNeededToCommitChanges()); results.SetBoolean(flags_ui::kShowOwnerWarning,
diff --git a/chrome/browser/ui/webui/flash_ui.cc b/chrome/browser/ui/webui/flash_ui.cc index 35e5d818..451ca502 100644 --- a/chrome/browser/ui/webui/flash_ui.cc +++ b/chrome/browser/ui/webui/flash_ui.cc
@@ -242,13 +242,12 @@ // need to jump through hoops to offload this to the IO thread. base::ThreadRestrictions::ScopedAllowIO allow_io; - base::ListValue* list = new base::ListValue(); + auto list = base::MakeUnique<base::ListValue>(); // Chrome version information. - AddPair(list, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), - version_info::GetVersionNumber() + " (" + - chrome::GetChannelString() + ")"); + AddPair(list.get(), l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), + version_info::GetVersionNumber() + " (" + chrome::GetChannelString() + + ")"); // OS version information. std::string os_label = version_info::GetOSType(); @@ -270,14 +269,14 @@ if (os->architecture() == base::win::OSInfo::X64_ARCHITECTURE) os_label += " 64 bit"; #endif - AddPair(list, l10n_util::GetStringUTF16(IDS_VERSION_UI_OS), os_label); + AddPair(list.get(), l10n_util::GetStringUTF16(IDS_VERSION_UI_OS), os_label); // Obtain the version of the Flash plugins. std::vector<content::WebPluginInfo> info_array; PluginService::GetInstance()->GetPluginInfoArray( GURL(), content::kFlashPluginSwfMimeType, false, &info_array, NULL); if (info_array.empty()) { - AddPair(list, ASCIIToUTF16(kFlashPlugin), "Not installed"); + AddPair(list.get(), ASCIIToUTF16(kFlashPlugin), "Not installed"); } else { PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(Profile::FromWebUI(web_ui())).get(); @@ -295,12 +294,12 @@ } else { flash_version += ASCIIToUTF16(" (disabled)"); } - AddPair(list, ASCIIToUTF16(kFlashPlugin), flash_version); + AddPair(list.get(), ASCIIToUTF16(kFlashPlugin), flash_version); } } // Crash information. - AddPair(list, base::string16(), "--- Crash data ---"); + AddPair(list.get(), base::string16(), "--- Crash data ---"); bool crash_reporting_enabled = ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); if (crash_reporting_enabled) { @@ -312,22 +311,22 @@ base::string16 crash_string(ASCIIToUTF16(i->upload_id)); crash_string += ASCIIToUTF16(" "); crash_string += base::TimeFormatFriendlyDateAndTime(i->upload_time); - AddPair(list, ASCIIToUTF16("crash id"), crash_string); + AddPair(list.get(), ASCIIToUTF16("crash id"), crash_string); } } else { - AddPair(list, ASCIIToUTF16("Crash Reporting"), - "Enable crash reporting to see crash IDs"); - AddPair(list, ASCIIToUTF16("For more details"), - chrome::kLearnMoreReportingURL); + AddPair(list.get(), ASCIIToUTF16("Crash Reporting"), + "Enable crash reporting to see crash IDs"); + AddPair(list.get(), ASCIIToUTF16("For more details"), + chrome::kLearnMoreReportingURL); } // GPU information. - AddPair(list, base::string16(), "--- GPU information ---"); + AddPair(list.get(), base::string16(), "--- GPU information ---"); gpu::GPUInfo gpu_info = GpuDataManager::GetInstance()->GetGPUInfo(); std::string reason; if (!GpuDataManager::GetInstance()->GpuAccessAllowed(&reason)) { - AddPair(list, ASCIIToUTF16("WARNING:"), + AddPair(list.get(), ASCIIToUTF16("WARNING:"), "GPU access is not allowed: " + reason); } #if defined(OS_WIN) @@ -342,40 +341,37 @@ ++it2) { if (!it2->second.empty()) { if (it2->first == "szDescription") { - AddPair(list, ASCIIToUTF16("Graphics card"), it2->second); + AddPair(list.get(), ASCIIToUTF16("Graphics card"), it2->second); } else if (it2->first == "szDriverNodeStrongName") { - AddPair(list, ASCIIToUTF16("Driver name (strong)"), it2->second); + AddPair(list.get(), ASCIIToUTF16("Driver name (strong)"), + it2->second); } else if (it2->first == "szDriverName") { - AddPair(list, ASCIIToUTF16("Driver display name"), it2->second); + AddPair(list.get(), ASCIIToUTF16("Driver display name"), it2->second); } } } } #endif - AddPair(list, base::string16(), "--- GPU driver, more information ---"); - AddPair(list, - ASCIIToUTF16("Vendor Id"), + AddPair(list.get(), base::string16(), "--- GPU driver, more information ---"); + AddPair(list.get(), ASCIIToUTF16("Vendor Id"), base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); - AddPair(list, - ASCIIToUTF16("Device Id"), + AddPair(list.get(), ASCIIToUTF16("Device Id"), base::StringPrintf("0x%04x", gpu_info.gpu.device_id)); - AddPair(list, ASCIIToUTF16("Driver vendor"), gpu_info.driver_vendor); - AddPair(list, ASCIIToUTF16("Driver version"), gpu_info.driver_version); - AddPair(list, ASCIIToUTF16("Driver date"), gpu_info.driver_date); - AddPair(list, - ASCIIToUTF16("Pixel shader version"), + AddPair(list.get(), ASCIIToUTF16("Driver vendor"), gpu_info.driver_vendor); + AddPair(list.get(), ASCIIToUTF16("Driver version"), gpu_info.driver_version); + AddPair(list.get(), ASCIIToUTF16("Driver date"), gpu_info.driver_date); + AddPair(list.get(), ASCIIToUTF16("Pixel shader version"), gpu_info.pixel_shader_version); - AddPair(list, - ASCIIToUTF16("Vertex shader version"), + AddPair(list.get(), ASCIIToUTF16("Vertex shader version"), gpu_info.vertex_shader_version); - AddPair(list, ASCIIToUTF16("GL_VENDOR"), gpu_info.gl_vendor); - AddPair(list, ASCIIToUTF16("GL_RENDERER"), gpu_info.gl_renderer); - AddPair(list, ASCIIToUTF16("GL_VERSION"), gpu_info.gl_version); - AddPair(list, ASCIIToUTF16("GL_EXTENSIONS"), gpu_info.gl_extensions); + AddPair(list.get(), ASCIIToUTF16("GL_VENDOR"), gpu_info.gl_vendor); + AddPair(list.get(), ASCIIToUTF16("GL_RENDERER"), gpu_info.gl_renderer); + AddPair(list.get(), ASCIIToUTF16("GL_VERSION"), gpu_info.gl_version); + AddPair(list.get(), ASCIIToUTF16("GL_EXTENSIONS"), gpu_info.gl_extensions); base::DictionaryValue flashInfo; - flashInfo.Set("flashInfo", list); + flashInfo.Set("flashInfo", std::move(list)); web_ui()->CallJavascriptFunctionUnsafe("returnFlashInfo", flashInfo); }
diff --git a/chrome/browser/ui/webui/foreign_session_handler.cc b/chrome/browser/ui/webui/foreign_session_handler.cc index d8b1c255..425ffff 100644 --- a/chrome/browser/ui/webui/foreign_session_handler.cc +++ b/chrome/browser/ui/webui/foreign_session_handler.cc
@@ -121,7 +121,7 @@ return nullptr; std::unique_ptr<base::DictionaryValue> dictionary( BuildWindowData(window.timestamp, window.window_id.id())); - dictionary->Set("tabs", tab_values.release()); + dictionary->Set("tabs", std::move(tab_values)); return dictionary; } @@ -323,12 +323,12 @@ if (tab_values->GetSize() != 0) { std::unique_ptr<base::DictionaryValue> window_data( BuildWindowData(modification_time, 1)); - window_data->Set("tabs", tab_values.release()); + window_data->Set("tabs", std::move(tab_values)); window_list->Append(std::move(window_data)); } } - session_data->Set("windows", window_list.release()); + session_data->Set("windows", std::move(window_list)); session_list.Append(std::move(session_data)); } }
diff --git a/chrome/browser/ui/webui/identity_internals_ui.cc b/chrome/browser/ui/webui/identity_internals_ui.cc index 1d6fe85..d519d8a 100644 --- a/chrome/browser/ui/webui/identity_internals_ui.cc +++ b/chrome/browser/ui/webui/identity_internals_ui.cc
@@ -66,7 +66,7 @@ // Gets a list of scopes specified in |token_cache_key| and returns a pointer // to a ListValue containing the scopes. The caller gets ownership of the // returned object. - base::ListValue* GetScopes( + std::unique_ptr<base::ListValue> GetScopes( const extensions::ExtensionTokenKey& token_cache_key); // Gets a localized status of the access token in |token_cache_value|. @@ -181,9 +181,9 @@ return extension->name(); } -base::ListValue* IdentityInternalsUIMessageHandler::GetScopes( +std::unique_ptr<base::ListValue> IdentityInternalsUIMessageHandler::GetScopes( const extensions::ExtensionTokenKey& token_cache_key) { - base::ListValue* scopes_value = new base::ListValue(); + auto scopes_value = base::MakeUnique<base::ListValue>(); for (std::set<std::string>::const_iterator iter = token_cache_key.scopes.begin(); iter != token_cache_key.scopes.end(); ++iter) {
diff --git a/chrome/browser/ui/webui/instant_ui.cc b/chrome/browser/ui/webui/instant_ui.cc index 859d307..298ebe8d 100644 --- a/chrome/browser/ui/webui/instant_ui.cc +++ b/chrome/browser/ui/webui/instant_ui.cc
@@ -14,6 +14,7 @@ #include "base/memory/ptr_util.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" +#include "base/values.h" #include "build/build_config.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_finder.h" @@ -140,7 +141,7 @@ const std::list<DebugEvent>& events = instant->debug_events(); base::DictionaryValue data; - base::ListValue* entries = new base::ListValue(); + auto entries = base::MakeUnique<base::ListValue>(); for (std::list<DebugEvent>::const_iterator it = events.begin(); it != events.end(); ++it) { std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); @@ -148,7 +149,7 @@ entry->SetString("text", it->second); entries->Append(std::move(entry)); } - data.Set("entries", entries); + data.Set("entries", std::move(entries)); web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult", data);
diff --git a/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc b/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc index f4ac35ec..dd933f0 100644 --- a/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc +++ b/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h" +#include <memory> #include <string> #include <utility> @@ -131,7 +132,7 @@ sinks_val->Append(std::move(sink_val)); } - sink_list_and_identity->Set("sinks", sinks_val.release()); + sink_list_and_identity->Set("sinks", std::move(sinks_val)); sink_list_and_identity->SetBoolean("showEmail", show_email); sink_list_and_identity->SetBoolean("showDomain", show_domain); return sink_list_and_identity; @@ -414,17 +415,17 @@ std::unique_ptr<base::DictionaryValue> sinks_and_identity( SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo())); - initial_data.Set("sinksAndIdentity", sinks_and_identity.release()); + initial_data.Set("sinksAndIdentity", std::move(sinks_and_identity)); std::unique_ptr<base::ListValue> routes(RoutesToValue( media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), media_router_ui_->routes_and_cast_modes())); - initial_data.Set("routes", routes.release()); + initial_data.Set("routes", std::move(routes)); const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( cast_modes, media_router_ui_->GetPresentationRequestSourceName())); - initial_data.Set("castModes", cast_modes_list.release()); + initial_data.Set("castModes", std::move(cast_modes_list)); // If the cast mode last chosen for the current origin is tab mirroring, // that should be the cast mode initially selected in the dialog. Otherwise
diff --git a/chrome/browser/ui/webui/nacl_ui.cc b/chrome/browser/ui/webui/nacl_ui.cc index 78b3768..276468acd 100644 --- a/chrome/browser/ui/webui/nacl_ui.cc +++ b/chrome/browser/ui/webui/nacl_ui.cc
@@ -320,7 +320,7 @@ // Display information relevant to NaCl (non-portable. AddNaClInfo(list.get()); // naclInfo will take ownership of list, and clean it up on destruction. - naclInfo->Set("naclInfo", list.release()); + naclInfo->Set("naclInfo", std::move(list)); } void NaClDomHandler::DidCheckPathAndVersion(const std::string* version,
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 488ace9..b6b522a 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -6,6 +6,8 @@ #include <stddef.h> +#include <string> +#include <utility> #include <vector> #include "apps/metrics_names.h" @@ -14,6 +16,7 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/i18n/rtl.h" +#include "base/memory/ptr_util.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_macros.h" #include "base/strings/string_util.h" @@ -359,7 +362,7 @@ // CreateAppInfo and ClearOrdinals can change the extension prefs. base::AutoReset<bool> auto_reset(&ignore_changes_, true); - base::ListValue* list = new base::ListValue(); + auto installed_extensions = base::MakeUnique<base::ListValue>(); Profile* profile = Profile::FromWebUI(web_ui()); PrefService* prefs = profile->GetPrefs(); @@ -368,24 +371,23 @@ const Extension* extension = extension_service_->GetInstalledExtension(*it); if (extension && extensions::ui_util::ShouldDisplayInNewTabPage( extension, profile)) { - list->Append(GetAppInfo(extension)); + installed_extensions->Append(GetAppInfo(extension)); } } - dictionary->Set("apps", list); + dictionary->Set("apps", std::move(installed_extensions)); const base::ListValue* app_page_names = prefs->GetList(prefs::kNtpAppPageNames); if (!app_page_names || !app_page_names->GetSize()) { ListPrefUpdate update(prefs, prefs::kNtpAppPageNames); base::ListValue* list = update.Get(); - list->Set(0, new base::Value( + list->Set(0, base::MakeUnique<base::Value>( l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); - dictionary->Set("appPageNames", - static_cast<base::ListValue*>(list->DeepCopy())); + dictionary->Set("appPageNames", base::MakeUnique<base::Value>(*list)); } else { dictionary->Set("appPageNames", - static_cast<base::ListValue*>(app_page_names->DeepCopy())); + base::MakeUnique<base::Value>(*app_page_names)); } } @@ -681,7 +683,7 @@ } void AppLauncherHandler::HandleSaveAppPageName(const base::ListValue* args) { - base::string16 name; + std::string name; CHECK(args->GetString(0, &name)); double page_index; @@ -691,7 +693,8 @@ PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); ListPrefUpdate update(prefs, prefs::kNtpAppPageNames); base::ListValue* list = update.Get(); - list->Set(static_cast<size_t>(page_index), new base::Value(name)); + list->Set(static_cast<size_t>(page_index), + base::MakeUnique<base::Value>(name)); } void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index b3362a2a..f4480a23 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc
@@ -290,7 +290,7 @@ autofill::GetAddressComponents(country_code, g_browser_process->GetApplicationLocale(), components.get(), &language_code); - input.Set(kComponents, components.release()); + input.Set(kComponents, std::move(components)); input.SetString(kLanguageCode, language_code); web_ui()->CallJavascriptFunctionUnsafe( @@ -501,7 +501,7 @@ autofill::GetAddressComponents( base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), profile.language_code(), components.get(), nullptr); - address->Set(kComponents, components.release()); + address->Set(kComponents, std::move(components)); } } // namespace options
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc index f851526ad..c976322 100644 --- a/chrome/browser/ui/webui/options/browser_options_handler.cc +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -166,7 +166,7 @@ std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); details->SetString("id", extension ? extension->id() : std::string()); details->SetString("name", extension ? extension->name() : std::string()); - dict->Set(key, details.release()); + dict->Set(key, std::move(details)); } #if !defined(OS_CHROMEOS) @@ -662,7 +662,7 @@ values->SetString("username", username); #endif // Pass along sync status early so it will be available during page init. - values->Set("syncData", GetSyncStateDictionary().release()); + values->Set("syncData", GetSyncStateDictionary()); values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL); @@ -675,7 +675,7 @@ #if defined(OS_CHROMEOS) // TODO(pastarmovj): replace this with a call to the CrosSettings list // handling functionality to come. - values->Set("timezoneList", chromeos::system::GetTimezoneList().release()); + values->Set("timezoneList", chromeos::system::GetTimezoneList()); values->SetString("accessibilityLearnMoreURL", chrome::kChromeAccessibilityHelpURL); @@ -705,7 +705,7 @@ IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_PARTIAL)); magnifier_list->Append(std::move(option_partial)); - values->Set("magnifierList", magnifier_list.release()); + values->Set("magnifierList", std::move(magnifier_list)); values->SetBoolean("enablePolymerPreload", g_enable_polymer_preload); #endif // defined(OS_CHROMEOS) @@ -717,7 +717,7 @@ #endif if (ShouldShowMultiProfilesUserList()) - values->Set("profilesInfo", GetProfilesInfoList().release()); + values->Set("profilesInfo", GetProfilesInfoList()); // Profile deletion is not allowed for any users in ChromeOS. bool allow_deletion = true;
diff --git a/chrome/browser/ui/webui/options/certificate_manager_handler.cc b/chrome/browser/ui/webui/options/certificate_manager_handler.cc index e4c42f4..91f5f9f 100644 --- a/chrome/browser/ui/webui/options/certificate_manager_handler.cc +++ b/chrome/browser/ui/webui/options/certificate_manager_handler.cc
@@ -1144,7 +1144,7 @@ dict->SetString(kNameId, i->first); // Populate second level (certs). - base::ListValue* subnodes = new base::ListValue; + auto subnodes = base::MakeUnique<base::ListValue>(); for (net::CertificateList::const_iterator org_cert_it = i->second.begin(); org_cert_it != i->second.end(); ++org_cert_it) { std::unique_ptr<base::DictionaryValue> cert_dict( @@ -1175,7 +1175,7 @@ } std::sort(subnodes->begin(), subnodes->end(), comparator); - dict->Set(kSubNodesId, subnodes); + dict->Set(kSubNodesId, std::move(subnodes)); nodes->Append(std::move(dict)); } std::sort(nodes->begin(), nodes->end(), comparator);
diff --git a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc index 2dfe3d2..6fd29ce1 100644 --- a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
@@ -89,10 +89,11 @@ // This function decorates the bare list of emails with some more information // needed by the UI to properly display the Accounts page. -base::Value* CreateUsersWhitelist(const base::Value *pref_value) { +std::unique_ptr<base::Value> CreateUsersWhitelist( + const base::Value* pref_value) { const base::ListValue* list_value = static_cast<const base::ListValue*>(pref_value); - base::ListValue* user_list = new base::ListValue(); + auto user_list = base::MakeUnique<base::ListValue>(); user_manager::UserManager* user_manager = user_manager::UserManager::Get(); for (base::ListValue::const_iterator i = list_value->begin(); @@ -171,13 +172,13 @@ NotifySettingsChanged(it.first); } -base::Value* CoreChromeOSOptionsHandler::FetchPref( +std::unique_ptr<base::Value> CoreChromeOSOptionsHandler::FetchPref( const std::string& pref_name) { if (proxy_cros_settings_parser::IsProxyPref(pref_name)) { - base::Value* value = nullptr; + std::unique_ptr<base::Value> value; proxy_cros_settings_parser::GetProxyPrefValue( network_guid_, pref_name, GetUiProxyConfigService(), &value); - return value ? value : new base::Value(); + return value; } Profile* profile = Profile::FromWebUI(web_ui()); @@ -186,7 +187,8 @@ pref_name == proxy_config::prefs::kUseSharedProxies ? proxy_config::prefs::kProxy : std::string(); - base::Value* value = CreateValueForPref(pref_name, controlling_pref); + std::unique_ptr<base::Value> value = + CreateValueForPref(pref_name, controlling_pref); if (!IsSettingShared(pref_name) || !IsSecondaryUser(profile)) return value; base::DictionaryValue* dict; @@ -200,20 +202,20 @@ dict->SetBoolean("disabled", true); dict->SetBoolean("value", primary_profile->GetPrefs()->GetBoolean( pref_name)); - return dict; + return value; } const base::Value* pref_value = CrosSettings::Get()->GetPref(pref_name); if (!pref_value) - return new base::Value(); + return base::MakeUnique<base::Value>(); // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. // TODO(estade): seems that this should replicate CreateValueForPref less. - base::DictionaryValue* dict = new base::DictionaryValue; + auto dict = base::MakeUnique<base::DictionaryValue>(); if (pref_name == kAccountsPrefUsers) dict->Set("value", CreateUsersWhitelist(pref_value)); else - dict->Set("value", pref_value->DeepCopy()); + dict->Set("value", base::MakeUnique<base::Value>(*pref_value)); std::string controlled_by; if (IsSettingPrivileged(pref_name)) { @@ -281,7 +283,7 @@ ::options::CoreOptionsHandler::StopObservingPref(path); } -base::Value* CoreChromeOSOptionsHandler::CreateValueForPref( +std::unique_ptr<base::Value> CoreChromeOSOptionsHandler::CreateValueForPref( const std::string& pref_name, const std::string& controlling_pref_name) { // The screen lock setting is shared if multiple users are logged in and at @@ -302,8 +304,8 @@ // Screen lock is enabled for the session, but not in the user's // preferences. Show the user's value in the checkbox, but indicate // that the password requirement is enabled by some other user. - base::DictionaryValue* dict = new base::DictionaryValue; - dict->Set("value", pref->GetValue()->DeepCopy()); + auto dict = base::MakeUnique<base::DictionaryValue>(); + dict->Set("value", base::MakeUnique<base::Value>(*pref->GetValue())); dict->SetString("controlledBy", "shared"); return dict; } @@ -411,14 +413,13 @@ void CoreChromeOSOptionsHandler::NotifyProxyPrefsChanged() { GetUiProxyConfigService()->UpdateFromPrefs(network_guid_); for (size_t i = 0; i < proxy_cros_settings_parser::kProxySettingsCount; ++i) { - base::Value* value = NULL; + std::unique_ptr<base::Value> value; proxy_cros_settings_parser::GetProxyPrefValue( network_guid_, proxy_cros_settings_parser::kProxySettings[i], GetUiProxyConfigService(), &value); DCHECK(value); - std::unique_ptr<base::Value> ptr(value); DispatchPrefChangeNotification( - proxy_cros_settings_parser::kProxySettings[i], std::move(ptr)); + proxy_cros_settings_parser::kProxySettings[i], std::move(value)); } }
diff --git a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h index 2381d54..0bc9e74 100644 --- a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CORE_CHROMEOS_OPTIONS_HANDLER_H_ #include <map> +#include <memory> #include <string> #include "base/macros.h" @@ -27,14 +28,14 @@ // ::CoreOptionsHandler overrides void RegisterMessages() override; - base::Value* FetchPref(const std::string& pref_name) override; + std::unique_ptr<base::Value> FetchPref(const std::string& pref_name) override; void InitializeHandler() override; void ObservePref(const std::string& pref_name) override; void SetPref(const std::string& pref_name, const base::Value* value, const std::string& metric) override; void StopObservingPref(const std::string& path) override; - base::Value* CreateValueForPref( + std::unique_ptr<base::Value> CreateValueForPref( const std::string& pref_name, const std::string& controlling_pref_name) override;
diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc index be140f8..1c938f22 100644 --- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
@@ -94,7 +94,7 @@ IDS_OPTIONS_SETTINGS_LANGUAGES_ACTIVATE_IME_MENU)); // GetSupportedInputMethods() never returns NULL. - localized_strings->Set("languageList", GetAcceptLanguageList().release()); + localized_strings->Set("languageList", GetAcceptLanguageList()); localized_strings->Set("inputMethodList", GetInputMethodList()); input_method::InputMethodManager* manager = @@ -102,10 +102,10 @@ input_method::InputMethodDescriptors ext_ime_descriptors; manager->GetActiveIMEState()->GetInputMethodExtensions(&ext_ime_descriptors); - base::ListValue* ext_ime_list = ConvertInputMethodDescriptorsToIMEList( - ext_ime_descriptors); - AddImeProvider(ext_ime_list); - localized_strings->Set("extensionImeList", ext_ime_list); + std::unique_ptr<base::ListValue> ext_ime_list = + ConvertInputMethodDescriptorsToIMEList(ext_ime_descriptors); + AddImeProvider(ext_ime_list.get()); + localized_strings->Set("extensionImeList", std::move(ext_ime_list)); ComponentExtensionIMEManager* component_extension_manager = input_method::InputMethodManager::Get() @@ -134,14 +134,15 @@ } // static -base::ListValue* CrosLanguageOptionsHandler::GetInputMethodList() { +std::unique_ptr<base::ListValue> +CrosLanguageOptionsHandler::GetInputMethodList() { input_method::InputMethodManager* manager = input_method::InputMethodManager::Get(); // GetSupportedInputMethods() never return NULL. std::unique_ptr<input_method::InputMethodDescriptors> descriptors( manager->GetSupportedInputMethods()); - base::ListValue* input_method_list = new base::ListValue(); + auto input_method_list = base::MakeUnique<base::ListValue>(); for (size_t i = 0; i < descriptors->size(); ++i) { const input_method::InputMethodDescriptor& descriptor = @@ -155,11 +156,11 @@ // One input method can be associated with multiple languages, hence // we use a dictionary here. - base::DictionaryValue* languages = new base::DictionaryValue(); + auto languages = base::MakeUnique<base::DictionaryValue>(); for (size_t i = 0; i < descriptor.language_codes().size(); ++i) { languages->SetBoolean(descriptor.language_codes().at(i), true); } - dictionary->Set("languageCodeSet", languages); + dictionary->Set("languageCodeSet", std::move(languages)); input_method_list->Append(std::move(dictionary)); } @@ -167,9 +168,9 @@ return input_method_list; } -base::ListValue* - CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList( - const input_method::InputMethodDescriptors& descriptors) { +std::unique_ptr<base::ListValue> +CrosLanguageOptionsHandler::ConvertInputMethodDescriptorsToIMEList( + const input_method::InputMethodDescriptors& descriptors) { input_method::InputMethodUtil* util = input_method::InputMethodManager::Get()->GetInputMethodUtil(); std::unique_ptr<base::ListValue> ime_ids_list(new base::ListValue()); @@ -185,10 +186,10 @@ new base::DictionaryValue()); for (size_t i = 0; i < descriptor.language_codes().size(); ++i) language_codes->SetBoolean(descriptor.language_codes().at(i), true); - dictionary->Set("languageCodeSet", language_codes.release()); + dictionary->Set("languageCodeSet", std::move(language_codes)); ime_ids_list->Append(std::move(dictionary)); } - return ime_ids_list.release(); + return ime_ids_list; } void CrosLanguageOptionsHandler::SetApplicationLocale(
diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h index e2086e7c..0a657c14 100644 --- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H_ +#include <memory> #include <string> #include "base/compiler_specific.h" @@ -13,6 +14,10 @@ #include "ui/base/ime/chromeos/component_extension_ime_manager.h" #include "ui/base/ime/chromeos/input_method_descriptor.h" +namespace base { +class ListValue; +} + namespace chromeos { namespace options { @@ -39,13 +44,14 @@ // // Note that true in languageCodeSet does not mean anything. We just use // the dictionary as a set. - static base::ListValue* GetInputMethodList(); + static std::unique_ptr<base::ListValue> GetInputMethodList(); // Converts input method descriptors to the list of input methods. // The return value will look like: // [{'id': '_ext_ime_nejguenhnsnjnwychcnsdsdjketest', // 'displayName': 'Sample IME'}, ...] - static base::ListValue* ConvertInputMethodDescriptorsToIMEList( + static std::unique_ptr<base::ListValue> + ConvertInputMethodDescriptorsToIMEList( const input_method::InputMethodDescriptors& descriptors); private:
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc index fc794b79..f18f3b2 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
@@ -182,8 +182,9 @@ return result; } -base::DictionaryValue* ConvertBoundsToValue(const gfx::Rect& bounds) { - base::DictionaryValue* result = new base::DictionaryValue(); +std::unique_ptr<base::DictionaryValue> ConvertBoundsToValue( + const gfx::Rect& bounds) { + auto result = base::MakeUnique<base::DictionaryValue>(); result->SetInteger("left", bounds.x()); result->SetInteger("top", bounds.y()); result->SetInteger("width", bounds.width()); @@ -329,23 +330,21 @@ js_display->SetString("id", base::Int64ToString(display.id())); js_display->SetString("name", display_manager->GetDisplayNameForId(display.id())); - base::DictionaryValue* display_bounds = - ConvertBoundsToValue(display.bounds()); - js_display->Set("bounds", display_bounds); + js_display->Set("bounds", ConvertBoundsToValue(display.bounds())); js_display->SetBoolean("isPrimary", display.id() == primary_id); js_display->SetBoolean("isInternal", display.IsInternal()); js_display->SetInteger("rotation", display.RotationAsDegree()); - base::ListValue* js_resolutions = new base::ListValue(); + auto js_resolutions = base::MakeUnique<base::ListValue>(); for (const scoped_refptr<display::ManagedDisplayMode>& display_mode : display_info.display_modes()) { js_resolutions->Append( ConvertDisplayModeToValue(display.id(), display_mode)); } - js_display->Set("resolutions", js_resolutions); + js_display->Set("resolutions", std::move(js_resolutions)); js_display->SetInteger("colorProfileId", display_info.color_profile()); - base::ListValue* available_color_profiles = new base::ListValue(); + auto available_color_profiles = base::MakeUnique<base::ListValue>(); for (const auto& color_profile : display_info.available_color_profiles()) { const base::string16 profile_name = GetColorProfileName(color_profile); if (profile_name.empty()) @@ -355,7 +354,8 @@ color_profile_dict->SetString("name", profile_name); available_color_profiles->Append(std::move(color_profile_dict)); } - js_display->Set("availableColorProfiles", available_color_profiles); + js_display->Set("availableColorProfiles", + std::move(available_color_profiles)); if (display_manager->GetNumDisplays() > 1) { // The settings UI must use the resolved display layout to show the
diff --git a/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc b/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc index 4297e46..1d6882b 100644 --- a/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc
@@ -139,7 +139,7 @@ IDS_OPTIONS_SETTINGS_SHOW_KEYBOARD_SHORTCUTS)); for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) { - base::ListValue* list_value = new base::ListValue(); + auto list_value = base::MakeUnique<base::ListValue>(); for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) { const input_method::ModifierKey value = kModifierKeysSelectItems[j].value; @@ -149,7 +149,7 @@ option->AppendString(l10n_util::GetStringUTF16(message_id)); list_value->Append(std::move(option)); } - localized_strings->Set(kDataValuesNames[i], list_value); + localized_strings->Set(kDataValuesNames[i], std::move(list_value)); } }
diff --git a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc index fb1914e..527531cc 100644 --- a/chrome/browser/ui/webui/options/clear_browser_data_handler.cc +++ b/chrome/browser/ui/webui/options/clear_browser_data_handler.cc
@@ -199,7 +199,7 @@ IDS_CLEAR_BROWSING_DATA_HISTORY_NOTICE, base::ASCIIToUTF16(kMyActivityUrlInDialog))); - base::ListValue* time_list = new base::ListValue; + auto time_list = base::MakeUnique<base::ListValue>(); for (int i = 0; i < 5; i++) { base::string16 label_string; switch (i) { @@ -224,7 +224,7 @@ option->AppendString(label_string); time_list->Append(std::move(option)); } - localized_strings->Set("clearBrowserDataTimeList", time_list); + localized_strings->Set("clearBrowserDataTimeList", std::move(time_list)); localized_strings->SetBoolean("showDeleteBrowsingHistoryCheckboxes", !Profile::FromWebUI(web_ui())->IsSupervised()); }
diff --git a/chrome/browser/ui/webui/options/core_options_handler.cc b/chrome/browser/ui/webui/options/core_options_handler.cc index c7098cab..ec45725b 100644 --- a/chrome/browser/ui/webui/options/core_options_handler.cc +++ b/chrome/browser/ui/webui/options/core_options_handler.cc
@@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/json/json_reader.h" +#include "base/memory/ptr_util.h" #include "base/metrics/user_metrics.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" @@ -252,7 +253,8 @@ handlers_host_->OnFinishedLoading(); } -base::Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { +std::unique_ptr<base::Value> CoreOptionsHandler::FetchPref( + const std::string& pref_name) { return CreateValueForPref(pref_name, std::string()); } @@ -364,7 +366,7 @@ } } -base::Value* CoreOptionsHandler::CreateValueForPref( +std::unique_ptr<base::Value> CoreOptionsHandler::CreateValueForPref( const std::string& pref_name, const std::string& controlling_pref_name) { const PrefService* pref_service = FindServiceForPref(pref_name); @@ -372,15 +374,15 @@ pref_service->FindPreference(pref_name); if (!pref) { NOTREACHED(); - return new base::Value(); + return base::MakeUnique<base::Value>(); } const PrefService::Preference* controlling_pref = pref_service->FindPreference(controlling_pref_name); if (!controlling_pref) controlling_pref = pref; - base::DictionaryValue* dict = new base::DictionaryValue; - dict->Set("value", pref->GetValue()->DeepCopy()); + auto dict = base::MakeUnique<base::DictionaryValue>(); + dict->Set("value", base::MakeUnique<base::Value>(*pref->GetValue())); if (controlling_pref->IsManaged()) { dict->SetString("controlledBy", "policy"); } else if (controlling_pref->IsExtensionControlled() && @@ -397,8 +399,7 @@ extension_id, extensions::ExtensionRegistry::EVERYTHING); if (extension) { dict->SetString("controlledBy", "extension"); - dict->Set("extension", - extensions::util::GetExtensionInfo(extension).release()); + dict->Set("extension", extensions::util::GetExtensionInfo(extension)); } } else if (controlling_pref->IsRecommended()) { dict->SetString("controlledBy", "recommended"); @@ -407,9 +408,10 @@ const base::Value* recommended_value = controlling_pref->GetRecommendedValue(); if (recommended_value) - dict->Set("recommendedValue", recommended_value->DeepCopy()); + dict->Set("recommendedValue", + base::MakeUnique<base::Value>(*recommended_value)); dict->SetBoolean("disabled", !controlling_pref->IsUserModifiable()); - return dict; + return std::move(dict); } PrefService* CoreOptionsHandler::FindServiceForPref(
diff --git a/chrome/browser/ui/webui/options/core_options_handler.h b/chrome/browser/ui/webui/options/core_options_handler.h index ae17b20..1ff2c16 100644 --- a/chrome/browser/ui/webui/options/core_options_handler.h +++ b/chrome/browser/ui/webui/options/core_options_handler.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ #include <map> +#include <memory> #include <string> #include "base/callback.h" @@ -45,7 +46,7 @@ protected: // Fetches a pref value of given |pref_name|. // Note that caller owns the returned Value. - virtual base::Value* FetchPref(const std::string& pref_name); + virtual std::unique_ptr<base::Value> FetchPref(const std::string& pref_name); // Observes a pref of given |pref_name|. virtual void ObservePref(const std::string& pref_name); @@ -88,7 +89,7 @@ // Creates dictionary value for the pref described by |pref_name|. // If |controlling_pref| is not empty, it describes the pref that manages // |pref| via policy or extension. - virtual base::Value* CreateValueForPref( + virtual std::unique_ptr<base::Value> CreateValueForPref( const std::string& pref_name, const std::string& controlling_pref_name);
diff --git a/chrome/browser/ui/webui/options/handler_options_handler.cc b/chrome/browser/ui/webui/options/handler_options_handler.cc index 0e5ea477..73b3fdea0 100644 --- a/chrome/browser/ui/webui/options/handler_options_handler.cc +++ b/chrome/browser/ui/webui/options/handler_options_handler.cc
@@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/chrome_notification_types.h" @@ -115,9 +116,10 @@ handlers_value->SetBoolean("has_policy_recommendations", registry->HasPolicyRegisteredHandler(protocol)); - base::ListValue* handlers_list = new base::ListValue(); - GetHandlersAsListValue(registry->GetHandlersFor(protocol), handlers_list); - handlers_value->Set("handlers", handlers_list); + auto handlers_list = base::MakeUnique<base::ListValue>(); + GetHandlersAsListValue(registry->GetHandlersFor(protocol), + handlers_list.get()); + handlers_value->Set("handlers", std::move(handlers_list)); } void HandlerOptionsHandler::GetIgnoredHandlers(base::ListValue* handlers) {
diff --git a/chrome/browser/ui/webui/options/language_options_handler.cc b/chrome/browser/ui/webui/options/language_options_handler.cc index 66c7e9c..15491927 100644 --- a/chrome/browser/ui/webui/options/language_options_handler.cc +++ b/chrome/browser/ui/webui/options/language_options_handler.cc
@@ -15,6 +15,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/i18n/rtl.h" +#include "base/memory/ptr_util.h" #include "base/metrics/user_metrics.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" @@ -57,7 +58,7 @@ base::Unretained(this))); } -base::ListValue* LanguageOptionsHandler::GetLanguageList() { +std::unique_ptr<base::ListValue> LanguageOptionsHandler::GetLanguageList() { // Collect the language codes from the supported accept-languages. const std::string app_locale = g_browser_process->GetApplicationLocale(); std::vector<std::string> language_codes; @@ -91,7 +92,7 @@ l10n_util::SortStrings16(app_locale, &display_names); // Build the language list from the language map. - base::ListValue* language_list = new base::ListValue(); + auto language_list = base::MakeUnique<base::ListValue>(); for (size_t i = 0; i < display_names.size(); ++i) { base::string16& display_name = display_names[i]; base::string16 adjusted_display_name(display_name);
diff --git a/chrome/browser/ui/webui/options/language_options_handler.h b/chrome/browser/ui/webui/options/language_options_handler.h index 4172579..93943cd 100644 --- a/chrome/browser/ui/webui/options/language_options_handler.h +++ b/chrome/browser/ui/webui/options/language_options_handler.h
@@ -5,9 +5,15 @@ #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_H_ +#include <memory> + #include "base/macros.h" #include "chrome/browser/ui/webui/options/language_options_handler_common.h" +namespace base { +class ListValue; +} + namespace options { // Language options UI page handler for non-Chrome OS platforms. For Chrome OS, @@ -29,7 +35,7 @@ // The return value will look like: // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, // ...] - static base::ListValue* GetLanguageList(); + static std::unique_ptr<base::ListValue> GetLanguageList(); private: // LanguageOptionsHandlerCommon implementation.
diff --git a/chrome/browser/ui/webui/options/language_options_handler_common.cc b/chrome/browser/ui/webui/options/language_options_handler_common.cc index 151d4d7..fd127384 100644 --- a/chrome/browser/ui/webui/options/language_options_handler_common.cc +++ b/chrome/browser/ui/webui/options/language_options_handler_common.cc
@@ -14,6 +14,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/metrics/user_metrics.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -117,13 +118,14 @@ std::vector<std::string> languages; translate::TranslateDownloadManager::GetSupportedLanguages(&languages); - base::ListValue* languages_list = new base::ListValue(); + auto languages_list = base::MakeUnique<base::ListValue>(); for (std::vector<std::string>::iterator it = languages.begin(); it != languages.end(); ++it) { languages_list->AppendString(*it); } - localized_strings->Set("translateSupportedLanguages", languages_list); + localized_strings->Set("translateSupportedLanguages", + std::move(languages_list)); } void LanguageOptionsHandlerCommon::Uninitialize() { @@ -183,8 +185,9 @@ base::Value(language)); } -base::DictionaryValue* LanguageOptionsHandlerCommon::GetUILanguageCodeSet() { - base::DictionaryValue* dictionary = new base::DictionaryValue(); +std::unique_ptr<base::DictionaryValue> +LanguageOptionsHandlerCommon::GetUILanguageCodeSet() { + auto dictionary = base::MakeUnique<base::DictionaryValue>(); const std::vector<std::string>& available_locales = l10n_util::GetAvailableLocales(); for (size_t i = 0; i < available_locales.size(); ++i) @@ -192,9 +195,9 @@ return dictionary; } -base::DictionaryValue* +std::unique_ptr<base::DictionaryValue> LanguageOptionsHandlerCommon::GetSpellCheckLanguageCodeSet() { - base::DictionaryValue* dictionary = new base::DictionaryValue(); + auto dictionary = base::MakeUnique<base::DictionaryValue>(); std::vector<std::string> spell_check_languages; spellcheck::SpellCheckLanguages(&spell_check_languages); for (size_t i = 0; i < spell_check_languages.size(); ++i) {
diff --git a/chrome/browser/ui/webui/options/language_options_handler_common.h b/chrome/browser/ui/webui/options/language_options_handler_common.h index 1b94a67..18e3355 100644 --- a/chrome/browser/ui/webui/options/language_options_handler_common.h +++ b/chrome/browser/ui/webui/options/language_options_handler_common.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" @@ -49,7 +51,7 @@ // // Note that true in values does not mean anything. We just use the // dictionary as a set. - static base::DictionaryValue* GetUILanguageCodeSet(); + static std::unique_ptr<base::DictionaryValue> GetUILanguageCodeSet(); // Gets the set of language codes that can be used for spellchecking. // The return value will look like: @@ -57,7 +59,7 @@ // // Note that true in values does not mean anything. We just use the // dictionary as a set. - static base::DictionaryValue* GetSpellCheckLanguageCodeSet(); + static std::unique_ptr<base::DictionaryValue> GetSpellCheckLanguageCodeSet(); private: // Sets the application locale.
diff --git a/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc b/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc index 5f6f2459..bc254c36 100644 --- a/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc +++ b/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc
@@ -261,7 +261,7 @@ std::unique_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot( Profile::FromWebUI(web_ui()), *setting_snapshot_); base::DictionaryValue feedback_info; - feedback_info.Set("feedbackInfo", list.release()); + feedback_info.Set("feedbackInfo", std::move(list)); web_ui()->CallJavascriptFunctionUnsafe( "ResetProfileSettingsOverlay.setFeedbackInfo", feedback_info); }
diff --git a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc index e93cdd3..a9d43ebc 100644 --- a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc +++ b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
@@ -207,8 +207,7 @@ ->GetExtensionById(template_url->GetExtensionId(), extensions::ExtensionRegistry::EVERYTHING); if (extension) { - dict->Set("extension", - extensions::util::GetExtensionInfo(extension).release()); + dict->Set("extension", extensions::util::GetExtensionInfo(extension)); } } return dict;
diff --git a/chrome/browser/ui/webui/options/supervised_user_import_handler.cc b/chrome/browser/ui/webui/options/supervised_user_import_handler.cc index e52ce987..e768ff1 100644 --- a/chrome/browser/ui/webui/options/supervised_user_import_handler.cc +++ b/chrome/browser/ui/webui/options/supervised_user_import_handler.cc
@@ -96,7 +96,7 @@ }; RegisterStrings(localized_strings, resources, arraysize(resources)); - localized_strings->Set("avatarIcons", GetAvatarIcons().release()); + localized_strings->Set("avatarIcons", GetAvatarIcons()); } void SupervisedUserImportHandler::InitializeHandler() {
diff --git a/chrome/browser/ui/webui/policy_ui_handler.cc b/chrome/browser/ui/webui/policy_ui_handler.cc index 9d8f9444..b0ba068 100644 --- a/chrome/browser/ui/webui/policy_ui_handler.cc +++ b/chrome/browser/ui/webui/policy_ui_handler.cc
@@ -644,18 +644,18 @@ scoped_refptr<policy::SchemaMap> schema_map = registry->schema_map(); // Add Chrome policy names. - base::DictionaryValue* chrome_policy_names = new base::DictionaryValue; + auto chrome_policy_names = base::MakeUnique<base::DictionaryValue>(); policy::PolicyNamespace chrome_ns(policy::POLICY_DOMAIN_CHROME, ""); const policy::Schema* chrome_schema = schema_map->GetSchema(chrome_ns); for (policy::Schema::Iterator it = chrome_schema->GetPropertiesIterator(); !it.IsAtEnd(); it.Advance()) { - AddPolicyName(it.key(), chrome_policy_names); + AddPolicyName(it.key(), chrome_policy_names.get()); } - names.Set("chromePolicyNames", chrome_policy_names); + names.Set("chromePolicyNames", std::move(chrome_policy_names)); #if BUILDFLAG(ENABLE_EXTENSIONS) // Add extension policy names. - base::DictionaryValue* extension_policy_names = new base::DictionaryValue; + auto extension_policy_names = base::MakeUnique<base::DictionaryValue>(); for (const scoped_refptr<const extensions::Extension>& extension : extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) { @@ -663,12 +663,12 @@ if (!extension->manifest()->HasPath( extensions::manifest_keys::kStorageManagedSchema)) continue; - base::DictionaryValue* extension_value = new base::DictionaryValue; + auto extension_value = base::MakeUnique<base::DictionaryValue>(); extension_value->SetString("name", extension->name()); const policy::Schema* schema = schema_map->GetSchema(policy::PolicyNamespace( policy::POLICY_DOMAIN_EXTENSIONS, extension->id())); - base::DictionaryValue* policy_names = new base::DictionaryValue; + auto policy_names = base::MakeUnique<base::DictionaryValue>(); if (schema && schema->valid()) { // Get policy names from the extension's policy schema. // Store in a map, not an array, for faster lookup on JS side. @@ -677,10 +677,10 @@ policy_names->SetBoolean(prop.key(), true); } } - extension_value->Set("policyNames", policy_names); - extension_policy_names->Set(extension->id(), extension_value); + extension_value->Set("policyNames", std::move(policy_names)); + extension_policy_names->Set(extension->id(), std::move(extension_value)); } - names.Set("extensionPolicyNames", extension_policy_names); + names.Set("extensionPolicyNames", std::move(extension_policy_names)); #endif // BUILDFLAG(ENABLE_EXTENSIONS) web_ui()->CallJavascriptFunctionUnsafe("policy.Page.setPolicyNames", names); @@ -690,15 +690,15 @@ base::DictionaryValue all_policies; // Add Chrome policy values. - base::DictionaryValue* chrome_policies = new base::DictionaryValue; - GetChromePolicyValues(chrome_policies); - all_policies.Set("chromePolicies", chrome_policies); + auto chrome_policies = base::MakeUnique<base::DictionaryValue>(); + GetChromePolicyValues(chrome_policies.get()); + all_policies.Set("chromePolicies", std::move(chrome_policies)); #if BUILDFLAG(ENABLE_EXTENSIONS) // Add extension policy values. extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui())); - base::DictionaryValue* extension_values = new base::DictionaryValue; + auto extension_values = base::MakeUnique<base::DictionaryValue>(); for (const scoped_refptr<const extensions::Extension>& extension : registry->enabled_extensions()) { @@ -706,15 +706,15 @@ if (!extension->manifest()->HasPath( extensions::manifest_keys::kStorageManagedSchema)) continue; - base::DictionaryValue* extension_policies = new base::DictionaryValue; + auto extension_policies = base::MakeUnique<base::DictionaryValue>(); policy::PolicyNamespace policy_namespace = policy::PolicyNamespace( policy::POLICY_DOMAIN_EXTENSIONS, extension->id()); policy::PolicyErrorMap empty_error_map; GetPolicyValues(GetPolicyService()->GetPolicies(policy_namespace), - &empty_error_map, extension_policies); - extension_values->Set(extension->id(), extension_policies); + &empty_error_map, extension_policies.get()); + extension_values->Set(extension->id(), std::move(extension_policies)); } - all_policies.Set("extensionPolicies", extension_values); + all_policies.Set("extensionPolicies", std::move(extension_values)); #endif web_ui()->CallJavascriptFunctionUnsafe("policy.Page.setPolicyValues", all_policies); @@ -779,9 +779,9 @@ base::DictionaryValue status; if (!device_status->empty()) - status.Set("device", device_status.release()); + status.Set("device", std::move(device_status)); if (!user_status->empty()) - status.Set("user", user_status.release()); + status.Set("user", std::move(user_status)); web_ui()->CallJavascriptFunctionUnsafe("policy.Page.setStatus", status); }
diff --git a/chrome/browser/ui/webui/predictors/predictors_handler.cc b/chrome/browser/ui/webui/predictors/predictors_handler.cc index bd03c65..d9dce05 100644 --- a/chrome/browser/ui/webui/predictors/predictors_handler.cc +++ b/chrome/browser/ui/webui/predictors/predictors_handler.cc
@@ -9,6 +9,7 @@ #include <utility> #include "base/bind.h" +#include "base/memory/ptr_util.h" #include "base/values.h" #include "chrome/browser/predictors/autocomplete_action_predictor.h" #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" @@ -68,7 +69,7 @@ base::DictionaryValue dict; dict.SetBoolean("enabled", enabled); if (enabled) { - base::ListValue* db = new base::ListValue(); + auto db = base::MakeUnique<base::ListValue>(); for (AutocompleteActionPredictor::DBCacheMap::const_iterator it = autocomplete_action_predictor_->db_cache_.begin(); it != autocomplete_action_predictor_->db_cache_.end(); @@ -82,7 +83,7 @@ autocomplete_action_predictor_->CalculateConfidenceForDbEntry(it)); db->Append(std::move(entry)); } - dict.Set("db", db); + dict.Set("db", std::move(db)); } web_ui()->CallJavascriptFunctionUnsafe("updateAutocompleteActionPredictorDb", @@ -97,15 +98,15 @@ if (enabled) { // Url Database cache. - base::ListValue* db = new base::ListValue(); + auto db = base::MakeUnique<base::ListValue>(); AddPrefetchDataMapToListValue( - *resource_prefetch_predictor_->url_table_cache_, db); - dict.Set("url_db", db); + *resource_prefetch_predictor_->url_table_cache_, db.get()); + dict.Set("url_db", std::move(db)); - db = new base::ListValue(); + db = base::MakeUnique<base::ListValue>(); AddPrefetchDataMapToListValue( - *resource_prefetch_predictor_->host_table_cache_, db); - dict.Set("host_db", db); + *resource_prefetch_predictor_->host_table_cache_, db.get()); + dict.Set("host_db", std::move(db)); } web_ui()->CallJavascriptFunctionUnsafe("updateResourcePrefetchPredictorDb", @@ -118,7 +119,7 @@ for (const auto& p : data_map) { std::unique_ptr<base::DictionaryValue> main(new base::DictionaryValue()); main->SetString("main_frame_url", p.first); - base::ListValue* resources = new base::ListValue(); + auto resources = base::MakeUnique<base::ListValue>(); for (const predictors::ResourceData& r : p.second.resources()) { std::unique_ptr<base::DictionaryValue> resource( new base::DictionaryValue()); @@ -136,7 +137,7 @@ resource_prefetch_predictor_->IsResourcePrefetchable(r)); resources->Append(std::move(resource)); } - main->Set("resources", resources); + main->Set("resources", std::move(resources)); db->Append(std::move(main)); } }
diff --git a/chrome/browser/ui/webui/settings/certificates_handler.cc b/chrome/browser/ui/webui/settings/certificates_handler.cc index d80b14b..25500d5 100644 --- a/chrome/browser/ui/webui/settings/certificates_handler.cc +++ b/chrome/browser/ui/webui/settings/certificates_handler.cc
@@ -1043,7 +1043,7 @@ dict->SetString(kNameField, i->first); // Populate second level (certs). - base::ListValue* subnodes = new base::ListValue; + auto subnodes = base::MakeUnique<base::ListValue>(); for (net::CertificateList::const_iterator org_cert_it = i->second.begin(); org_cert_it != i->second.end(); ++org_cert_it) { std::unique_ptr<base::DictionaryValue> cert_dict( @@ -1075,7 +1075,7 @@ } std::sort(subnodes->begin(), subnodes->end(), comparator); - dict->Set(kSubnodesField, subnodes); + dict->Set(kSubnodesField, std::move(subnodes)); nodes->Append(std::move(dict)); } std::sort(nodes->begin(), nodes->end(), comparator);
diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc index 8a8b009..9c20c79 100644 --- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -138,16 +138,15 @@ std::vector<std::unique_ptr<Printer>> printers = PrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinters(); - base::ListValue* printers_list = new base::ListValue; + auto printers_list = base::MakeUnique<base::ListValue>(); for (const std::unique_ptr<Printer>& printer : printers) { std::unique_ptr<base::DictionaryValue> printer_info = GetPrinterInfo(*printer.get()); printers_list->Append(std::move(printer_info)); } - std::unique_ptr<base::DictionaryValue> response = - base::MakeUnique<base::DictionaryValue>(); - response->Set("printerList", printers_list); + auto response = base::MakeUnique<base::DictionaryValue>(); + response->Set("printerList", std::move(printers_list)); ResolveJavascriptCallback(base::Value(callback_id), *response); }
diff --git a/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc b/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc index 70d02e81..c851eb5 100644 --- a/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc +++ b/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
@@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/chrome_notification_types.h" @@ -99,9 +100,10 @@ handlers_value->SetBoolean("has_policy_recommendations", registry->HasPolicyRegisteredHandler(protocol)); - base::ListValue* handlers_list = new base::ListValue(); - GetHandlersAsListValue(registry->GetHandlersFor(protocol), handlers_list); - handlers_value->Set("handlers", handlers_list); + auto handlers_list = base::MakeUnique<base::ListValue>(); + GetHandlersAsListValue(registry->GetHandlersFor(protocol), + handlers_list.get()); + handlers_value->Set("handlers", std::move(handlers_list)); } void ProtocolHandlersHandler::GetIgnoredHandlers(base::ListValue* handlers) {
diff --git a/chrome/browser/ui/webui/settings/search_engines_handler.cc b/chrome/browser/ui/webui/settings/search_engines_handler.cc index 6d6e72ea..077d940 100644 --- a/chrome/browser/ui/webui/settings/search_engines_handler.cc +++ b/chrome/browser/ui/webui/settings/search_engines_handler.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/ui/webui/settings/search_engines_handler.h" +#include <utility> + #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/metrics/field_trial.h" @@ -262,7 +264,7 @@ !extensions::ExtensionSystem::Get(profile) ->management_policy() ->MustRemainEnabled(extension, nullptr)); - dict->Set("extension", ext_info.release()); + dict->Set("extension", std::move(ext_info)); } } return dict;
diff --git a/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc b/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc index c1373eb..0fadf5e 100644 --- a/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc +++ b/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" +#include "base/memory/ptr_util.h" #include "base/test/user_action_tester.h" #include "base/values.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h" @@ -189,7 +190,7 @@ "http://picture.example.com/picture.jpg"); base::ListValue args; - args.Set(0, new base::Value(kDefaultDialogHeight)); + args.Set(0, base::MakeUnique<base::Value>(kDefaultDialogHeight)); handler()->HandleInitializedWithSize(&args); EXPECT_EQ(2U, web_ui()->call_data().size()); @@ -218,7 +219,7 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) { base::ListValue args; - args.Set(0, new base::Value(kDefaultDialogHeight)); + args.Set(0, base::MakeUnique<base::Value>(kDefaultDialogHeight)); handler()->HandleInitializedWithSize(&args); EXPECT_EQ(2U, web_ui()->call_data().size()); @@ -270,7 +271,7 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIgnoredIfSecondaryAccountUpdated) { base::ListValue args; - args.Set(0, new base::Value(kDefaultDialogHeight)); + args.Set(0, base::MakeUnique<base::Value>(kDefaultDialogHeight)); handler()->HandleInitializedWithSize(&args); EXPECT_EQ(2U, web_ui()->call_data().size());
diff --git a/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc b/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc index 2bd6144..a17ed60d 100644 --- a/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc +++ b/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
@@ -107,7 +107,7 @@ std::unique_ptr<base::ListValue> details(new base::ListValue); details->AppendStrings(task_log.details); - dict.Set("details", details.release()); + dict.Set("details", std::move(details)); web_ui()->CallJavascriptFunctionUnsafe("TaskLog.onTaskLogRecorded", dict); }
diff --git a/chrome/browser/ui/webui/system_info_ui.cc b/chrome/browser/ui/webui/system_info_ui.cc index 1c14d01..ebf7121c 100644 --- a/chrome/browser/ui/webui/system_info_ui.cc +++ b/chrome/browser/ui/webui/system_info_ui.cc
@@ -152,8 +152,7 @@ webui::SetLoadTimeDataDefaults(app_locale, &strings); if (response_.get()) { - base::ListValue* details = new base::ListValue(); - strings.Set("details", details); + auto details = base::MakeUnique<base::ListValue>(); for (SystemLogsResponse::const_iterator it = response_->begin(); it != response_->end(); ++it) { @@ -162,6 +161,7 @@ val->SetString("statValue", it->second); details->Append(std::move(val)); } + strings.Set("details", std::move(details)); } static const base::StringPiece systeminfo_html( ResourceBundle::GetSharedInstance().GetRawDataResource(
diff --git a/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc b/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc index 8827d4e8..f95427c 100644 --- a/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc +++ b/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
@@ -5,10 +5,12 @@ #include "chrome/browser/ui/webui/translate_internals/translate_internals_handler.h" #include <map> +#include <utility> #include <vector> #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/memory/ptr_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" @@ -87,41 +89,39 @@ } base::DictionaryValue dict; - dict.Set("time", - new base::Value(language_detection_details->time.ToJsTime())); - dict.Set("url", new base::Value(language_detection_details->url.spec())); - dict.Set("content_language", - new base::Value(language_detection_details->content_language)); - dict.Set("cld_language", - new base::Value(language_detection_details->cld_language)); - dict.Set("is_cld_reliable", - new base::Value(language_detection_details->is_cld_reliable)); - dict.Set("has_notranslate", - new base::Value(language_detection_details->has_notranslate)); - dict.Set("html_root_language", - new base::Value(language_detection_details->html_root_language)); - dict.Set("adopted_language", - new base::Value(language_detection_details->adopted_language)); - dict.Set("content", new base::Value(language_detection_details->contents)); + dict.SetDouble("time", language_detection_details->time.ToJsTime()); + dict.SetString("url", language_detection_details->url.spec()); + dict.SetString("content_language", + language_detection_details->content_language); + dict.SetString("cld_language", language_detection_details->cld_language); + dict.SetBoolean("is_cld_reliable", + language_detection_details->is_cld_reliable); + dict.SetBoolean("has_notranslate", + language_detection_details->has_notranslate); + dict.SetString("html_root_language", + language_detection_details->html_root_language); + dict.SetString("adopted_language", + language_detection_details->adopted_language); + dict.SetString("content", language_detection_details->contents); SendMessageToJs("languageDetectionInfoAdded", dict); } void TranslateInternalsHandler::OnTranslateError( const translate::TranslateErrorDetails& details) { base::DictionaryValue dict; - dict.Set("time", new base::Value(details.time.ToJsTime())); - dict.Set("url", new base::Value(details.url.spec())); - dict.Set("error", new base::Value(details.error)); + dict.SetDouble("time", details.time.ToJsTime()); + dict.SetString("url", details.url.spec()); + dict.SetInteger("error", details.error); SendMessageToJs("translateErrorDetailsAdded", dict); } void TranslateInternalsHandler::OnTranslateEvent( const translate::TranslateEventDetails& details) { base::DictionaryValue dict; - dict.Set("time", new base::Value(details.time.ToJsTime())); - dict.Set("filename", new base::Value(details.filename)); - dict.Set("line", new base::Value(details.line)); - dict.Set("message", new base::Value(details.message)); + dict.SetDouble("time", details.time.ToJsTime()); + dict.SetString("filename", details.filename); + dict.SetInteger("line", details.line); + dict.SetString("message", details.message); SendMessageToJs("translateEventDetailsAdded", dict); } @@ -210,7 +210,7 @@ for (const char* key : keys) { const PrefService::Preference* pref = prefs->FindPreference(key); if (pref) - dict.Set(key, pref->GetValue()->DeepCopy()); + dict.Set(key, base::MakeUnique<base::Value>(*pref->GetValue())); } SendMessageToJs("prefsUpdated", dict); @@ -224,8 +224,8 @@ base::Time last_updated = translate::TranslateDownloadManager::GetSupportedLanguagesLastUpdated(); - base::ListValue* languages_list = new base::ListValue(); - base::ListValue* alpha_languages_list = new base::ListValue(); + auto languages_list = base::MakeUnique<base::ListValue>(); + auto alpha_languages_list = base::MakeUnique<base::ListValue>(); for (std::vector<std::string>::iterator it = languages.begin(); it != languages.end(); ++it) { const std::string& lang = *it; @@ -234,9 +234,9 @@ alpha_languages_list->AppendString(lang); } - dict.Set("languages", languages_list); - dict.Set("alpha_languages", alpha_languages_list); - dict.Set("last_updated", new base::Value(last_updated.ToJsTime())); + dict.Set("languages", std::move(languages_list)); + dict.Set("alpha_languages", std::move(alpha_languages_list)); + dict.SetDouble("last_updated", last_updated.ToJsTime()); SendMessageToJs("supportedLanguagesUpdated", dict); } @@ -249,8 +249,8 @@ base::DictionaryValue dict; if (!country.empty()) { - dict.Set("country", new base::Value(country)); - dict.Set("update", new base::Value(was_updated)); + dict.SetString("country", country); + dict.SetBoolean("update", was_updated); } SendMessageToJs("countryUpdated", dict); }
diff --git a/chrome/browser/ui/webui/voice_search_ui.cc b/chrome/browser/ui/webui/voice_search_ui.cc index 5eba13c..6e3882b6 100644 --- a/chrome/browser/ui/webui/voice_search_ui.cc +++ b/chrome/browser/ui/webui/voice_search_ui.cc
@@ -164,7 +164,7 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(info); base::DictionaryValue voiceSearchInfo; - voiceSearchInfo.Set("voiceSearchInfo", info.release()); + voiceSearchInfo.Set("voiceSearchInfo", std::move(info)); web_ui()->CallJavascriptFunctionUnsafe("returnVoiceSearchInfo", voiceSearchInfo); }
diff --git a/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc b/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc index 65576ae..cde991f 100644 --- a/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc +++ b/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc
@@ -6,7 +6,10 @@ #include <stddef.h> +#include <memory> + #include "base/bind.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "chrome/common/chrome_constants.h" @@ -109,17 +112,21 @@ bool modification_is_removal = content::ZoomValuesEqual(level, host_zoom_map_->GetDefaultZoomLevel()); - base::DictionaryValue* host_zoom_dictionary = nullptr; + base::DictionaryValue* host_zoom_dictionary_weak = nullptr; if (!host_zoom_dictionaries->GetDictionary(partition_key_, - &host_zoom_dictionary)) { - host_zoom_dictionary = new base::DictionaryValue(); - host_zoom_dictionaries->Set(partition_key_, host_zoom_dictionary); + &host_zoom_dictionary_weak)) { + auto host_zoom_dictionary = base::MakeUnique<base::DictionaryValue>(); + host_zoom_dictionary_weak = host_zoom_dictionary.get(); + host_zoom_dictionaries->Set(partition_key_, + std::move(host_zoom_dictionary)); } - if (modification_is_removal) - host_zoom_dictionary->RemoveWithoutPathExpansion(change.host, nullptr); - else - host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level); + if (modification_is_removal) { + host_zoom_dictionary_weak->RemoveWithoutPathExpansion(change.host, nullptr); + } else { + host_zoom_dictionary_weak->SetDoubleWithoutPathExpansion(change.host, + level); + } } // TODO(wjmaclean): Remove the dictionary_path once the migration code is
diff --git a/components/login/base_screen_handler_utils.cc b/components/login/base_screen_handler_utils.cc index fe1851b..a96e2cb 100644 --- a/components/login/base_screen_handler_utils.cc +++ b/components/login/base_screen_handler_utils.cc
@@ -67,8 +67,9 @@ if (AccountId::Deserialize(serialized, out_value)) return true; - LOG(ERROR) << "Failed to deserialize '" << serialized << "'"; *out_value = AccountId::FromUserEmail(serialized); + LOG(ERROR) << "Failed to deserialize, parse as email, valid=" + << out_value->is_valid(); return true; }
diff --git a/components/policy/core/common/mac_util.cc b/components/policy/core/common/mac_util.cc index 911453d..7faecd2 100644 --- a/components/policy/core/common/mac_util.cc +++ b/components/policy/core/common/mac_util.cc
@@ -40,7 +40,7 @@ std::unique_ptr<base::Value> converted = PropertyToValue(static_cast<CFPropertyListRef>(value)); if (converted) - static_cast<base::ListValue *>(context)->Append(converted.release()); + static_cast<base::ListValue*>(context)->Append(std::move(converted)); } } // namespace
diff --git a/components/policy/core/common/mac_util_unittest.cc b/components/policy/core/common/mac_util_unittest.cc index c25610b..00e53942 100644 --- a/components/policy/core/common/mac_util_unittest.cc +++ b/components/policy/core/common/mac_util_unittest.cc
@@ -39,19 +39,19 @@ root.SetString("empty", ""); // base::Value::Type::LIST + root.Set("emptyl", base::MakeUnique<base::Value>(base::Value::Type::LIST)); base::ListValue list; - root.Set("emptyl", list.DeepCopy()); for (base::DictionaryValue::Iterator it(root); !it.IsAtEnd(); it.Advance()) - list.Append(it.value().DeepCopy()); + list.Append(base::MakeUnique<base::Value>(it.value())); EXPECT_EQ(root.size(), list.GetSize()); - list.Append(root.DeepCopy()); - root.Set("list", list.DeepCopy()); + list.Append(base::MakeUnique<base::Value>(root)); + root.Set("list", base::MakeUnique<base::Value>(list)); // base::Value::Type::DICTIONARY - base::DictionaryValue dict; - root.Set("emptyd", dict.DeepCopy()); + root.Set("emptyd", + base::MakeUnique<base::Value>(base::Value::Type::DICTIONARY)); // Very meta. - root.Set("dict", root.DeepCopy()); + root.Set("dict", base::MakeUnique<base::Value>(root)); base::ScopedCFTypeRef<CFPropertyListRef> property(ValueToProperty(root)); ASSERT_TRUE(property);
diff --git a/components/wifi/fake_wifi_service.cc b/components/wifi/fake_wifi_service.cc index bbf3f8e4..e3a46836 100644 --- a/components/wifi/fake_wifi_service.cc +++ b/components/wifi/fake_wifi_service.cc
@@ -5,9 +5,11 @@ #include "components/wifi/fake_wifi_service.h" #include <memory> +#include <utility> #include "base/bind.h" #include "base/message_loop/message_loop.h" +#include "base/values.h" #include "components/onc/onc_constants.h" namespace wifi { @@ -118,7 +120,7 @@ it->type == network_type) { std::unique_ptr<base::DictionaryValue> network( it->ToValue(!include_details)); - network_list->Append(network.release()); + network_list->Append(std::move(network)); } } }
diff --git a/components/wifi/wifi_service_mac.mm b/components/wifi/wifi_service_mac.mm index 17ee60c..5b43a4a 100644 --- a/components/wifi/wifi_service_mac.mm +++ b/components/wifi/wifi_service_mac.mm
@@ -8,6 +8,8 @@ #import <netinet/in.h> #import <SystemConfiguration/SystemConfiguration.h> +#include <utility> + #include "base/bind.h" #include "base/mac/foundation_util.h" #include "base/mac/scoped_cftyperef.h" @@ -16,6 +18,7 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/strings/sys_string_conversions.h" +#include "base/values.h" #include "components/onc/onc_constants.h" #include "components/wifi/network_properties.h" #include "crypto/apple_keychain.h" @@ -264,7 +267,7 @@ ++it) { std::unique_ptr<base::DictionaryValue> network( it->ToValue(!include_details)); - network_list->Append(network.release()); + network_list->Append(std::move(network)); } }
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 004de515..75dd323 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -145,6 +145,7 @@ "//ui/events", "//ui/events:gesture_detection", "//ui/events/blink", + "//ui/events/devices", "//ui/gfx", "//ui/gfx/animation", "//ui/gfx/geometry", @@ -1067,6 +1068,8 @@ "renderer_host/input/gesture_event_queue.cc", "renderer_host/input/gesture_event_queue.h", "renderer_host/input/input_ack_handler.h", + "renderer_host/input/input_device_change_observer.cc", + "renderer_host/input/input_device_change_observer.h", "renderer_host/input/input_router.h", "renderer_host/input/input_router_client.h", "renderer_host/input/input_router_config_helper.cc",
diff --git a/content/browser/accessibility/accessibility_tree_formatter_mac.mm b/content/browser/accessibility/accessibility_tree_formatter_mac.mm index 1d67d2d..6ef7033d 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_mac.mm +++ b/content/browser/accessibility/accessibility_tree_formatter_mac.mm
@@ -12,6 +12,7 @@ #include "base/strings/stringprintf.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "base/values.h" #include "content/browser/accessibility/browser_accessibility_cocoa.h" #include "content/browser/accessibility/browser_accessibility_mac.h" #include "content/browser/accessibility/browser_accessibility_manager.h" @@ -88,7 +89,7 @@ std::unique_ptr<base::ListValue> PopulateArray(NSArray* array) { std::unique_ptr<base::ListValue> list(new base::ListValue); for (NSUInteger i = 0; i < [array count]; i++) - list->Append(PopulateObject([array objectAtIndex:i]).release()); + list->Append(PopulateObject([array objectAtIndex:i])); return list; } @@ -253,11 +254,11 @@ if (value != nil) { dict->Set( SysNSStringToUTF8(requestedAttribute), - PopulateObject(value).release()); + PopulateObject(value)); } } - dict->Set(kPositionDictAttr, PopulatePosition(node).release()); - dict->Set(kSizeDictAttr, PopulateSize(cocoa_node).release()); + dict->Set(kPositionDictAttr, PopulatePosition(node)); + dict->Set(kSizeDictAttr, PopulateSize(cocoa_node)); } base::string16 AccessibilityTreeFormatterMac::ToString(
diff --git a/content/browser/appcache/appcache_storage_unittest.cc b/content/browser/appcache/appcache_storage_unittest.cc index c6b50bf..857728f 100644 --- a/content/browser/appcache/appcache_storage_unittest.cc +++ b/content/browser/appcache/appcache_storage_unittest.cc
@@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/appcache/appcache_storage.h" #include "base/message_loop/message_loop.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_group.h" #include "content/browser/appcache/appcache_response.h" -#include "content/browser/appcache/appcache_storage.h" #include "content/browser/appcache/mock_appcache_service.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "testing/gtest/include/gtest/gtest.h" namespace content {
diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc index cf7d2e1..0c5bb819 100644 --- a/content/browser/cache_storage/cache_storage_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -22,7 +22,6 @@ #include "base/threading/thread_task_runner_handle.h" #include "content/browser/blob_storage/chrome_blob_storage_context.h" #include "content/browser/cache_storage/cache_storage_cache_handle.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/common/cache_storage/cache_storage_types.h" #include "content/common/service_worker/service_worker_types.h" #include "content/public/browser/browser_thread.h" @@ -40,6 +39,7 @@ #include "storage/browser/blob/blob_storage_context.h" #include "storage/browser/blob/blob_url_request_job_factory.h" #include "storage/browser/quota/quota_manager_proxy.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/browser/test/mock_special_storage_policy.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc index 97c5918..2bcc478 100644 --- a/content/browser/cache_storage/cache_storage_manager_unittest.cc +++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -29,7 +29,6 @@ #include "content/browser/cache_storage/cache_storage_cache_handle.h" #include "content/browser/cache_storage/cache_storage_index.h" #include "content/browser/cache_storage/cache_storage_quota_client.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cache_storage_usage_info.h" #include "content/public/browser/storage_partition.h" @@ -43,6 +42,7 @@ #include "storage/browser/blob/blob_storage_context.h" #include "storage/browser/blob/blob_url_request_job_factory.h" #include "storage/browser/quota/quota_manager_proxy.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/browser/test/mock_special_storage_policy.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc b/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc index 1ea67d85..87d9db6 100644 --- a/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc +++ b/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc
@@ -17,8 +17,6 @@ #include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/threading/thread_task_runner_handle.h" -#include "content/browser/quota/mock_quota_manager.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/test/fileapi_test_file_set.h" #include "storage/browser/fileapi/copy_or_move_file_validator.h" #include "storage/browser/fileapi/copy_or_move_operation_delegate.h" @@ -30,6 +28,8 @@ #include "storage/browser/fileapi/file_system_url.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/test/async_file_test_helper.h" +#include "storage/browser/test/mock_quota_manager.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/browser/test/test_file_system_backend.h" #include "storage/browser/test/test_file_system_context.h" #include "storage/common/fileapi/file_system_mount_option.h"
diff --git a/content/browser/fileapi/file_system_context_unittest.cc b/content/browser/fileapi/file_system_context_unittest.cc index 8587ce48..44b5e4e 100644 --- a/content/browser/fileapi/file_system_context_unittest.cc +++ b/content/browser/fileapi/file_system_context_unittest.cc
@@ -12,10 +12,10 @@ #include "base/test/scoped_task_environment.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" -#include "content/browser/quota/mock_quota_manager.h" #include "storage/browser/fileapi/external_mount_points.h" #include "storage/browser/fileapi/file_system_backend.h" #include "storage/browser/fileapi/isolated_context.h" +#include "storage/browser/test/mock_quota_manager.h" #include "storage/browser/test/mock_special_storage_policy.h" #include "storage/browser/test/test_file_system_options.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/browser/fileapi/file_system_operation_impl_unittest.cc b/content/browser/fileapi/file_system_operation_impl_unittest.cc index 00384092..2db460b 100644 --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc
@@ -21,8 +21,6 @@ #include "base/threading/thread_task_runner_handle.h" #include "content/browser/fileapi/mock_file_change_observer.h" #include "content/browser/fileapi/mock_file_update_observer.h" -#include "content/browser/quota/mock_quota_manager.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/public/test/sandbox_file_system_test_helper.h" #include "storage/browser/blob/shareable_file_reference.h" #include "storage/browser/fileapi/file_system_context.h" @@ -33,6 +31,8 @@ #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_manager_proxy.h" #include "storage/browser/test/async_file_test_helper.h" +#include "storage/browser/test/mock_quota_manager.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/common/fileapi/file_system_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h"
diff --git a/content/browser/fileapi/file_system_operation_impl_write_unittest.cc b/content/browser/fileapi/file_system_operation_impl_write_unittest.cc index 5180c22..314aa75 100644 --- a/content/browser/fileapi/file_system_operation_impl_write_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_write_unittest.cc
@@ -14,7 +14,6 @@ #include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "content/browser/fileapi/mock_file_change_observer.h" -#include "content/browser/quota/mock_quota_manager.h" #include "content/public/test/mock_blob_url_request_context.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" @@ -27,6 +26,7 @@ #include "storage/browser/fileapi/file_system_operation_context.h" #include "storage/browser/fileapi/file_system_operation_runner.h" #include "storage/browser/fileapi/local_file_util.h" +#include "storage/browser/test/mock_quota_manager.h" #include "storage/browser/test/test_file_system_backend.h" #include "storage/browser/test/test_file_system_context.h" #include "storage/common/fileapi/file_system_util.h"
diff --git a/content/browser/indexed_db/indexed_db_backing_store_unittest.cc b/content/browser/indexed_db/indexed_db_backing_store_unittest.cc index 6a75740..f612670 100644 --- a/content/browser/indexed_db/indexed_db_backing_store_unittest.cc +++ b/content/browser/indexed_db/indexed_db_backing_store_unittest.cc
@@ -23,11 +23,11 @@ #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" #include "content/browser/indexed_db/indexed_db_value.h" #include "content/browser/indexed_db/leveldb/leveldb_factory.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/public/test/test_browser_thread_bundle.h" #include "net/url_request/url_request_test_util.h" #include "storage/browser/blob/blob_data_handle.h" #include "storage/browser/quota/special_storage_policy.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/browser/test/mock_special_storage_policy.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc index 3320bf5..b097121 100644 --- a/content/browser/indexed_db/indexed_db_factory_unittest.cc +++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc
@@ -19,8 +19,8 @@ #include "content/browser/indexed_db/indexed_db_factory_impl.h" #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/public/test/test_browser_thread_bundle.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseException.h" #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
diff --git a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc index 04b00082..a5a11ce 100644 --- a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc +++ b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc
@@ -18,10 +18,10 @@ #include "content/browser/browser_thread_impl.h" #include "content/browser/indexed_db/indexed_db_context_impl.h" #include "content/browser/indexed_db/indexed_db_quota_client.h" -#include "content/browser/quota/mock_quota_manager.h" #include "content/public/browser/storage_partition.h" #include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" +#include "storage/browser/test/mock_quota_manager.h" #include "testing/gtest/include/gtest/gtest.h" // Declared to shorten the line lengths.
diff --git a/content/browser/indexed_db/indexed_db_unittest.cc b/content/browser/indexed_db/indexed_db_unittest.cc index 5bd4d30..2525861 100644 --- a/content/browser/indexed_db/indexed_db_unittest.cc +++ b/content/browser/indexed_db/indexed_db_unittest.cc
@@ -18,13 +18,13 @@ #include "content/browser/indexed_db/indexed_db_factory_impl.h" #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" -#include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/url_constants.h" #include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/special_storage_policy.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/browser/test/mock_special_storage_policy.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/origin.h"
diff --git a/content/browser/quota/DEPS b/content/browser/quota/DEPS deleted file mode 100644 index 3254542..0000000 --- a/content/browser/quota/DEPS +++ /dev/null
@@ -1,4 +0,0 @@ -include_rules = [ - "+third_party/leveldatabase/src/include/leveldb", - "+third_party/leveldatabase/src/helpers/memenv", -]
diff --git a/content/browser/quota/OWNERS b/content/browser/quota/OWNERS deleted file mode 100644 index c254a8f..0000000 --- a/content/browser/quota/OWNERS +++ /dev/null
@@ -1,5 +0,0 @@ -kinuko@chromium.org -michaeln@chromium.org - -# TEAM: storage-dev@chromium.org -# COMPONENT: Blink>Storage>Quota
diff --git a/content/browser/renderer_host/input/input_device_change_observer.cc b/content/browser/renderer_host/input/input_device_change_observer.cc new file mode 100644 index 0000000..7ef1041 --- /dev/null +++ b/content/browser/renderer_host/input/input_device_change_observer.cc
@@ -0,0 +1,60 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/renderer_host/input/input_device_change_observer.h" +#include "base/trace_event/trace_event.h" +#include "content/public/common/web_preferences.h" + +#if defined(OS_WIN) +#include "ui/events/devices/input_device_observer_win.h" +#endif + +namespace content { + +InputDeviceChangeObserver::InputDeviceChangeObserver(RenderViewHost* rvh) { + render_view_host_ = rvh; +#if defined(OS_WIN) + ui::InputDeviceObserverWin::GetInstance()->AddObserver(this); +#endif +} + +InputDeviceChangeObserver::~InputDeviceChangeObserver() { +#if defined(OS_WIN) + ui::InputDeviceObserverWin::GetInstance()->RemoveObserver(this); +#endif + render_view_host_ = nullptr; +} + +void InputDeviceChangeObserver::OnTouchscreenDeviceConfigurationChanged() { + NotifyRenderViewHost(); +} + +void InputDeviceChangeObserver::OnKeyboardDeviceConfigurationChanged() { + NotifyRenderViewHost(); +} + +void InputDeviceChangeObserver::OnMouseDeviceConfigurationChanged() { + NotifyRenderViewHost(); +} + +void InputDeviceChangeObserver::OnTouchpadDeviceConfigurationChanged() { + NotifyRenderViewHost(); +} + +void InputDeviceChangeObserver::NotifyRenderViewHost() { + WebPreferences prefs = render_view_host_->GetWebkitPreferences(); + int available_pointer_types, available_hover_types; + std::tie(available_pointer_types, available_hover_types) = + ui::GetAvailablePointerAndHoverTypes(); + bool input_device_changed = + prefs.available_pointer_types != available_pointer_types || + prefs.available_hover_types != available_hover_types; + + if (input_device_changed) { + TRACE_EVENT0("input", "InputDeviceChangeObserver::NotifyRendererViewHost"); + render_view_host_->OnWebkitPreferencesChanged(); + } +} + +} // namespace content
diff --git a/content/browser/renderer_host/input/input_device_change_observer.h b/content/browser/renderer_host/input/input_device_change_observer.h new file mode 100644 index 0000000..57f7354c --- /dev/null +++ b/content/browser/renderer_host/input/input_device_change_observer.h
@@ -0,0 +1,38 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_DEVICE_CHANGE_OBSERVER_H_ +#define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_DEVICE_CHANGE_OBSERVER_H_ + +#include "content/public/browser/render_view_host.h" +#include "ui/events/devices/input_device_event_observer.h" + +// This class monitors input changes on all platforms. +// +// It is responsible to instantiate the various platforms observers +// and it gets notified whenever the input capabilities change. Whenever +// a change is detected the WebKit preferences are getting updated so the +// interactions media-queries can be updated. +namespace content { +class CONTENT_EXPORT InputDeviceChangeObserver + : public ui::InputDeviceEventObserver { + public: + InputDeviceChangeObserver(RenderViewHost* rvh); + ~InputDeviceChangeObserver() override; + + // InputDeviceEventObserver public overrides. + void OnTouchscreenDeviceConfigurationChanged() override; + void OnKeyboardDeviceConfigurationChanged() override; + void OnMouseDeviceConfigurationChanged() override; + void OnTouchpadDeviceConfigurationChanged() override; + + private: + RenderViewHost* render_view_host_; + void NotifyRenderViewHost(); + DISALLOW_COPY_AND_ASSIGN(InputDeviceChangeObserver); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_DEVICE_CHANGE_OBSERVER_H_
diff --git a/content/browser/renderer_host/input/interaction_mq_dynamic_browsertest.cc b/content/browser/renderer_host/input/interaction_mq_dynamic_browsertest.cc new file mode 100644 index 0000000..03ad3c40 --- /dev/null +++ b/content/browser/renderer_host/input/interaction_mq_dynamic_browsertest.cc
@@ -0,0 +1,43 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/macros.h" +#include "base/strings/utf_string_conversions.h" +#include "content/browser/renderer_host/render_view_host_impl.h" +#include "content/public/browser/web_contents.h" +#include "content/public/test/browser_test_utils.h" +#include "content/public/test/content_browser_test.h" +#include "content/public/test/content_browser_test_utils.h" +#include "content/public/test/test_utils.h" +#include "content/shell/browser/shell.h" +#include "ui/base/touch/touch_device.h" + +namespace content { + +namespace { + +class InteractionMediaQueriesDynamicTest : public ContentBrowserTest { + public: + InteractionMediaQueriesDynamicTest() = default; + ~InteractionMediaQueriesDynamicTest() override = default; +}; + +} // namespace + +#if defined(OS_WIN) +IN_PROC_BROWSER_TEST_F(InteractionMediaQueriesDynamicTest, + PointerMediaQueriesDynamic) { + GURL test_url = GetTestUrl("", "interaction-mq-dynamic.html"); + const base::string16 kSuccessTitle(base::ASCIIToUTF16("SUCCESS")); + TitleWatcher title_watcher(shell()->web_contents(), kSuccessTitle); + NavigateToURL(shell(), test_url); + RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); + ui::SetAvailablePointerAndHoverTypesForTesting(ui::POINTER_TYPE_COARSE, + ui::HOVER_TYPE_HOVER); + rvh->OnWebkitPreferencesChanged(); + EXPECT_EQ(kSuccessTitle, title_watcher.WaitAndGetTitle()); +} +#endif + +} // namespace content
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 1de98c2..53a28b21 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -234,6 +234,8 @@ close_timeout_.reset(new TimeoutMonitor(base::Bind( &RenderViewHostImpl::ClosePageTimeout, weak_factory_.GetWeakPtr()))); + + input_device_change_observer_.reset(new InputDeviceChangeObserver(this)); } RenderViewHostImpl::~RenderViewHostImpl() { @@ -244,7 +246,6 @@ base::Unretained(ResourceDispatcherHostImpl::Get()), GetProcess()->GetID(), GetRoutingID())); } - delegate_->RenderViewDeleted(this); GetProcess()->RemoveObserver(this); }
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h index bcc702b..99f293f 100644 --- a/content/browser/renderer_host/render_view_host_impl.h +++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -20,6 +20,7 @@ #include "base/macros.h" #include "base/process/kill.h" #include "build/build_config.h" +#include "content/browser/renderer_host/input/input_device_change_observer.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_owner_delegate.h" #include "content/browser/site_instance_impl.h" @@ -324,6 +325,9 @@ // closed. std::unique_ptr<TimeoutMonitor> close_timeout_; + // This monitors input changes so they can be reflected to the interaction MQ. + std::unique_ptr<InputDeviceChangeObserver> input_device_change_observer_; + bool updating_web_preferences_; bool render_view_ready_on_process_launch_;
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc index 1df414f..4142782 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc
@@ -14,7 +14,6 @@ #include "base/threading/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/gpu/shader_cache_factory.h" -#include "content/browser/quota/mock_quota_manager.h" #include "content/browser/storage_partition_impl.h" #include "content/public/browser/local_storage_usage_info.h" #include "content/public/browser/storage_partition.h" @@ -28,6 +27,7 @@ #include "net/url_request/url_request_context_getter.h" #include "ppapi/features/features.h" #include "storage/browser/quota/quota_manager.h" +#include "storage/browser/test/mock_quota_manager.h" #include "storage/browser/test/mock_special_storage_policy.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/common/font_list_mac.mm b/content/common/font_list_mac.mm index 5eebf2c..2648a32 100644 --- a/content/common/font_list_mac.mm +++ b/content/common/font_list_mac.mm
@@ -6,7 +6,10 @@ #import <Cocoa/Cocoa.h> +#include <utility> + #include "base/mac/scoped_nsautorelease_pool.h" +#include "base/memory/ptr_util.h" #include "base/strings/sys_string_conversions.h" #include "base/values.h" @@ -31,12 +34,10 @@ for (NSString* family_name in sortedFonts) { NSString* localized_family_name = fonts_dict[family_name]; - base::ListValue* font_item = new base::ListValue(); - base::string16 family = base::SysNSStringToUTF16(family_name); - base::string16 loc_family = base::SysNSStringToUTF16(localized_family_name); - font_item->Append(new base::Value(family)); - font_item->Append(new base::Value(loc_family)); - font_list->Append(font_item); + auto font_item = base::MakeUnique<base::ListValue>(); + font_item->AppendString(base::SysNSStringToUTF16(family_name)); + font_item->AppendString(base::SysNSStringToUTF16(localized_family_name)); + font_list->Append(std::move(font_item)); } return font_list;
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 58969065..7f302a30 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -86,8 +86,6 @@ "../public/test/mock_render_thread.h", "../public/test/mock_resource_context.cc", "../public/test/mock_resource_context.h", - "../public/test/mock_storage_client.cc", - "../public/test/mock_storage_client.h", "../public/test/navigation_simulator.cc", "../public/test/navigation_simulator.h", "../public/test/ppapi_test_utils.cc", @@ -658,6 +656,7 @@ "../browser/pointer_lock_browsertest_mac.mm", "../browser/presentation/presentation_browsertest.cc", "../browser/renderer_host/input/composited_scrolling_browsertest.cc", + "../browser/renderer_host/input/interaction_mq_dynamic_browsertest.cc", "../browser/renderer_host/input/main_thread_event_queue_browsertest.cc", "../browser/renderer_host/input/non_blocking_event_browsertest.cc", "../browser/renderer_host/input/touch_action_browsertest.cc", @@ -1190,14 +1189,6 @@ "../browser/payments/payment_app_provider_impl_unittest.cc", "../browser/payments/payment_manager_unittest.cc", "../browser/presentation/presentation_service_impl_unittest.cc", - "../browser/quota/mock_quota_manager.cc", - "../browser/quota/mock_quota_manager.h", - "../browser/quota/mock_quota_manager_proxy.cc", - "../browser/quota/mock_quota_manager_proxy.h", - "../browser/quota/mock_quota_manager_unittest.cc", - "../browser/quota/quota_manager_unittest.cc", - "../browser/quota/quota_temporary_storage_evictor_unittest.cc", - "../browser/quota/storage_monitor_unittest.cc", "../browser/renderer_host/clipboard_message_filter_unittest.cc", "../browser/renderer_host/compositor_resize_lock_unittest.cc", "../browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc",
diff --git a/content/test/data/interaction-mq-dynamic.html b/content/test/data/interaction-mq-dynamic.html new file mode 100644 index 0000000..f841f69 --- /dev/null +++ b/content/test/data/interaction-mq-dynamic.html
@@ -0,0 +1,30 @@ +<!DOCTYPE html> +<html> +<head> + <title>Dynamic interaction media query test</title> + <script type="text/javascript"> + function handleMediaChange(mediaQueryList) { + if (mediaQueryList.matches) { + pass(); + } else { + fail(); + } + } + + function start() { + var mql = window.matchMedia("(pointer: coarse) and (hover:hover)"); + mql.addListener(handleMediaChange); + } + + function pass() { + document.title = 'SUCCESS'; + } + + function fail() { + document.title = 'FAIL'; + } + </script> +</head> +<body onLoad="start()"> +</body> +</html>
diff --git a/ios/chrome/browser/passwords/password_controller.mm b/ios/chrome/browser/passwords/password_controller.mm index d79a421b..2545cb3 100644 --- a/ios/chrome/browser/passwords/password_controller.mm +++ b/ios/chrome/browser/passwords/password_controller.mm
@@ -21,6 +21,7 @@ #include "base/strings/string16.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "base/values.h" #include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form_fill_data.h" #include "components/browser_sync/profile_sync_service.h" @@ -220,14 +221,14 @@ auto usernameField = base::MakeUnique<base::DictionaryValue>(); usernameField->SetString("name", formData.username_field.name); usernameField->SetString("value", formData.username_field.value); - fieldList->Append(usernameField.release()); + fieldList->Append(std::move(usernameField)); auto passwordField = base::MakeUnique<base::DictionaryValue>(); passwordField->SetString("name", formData.password_field.name); passwordField->SetString("value", formData.password_field.value); - fieldList->Append(passwordField.release()); + fieldList->Append(std::move(passwordField)); - rootDict.Set("fields", fieldList.release()); + rootDict.Set("fields", std::move(fieldList)); std::string jsonString; base::JSONWriter::Write(rootDict, &jsonString);
diff --git a/ios/chrome/browser/ui/settings/block_popups_collection_view_controller.mm b/ios/chrome/browser/ui/settings/block_popups_collection_view_controller.mm index c562d60..d256b12 100644 --- a/ios/chrome/browser/ui/settings/block_popups_collection_view_controller.mm +++ b/ios/chrome/browser/ui/settings/block_popups_collection_view_controller.mm
@@ -280,8 +280,7 @@ // wildcard pattern. So only show settings that the user is able to modify. if (entries[i].secondary_pattern == ContentSettingsPattern::Wildcard() && entries[i].setting == CONTENT_SETTING_ALLOW) { - _exceptions.Append( - new base::Value(entries[i].primary_pattern.ToString())); + _exceptions.AppendString(entries[i].primary_pattern.ToString()); } else { LOG(ERROR) << "Secondary content settings patterns are not " << "supported by the content settings UI";
diff --git a/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc b/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc index 4a136416..7b889fc5 100644 --- a/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc +++ b/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
@@ -125,7 +125,7 @@ ModelTypeSet protocol_types = syncer::ProtocolTypes(); for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good(); it.Inc()) { - type_list->Append(new base::Value(ModelTypeToString(it.Get()))); + type_list->AppendString(ModelTypeToString(it.Get())); } event_details.Set(syncer::sync_ui_util::kTypes, type_list.release()); web_ui()->CallJavascriptFunction(
diff --git a/printing/backend/cups_connection.cc b/printing/backend/cups_connection.cc index 867e0dc..b68d85a 100644 --- a/printing/backend/cups_connection.cc +++ b/printing/backend/cups_connection.cc
@@ -59,6 +59,12 @@ } // namespace +QueueStatus::QueueStatus() = default; + +QueueStatus::QueueStatus(const QueueStatus& other) = default; + +QueueStatus::~QueueStatus() = default; + CupsConnection::CupsConnection(const GURL& print_server_url, http_encryption_t encryption, bool blocking)
diff --git a/printing/backend/cups_connection.h b/printing/backend/cups_connection.h index 0f0475e4..c7deb45 100644 --- a/printing/backend/cups_connection.h +++ b/printing/backend/cups_connection.h
@@ -23,6 +23,10 @@ // Represents the status of a printer queue. struct PRINTING_EXPORT QueueStatus { + QueueStatus(); + QueueStatus(const QueueStatus& other); + ~QueueStatus(); + PrinterStatus printer_status; std::vector<CupsJob> jobs; };
diff --git a/printing/backend/cups_jobs.cc b/printing/backend/cups_jobs.cc index 8faf86a..e73ae8fb 100644 --- a/printing/backend/cups_jobs.cc +++ b/printing/backend/cups_jobs.cc
@@ -283,6 +283,18 @@ } // namespace +CupsJob::CupsJob() = default; + +CupsJob::CupsJob(const CupsJob& other) = default; + +CupsJob::~CupsJob() = default; + +PrinterStatus::PrinterStatus() = default; + +PrinterStatus::PrinterStatus(const PrinterStatus& other) = default; + +PrinterStatus::~PrinterStatus() = default; + void ParseJobsResponse(ipp_t* response, const std::string& printer_id, std::vector<CupsJob>* jobs) {
diff --git a/printing/backend/cups_jobs.h b/printing/backend/cups_jobs.h index 12c2d51..b1ca693c 100644 --- a/printing/backend/cups_jobs.h +++ b/printing/backend/cups_jobs.h
@@ -30,6 +30,10 @@ ABORTED // an error occurred causing the printer to give up }; + CupsJob(); + CupsJob(const CupsJob& other); + ~CupsJob(); + // job id int id = -1; // printer name in CUPS @@ -47,7 +51,7 @@ // Represents the status of a printer containing the properties printer-state, // printer-state-reasons, and printer-state-message. -struct PrinterStatus { +struct PRINTING_EXPORT PrinterStatus { struct PrinterReason { // Standardized reasons from RFC2911. enum Reason { @@ -94,6 +98,10 @@ Severity severity; }; + PrinterStatus(); + PrinterStatus(const PrinterStatus& other); + ~PrinterStatus(); + // printer-state ipp_pstate_t state; // printer-state-reasons
diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h index 9a2c463..367e000 100644 --- a/skia/config/SkUserConfig.h +++ b/skia/config/SkUserConfig.h
@@ -224,6 +224,10 @@ #define SK_LEGACY_SWEEP_GRADIENT #endif +#ifndef SK_SUPPORT_OBSOLETE_LOCKPIXELS +#define SK_SUPPORT_OBSOLETE_LOCKPIXELS +#endif + ///////////////////////// Imported from BUILD.gn and skia_common.gypi /* In some places Skia can use static initializers for global initialization,
diff --git a/storage/browser/BUILD.gn b/storage/browser/BUILD.gn index cffa1f7..e569c844 100644 --- a/storage/browser/BUILD.gn +++ b/storage/browser/BUILD.gn
@@ -262,7 +262,11 @@ "fileapi/timed_task_helper_unittest.cc", "fileapi/transient_file_util_unittest.cc", "quota/quota_database_unittest.cc", + "quota/quota_manager_unittest.cc", + "quota/quota_temporary_storage_evictor_unittest.cc", + "quota/storage_monitor_unittest.cc", "quota/usage_tracker_unittest.cc", + "test/mock_quota_manager_unittest.cc", ] deps = [ @@ -283,8 +287,14 @@ sources = [ "test/async_file_test_helper.cc", "test/async_file_test_helper.h", + "test/mock_quota_manager.cc", + "test/mock_quota_manager.h", + "test/mock_quota_manager_proxy.cc", + "test/mock_quota_manager_proxy.h", "test/mock_special_storage_policy.cc", "test/mock_special_storage_policy.h", + "test/mock_storage_client.cc", + "test/mock_storage_client.h", "test/test_file_system_backend.cc", "test/test_file_system_backend.h", "test/test_file_system_context.cc",
diff --git a/content/browser/quota/quota_manager_unittest.cc b/storage/browser/quota/quota_manager_unittest.cc similarity index 99% rename from content/browser/quota/quota_manager_unittest.cc rename to storage/browser/quota/quota_manager_unittest.cc index 91f8420..816aa5c 100644 --- a/content/browser/quota/quota_manager_unittest.cc +++ b/storage/browser/quota/quota_manager_unittest.cc
@@ -25,11 +25,11 @@ #include "base/test/scoped_task_environment.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" -#include "content/public/test/mock_storage_client.h" #include "storage/browser/quota/quota_database.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_manager_proxy.h" #include "storage/browser/test/mock_special_storage_policy.h" +#include "storage/browser/test/mock_storage_client.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h"
diff --git a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc b/storage/browser/quota/quota_temporary_storage_evictor_unittest.cc similarity index 99% rename from content/browser/quota/quota_temporary_storage_evictor_unittest.cc rename to storage/browser/quota/quota_temporary_storage_evictor_unittest.cc index 54447c99..f8a1cc8 100644 --- a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc +++ b/storage/browser/quota/quota_temporary_storage_evictor_unittest.cc
@@ -15,9 +15,9 @@ #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "base/test/scoped_task_environment.h" -#include "content/public/test/mock_storage_client.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_temporary_storage_evictor.h" +#include "storage/browser/test/mock_storage_client.h" #include "testing/gtest/include/gtest/gtest.h" using storage::QuotaTemporaryStorageEvictor;
diff --git a/content/browser/quota/storage_monitor_unittest.cc b/storage/browser/quota/storage_monitor_unittest.cc similarity index 99% rename from content/browser/quota/storage_monitor_unittest.cc rename to storage/browser/quota/storage_monitor_unittest.cc index 34653b1..9da7234 100644 --- a/content/browser/quota/storage_monitor_unittest.cc +++ b/storage/browser/quota/storage_monitor_unittest.cc
@@ -9,13 +9,13 @@ #include "base/files/scoped_temp_dir.h" #include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" -#include "content/public/test/mock_storage_client.h" #include "net/base/url_util.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_manager_proxy.h" #include "storage/browser/quota/storage_monitor.h" #include "storage/browser/quota/storage_observer.h" #include "storage/browser/test/mock_special_storage_policy.h" +#include "storage/browser/test/mock_storage_client.h" #include "testing/gtest/include/gtest/gtest.h" using storage::HostStorageObservers;
diff --git a/content/browser/quota/mock_quota_manager.cc b/storage/browser/test/mock_quota_manager.cc similarity index 98% rename from content/browser/quota/mock_quota_manager.cc rename to storage/browser/test/mock_quota_manager.cc index 65e197a..02311f1c0 100644 --- a/content/browser/quota/mock_quota_manager.cc +++ b/storage/browser/test/mock_quota_manager.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 "content/browser/quota/mock_quota_manager.h" +#include "storage/browser/test/mock_quota_manager.h" #include <limits> #include <memory>
diff --git a/content/browser/quota/mock_quota_manager.h b/storage/browser/test/mock_quota_manager.h similarity index 100% rename from content/browser/quota/mock_quota_manager.h rename to storage/browser/test/mock_quota_manager.h
diff --git a/content/browser/quota/mock_quota_manager_proxy.cc b/storage/browser/test/mock_quota_manager_proxy.cc similarity index 96% rename from content/browser/quota/mock_quota_manager_proxy.cc rename to storage/browser/test/mock_quota_manager_proxy.cc index 8ca0293..24f3124 100644 --- a/content/browser/quota/mock_quota_manager_proxy.cc +++ b/storage/browser/test/mock_quota_manager_proxy.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 "content/browser/quota/mock_quota_manager_proxy.h" +#include "storage/browser/test/mock_quota_manager_proxy.h" #include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h"
diff --git a/content/browser/quota/mock_quota_manager_proxy.h b/storage/browser/test/mock_quota_manager_proxy.h similarity index 97% rename from content/browser/quota/mock_quota_manager_proxy.h rename to storage/browser/test/mock_quota_manager_proxy.h index 3f9ddab..0677d4e83 100644 --- a/content/browser/quota/mock_quota_manager_proxy.h +++ b/storage/browser/test/mock_quota_manager_proxy.h
@@ -8,9 +8,9 @@ #include <stdint.h> #include "base/macros.h" -#include "content/browser/quota/mock_quota_manager.h" #include "storage/browser/quota/quota_client.h" #include "storage/browser/quota/quota_manager_proxy.h" +#include "storage/browser/test/mock_quota_manager.h" #include "storage/common/quota/quota_types.h" #include "url/gurl.h"
diff --git a/content/browser/quota/mock_quota_manager_unittest.cc b/storage/browser/test/mock_quota_manager_unittest.cc similarity index 98% rename from content/browser/quota/mock_quota_manager_unittest.cc rename to storage/browser/test/mock_quota_manager_unittest.cc index 0899b80..6ebfbf1 100644 --- a/content/browser/quota/mock_quota_manager_unittest.cc +++ b/storage/browser/test/mock_quota_manager_unittest.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 "content/browser/quota/mock_quota_manager.h" +#include "storage/browser/test/mock_quota_manager.h" #include <memory> #include <set> @@ -14,8 +14,8 @@ #include "base/run_loop.h" #include "base/test/scoped_task_environment.h" #include "base/threading/thread_task_runner_handle.h" -#include "content/public/test/mock_storage_client.h" #include "storage/browser/test/mock_special_storage_policy.h" +#include "storage/browser/test/mock_storage_client.h" #include "testing/gtest/include/gtest/gtest.h" using storage::kQuotaStatusOk;
diff --git a/content/public/test/mock_storage_client.cc b/storage/browser/test/mock_storage_client.cc similarity index 98% rename from content/public/test/mock_storage_client.cc rename to storage/browser/test/mock_storage_client.cc index 313aa21..9bb8da83 100644 --- a/content/public/test/mock_storage_client.cc +++ b/storage/browser/test/mock_storage_client.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 "content/public/test/mock_storage_client.h" +#include "storage/browser/test/mock_storage_client.h" #include <memory>
diff --git a/content/public/test/mock_storage_client.h b/storage/browser/test/mock_storage_client.h similarity index 100% rename from content/public/test/mock_storage_client.h rename to storage/browser/test/mock_storage_client.h
diff --git a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp index 893f9f50..12531ba2 100644 --- a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp +++ b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
@@ -69,6 +69,9 @@ struct SingleElementSelectorQueryTrait { typedef Element* OutputType; static const bool kShouldOnlyMatchFirstElement = true; + ALWAYS_INLINE static bool IsEmpty(const OutputType& output) { + return !output; + } ALWAYS_INLINE static void AppendElement(OutputType& output, Element& element) { DCHECK(!output); @@ -79,6 +82,9 @@ struct AllElementsSelectorQueryTrait { typedef HeapVector<Member<Element>> OutputType; static const bool kShouldOnlyMatchFirstElement = false; + ALWAYS_INLINE static bool IsEmpty(const OutputType& output) { + return output.IsEmpty(); + } ALWAYS_INLINE static void AppendElement(OutputType& output, Element& element) { output.push_back(&element); @@ -227,35 +233,12 @@ DCHECK_EQ(selectors_.size(), 1u); bool is_rightmost_selector = true; - bool start_from_parent = false; + bool is_affected_by_sibling_combinator = false; for (const CSSSelector* selector = selectors_[0]; selector; selector = selector->TagHistory()) { - if (selector->Match() == CSSSelector::kId && - !root_node.ContainingTreeScope().ContainsMultipleElementsWithId( - selector->Value())) { - // Id selectors in the right most selector are handled by the caller, - // we should never hit them here. - DCHECK(!is_rightmost_selector); - Element* element = - root_node.ContainingTreeScope().GetElementById(selector->Value()); - if (!element) - return; - ContainerNode* start = &root_node; - if (element->IsDescendantOf(&root_node)) - start = element; - if (start_from_parent) - start = start->parentNode(); - if (!start) - return; - ExecuteForTraverseRoot<SelectorQueryTrait>(*start, root_node, output); - return; - } - - // If we have both CSSSelector::Id and CSSSelector::Class at the same time, - // we should use Id to find traverse root. - if (!SelectorQueryTrait::kShouldOnlyMatchFirstElement && - !start_from_parent && selector->Match() == CSSSelector::kClass) { + if (!is_affected_by_sibling_combinator && + selector->Match() == CSSSelector::kClass) { if (is_rightmost_selector) { CollectElementsByClassName<SelectorQueryTrait>( root_node, selector->Value(), selectors_[0], output); @@ -273,6 +256,9 @@ if (HasClassName(*element, class_name)) { ExecuteForTraverseRoot<SelectorQueryTrait>(*element, root_node, output); + if (SelectorQueryTrait::kShouldOnlyMatchFirstElement && + !SelectorQueryTrait::IsEmpty(output)) + return; element = ElementTraversal::NextSkippingChildren(*element, &root_node); } else { @@ -285,11 +271,9 @@ if (selector->Relation() == CSSSelector::kSubSelector) continue; is_rightmost_selector = false; - if (selector->Relation() == CSSSelector::kDirectAdjacent || - selector->Relation() == CSSSelector::kIndirectAdjacent) - start_from_parent = true; - else - start_from_parent = false; + is_affected_by_sibling_combinator = + selector->Relation() == CSSSelector::kDirectAdjacent || + selector->Relation() == CSSSelector::kIndirectAdjacent; } ExecuteForTraverseRoot<SelectorQueryTrait>(root_node, root_node, output); @@ -399,22 +383,54 @@ } } -static const CSSSelector* SelectorForIdLookup( - const CSSSelector& first_selector) { - for (const CSSSelector* selector = &first_selector; selector; - selector = selector->TagHistory()) { - if (selector->Match() == CSSSelector::kId) - return selector; - // We only use the fast path when in standards mode where #id selectors - // are case sensitive, so we need the same behavior for [id=value]. - if (selector->Match() == CSSSelector::kAttributeExact && - selector->Attribute() == idAttr && - selector->AttributeMatch() == CSSSelector::kCaseSensitive) - return selector; - if (selector->Relation() != CSSSelector::kSubSelector) - break; +template <typename SelectorQueryTrait> +void SelectorQuery::ExecuteWithId( + ContainerNode& root_node, + typename SelectorQueryTrait::OutputType& output) const { + const CSSSelector& first_selector = *selectors_[0]; + const TreeScope& scope = root_node.ContainingTreeScope(); + + if (scope.ContainsMultipleElementsWithId(selector_id_)) { + // We don't currently handle cases where there's multiple elements with the + // id and it's not in the rightmost selector. + if (!selector_id_is_rightmost_) { + FindTraverseRootsAndExecute<SelectorQueryTrait>(root_node, output); + return; + } + const auto& elements = scope.GetAllElementsById(selector_id_); + for (const auto& element : elements) { + if (!element->IsDescendantOf(&root_node)) + continue; + QUERY_STATS_INCREMENT(fast_id); + if (SelectorMatches(first_selector, *element, root_node)) { + SelectorQueryTrait::AppendElement(output, *element); + if (SelectorQueryTrait::kShouldOnlyMatchFirstElement) + return; + } + } + return; } - return nullptr; + + Element* element = scope.GetElementById(selector_id_); + if (!element) + return; + if (selector_id_is_rightmost_) { + if (!element->IsDescendantOf(&root_node)) + return; + QUERY_STATS_INCREMENT(fast_id); + if (SelectorMatches(first_selector, *element, root_node)) + SelectorQueryTrait::AppendElement(output, *element); + return; + } + ContainerNode* start = &root_node; + if (element->IsDescendantOf(&root_node)) + start = element; + if (selector_id_affected_by_sibling_combinator_) + start = start->parentNode(); + if (!start) + return; + QUERY_STATS_INCREMENT(fast_id); + ExecuteForTraverseRoot<SelectorQueryTrait>(*start, root_node, output); } template <typename SelectorQueryTrait> @@ -438,39 +454,12 @@ DCHECK_EQ(selectors_.size(), 1u); DCHECK(!root_node.GetDocument().InQuirksMode()); - const CSSSelector& selector = *selectors_[0]; - const CSSSelector& first_selector = selector; - - // Fast path for querySelector*('#id'), querySelector*('tag#id'), - // querySelector*('tag[id=example]'). - if (const CSSSelector* id_selector = SelectorForIdLookup(first_selector)) { - const AtomicString& id_to_match = id_selector->Value(); - if (root_node.GetTreeScope().ContainsMultipleElementsWithId(id_to_match)) { - const HeapVector<Member<Element>>& elements = - root_node.GetTreeScope().GetAllElementsById(id_to_match); - for (const auto& element : elements) { - if (!element->IsDescendantOf(&root_node)) - continue; - QUERY_STATS_INCREMENT(fast_id); - if (SelectorMatches(selector, *element, root_node)) { - SelectorQueryTrait::AppendElement(output, *element); - if (SelectorQueryTrait::kShouldOnlyMatchFirstElement) - return; - } - } - return; - } - Element* element = root_node.GetTreeScope().GetElementById(id_to_match); - if (!element) - return; - if (!element->IsDescendantOf(&root_node)) - return; - QUERY_STATS_INCREMENT(fast_id); - if (SelectorMatches(selector, *element, root_node)) - SelectorQueryTrait::AppendElement(output, *element); + if (selector_id_) { + ExecuteWithId<SelectorQueryTrait>(root_node, output); return; } + const CSSSelector& first_selector = *selectors_[0]; if (!first_selector.TagHistory()) { // Fast path for querySelector*('.foo'), and querySelector*('div'). switch (first_selector.Match()) { @@ -504,6 +493,8 @@ SelectorQuery::SelectorQuery(CSSSelectorList selector_list) : selector_list_(std::move(selector_list)), + selector_id_is_rightmost_(true), + selector_id_affected_by_sibling_combinator_(false), uses_deep_combinator_or_shadow_pseudo_(false), needs_updated_distribution_(false) { selectors_.ReserveInitialCapacity(selector_list_.ComputeLength()); @@ -516,6 +507,31 @@ selector->HasDeepCombinatorOrShadowPseudo(); needs_updated_distribution_ |= selector->NeedsUpdatedDistribution(); } + + if (selectors_.size() == 1 && !uses_deep_combinator_or_shadow_pseudo_ && + !needs_updated_distribution_) { + for (const CSSSelector* current = selectors_[0]; current; + current = current->TagHistory()) { + if (current->Match() == CSSSelector::kId) { + selector_id_ = current->Value(); + break; + } + // We only use the fast path when in standards mode where #id selectors + // are case sensitive, so we need the same behavior for [id=value]. + if (current->Match() == CSSSelector::kAttributeExact && + current->Attribute() == idAttr && + current->AttributeMatch() == CSSSelector::kCaseSensitive) { + selector_id_ = current->Value(); + break; + } + if (current->Relation() == CSSSelector::kSubSelector) + continue; + selector_id_is_rightmost_ = false; + selector_id_affected_by_sibling_combinator_ = + current->Relation() == CSSSelector::kDirectAdjacent || + current->Relation() == CSSSelector::kIndirectAdjacent; + } + } } SelectorQuery* SelectorQueryCache::Add(const AtomicString& selectors,
diff --git a/third_party/WebKit/Source/core/dom/SelectorQuery.h b/third_party/WebKit/Source/core/dom/SelectorQuery.h index 934be7a2..660c681b6 100644 --- a/third_party/WebKit/Source/core/dom/SelectorQuery.h +++ b/third_party/WebKit/Source/core/dom/SelectorQuery.h
@@ -84,6 +84,9 @@ bool CanUseFastQuery(const ContainerNode& root_node) const; template <typename SelectorQueryTrait> + void ExecuteWithId(ContainerNode& root_node, + typename SelectorQueryTrait::OutputType&) const; + template <typename SelectorQueryTrait> void FindTraverseRootsAndExecute( ContainerNode& root_node, typename SelectorQueryTrait::OutputType&) const; @@ -110,6 +113,9 @@ // m_selectorList will never be empty as SelectorQueryCache::add would have // thrown an exception. Vector<const CSSSelector*> selectors_; + AtomicString selector_id_; + bool selector_id_is_rightmost_ : 1; + bool selector_id_affected_by_sibling_combinator_ : 1; bool uses_deep_combinator_or_shadow_pseudo_ : 1; bool needs_updated_distribution_ : 1; };
diff --git a/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp b/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp index d085bf4b..1828396e 100644 --- a/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp +++ b/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp
@@ -139,6 +139,8 @@ {"body #multiple", false, 1, {1, 1, 0, 0, 0, 0, 0}}, {"body span#multiple", false, 1, {2, 2, 0, 0, 0, 0, 0}}, {"body #multiple", true, 2, {2, 2, 0, 0, 0, 0, 0}}, + {"[id=multiple]", true, 2, {2, 2, 0, 0, 0, 0, 0}}, + {"body [id=multiple]", true, 2, {2, 2, 0, 0, 0, 0, 0}}, // Single selector tag fast path. {"span", false, 1, {4, 0, 0, 4, 0, 0, 0}}, @@ -149,39 +151,36 @@ {".two", true, 4, {14, 0, 14, 0, 0, 0, 0}}, // Class in the right most selector fast path. - {"body .two", false, 1, {6, 0, 0, 0, 6, 0, 0}}, - {"div .two", false, 1, {12, 0, 0, 0, 12, 0, 0}}, + {"body .two", false, 1, {6, 0, 6, 0, 0, 0, 0}}, + {"div .two", false, 1, {12, 0, 12, 0, 0, 0, 0}}, // Classes in the right most selector for querySelectorAll use a fast // path. {"body .two", true, 4, {14, 0, 14, 0, 0, 0, 0}}, {"div .two", true, 2, {14, 0, 14, 0, 0, 0, 0}}, - // TODO: querySelector disables the class fast path to favor the id, but - // this means some selectors always end up doing fastScan. - {"#second .two", false, 1, {2, 0, 0, 0, 2, 0, 0}}, - - // TODO(esprehn): This should have used getElementById instead of doing - // a fastClass scan. It could have looked at 4 elements instead. - {"#second .two", true, 2, {14, 0, 14, 0, 0, 0, 0}}, + // TODO: We could use the fast class path to find the elements inside + // the id scope instead of the fast scan. + {"#second .two", false, 1, {3, 1, 0, 0, 2, 0, 0}}, + {"#second .two", true, 2, {5, 1, 0, 0, 4, 0, 0}}, // We combine the class fast path with the fast scan mode when possible. - {".B span", false, 1, {11, 0, 0, 0, 11, 0, 0}}, + {".B span", false, 1, {11, 0, 10, 0, 1, 0, 0}}, {".B span", true, 4, {14, 0, 10, 0, 4, 0, 0}}, // We expand the scope of id selectors when affected by an adjectent // combinator. - {"#c + :last-child", false, 1, {4, 0, 0, 0, 4, 0, 0}}, - {"#a ~ :last-child", false, 1, {4, 0, 0, 0, 4, 0, 0}}, - {"#c + div", true, 1, {4, 0, 0, 0, 4, 0, 0}}, - {"#a ~ span", true, 2, {4, 0, 0, 0, 4, 0, 0}}, + {"#c + :last-child", false, 1, {5, 1, 0, 0, 4, 0, 0}}, + {"#a ~ :last-child", false, 1, {5, 1, 0, 0, 4, 0, 0}}, + {"#c + div", true, 1, {5, 1, 0, 0, 4, 0, 0}}, + {"#a ~ span", true, 2, {5, 1, 0, 0, 4, 0, 0}}, // We only expand the scope for id selectors if they're directly affected // the adjacent combinator. - {"#first span + span", false, 1, {2, 0, 0, 0, 2, 0, 0}}, - {"#first span ~ span", false, 1, {2, 0, 0, 0, 2, 0, 0}}, - {"#second span + span", true, 3, {4, 0, 0, 0, 4, 0, 0}}, - {"#second span ~ span", true, 3, {4, 0, 0, 0, 4, 0, 0}}, + {"#first span + span", false, 1, {3, 1, 0, 0, 2, 0, 0}}, + {"#first span ~ span", false, 1, {3, 1, 0, 0, 2, 0, 0}}, + {"#second span + span", true, 3, {5, 1, 0, 0, 4, 0, 0}}, + {"#second span ~ span", true, 3, {5, 1, 0, 0, 4, 0, 0}}, // We disable the fast path for class selectors when affected by adjacent // combinator. @@ -268,7 +267,7 @@ {".root-class span:nth-child(2)", true, 1, {7, 0, 0, 0, 7, 0, 0}}, // If the id is an ancestor we scan all the descendants. - {"#root-id span", true, 4, {7, 0, 0, 0, 7, 0, 0}}, + {"#root-id span", true, 4, {8, 1, 0, 0, 7, 0, 0}}, }; { @@ -304,6 +303,8 @@ {"#One", false, 1, {5, 0, 0, 0, 0, 5, 0}}, {"#ONE", false, 1, {5, 0, 0, 0, 0, 5, 0}}, {"#ONE", true, 2, {6, 0, 0, 0, 0, 6, 0}}, + {"[id=One]", false, 1, {5, 0, 0, 0, 0, 5, 0}}, + {"[id=One]", true, 1, {6, 0, 0, 0, 0, 6, 0}}, {"span", false, 1, {4, 0, 0, 0, 0, 4, 0}}, {"span", true, 3, {6, 0, 0, 0, 0, 6, 0}}, {".two", false, 1, {5, 0, 0, 0, 0, 5, 0}},
diff --git a/ui/base/touch/touch_device.h b/ui/base/touch/touch_device.h index b59699bf..7b1b65f 100644 --- a/ui/base/touch/touch_device.h +++ b/ui/base/touch/touch_device.h
@@ -62,6 +62,9 @@ }; UI_BASE_EXPORT std::pair<int, int> GetAvailablePointerAndHoverTypes(); +UI_BASE_EXPORT void SetAvailablePointerAndHoverTypesForTesting( + int available_pointer_types, + int available_hover_types); UI_BASE_EXPORT PointerType GetPrimaryPointerType(int available_pointer_types); UI_BASE_EXPORT HoverType GetPrimaryHoverType(int available_hover_types);
diff --git a/ui/base/touch/touch_device_win.cc b/ui/base/touch/touch_device_win.cc index bd7f1ea..3ccbb1b 100644 --- a/ui/base/touch/touch_device_win.cc +++ b/ui/base/touch/touch_device_win.cc
@@ -97,7 +97,21 @@ return HOVER_TYPE_NONE; } +bool return_available_pointer_and_hover_types_for_testing = false; +int available_pointer_types_for_testing = POINTER_TYPE_NONE; +int available_hover_types_for_testing = HOVER_TYPE_NONE; + +void SetAvailablePointerAndHoverTypesForTesting(int available_pointer_types, + int available_hover_types) { + return_available_pointer_and_hover_types_for_testing = true; + available_pointer_types_for_testing = available_pointer_types; + available_hover_types_for_testing = available_hover_types; +} + std::pair<int, int> GetAvailablePointerAndHoverTypes() { + if (return_available_pointer_and_hover_types_for_testing) + return std::make_pair(available_pointer_types_for_testing, + available_hover_types_for_testing); return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes()); }
diff --git a/ui/events/devices/BUILD.gn b/ui/events/devices/BUILD.gn index 1dc942f..9565cc7 100644 --- a/ui/events/devices/BUILD.gn +++ b/ui/events/devices/BUILD.gn
@@ -15,6 +15,8 @@ "input_device_event_observer.h", "input_device_manager.cc", "input_device_manager.h", + "input_device_observer_win.cc", + "input_device_observer_win.h", "stylus_state.h", "touchscreen_device.cc", "touchscreen_device.h",
diff --git a/ui/events/devices/input_device_observer_win.cc b/ui/events/devices/input_device_observer_win.cc new file mode 100644 index 0000000..5f9196bd --- /dev/null +++ b/ui/events/devices/input_device_observer_win.cc
@@ -0,0 +1,99 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/events/devices/input_device_observer_win.h" + +#include "base/bind.h" +#include "base/callback.h" +#include "base/memory/singleton.h" +#include "base/strings/string16.h" + +// This macro provides the implementation for the observer notification methods. +#define NOTIFY_OBSERVERS(method_decl, observer_call) \ + void InputDeviceObserverWin::method_decl { \ + for (InputDeviceEventObserver & observer : observers_) \ + observer.observer_call; \ + } + +namespace ui { + +namespace { + +// The registry subkey that contains information about the state of the +// detachable/convertible laptop, it tells if the device has an accessible +// keyboard. +// OEMs are expected to follow this guidelines to report docked/undocked state +// https://msdn.microsoft.com/en-us/windows/hardware/commercialize/customize/desktop/unattend/microsoft-windows-gpiobuttons-convertibleslatemode +const base::char16 kRegistryPriorityControl[] = + L"System\\CurrentControlSet\\Control\\PriorityControl"; + +const base::char16 kRegistryConvertibleSlateModeKey[] = L"ConvertibleSlateMode"; + +} // namespace + +InputDeviceObserverWin::InputDeviceObserverWin() : weak_factory_(this) { + registry_key_.reset(new base::win::RegKey( + HKEY_LOCAL_MACHINE, kRegistryPriorityControl, KEY_NOTIFY | KEY_READ)); + + if (registry_key_->Valid()) { + slate_mode_enabled_ = IsSlateModeEnabled(registry_key_.get()); + // Start watching the registry for changes. + base::win::RegKey::ChangeCallback callback = + base::Bind(&InputDeviceObserverWin::OnRegistryKeyChanged, + weak_factory_.GetWeakPtr(), registry_key_.get()); + registry_key_->StartWatching(callback); + } +} + +InputDeviceObserverWin* InputDeviceObserverWin::GetInstance() { + return base::Singleton< + InputDeviceObserverWin, + base::LeakySingletonTraits<InputDeviceObserverWin>>::get(); +} + +InputDeviceObserverWin::~InputDeviceObserverWin() {} + +void InputDeviceObserverWin::OnRegistryKeyChanged(base::win::RegKey* key) { + if (!key) + return; + + // |OnRegistryKeyChanged| is removed as an observer when the ChangeCallback is + // called, so we need to re-register. + key->StartWatching(base::Bind(&InputDeviceObserverWin::OnRegistryKeyChanged, + weak_factory_.GetWeakPtr(), + base::Unretained(key))); + + bool new_slate_mode = IsSlateModeEnabled(key); + if (slate_mode_enabled_ == new_slate_mode) + return; + + NotifyObserversTouchpadDeviceConfigurationChanged(); + NotifyObserversKeyboardDeviceConfigurationChanged(); + slate_mode_enabled_ = new_slate_mode; +} + +bool InputDeviceObserverWin::IsSlateModeEnabled(base::win::RegKey* key) { + DWORD slate_enabled; + if (key->ReadValueDW(kRegistryConvertibleSlateModeKey, &slate_enabled) != + ERROR_SUCCESS) + return false; + return slate_enabled == 1; +} + +void InputDeviceObserverWin::AddObserver(InputDeviceEventObserver* observer) { + observers_.AddObserver(observer); +} + +void InputDeviceObserverWin::RemoveObserver( + InputDeviceEventObserver* observer) { + observers_.RemoveObserver(observer); +} + +NOTIFY_OBSERVERS(NotifyObserversKeyboardDeviceConfigurationChanged(), + OnKeyboardDeviceConfigurationChanged()); + +NOTIFY_OBSERVERS(NotifyObserversTouchpadDeviceConfigurationChanged(), + OnTouchpadDeviceConfigurationChanged()); + +} // namespace ui
diff --git a/ui/events/devices/input_device_observer_win.h b/ui/events/devices/input_device_observer_win.h new file mode 100644 index 0000000..fd0f5b4 --- /dev/null +++ b/ui/events/devices/input_device_observer_win.h
@@ -0,0 +1,48 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_DEVICE_OBSERVER_WIN_H_ +#define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_DEVICE_OBSERVER_WIN_H_ + +#include "base/observer_list.h" +#include "base/win/registry.h" +#include "ui/events/devices/input_device_event_observer.h" + +namespace base { +template <typename T> +struct DefaultSingletonTraits; +} + +namespace ui { +class EVENTS_DEVICES_EXPORT InputDeviceObserverWin { + public: + static InputDeviceObserverWin* GetInstance(); + ~InputDeviceObserverWin(); + + void AddObserver(InputDeviceEventObserver* observer); + void RemoveObserver(InputDeviceEventObserver* observer); + + protected: + InputDeviceObserverWin(); + + private: + void OnRegistryKeyChanged(base::win::RegKey* key); + bool IsSlateModeEnabled(base::win::RegKey* key); + void NotifyObserversKeyboardDeviceConfigurationChanged(); + void NotifyObserversTouchpadDeviceConfigurationChanged(); + + std::unique_ptr<base::win::RegKey> registry_key_; + base::ObserverList<InputDeviceEventObserver> observers_; + bool slate_mode_enabled_; + + friend struct base::DefaultSingletonTraits<InputDeviceObserverWin>; + + base::WeakPtrFactory<InputDeviceObserverWin> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(InputDeviceObserverWin); +}; + +} // namespace ui + +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_DEVICE_OBSERVER_WIN_H_ \ No newline at end of file