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

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

Issue 291193009: Reland: Allow high-res bitmaps to be passed in from notifications API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test post-rebase. Created 6 years, 7 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..df02850fbcb2af802fad5b62c64afca7d5d648ed
--- /dev/null
+++ b/chrome/renderer/extensions/notifications_native_handler.cc
@@ -0,0 +1,48 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/notifications_native_handler.h"
+
+#include <string>
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/common/extensions/api/notifications/notification_style.h"
+#include "chrome/renderer/extensions/chrome_v8_context.h"
+#include "content/public/renderer/v8_value_converter.h"
+#include "ui/base/layout.h"
+
+namespace extensions {
+
+NotificationsNativeHandler::NotificationsNativeHandler(ScriptContext* context)
+ : ObjectBackedNativeHandler(context) {
+ RouteFunction(
+ "GetNotificationImageSizes",
+ base::Bind(&NotificationsNativeHandler::GetNotificationImageSizes,
+ base::Unretained(this)));
+}
+
+void NotificationsNativeHandler::GetNotificationImageSizes(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ NotificationBitmapSizes bitmap_sizes = NotificationBitmapSizes();
+
+ float scale_factor =
+ ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactors().back());
+
+ scoped_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());
+
+ scoped_ptr<content::V8ValueConverter> converter(
+ content::V8ValueConverter::create());
+ args.GetReturnValue().Set(
+ converter->ToV8Value(dict.get(), context()->v8_context()));
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/notifications_native_handler.h ('k') | chrome/renderer/resources/extensions/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698