Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / content_settings / permission_bubble_request_impl.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
7
8 #include "base/callback.h"
9 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
10 #include "components/content_settings/core/common/content_settings_types.h"
11 #include "components/content_settings/core/common/permission_request_id.h"
12
13 class GURL;
14
15 class PermissionContextBase;
16
17 // Default implementation of PermissionBubbleRequest, it is assumed that the
18 // caller owns it and that it can be deleted once the |delete_callback|
19 // is executed.
20 class PermissionBubbleRequestImpl : public PermissionBubbleRequest {
21  public:
22
23   typedef base::Callback<void(bool persist_permission, bool grant_permission)>
24       PermissionDecidedCallback;
25
26   PermissionBubbleRequestImpl(
27       const GURL& request_origin,
28       bool user_gesture,
29       ContentSettingsType type,
30       const std::string& display_languages,
31       const PermissionDecidedCallback permission_decided_callback,
32       const base::Closure delete_callback);
33
34   virtual ~PermissionBubbleRequestImpl();
35
36   // PermissionBubbleRequest:
37   virtual int GetIconID() const OVERRIDE;
38   virtual base::string16 GetMessageText() const OVERRIDE;
39   virtual base::string16 GetMessageTextFragment() const OVERRIDE;
40   virtual bool HasUserGesture() const OVERRIDE;
41
42   // TODO(miguelg) Change this method to GetOrigin()
43   virtual GURL GetRequestingHostname() const OVERRIDE;
44
45   // Remember to call RegisterActionTaken for these methods if you are
46   // overriding them.
47   virtual void PermissionGranted() OVERRIDE;
48   virtual void PermissionDenied() OVERRIDE;
49   virtual void Cancelled() OVERRIDE;
50   virtual void RequestFinished() OVERRIDE;
51
52  protected:
53   void RegisterActionTaken() { action_taken_ = true; }
54
55  private:
56   GURL request_origin_;
57   bool user_gesture_;
58   ContentSettingsType type_;
59   std::string display_languages_;
60
61   // Called once a decision is made about the permission.
62   const PermissionDecidedCallback permission_decided_callback_;
63
64   // Called when the bubble is no longer in use so it can be deleted by
65   // the caller.
66   const base::Closure delete_callback_;
67   bool is_finished_;
68   bool action_taken_;
69
70   DISALLOW_COPY_AND_ASSIGN(PermissionBubbleRequestImpl);
71 };
72
73 #endif  // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_BUBBLE_REQUEST_IMPL_H_