Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome/renderer/extensions/notifications_native_handler.cc

Issue 2937543002: [Extensions] Use gin::DataObjectBuilder in NotificationsNativeHandler (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/notifications_native_handler.cc
diff --git a/chrome/renderer/extensions/notifications_native_handler.cc b/chrome/renderer/extensions/notifications_native_handler.cc
index b45b540c0fc21b577cef2922bc891e10e4321765..803de0d3c829d390d2118c1d714be25cc604561a 100644
--- a/chrome/renderer/extensions/notifications_native_handler.cc
+++ b/chrome/renderer/extensions/notifications_native_handler.cc
@@ -10,8 +10,8 @@
#include "base/logging.h"
#include "base/values.h"
#include "chrome/common/extensions/api/notifications/notification_style.h"
-#include "content/public/child/v8_value_converter.h"
#include "extensions/renderer/script_context.h"
+#include "gin/data_object_builder.h"
#include "ui/base/layout.h"
namespace extensions {
@@ -31,23 +31,29 @@ void NotificationsNativeHandler::GetNotificationImageSizes(
float scale_factor =
ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactors().back());
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
- dict->SetDouble("scaleFactor", scale_factor);
- dict->SetInteger("icon.width", bitmap_sizes.icon_size.width());
- dict->SetInteger("icon.height", bitmap_sizes.icon_size.height());
- dict->SetInteger("image.width", bitmap_sizes.image_size.width());
- dict->SetInteger("image.height", bitmap_sizes.image_size.height());
- dict->SetInteger("buttonIcon.width", bitmap_sizes.button_icon_size.width());
- dict->SetInteger("buttonIcon.height", bitmap_sizes.button_icon_size.height());
- dict->SetInteger("appIconMask.width",
- bitmap_sizes.app_icon_mask_size.width());
- dict->SetInteger("appIconMask.height",
- bitmap_sizes.app_icon_mask_size.height());
-
- std::unique_ptr<content::V8ValueConverter> converter(
- content::V8ValueConverter::create());
- args.GetReturnValue().Set(
- converter->ToV8Value(dict.get(), context()->v8_context()));
+ v8::Isolate* isolate = GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+
+ struct {
+ const char* key;
+ const gfx::Size& size;
+ } entries[] = {
+ {"icon", bitmap_sizes.icon_size},
+ {"image", bitmap_sizes.image_size},
+ {"buttonIcon", bitmap_sizes.button_icon_size},
+ {"appIconMask", bitmap_sizes.app_icon_mask_size},
+ };
+
+ gin::DataObjectBuilder builder(isolate);
+ builder.Set("scaleFactor", scale_factor);
+ for (const auto& entry : entries) {
+ builder.Set(entry.key, gin::DataObjectBuilder(isolate)
+ .Set("width", entry.size.width())
+ .Set("height", entry.size.height())
+ .Build());
+ }
+
+ args.GetReturnValue().Set(builder.Build());
}
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698