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/notifications/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "extensions/common/constants.h" | 56 #include "extensions/common/constants.h" |
57 #include "extensions/common/permissions/api_permission.h" | 57 #include "extensions/common/permissions/api_permission.h" |
58 #include "extensions/common/permissions/permissions_data.h" | 58 #include "extensions/common/permissions/permissions_data.h" |
59 #endif | 59 #endif |
60 | 60 |
61 using content::BrowserContext; | 61 using content::BrowserContext; |
62 using content::BrowserThread; | 62 using content::BrowserThread; |
63 using content::PlatformNotificationContext; | 63 using content::PlatformNotificationContext; |
64 using message_center::NotifierId; | 64 using message_center::NotifierId; |
65 | 65 |
| 66 class ProfileAttributesEntry; |
| 67 |
66 namespace { | 68 namespace { |
67 | 69 |
68 // Invalid id for a renderer process. Used in cases where we need to check for | 70 // Invalid id for a renderer process. Used in cases where we need to check for |
69 // permission without having an associated renderer process yet. | 71 // permission without having an associated renderer process yet. |
70 const int kInvalidRenderProcessId = -1; | 72 const int kInvalidRenderProcessId = -1; |
71 | 73 |
72 // Persistent notifications fired through the delegate do not care about the | 74 // Persistent notifications fired through the delegate do not care about the |
73 // lifetime of the Service Worker responsible for executing the event. | 75 // lifetime of the Service Worker responsible for executing the event. |
74 void OnClickEventDispatchComplete( | 76 void OnClickEventDispatchComplete( |
75 content::PersistentNotificationStatus status) { | 77 content::PersistentNotificationStatus status) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 int64_t persistent_notification_id, | 158 int64_t persistent_notification_id, |
157 int action_index) { | 159 int action_index) { |
158 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 160 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
159 DCHECK(profile_manager); | 161 DCHECK(profile_manager); |
160 | 162 |
161 // ProfileManager does not offer a good interface to load a profile or | 163 // ProfileManager does not offer a good interface to load a profile or |
162 // fail. Instead it offers a method to create the profile and simply load it | 164 // fail. Instead it offers a method to create the profile and simply load it |
163 // if it already exist. We therefore check first that the profile is there | 165 // if it already exist. We therefore check first that the profile is there |
164 // and fail early otherwise. | 166 // and fail early otherwise. |
165 const base::FilePath profile_path = | 167 const base::FilePath profile_path = |
166 profile_manager->GetProfileInfoCache().GetUserDataDir().AppendASCII( | 168 profile_manager->user_data_dir().AppendASCII(profile_id); |
167 profile_id); | |
168 | 169 |
169 if (profile_manager->GetProfileInfoCache().GetIndexOfProfileWithPath( | 170 ProfileAttributesEntry* entry = nullptr; |
170 profile_path) == std::string::npos) { | 171 if (!profile_manager->GetProfileAttributesStorage(). |
| 172 GetProfileAttributesWithPath(profile_path, &entry)) { |
171 LOG(ERROR) << "Loading a path that does not exist"; | 173 LOG(ERROR) << "Loading a path that does not exist"; |
172 return; | 174 return; |
173 } | 175 } |
174 | 176 |
175 profile_manager->CreateProfileAsync( | 177 profile_manager->CreateProfileAsync( |
176 profile_path, | 178 profile_path, |
177 base::Bind(&ProfileLoadedCallback, operation, origin, | 179 base::Bind(&ProfileLoadedCallback, operation, origin, |
178 persistent_notification_id, action_index, incognito), | 180 persistent_notification_id, action_index, incognito), |
179 base::string16(), std::string(), std::string()); | 181 base::string16(), std::string(), std::string()); |
180 } | 182 } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 542 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
541 origin.host(), extensions::ExtensionRegistry::EVERYTHING); | 543 origin.host(), extensions::ExtensionRegistry::EVERYTHING); |
542 DCHECK(extension); | 544 DCHECK(extension); |
543 | 545 |
544 return base::UTF8ToUTF16(extension->name()); | 546 return base::UTF8ToUTF16(extension->name()); |
545 } | 547 } |
546 #endif | 548 #endif |
547 | 549 |
548 return base::string16(); | 550 return base::string16(); |
549 } | 551 } |
OLD | NEW |