15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_DELEGATE_H_
6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_DELEGATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include <string>
9eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/content_settings/core/common/permission_request_id.h"
11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/infobars/core/confirm_infobar_delegate.h"
12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14a3f7b4e666c476898878fa745f637129375cd889Ben Murdochclass PermissionQueueController;
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class InfoBarService;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// GeolocationInfoBarDelegates are created by the
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// GeolocationInfoBarQueueController to control the display
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and handling of geolocation permission infobars to the user.
20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class GeolocationInfoBarDelegate : public ConfirmInfoBarDelegate {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Creates a geolocation infobar and delegate and adds the infobar to
23a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // |infobar_service|.  Returns the infobar if it was successfully added.
240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  static infobars::InfoBar* Create(InfoBarService* infobar_service,
250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                   PermissionQueueController* controller,
260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                   const PermissionRequestID& id,
270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                   const GURL& requesting_frame,
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                                   const std::string& display_languages);
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) private:
31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  GeolocationInfoBarDelegate(PermissionQueueController* controller,
32a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch                             const PermissionRequestID& id,
33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                             const GURL& requesting_frame,
34ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch                             int contents_unique_id,
355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             const std::string& display_languages);
367dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  virtual ~GeolocationInfoBarDelegate();
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
38c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // ConfirmInfoBarDelegate:
39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual bool Accept() OVERRIDE;
405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual void InfoBarDismissed() OVERRIDE;
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual int GetIconID() const OVERRIDE;
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Type GetInfoBarType() const OVERRIDE;
435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual bool ShouldExpireInternal(
445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      const NavigationDetails& details) const OVERRIDE;
455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual base::string16 GetMessageText() const OVERRIDE;
465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual bool Cancel() OVERRIDE;
485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Call back to the controller, to inform of the user's decision.
51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetPermission(bool update_content_setting, bool allowed);
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Marks a flag internally to indicate that the user has interacted with the
548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // bar. This makes it possible to log from the destructor when the bar has not
558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // been used, i.e. it has been ignored by the user.
568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void set_user_has_interacted() {
578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    user_has_interacted_ = true;
588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
60a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  PermissionQueueController* controller_;
61a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  const PermissionRequestID id_;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL requesting_frame_;
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int contents_unique_id_;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string display_languages_;
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Whether the user has interacted with the geolocation infobar.
678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool user_has_interacted_;
688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
69c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(GeolocationInfoBarDelegate);
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif  // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_DELEGATE_H_
73