Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: chrome/browser/android/prerender_condition_platform.cc

Issue 517843005: Remove PrerenderCondition*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
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"
10
11 namespace android {
12
13 namespace {
14
15 const char kAllowPrerender[] = "allow-prerender";
16
17 class BooleanWrapper : public base::SupportsUserData::Data {
18 public:
19 explicit BooleanWrapper(bool b) : m_b(b) { }
20 virtual ~BooleanWrapper() { }
21
22 operator bool() const { return m_b; }
23 private:
24 bool m_b;
25 DISALLOW_COPY_AND_ASSIGN(BooleanWrapper);
26 };
27
28 } // namespace
29
30 PrerenderConditionPlatform::PrerenderConditionPlatform(
31 content::BrowserContext* context)
32 : context_(context) {}
33
34 PrerenderConditionPlatform::~PrerenderConditionPlatform() {}
35
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;
42 }
43
44 void PrerenderConditionPlatform::SetEnabled(content::BrowserContext* context,
45 bool enabled) {
46 BooleanWrapper* wrapper = new BooleanWrapper(enabled);
47 context->SetUserData(kAllowPrerender, wrapper);
48 }
49
50 } // namespace android
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698