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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 // static | 56 // static |
57 ScreenlockBridge* ScreenlockBridge::Get() { | 57 ScreenlockBridge* ScreenlockBridge::Get() { |
58 return g_screenlock_bridge_bridge_instance.Pointer(); | 58 return g_screenlock_bridge_bridge_instance.Pointer(); |
59 } | 59 } |
60 | 60 |
61 ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() | 61 ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() |
62 : autoshow_tooltip_(false), | 62 : autoshow_tooltip_(false), |
63 hardlock_on_click_(false) { | 63 hardlock_on_click_(false), |
| 64 is_trial_run_(false) { |
64 } | 65 } |
65 | 66 |
66 ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {} | 67 ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {} |
67 | 68 |
68 scoped_ptr<base::DictionaryValue> | 69 scoped_ptr<base::DictionaryValue> |
69 ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const { | 70 ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const { |
70 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 71 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
71 std::string icon_id = GetIdForIcon(icon_); | 72 std::string icon_id = GetIdForIcon(icon_); |
72 result->SetString("id", icon_id); | 73 result->SetString("id", icon_id); |
73 | 74 |
74 if (!tooltip_.empty()) { | 75 if (!tooltip_.empty()) { |
75 base::DictionaryValue* tooltip_options = new base::DictionaryValue(); | 76 base::DictionaryValue* tooltip_options = new base::DictionaryValue(); |
76 tooltip_options->SetString("text", tooltip_); | 77 tooltip_options->SetString("text", tooltip_); |
77 tooltip_options->SetBoolean("autoshow", autoshow_tooltip_); | 78 tooltip_options->SetBoolean("autoshow", autoshow_tooltip_); |
78 result->Set("tooltip", tooltip_options); | 79 result->Set("tooltip", tooltip_options); |
79 } | 80 } |
80 | 81 |
81 if (!aria_label_.empty()) | 82 if (!aria_label_.empty()) |
82 result->SetString("ariaLabel", aria_label_); | 83 result->SetString("ariaLabel", aria_label_); |
83 | 84 |
84 if (hardlock_on_click_) | 85 if (hardlock_on_click_) |
85 result->SetBoolean("hardlockOnClick", true); | 86 result->SetBoolean("hardlockOnClick", true); |
86 | 87 |
| 88 if (is_trial_run_) |
| 89 result->SetBoolean("isTrialRun", true); |
| 90 |
87 return result.Pass(); | 91 return result.Pass(); |
88 } | 92 } |
89 | 93 |
90 void ScreenlockBridge::UserPodCustomIconOptions::SetIcon( | 94 void ScreenlockBridge::UserPodCustomIconOptions::SetIcon( |
91 ScreenlockBridge::UserPodCustomIcon icon) { | 95 ScreenlockBridge::UserPodCustomIcon icon) { |
92 icon_ = icon; | 96 icon_ = icon; |
93 } | 97 } |
94 | 98 |
95 void ScreenlockBridge::UserPodCustomIconOptions::SetTooltip( | 99 void ScreenlockBridge::UserPodCustomIconOptions::SetTooltip( |
96 const base::string16& tooltip, | 100 const base::string16& tooltip, |
97 bool autoshow) { | 101 bool autoshow) { |
98 tooltip_ = tooltip; | 102 tooltip_ = tooltip; |
99 autoshow_tooltip_ = autoshow; | 103 autoshow_tooltip_ = autoshow; |
100 } | 104 } |
101 | 105 |
102 void ScreenlockBridge::UserPodCustomIconOptions::SetAriaLabel( | 106 void ScreenlockBridge::UserPodCustomIconOptions::SetAriaLabel( |
103 const base::string16& aria_label) { | 107 const base::string16& aria_label) { |
104 aria_label_ = aria_label; | 108 aria_label_ = aria_label; |
105 } | 109 } |
106 | 110 |
107 void ScreenlockBridge::UserPodCustomIconOptions::SetHardlockOnClick() { | 111 void ScreenlockBridge::UserPodCustomIconOptions::SetHardlockOnClick() { |
108 hardlock_on_click_ = true; | 112 hardlock_on_click_ = true; |
109 } | 113 } |
110 | 114 |
| 115 void ScreenlockBridge::UserPodCustomIconOptions::SetTrialRun() { |
| 116 is_trial_run_ = true; |
| 117 } |
| 118 |
111 // static | 119 // static |
112 std::string ScreenlockBridge::GetAuthenticatedUserEmail(Profile* profile) { | 120 std::string ScreenlockBridge::GetAuthenticatedUserEmail(Profile* profile) { |
113 // |profile| has to be a signed-in profile with SigninManager already | 121 // |profile| has to be a signed-in profile with SigninManager already |
114 // created. Otherwise, just crash to collect stack. | 122 // created. Otherwise, just crash to collect stack. |
115 SigninManagerBase* signin_manager = | 123 SigninManagerBase* signin_manager = |
116 SigninManagerFactory::GetForProfileIfExists(profile); | 124 SigninManagerFactory::GetForProfileIfExists(profile); |
117 return signin_manager->GetAuthenticatedUsername(); | 125 return signin_manager->GetAuthenticatedUsername(); |
118 } | 126 } |
119 | 127 |
120 ScreenlockBridge::ScreenlockBridge() : lock_handler_(NULL) { | 128 ScreenlockBridge::ScreenlockBridge() : lock_handler_(NULL) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); | 180 lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); |
173 } | 181 } |
174 | 182 |
175 void ScreenlockBridge::AddObserver(Observer* observer) { | 183 void ScreenlockBridge::AddObserver(Observer* observer) { |
176 observers_.AddObserver(observer); | 184 observers_.AddObserver(observer); |
177 } | 185 } |
178 | 186 |
179 void ScreenlockBridge::RemoveObserver(Observer* observer) { | 187 void ScreenlockBridge::RemoveObserver(Observer* observer) { |
180 observers_.RemoveObserver(observer); | 188 observers_.RemoveObserver(observer); |
181 } | 189 } |
OLD | NEW |