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 "url/url_constants.h" |
| 8 |
7 namespace { | 9 namespace { |
8 ClipboardRecentContent* g_clipboard_recent_content = nullptr; | 10 ClipboardRecentContent* g_clipboard_recent_content = nullptr; |
9 } | 11 |
| 12 // Schemes appropriate for suggestion by ClipboardRecentContent. |
| 13 const char* kAuthorizedSchemes[] = { |
| 14 url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, |
| 15 // TODO(mpearson): add support for chrome:// URLs. Right now the scheme |
| 16 // for that lives in content and is accessible via |
| 17 // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme |
| 18 // TODO(mpearson): when adding desktop support, add kFileScheme, kFtpScheme, |
| 19 // and kGopherScheme. |
| 20 }; |
| 21 |
| 22 } // namespace |
10 | 23 |
11 ClipboardRecentContent::ClipboardRecentContent() {} | 24 ClipboardRecentContent::ClipboardRecentContent() {} |
12 | 25 |
13 ClipboardRecentContent::~ClipboardRecentContent() {} | 26 ClipboardRecentContent::~ClipboardRecentContent() {} |
14 | 27 |
15 // static | 28 // static |
16 ClipboardRecentContent* ClipboardRecentContent::GetInstance() { | 29 ClipboardRecentContent* ClipboardRecentContent::GetInstance() { |
17 return g_clipboard_recent_content; | 30 return g_clipboard_recent_content; |
18 } | 31 } |
19 | 32 |
20 // static | 33 // static |
21 void ClipboardRecentContent::SetInstance(ClipboardRecentContent* instance) { | 34 void ClipboardRecentContent::SetInstance(ClipboardRecentContent* instance) { |
22 g_clipboard_recent_content = instance; | 35 g_clipboard_recent_content = instance; |
23 } | 36 } |
| 37 |
| 38 // static |
| 39 bool ClipboardRecentContent::IsAppropriateSuggestion(const GURL& url) { |
| 40 // Check to make sure it's a scheme we're willing to suggest. |
| 41 for (const auto* authorized_scheme : kAuthorizedSchemes) { |
| 42 if (url.SchemeIs(authorized_scheme)) |
| 43 return true; |
| 44 } |
| 45 |
| 46 // Not a scheme we're allowed to return. |
| 47 return false; |
| 48 } |
OLD | NEW |