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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp

Issue 2786673002: Separate ContentSettingsClient out from LocalFrameClient (Closed)
Patch Set: fix 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/webdatabase/DatabaseClient.h" 31 #include "modules/webdatabase/DatabaseClient.h"
32 32
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/frame/ContentSettingsClient.h"
35 #include "core/frame/LocalFrame.h"
34 #include "core/page/Page.h" 36 #include "core/page/Page.h"
35 #include "modules/webdatabase/Database.h" 37 #include "modules/webdatabase/Database.h"
36 #include "modules/webdatabase/InspectorDatabaseAgent.h" 38 #include "modules/webdatabase/InspectorDatabaseAgent.h"
37 39
38 namespace blink { 40 namespace blink {
39 41
40 DatabaseClient::DatabaseClient() : m_inspectorAgent(nullptr) {} 42 DatabaseClient::DatabaseClient() : m_inspectorAgent(nullptr) {}
41 43
42 DEFINE_TRACE(DatabaseClient) { 44 DEFINE_TRACE(DatabaseClient) {
43 visitor->trace(m_inspectorAgent); 45 visitor->trace(m_inspectorAgent);
44 Supplement<Page>::trace(visitor); 46 Supplement<Page>::trace(visitor);
45 } 47 }
46 48
47 DatabaseClient* DatabaseClient::fromPage(Page* page) { 49 DatabaseClient* DatabaseClient::fromPage(Page* page) {
48 return static_cast<DatabaseClient*>( 50 return static_cast<DatabaseClient*>(
49 Supplement<Page>::from(page, supplementName())); 51 Supplement<Page>::from(page, supplementName()));
50 } 52 }
51 53
52 DatabaseClient* DatabaseClient::from(ExecutionContext* context) { 54 DatabaseClient* DatabaseClient::from(ExecutionContext* context) {
53 return DatabaseClient::fromPage(toDocument(context)->page()); 55 return DatabaseClient::fromPage(toDocument(context)->page());
54 } 56 }
55 57
56 const char* DatabaseClient::supplementName() { 58 const char* DatabaseClient::supplementName() {
57 return "DatabaseClient"; 59 return "DatabaseClient";
58 } 60 }
59 61
62 bool DatabaseClient::allowDatabase(ExecutionContext* context,
63 const String& name,
64 const String& displayName,
65 unsigned estimatedSize) {
66 DCHECK(context->isContextThread());
67 Document* document = toDocument(context);
68 DCHECK(document->frame());
michaeln 2017/04/04 23:45:08 lgtm... but the old code returned false in case th
69 if (document->frame()->contentSettingsClient()) {
70 return document->frame()->contentSettingsClient()->allowDatabase(
71 name, displayName, estimatedSize);
72 }
73 return true;
74 }
75
60 void DatabaseClient::didOpenDatabase(blink::Database* database, 76 void DatabaseClient::didOpenDatabase(blink::Database* database,
61 const String& domain, 77 const String& domain,
62 const String& name, 78 const String& name,
63 const String& version) { 79 const String& version) {
64 if (m_inspectorAgent) 80 if (m_inspectorAgent)
65 m_inspectorAgent->didOpenDatabase(database, domain, name, version); 81 m_inspectorAgent->didOpenDatabase(database, domain, name, version);
66 } 82 }
67 83
68 void DatabaseClient::setInspectorAgent(InspectorDatabaseAgent* agent) { 84 void DatabaseClient::setInspectorAgent(InspectorDatabaseAgent* agent) {
69 // TODO(dgozman): we should not set agent twice, but it's happening in OOPIF 85 // TODO(dgozman): we should not set agent twice, but it's happening in OOPIF
70 // case. 86 // case.
71 m_inspectorAgent = agent; 87 m_inspectorAgent = agent;
72 } 88 }
73 89
74 void provideDatabaseClientTo(Page& page, DatabaseClient* client) { 90 void provideDatabaseClientTo(Page& page, DatabaseClient* client) {
75 page.provideSupplement(DatabaseClient::supplementName(), client); 91 page.provideSupplement(DatabaseClient::supplementName(), client);
76 } 92 }
77 93
78 } // namespace blink 94 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webdatabase/DatabaseClient.h ('k') | third_party/WebKit/Source/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698