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

Side by Side Diff: trunk/src/chrome/renderer/extensions/notifications_native_handler.cc

Issue 296113009: Revert 272211 "Allow high-res bitmaps to be passed in from notif..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/extensions/notifications_native_handler.h"
6
7 #include <string>
8
9 #include "base/logging.h"
10 #include "base/values.h"
11 #include "chrome/common/extensions/api/notifications/notification_style.h"
12 #include "chrome/renderer/extensions/chrome_v8_context.h"
13 #include "content/public/renderer/v8_value_converter.h"
14 #include "ui/base/layout.h"
15
16 namespace extensions {
17
18 NotificationsNativeHandler::NotificationsNativeHandler(ScriptContext* context)
19 : ObjectBackedNativeHandler(context) {
20 RouteFunction(
21 "GetNotificationImageSizes",
22 base::Bind(&NotificationsNativeHandler::GetNotificationImageSizes,
23 base::Unretained(this)));
24 }
25
26 void NotificationsNativeHandler::GetNotificationImageSizes(
27 const v8::FunctionCallbackInfo<v8::Value>& args) {
28 NotificationBitmapSizes bitmap_sizes = NotificationBitmapSizes();
29
30 float scale_factor =
31 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactors().back());
32
33 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
34 dict->SetDouble("scaleFactor", scale_factor);
35 dict->SetInteger("icon.width", bitmap_sizes.icon_size.width());
36 dict->SetInteger("icon.height", bitmap_sizes.icon_size.height());
37 dict->SetInteger("image.width", bitmap_sizes.image_size.width());
38 dict->SetInteger("image.height", bitmap_sizes.image_size.height());
39 dict->SetInteger("buttonIcon.width", bitmap_sizes.button_icon_size.width());
40 dict->SetInteger("buttonIcon.height", bitmap_sizes.button_icon_size.height());
41
42 scoped_ptr<content::V8ValueConverter> converter(
43 content::V8ValueConverter::create());
44 args.GetReturnValue().Set(
45 converter->ToV8Value(dict.get(), context()->v8_context()));
46 }
47
48 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698