Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / android / prerender_condition_platform.cc
blobfab60b9d8655be2a805aee8faed7edae41296c02
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"
11 namespace android {
13 namespace {
15 const char kAllowPrerender[] = "allow-prerender";
17 class BooleanWrapper : public base::SupportsUserData::Data {
18 public:
19 explicit BooleanWrapper(bool b) : m_b(b) { }
20 virtual ~BooleanWrapper() { }
22 operator bool() const { return m_b; }
23 private:
24 bool m_b;
25 DISALLOW_COPY_AND_ASSIGN(BooleanWrapper);
28 } // namespace
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);
38 if (!data)
39 return true;
40 BooleanWrapper* b = static_cast<BooleanWrapper*>(data);
41 return *b;
44 void PrerenderConditionPlatform::SetEnabled(content::BrowserContext* context,
45 bool enabled) {
46 BooleanWrapper* wrapper = new BooleanWrapper(enabled);
47 context->SetUserData(kAllowPrerender, wrapper);
50 } // namespace android