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

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

Issue 2801813003: Omnibox - ClipboardRecentContent - Make Proper Singleton (Closed)
Patch Set: restore field trial state 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;
Peter Kasting 2017/04/05 23:23:51 Why are you removing this line? The only effect o
Mark P 2017/04/06 17:58:00 No, that's not the only effect. If someone create
Peter Kasting 2017/04/06 19:35:41 OK. I think my assumption mentally is that creati
Mark P 2017/04/06 23:25:27 Acknowledged.
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(ClipboardRecentContent* instance) {
Peter Kasting 2017/04/05 23:23:51 Is there an advantage of having this setter at all
Mark P 2017/04/06 17:58:00 Oh, do you mean have the constructor set the globa
Peter Kasting 2017/04/06 19:35:41 True, but sort of makes sense if no one is ever ex
Mark P 2017/04/06 23:25:27 Left as-is because the side effect of what you pro
36 DCHECK(g_clipboard_recent_content == nullptr);
37 g_clipboard_recent_content = instance; 37 g_clipboard_recent_content = instance;
38 } 38 }
39 39
40 // static 40 // static
41 bool ClipboardRecentContent::IsAppropriateSuggestion(const GURL& url) { 41 bool ClipboardRecentContent::IsAppropriateSuggestion(const GURL& url) {
42 // Check to make sure it's a scheme we're willing to suggest. 42 // Check to make sure it's a scheme we're willing to suggest.
43 for (const auto* authorized_scheme : kAuthorizedSchemes) { 43 for (const auto* authorized_scheme : kAuthorizedSchemes) {
44 if (url.SchemeIs(authorized_scheme)) 44 if (url.SchemeIs(authorized_scheme))
45 return true; 45 return true;
46 } 46 }
47 47
48 // Not a scheme we're allowed to return. 48 // Not a scheme we're allowed to return.
49 return false; 49 return false;
50 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698