summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/database_permission_request.h
blob: 7760dcd4ab4e9fc586b7bfb08a3d8821b14e6cd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_RENDERER_HOST_DATABASE_PERMISSION_REQUEST_H_
#define CHROME_BROWSER_RENDERER_HOST_DATABASE_PERMISSION_REQUEST_H_

#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"

class Task;

// This class is fully threadsafe.
class DatabasePermissionRequest
    : public base::RefCountedThreadSafe<DatabasePermissionRequest> {
 public:
  DatabasePermissionRequest(const string16& origin,
                            const string16& database_name,
                            Task* on_allow,
                            Task* on_block);
  ~DatabasePermissionRequest();

  const string16& origin() const { return origin_; }
  const string16& database_name() const { return database_name_; }

  // Start the permission request process.
  void RequestPermission();

 private:
  // Called on the UI thread to pop up UI to request permission to open the
  // database.
  void RequestPermissionUI();

  // Info to provide the user while asking for permission.
  const string16 origin_;
  const string16 database_name_;

  // Set on IO, possibly release()ed on UI, destroyed on IO or UI.
  scoped_ptr<Task> on_allow_;
  scoped_ptr<Task> on_block_;

  DISALLOW_IMPLICIT_CONSTRUCTORS(DatabasePermissionRequest);
};

#endif  // CHROME_BROWSER_RENDERER_HOST_DATABASE_PERMISSION_REQUEST_H_