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

Side by Side Diff: components/open_from_clipboard/clipboard_recent_content.cc

Issue 2801813003: Omnibox - ClipboardRecentContent - Make Proper Singleton (Closed)
Patch Set: fix iOS Created 3 years, 8 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
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" 7 #include "url/url_constants.h"
8 8
9 namespace { 9 namespace {
10 ClipboardRecentContent* g_clipboard_recent_content = nullptr; 10 ClipboardRecentContent* g_clipboard_recent_content = nullptr;
11 11
12 // Schemes appropriate for suggestion by ClipboardRecentContent. 12 // Schemes appropriate for suggestion by ClipboardRecentContent.
13 const char* kAuthorizedSchemes[] = { 13 const char* kAuthorizedSchemes[] = {
14 url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, 14 url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme,
15 // TODO(mpearson): add support for chrome:// URLs. Right now the scheme 15 // TODO(mpearson): add support for chrome:// URLs. Right now the scheme
16 // for that lives in content and is accessible via 16 // for that lives in content and is accessible via
17 // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme 17 // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme
18 // TODO(mpearson): when adding desktop support, add kFileScheme, kFtpScheme, 18 // TODO(mpearson): when adding desktop support, add kFileScheme, kFtpScheme,
19 // and kGopherScheme. 19 // and kGopherScheme.
20 }; 20 };
21 21
22 } // namespace 22 } // namespace
23 23
24 ClipboardRecentContent::ClipboardRecentContent() {} 24 ClipboardRecentContent::ClipboardRecentContent() {}
25 25
26 ClipboardRecentContent::~ClipboardRecentContent() { 26 ClipboardRecentContent::~ClipboardRecentContent() {
27 g_clipboard_recent_content = nullptr;
28 } 27 }
29 28
30 // static 29 // static
31 ClipboardRecentContent* ClipboardRecentContent::GetInstance() { 30 ClipboardRecentContent* ClipboardRecentContent::GetInstance() {
32 return g_clipboard_recent_content; 31 return g_clipboard_recent_content;
33 } 32 }
34 33
35 // static 34 // static
36 void ClipboardRecentContent::SetInstance(ClipboardRecentContent* instance) { 35 void ClipboardRecentContent::SetInstance(
37 g_clipboard_recent_content = instance; 36 std::unique_ptr<ClipboardRecentContent> new_instance) {
37 delete g_clipboard_recent_content;
38 g_clipboard_recent_content = new_instance.release();
38 } 39 }
39 40
40 // static 41 // static
41 bool ClipboardRecentContent::IsAppropriateSuggestion(const GURL& url) { 42 bool ClipboardRecentContent::IsAppropriateSuggestion(const GURL& url) {
42 // Check to make sure it's a scheme we're willing to suggest. 43 // Check to make sure it's a scheme we're willing to suggest.
43 for (const auto* authorized_scheme : kAuthorizedSchemes) { 44 for (const auto* authorized_scheme : kAuthorizedSchemes) {
44 if (url.SchemeIs(authorized_scheme)) 45 if (url.SchemeIs(authorized_scheme))
45 return true; 46 return true;
46 } 47 }
47 48
48 // Not a scheme we're allowed to return. 49 // Not a scheme we're allowed to return.
49 return false; 50 return false;
50 } 51 }
OLDNEW
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content.h ('k') | ios/chrome/browser/ios_chrome_main_parts.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698