OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/open_from_clipboard/clipboard_recent_content.h" | 5 #include "components/open_from_clipboard/clipboard_recent_content.h" |
6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/time/time.h" |
| 9 #include "components/variations/variations_associated_data.h" |
7 #include "url/url_constants.h" | 10 #include "url/url_constants.h" |
8 | 11 |
9 namespace { | 12 namespace { |
10 ClipboardRecentContent* g_clipboard_recent_content = nullptr; | 13 ClipboardRecentContent* g_clipboard_recent_content = nullptr; |
11 | 14 |
12 // Schemes appropriate for suggestion by ClipboardRecentContent. | 15 // Schemes appropriate for suggestion by ClipboardRecentContent. |
13 const char* kAuthorizedSchemes[] = { | 16 const char* kAuthorizedSchemes[] = { |
14 url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, | 17 url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, |
15 // TODO(mpearson): add support for chrome:// URLs. Right now the scheme | 18 // TODO(mpearson): add support for chrome:// URLs. Right now the scheme |
16 // for that lives in content and is accessible via | 19 // for that lives in content and is accessible via |
(...skipping 28 matching lines...) Expand all Loading... |
45 if (url.SchemeIs(authorized_scheme)) | 48 if (url.SchemeIs(authorized_scheme)) |
46 return true; | 49 return true; |
47 } | 50 } |
48 | 51 |
49 // Not a scheme we're allowed to return. | 52 // Not a scheme we're allowed to return. |
50 return false; | 53 return false; |
51 } | 54 } |
52 | 55 |
53 // static | 56 // static |
54 base::TimeDelta ClipboardRecentContent::MaximumAgeOfClipboard() { | 57 base::TimeDelta ClipboardRecentContent::MaximumAgeOfClipboard() { |
55 return base::TimeDelta::FromHours(3); | 58 // Identify the current setting for this parameter from the omnibox field |
| 59 // trial. |
| 60 std::string value_str = variations::GetVariationParamValue( |
| 61 "OmniboxBundledExperimentV1", "ClipboardURLMaximumAge"); |
| 62 // If the parameter is not set, use a 1 hour timeout. |
| 63 if (value_str.empty()) |
| 64 return base::TimeDelta::FromHours(1); |
| 65 // This is a best-effort conversion; we trust the hand-crafted parameters |
| 66 // downloaded from the server to be perfect. There's no need for handle |
| 67 // errors smartly. |
| 68 int value; |
| 69 // The value in the parameter is stored in seconds. |
| 70 base::StringToInt(value_str, &value); |
| 71 return base::TimeDelta::FromSeconds(value); |
56 } | 72 } |
OLD | NEW |