Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/extensions/notifications_native_handler.h" | 5 #include "chrome/renderer/extensions/notifications_native_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 base::Unretained(this))); | 24 base::Unretained(this))); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void NotificationsNativeHandler::GetNotificationImageSizes( | 27 void NotificationsNativeHandler::GetNotificationImageSizes( |
| 28 const v8::FunctionCallbackInfo<v8::Value>& args) { | 28 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 29 NotificationBitmapSizes bitmap_sizes = GetNotificationBitmapSizes(); | 29 NotificationBitmapSizes bitmap_sizes = GetNotificationBitmapSizes(); |
| 30 | 30 |
| 31 float scale_factor = | 31 float scale_factor = |
| 32 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactors().back()); | 32 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactors().back()); |
| 33 | 33 |
| 34 // TODO(devlin): Prefer gin::DataObjectBuilder here. | |
|
Devlin
2017/06/12 20:22:16
(If https://codereview.chromium.org/2937543002/ la
| |
| 34 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 35 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 35 dict->SetDouble("scaleFactor", scale_factor); | 36 dict->SetDouble("scaleFactor", scale_factor); |
| 36 dict->SetInteger("icon.width", bitmap_sizes.icon_size.width()); | 37 dict->SetInteger("icon.width", bitmap_sizes.icon_size.width()); |
| 37 dict->SetInteger("icon.height", bitmap_sizes.icon_size.height()); | 38 dict->SetInteger("icon.height", bitmap_sizes.icon_size.height()); |
| 38 dict->SetInteger("image.width", bitmap_sizes.image_size.width()); | 39 dict->SetInteger("image.width", bitmap_sizes.image_size.width()); |
| 39 dict->SetInteger("image.height", bitmap_sizes.image_size.height()); | 40 dict->SetInteger("image.height", bitmap_sizes.image_size.height()); |
| 40 dict->SetInteger("buttonIcon.width", bitmap_sizes.button_icon_size.width()); | 41 dict->SetInteger("buttonIcon.width", bitmap_sizes.button_icon_size.width()); |
| 41 dict->SetInteger("buttonIcon.height", bitmap_sizes.button_icon_size.height()); | 42 dict->SetInteger("buttonIcon.height", bitmap_sizes.button_icon_size.height()); |
| 42 dict->SetInteger("appIconMask.width", | 43 dict->SetInteger("appIconMask.width", |
| 43 bitmap_sizes.app_icon_mask_size.width()); | 44 bitmap_sizes.app_icon_mask_size.width()); |
| 44 dict->SetInteger("appIconMask.height", | 45 dict->SetInteger("appIconMask.height", |
| 45 bitmap_sizes.app_icon_mask_size.height()); | 46 bitmap_sizes.app_icon_mask_size.height()); |
| 46 | 47 |
| 47 std::unique_ptr<content::V8ValueConverter> converter( | 48 args.GetReturnValue().Set(content::V8ValueConverter::Create()->ToV8Value( |
| 48 content::V8ValueConverter::create()); | 49 dict.get(), context()->v8_context())); |
| 49 args.GetReturnValue().Set( | |
| 50 converter->ToV8Value(dict.get(), context()->v8_context())); | |
| 51 } | 50 } |
| 52 | 51 |
| 53 } // namespace extensions | 52 } // namespace extensions |
| OLD | NEW |