blob: fab60b9d8655be2a805aee8faed7edae41296c02 (
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
47
48
49
50
|
// Copyright 2013 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.
#include "base/prefs/pref_service.h"
#include "chrome/browser/android/prerender_condition_platform.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
namespace android {
namespace {
const char kAllowPrerender[] = "allow-prerender";
class BooleanWrapper : public base::SupportsUserData::Data {
public:
explicit BooleanWrapper(bool b) : m_b(b) { }
virtual ~BooleanWrapper() { }
operator bool() const { return m_b; }
private:
bool m_b;
DISALLOW_COPY_AND_ASSIGN(BooleanWrapper);
};
} // namespace
PrerenderConditionPlatform::PrerenderConditionPlatform(
content::BrowserContext* context)
: context_(context) {}
PrerenderConditionPlatform::~PrerenderConditionPlatform() {}
bool PrerenderConditionPlatform::CanPrerender() const {
base::SupportsUserData::Data* data = context_->GetUserData(kAllowPrerender);
if (!data)
return true;
BooleanWrapper* b = static_cast<BooleanWrapper*>(data);
return *b;
}
void PrerenderConditionPlatform::SetEnabled(content::BrowserContext* context,
bool enabled) {
BooleanWrapper* wrapper = new BooleanWrapper(enabled);
context->SetUserData(kAllowPrerender, wrapper);
}
} // namespace android
|