Chromium Code Reviews| 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 std::string preferred_app_id = | |
|
xiyuan
2017/05/26 22:44:52
nit: const std::string
tbarzic
2017/05/27 00:48:35
Done.
| |
| 159 profile->GetPrefs()->GetString(prefs::kNoteTakingAppId); | |
| 160 if (LooksLikeAndroidPackageName(preferred_app_id)) | |
| 161 return nullptr; | |
| 162 const extensions::Extension* preferred_app = | |
|
xiyuan
2017/05/26 22:44:52
nit: insert an empty line before
tbarzic
2017/05/27 00:48:36
Done.
| |
| 163 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | |
| 164 preferred_app_id, extensions::ExtensionRegistry::ENABLED); | |
| 165 if (!preferred_app) | |
| 166 return nullptr; | |
| 167 if (!IsWhitelistedChromeApp(preferred_app) && | |
|
xiyuan
2017/05/26 22:44:52
nit: insert an empty line before
tbarzic
2017/05/27 00:48:35
Done.
| |
| 168 !extensions::ActionHandlersInfo::HasActionHandler( | |
| 169 preferred_app, app_runtime::ACTION_TYPE_NEW_NOTE)) { | |
| 170 return nullptr; | |
| 171 } | |
| 172 NoteTakingLockScreenSupport lock_screen_support = | |
|
xiyuan
2017/05/26 22:44:52
nit: insert an empty line before
tbarzic
2017/05/27 00:48:35
Done.
| |
| 173 NoteTakingLockScreenSupport::kNotSupported; | |
| 174 if (IsLockScreenEnabled(preferred_app)) { | |
| 175 if (profile->GetPrefs()->GetBoolean( | |
| 176 prefs::kNoteTakingAppEnabledOnLockScreen)) { | |
| 177 lock_screen_support = NoteTakingLockScreenSupport::kSelected; | |
| 178 } else { | |
| 179 lock_screen_support = NoteTakingLockScreenSupport::kSupported; | |
| 180 } | |
| 181 } | |
| 182 std::unique_ptr<NoteTakingAppInfo> info = | |
|
xiyuan
2017/05/26 22:44:53
nit: insert an empty line before
tbarzic
2017/05/27 00:48:36
Done.
| |
| 183 base::MakeUnique<NoteTakingAppInfo>(); | |
| 184 info->name = preferred_app->name(); | |
| 185 info->app_id = preferred_app->id(); | |
| 186 info->preferred = true; | |
| 187 info->lock_screen_support = lock_screen_support; | |
| 188 return info; | |
| 189 } | |
| 190 | |
| 156 void NoteTakingHelper::SetPreferredApp(Profile* profile, | 191 void NoteTakingHelper::SetPreferredApp(Profile* profile, |
| 157 const std::string& app_id) { | 192 const std::string& app_id) { |
| 158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 193 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 159 DCHECK(profile); | 194 DCHECK(profile); |
| 160 | 195 |
| 161 const extensions::Extension* app = | 196 const extensions::Extension* app = |
| 162 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 197 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
| 163 app_id, extensions::ExtensionRegistry::ENABLED); | 198 app_id, extensions::ExtensionRegistry::ENABLED); |
| 164 | 199 |
| 165 if (!app || !IsLockScreenEnabled(app)) { | 200 if (!app || !IsLockScreenEnabled(app)) { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 for (auto& observer : observers_) | 497 for (auto& observer : observers_) |
| 463 observer.OnAvailableNoteTakingAppsUpdated(); | 498 observer.OnAvailableNoteTakingAppsUpdated(); |
| 464 } | 499 } |
| 465 } | 500 } |
| 466 | 501 |
| 467 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { | 502 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { |
| 468 extension_registry_observer_.Remove(registry); | 503 extension_registry_observer_.Remove(registry); |
| 469 } | 504 } |
| 470 | 505 |
| 471 } // namespace chromeos | 506 } // namespace chromeos |
| OLD | NEW |