summaryrefslogtreecommitdiffstats
path: root/components/open_from_clipboard/fake_clipboard_recent_content.cc
blob: a8e68259aca66da87699a3c322ed0c49c051cafb (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
// Copyright 2015 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 "components/open_from_clipboard/fake_clipboard_recent_content.h"

FakeClipboardRecentContent::FakeClipboardRecentContent()
    : content_age_(base::TimeDelta::Max()), suppress_content_(false) {}

FakeClipboardRecentContent::~FakeClipboardRecentContent() {}

bool FakeClipboardRecentContent::GetRecentURLFromClipboard(GURL* url) const {
  if (suppress_content_)
    return false;

  if (!clipboard_content_.is_valid())
    return false;

  *url = clipboard_content_;
  return true;
}

base::TimeDelta FakeClipboardRecentContent::GetClipboardContentAge() const {
  return content_age_;
}

void FakeClipboardRecentContent::SuppressClipboardContent() {
  suppress_content_ = true;
}

void FakeClipboardRecentContent::SetClipboardContent(
    const GURL& url,
    base::TimeDelta content_age) {
  clipboard_content_ = url;
  content_age_ = content_age;
  suppress_content_ = false;
}