Change calls to GeolocationProvider::UserDidOptIntoLocationServices() to occur via Mojo.

https://chromium-review.googlesource.com/c/chromium/src/+/760239
This commit is contained in:
deepak1556 2018-04-12 15:23:49 +05:30 committed by Samuel Attard
parent a5bdb8103b
commit 383b21e20a
2 changed files with 24 additions and 2 deletions

View file

@ -20,7 +20,9 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "device/geolocation/geolocation_provider.h" #include "content/public/common/service_manager_connection.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/idle/idle.h" #include "ui/base/idle/idle.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
@ -229,7 +231,7 @@ void AtomBrowserMainParts::PostMainMessageLoopStart() {
#endif #endif
// TODO(deepak1556): Enable this optionally based on response // TODO(deepak1556): Enable this optionally based on response
// from AtomPermissionManager. // from AtomPermissionManager.
device::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices(); GetGeolocationControl()->UserDidOptIntoLocationServices();
} }
void AtomBrowserMainParts::PostMainMessageLoopRun() { void AtomBrowserMainParts::PostMainMessageLoopRun() {
@ -254,4 +256,19 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() {
} }
} }
device::mojom::GeolocationControl*
AtomBrowserMainParts::GetGeolocationControl() {
if (geolocation_control_)
return geolocation_control_.get();
auto request = mojo::MakeRequest(&geolocation_control_);
if (!content::ServiceManagerConnection::GetForProcess())
return geolocation_control_.get();
service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(device::mojom::kServiceName, std::move(request));
return geolocation_control_.get();
}
} // namespace atom } // namespace atom

View file

@ -12,6 +12,7 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "brightray/browser/browser_main_parts.h" #include "brightray/browser/browser_main_parts.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "services/device/public/mojom/geolocation_control.mojom.h"
class BrowserProcess; class BrowserProcess;
@ -86,6 +87,8 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
std::unique_ptr<brightray::ViewsDelegate> views_delegate_; std::unique_ptr<brightray::ViewsDelegate> views_delegate_;
#endif #endif
device::mojom::GeolocationControl* GetGeolocationControl();
// A fake BrowserProcess object that used to feed the source code from chrome. // A fake BrowserProcess object that used to feed the source code from chrome.
std::unique_ptr<BrowserProcess> fake_browser_process_; std::unique_ptr<BrowserProcess> fake_browser_process_;
@ -108,6 +111,8 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
// List of callbacks should be executed before destroying JS env. // List of callbacks should be executed before destroying JS env.
std::list<base::OnceClosure> destructors_; std::list<base::OnceClosure> destructors_;
device::mojom::GeolocationControlPtr geolocation_control_;
static AtomBrowserMainParts* self_; static AtomBrowserMainParts* self_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts); DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);