| 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 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
| 12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "extensions/common/constants.h" | 55 #include "extensions/common/constants.h" |
| 55 #include "extensions/common/permissions/api_permission.h" | 56 #include "extensions/common/permissions/api_permission.h" |
| 56 #include "extensions/common/permissions/permissions_data.h" | 57 #include "extensions/common/permissions/permissions_data.h" |
| 57 #endif | 58 #endif |
| 58 | 59 |
| 59 using content::BrowserContext; | 60 using content::BrowserContext; |
| 60 using content::BrowserThread; | 61 using content::BrowserThread; |
| 61 using content::PlatformNotificationContext; | 62 using content::PlatformNotificationContext; |
| 62 using message_center::NotifierId; | 63 using message_center::NotifierId; |
| 63 | 64 |
| 65 class ProfileAttributesEntry; |
| 66 |
| 64 namespace { | 67 namespace { |
| 65 | 68 |
| 66 // Invalid id for a renderer process. Used in cases where we need to check for | 69 // Invalid id for a renderer process. Used in cases where we need to check for |
| 67 // permission without having an associated renderer process yet. | 70 // permission without having an associated renderer process yet. |
| 68 const int kInvalidRenderProcessId = -1; | 71 const int kInvalidRenderProcessId = -1; |
| 69 | 72 |
| 70 // Callback to provide when deleting the data associated with persistent Web | 73 // Callback to provide when deleting the data associated with persistent Web |
| 71 // Notifications from the notification database. | 74 // Notifications from the notification database. |
| 72 void OnPersistentNotificationDataDeleted(bool success) { | 75 void OnPersistentNotificationDataDeleted(bool success) { |
| 73 UMA_HISTOGRAM_BOOLEAN("Notifications.PersistentNotificationDataDeleted", | 76 UMA_HISTOGRAM_BOOLEAN("Notifications.PersistentNotificationDataDeleted", |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 int64_t persistent_notification_id, | 155 int64_t persistent_notification_id, |
| 153 int action_index) { | 156 int action_index) { |
| 154 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 157 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 155 DCHECK(profile_manager); | 158 DCHECK(profile_manager); |
| 156 | 159 |
| 157 // ProfileManager does not offer a good interface to load a profile or | 160 // ProfileManager does not offer a good interface to load a profile or |
| 158 // fail. Instead it offers a method to create the profile and simply load it | 161 // fail. Instead it offers a method to create the profile and simply load it |
| 159 // if it already exist. We therefore check first that the profile is there | 162 // if it already exist. We therefore check first that the profile is there |
| 160 // and fail early otherwise. | 163 // and fail early otherwise. |
| 161 const base::FilePath profile_path = | 164 const base::FilePath profile_path = |
| 162 profile_manager->GetProfileInfoCache().GetUserDataDir().AppendASCII( | 165 profile_manager->user_data_dir().AppendASCII(profile_id); |
| 163 profile_id); | |
| 164 | 166 |
| 165 if (profile_manager->GetProfileInfoCache().GetIndexOfProfileWithPath( | 167 ProfileAttributesEntry* entry = nullptr; |
| 166 profile_path) == std::string::npos) { | 168 if (!profile_manager->GetProfileAttributesStorage(). |
| 169 GetProfileAttributesWithPath(profile_path, &entry)) { |
| 167 LOG(ERROR) << "Loading a path that does not exist"; | 170 LOG(ERROR) << "Loading a path that does not exist"; |
| 168 return; | 171 return; |
| 169 } | 172 } |
| 170 | 173 |
| 171 profile_manager->CreateProfileAsync( | 174 profile_manager->CreateProfileAsync( |
| 172 profile_path, | 175 profile_path, |
| 173 base::Bind(&ProfileLoadedCallback, operation, origin, | 176 base::Bind(&ProfileLoadedCallback, operation, origin, |
| 174 persistent_notification_id, action_index, incognito), | 177 persistent_notification_id, action_index, incognito), |
| 175 base::string16(), std::string(), std::string()); | 178 base::string16(), std::string(), std::string()); |
| 176 } | 179 } |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 549 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
| 547 origin.host(), extensions::ExtensionRegistry::EVERYTHING); | 550 origin.host(), extensions::ExtensionRegistry::EVERYTHING); |
| 548 DCHECK(extension); | 551 DCHECK(extension); |
| 549 | 552 |
| 550 return base::UTF8ToUTF16(extension->name()); | 553 return base::UTF8ToUTF16(extension->name()); |
| 551 } | 554 } |
| 552 #endif | 555 #endif |
| 553 | 556 |
| 554 return base::string16(); | 557 return base::string16(); |
| 555 } | 558 } |
| OLD | NEW |