1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be
3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file.
4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/callback.h"
9116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/ui/website_settings/permission_bubble_request.h"
105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "components/content_settings/core/common/content_settings_types.h"
111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/content_settings/core/common/permission_request_id.h"
12116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass GURL;
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
15116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PermissionContextBase;
16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
17116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Default implementation of PermissionBubbleRequest, it is assumed that the
18116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// caller owns it and that it can be deleted once the |delete_callback|
19116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// is executed.
20116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PermissionBubbleRequestImpl : public PermissionBubbleRequest {
21116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public:
22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
23116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  typedef base::Callback<void(bool persist_permission, bool grant_permission)>
24116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      PermissionDecidedCallback;
25116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
26116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  PermissionBubbleRequestImpl(
27116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      const GURL& request_origin,
28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      bool user_gesture,
29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      ContentSettingsType type,
30116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      const std::string& display_languages,
31116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      const PermissionDecidedCallback permission_decided_callback,
32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      const base::Closure delete_callback);
33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
34116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual ~PermissionBubbleRequestImpl();
35116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // PermissionBubbleRequest:
37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual int GetIconID() const OVERRIDE;
38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual base::string16 GetMessageText() const OVERRIDE;
39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual base::string16 GetMessageTextFragment() const OVERRIDE;
40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual bool HasUserGesture() const OVERRIDE;
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // TODO(miguelg) Change this method to GetOrigin()
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual GURL GetRequestingHostname() const OVERRIDE;
44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Remember to call RegisterActionTaken for these methods if you are
46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // overriding them.
47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void PermissionGranted() OVERRIDE;
48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void PermissionDenied() OVERRIDE;
49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void Cancelled() OVERRIDE;
50116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void RequestFinished() OVERRIDE;
51116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
52116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch protected:
53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void RegisterActionTaken() { action_taken_ = true; }
54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch private:
56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  GURL request_origin_;
57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool user_gesture_;
58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  ContentSettingsType type_;
59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  std::string display_languages_;
60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Called once a decision is made about the permission.
62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  const PermissionDecidedCallback permission_decided_callback_;
63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Called when the bubble is no longer in use so it can be deleted by
65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // the caller.
66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  const base::Closure delete_callback_;
67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool is_finished_;
68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool action_taken_;
69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  DISALLOW_COPY_AND_ASSIGN(PermissionBubbleRequestImpl);
71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch};
72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
73116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif  // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
74