| Index: chrome/browser/budget_service/budget_service_impl.cc
|
| diff --git a/chrome/browser/budget_service/budget_service_impl.cc b/chrome/browser/budget_service/budget_service_impl.cc
|
| index 5bbb9b42ea5e048be45223927a32f6f4ff7e053d..2db176cbc6e2f8da9ce771f30edb04aea2f6b104 100644
|
| --- a/chrome/browser/budget_service/budget_service_impl.cc
|
| +++ b/chrome/browser/budget_service/budget_service_impl.cc
|
| @@ -7,7 +7,10 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "chrome/browser/budget_service/budget_manager.h"
|
| #include "chrome/browser/budget_service/budget_manager_factory.h"
|
| +#include "chrome/browser/permissions/permission_manager.h"
|
| +#include "chrome/browser/permissions/permission_manager_factory.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "content/public/browser/permission_type.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "mojo/public/cpp/bindings/strong_binding.h"
|
|
|
| @@ -50,9 +53,33 @@ void BudgetServiceImpl::GetBudget(const url::Origin& origin,
|
| content::RenderProcessHost::FromID(render_process_id_);
|
| DCHECK(host);
|
|
|
| + Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
|
| +
|
| + PermissionManager* permission_manager =
|
| + PermissionManagerFactory::GetForProfile(profile);
|
| + DCHECK(permission_manager);
|
| +
|
| + // By request of the Privacy Team, we only communicate the budget buckets with
|
| + // the developer when the notification permission has been granted. This is
|
| + // something the impact of which has to be reconsidered when the feature is
|
| + // ready to ship for real. See https://crbug.com/710809 for context.
|
| + if (permission_manager->GetPermissionStatus(
|
| + content::PermissionType::NOTIFICATIONS, origin.GetURL(), GURL()) !=
|
| + blink::mojom::PermissionStatus::GRANTED) {
|
| + blink::mojom::BudgetStatePtr empty_state(blink::mojom::BudgetState::New());
|
| + empty_state->budget_at = 0;
|
| + empty_state->time = base::Time::Now().ToDoubleT();
|
| +
|
| + std::vector<blink::mojom::BudgetStatePtr> predictions;
|
| + predictions.push_back(std::move(empty_state));
|
| +
|
| + callback.Run(blink::mojom::BudgetServiceErrorType::NONE,
|
| + std::move(predictions));
|
| + return;
|
| + }
|
| +
|
| // Query the BudgetManager for the budget.
|
| - content::BrowserContext* context = host->GetBrowserContext();
|
| - BudgetManagerFactory::GetForProfile(context)->GetBudget(origin, callback);
|
| + BudgetManagerFactory::GetForProfile(profile)->GetBudget(origin, callback);
|
| }
|
|
|
| void BudgetServiceImpl::Reserve(const url::Origin& origin,
|
|
|