| 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/browser/signin/screenlock_bridge.h" | 5 #include "chrome/browser/signin/screenlock_bridge.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "chrome/browser/profiles/profile_window.h" | 9 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| 11 #include "components/signin/core/browser/signin_manager.h" | 11 #include "components/signin/core/browser/signin_manager.h" |
| 12 #include "ui/base/webui/web_ui_util.h" | |
| 13 #include "ui/gfx/image/image.h" | |
| 14 #include "ui/gfx/image/image_skia.h" | |
| 15 | 12 |
| 16 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
| 17 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
| 18 #include "chromeos/dbus/session_manager_client.h" | 15 #include "chromeos/dbus/session_manager_client.h" |
| 19 #endif | 16 #endif |
| 20 | 17 |
| 21 namespace { | 18 namespace { |
| 22 | 19 |
| 23 base::LazyInstance<ScreenlockBridge> g_screenlock_bridge_bridge_instance = | 20 base::LazyInstance<ScreenlockBridge> g_screenlock_bridge_bridge_instance = |
| 24 LAZY_INSTANCE_INITIALIZER; | 21 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 opacity_(100u), | 36 opacity_(100u), |
| 40 autoshow_tooltip_(false), | 37 autoshow_tooltip_(false), |
| 41 hardlock_on_click_(false) { | 38 hardlock_on_click_(false) { |
| 42 } | 39 } |
| 43 | 40 |
| 44 ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {} | 41 ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {} |
| 45 | 42 |
| 46 scoped_ptr<base::DictionaryValue> | 43 scoped_ptr<base::DictionaryValue> |
| 47 ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const { | 44 ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const { |
| 48 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 45 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 49 if (!icon_image_ && icon_resource_url_.empty()) | 46 if (icon_resource_url_.empty()) |
| 50 return result.Pass(); | 47 return result.Pass(); |
| 51 | 48 |
| 52 if (icon_image_) { | 49 result->SetString("resourceUrl", icon_resource_url_); |
| 53 gfx::ImageSkia icon_skia = icon_image_->AsImageSkia(); | |
| 54 base::DictionaryValue* icon_representations = new base::DictionaryValue(); | |
| 55 icon_representations->SetString( | |
| 56 "scale1x", | |
| 57 webui::GetBitmapDataUrl( | |
| 58 icon_skia.GetRepresentation(1.0f).sk_bitmap())); | |
| 59 icon_representations->SetString( | |
| 60 "scale2x", | |
| 61 webui::GetBitmapDataUrl( | |
| 62 icon_skia.GetRepresentation(2.0f).sk_bitmap())); | |
| 63 result->Set("data", icon_representations); | |
| 64 } else { | |
| 65 result->SetString("resourceUrl", icon_resource_url_); | |
| 66 } | |
| 67 | 50 |
| 68 if (!tooltip_.empty()) { | 51 if (!tooltip_.empty()) { |
| 69 base::DictionaryValue* tooltip_options = new base::DictionaryValue(); | 52 base::DictionaryValue* tooltip_options = new base::DictionaryValue(); |
| 70 tooltip_options->SetString("text", tooltip_); | 53 tooltip_options->SetString("text", tooltip_); |
| 71 tooltip_options->SetBoolean("autoshow", autoshow_tooltip_); | 54 tooltip_options->SetBoolean("autoshow", autoshow_tooltip_); |
| 72 result->Set("tooltip", tooltip_options); | 55 result->Set("tooltip", tooltip_options); |
| 73 } | 56 } |
| 74 | 57 |
| 75 base::DictionaryValue* size = new base::DictionaryValue(); | 58 base::DictionaryValue* size = new base::DictionaryValue(); |
| 76 size->SetInteger("height", height_); | 59 size->SetInteger("height", height_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 89 } | 72 } |
| 90 | 73 |
| 91 if (hardlock_on_click_) | 74 if (hardlock_on_click_) |
| 92 result->SetBoolean("hardlockOnClick", true); | 75 result->SetBoolean("hardlockOnClick", true); |
| 93 | 76 |
| 94 return result.Pass(); | 77 return result.Pass(); |
| 95 } | 78 } |
| 96 | 79 |
| 97 void ScreenlockBridge::UserPodCustomIconOptions::SetIconAsResourceURL( | 80 void ScreenlockBridge::UserPodCustomIconOptions::SetIconAsResourceURL( |
| 98 const std::string& url) { | 81 const std::string& url) { |
| 99 DCHECK(!icon_image_); | |
| 100 | |
| 101 icon_resource_url_ = url; | 82 icon_resource_url_ = url; |
| 102 } | 83 } |
| 103 | 84 |
| 104 void ScreenlockBridge::UserPodCustomIconOptions::SetIconAsImage( | |
| 105 const gfx::Image& image) { | |
| 106 DCHECK(icon_resource_url_.empty()); | |
| 107 | |
| 108 icon_image_.reset(new gfx::Image(image)); | |
| 109 SetSize(image.Width(), image.Height()); | |
| 110 } | |
| 111 | 85 |
| 112 void ScreenlockBridge::UserPodCustomIconOptions::SetSize(size_t icon_width, | 86 void ScreenlockBridge::UserPodCustomIconOptions::SetSize(size_t icon_width, |
| 113 size_t icon_height) { | 87 size_t icon_height) { |
| 114 width_ = icon_width; | 88 width_ = icon_width; |
| 115 height_ = icon_height; | 89 height_ = icon_height; |
| 116 } | 90 } |
| 117 | 91 |
| 118 void ScreenlockBridge::UserPodCustomIconOptions::SetAnimation( | 92 void ScreenlockBridge::UserPodCustomIconOptions::SetAnimation( |
| 119 size_t resource_width, | 93 size_t resource_width, |
| 120 size_t frame_length_ms) { | 94 size_t frame_length_ms) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); | 156 lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); |
| 183 } | 157 } |
| 184 | 158 |
| 185 void ScreenlockBridge::AddObserver(Observer* observer) { | 159 void ScreenlockBridge::AddObserver(Observer* observer) { |
| 186 observers_.AddObserver(observer); | 160 observers_.AddObserver(observer); |
| 187 } | 161 } |
| 188 | 162 |
| 189 void ScreenlockBridge::RemoveObserver(Observer* observer) { | 163 void ScreenlockBridge::RemoveObserver(Observer* observer) { |
| 190 observers_.RemoveObserver(observer); | 164 observers_.RemoveObserver(observer); |
| 191 } | 165 } |
| OLD | NEW |