1 // Copyright 2013 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.
5 #include "base/prefs/pref_service.h"
6 #include "chrome/browser/android/prerender_condition_platform.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/common/pref_names.h"
15 const char kAllowPrerender
[] = "allow-prerender";
17 class BooleanWrapper
: public base::SupportsUserData::Data
{
19 explicit BooleanWrapper(bool b
) : m_b(b
) { }
20 virtual ~BooleanWrapper() { }
22 operator bool() const { return m_b
; }
25 DISALLOW_COPY_AND_ASSIGN(BooleanWrapper
);
30 PrerenderConditionPlatform::PrerenderConditionPlatform(
31 content::BrowserContext
* context
)
32 : context_(context
) {}
34 PrerenderConditionPlatform::~PrerenderConditionPlatform() {}
36 bool PrerenderConditionPlatform::CanPrerender() const {
37 base::SupportsUserData::Data
* data
= context_
->GetUserData(kAllowPrerender
);
40 BooleanWrapper
* b
= static_cast<BooleanWrapper
*>(data
);
44 void PrerenderConditionPlatform::SetEnabled(content::BrowserContext
* context
,
46 BooleanWrapper
* wrapper
= new BooleanWrapper(enabled
);
47 context
->SetUserData(kAllowPrerender
, wrapper
);
50 } // namespace android