OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/note_taking_helper.h" | 5 #include "chrome/browser/chromeos/note_taking_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "apps/launcher.h" | 10 #include "apps/launcher.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 prefs::kNoteTakingAppEnabledOnLockScreen)) { | 146 prefs::kNoteTakingAppEnabledOnLockScreen)) { |
147 info.lock_screen_support = NoteTakingLockScreenSupport::kSelected; | 147 info.lock_screen_support = NoteTakingLockScreenSupport::kSelected; |
148 } | 148 } |
149 break; | 149 break; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 return infos; | 153 return infos; |
154 } | 154 } |
155 | 155 |
156 std::unique_ptr<NoteTakingAppInfo> NoteTakingHelper::GetPreferredChromeAppInfo( | |
157 Profile* profile) { | |
158 if (!ash::palette_utils::HasStylusInput()) | |
jdufault
2017/05/26 19:15:53
Why do we disable preferred app if there is no sty
tbarzic
2017/05/26 19:34:14
Yeah, I guess we don;t have to.
| |
159 return nullptr; | |
160 std::string preferred_app_id = | |
161 profile->GetPrefs()->GetString(prefs::kNoteTakingAppId); | |
162 if (LooksLikeAndroidPackageName(preferred_app_id)) | |
jdufault
2017/05/26 19:15:53
Add a comment,
// Lock screen does not currently
tbarzic
2017/05/26 19:34:14
Added a comment, but at the place where this metho
| |
163 return nullptr; | |
164 const extensions::Extension* preferred_app = | |
165 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | |
166 preferred_app_id, extensions::ExtensionRegistry::ENABLED); | |
167 if (!preferred_app) | |
168 return nullptr; | |
169 if (!IsWhitelistedChromeApp(preferred_app) && | |
170 !extensions::ActionHandlersInfo::HasActionHandler( | |
171 preferred_app, app_runtime::ACTION_TYPE_NEW_NOTE)) { | |
172 return nullptr; | |
173 } | |
174 NoteTakingLockScreenSupport lock_screen_support = | |
175 NoteTakingLockScreenSupport::kNotSupported; | |
176 if (IsLockScreenEnabled(preferred_app)) { | |
177 if (profile->GetPrefs()->GetBoolean( | |
178 prefs::kNoteTakingAppEnabledOnLockScreen)) { | |
179 lock_screen_support = NoteTakingLockScreenSupport::kSelected; | |
180 } else { | |
181 lock_screen_support = NoteTakingLockScreenSupport::kSupported; | |
182 } | |
183 } | |
184 std::unique_ptr<NoteTakingAppInfo> info = | |
185 base::MakeUnique<NoteTakingAppInfo>(); | |
186 info->name = preferred_app->name(); | |
187 info->app_id = preferred_app->id(); | |
188 info->preferred = true; | |
189 info->lock_screen_support = lock_screen_support; | |
190 return info; | |
191 } | |
192 | |
156 void NoteTakingHelper::SetPreferredApp(Profile* profile, | 193 void NoteTakingHelper::SetPreferredApp(Profile* profile, |
157 const std::string& app_id) { | 194 const std::string& app_id) { |
158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 195 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
159 DCHECK(profile); | 196 DCHECK(profile); |
160 | 197 |
161 const extensions::Extension* app = | 198 const extensions::Extension* app = |
162 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 199 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
163 app_id, extensions::ExtensionRegistry::ENABLED); | 200 app_id, extensions::ExtensionRegistry::ENABLED); |
164 | 201 |
165 if (!app || !IsLockScreenEnabled(app)) { | 202 if (!app || !IsLockScreenEnabled(app)) { |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 for (auto& observer : observers_) | 499 for (auto& observer : observers_) |
463 observer.OnAvailableNoteTakingAppsUpdated(); | 500 observer.OnAvailableNoteTakingAppsUpdated(); |
464 } | 501 } |
465 } | 502 } |
466 | 503 |
467 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { | 504 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { |
468 extension_registry_observer_.Remove(registry); | 505 extension_registry_observer_.Remove(registry); |
469 } | 506 } |
470 | 507 |
471 } // namespace chromeos | 508 } // namespace chromeos |
OLD | NEW |