OLD | NEW |
---|---|
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 Loading... | |
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 if (document->frame()->contentSettingsClient()) { | |
dcheng
2017/04/02 05:26:19
Do we need to null-check that frame is not null?
kinuko
2017/04/03 15:15:06
I think we do, done.
dcheng
2017/04/03 19:28:23
Btw, I didn't trace this back far enough: the only
kinuko
2017/04/04 03:26:23
Thanks for looking! I turned this into DCHECK.
| |
69 return document->frame()->contentSettingsClient()->allowDatabase( | |
70 name, displayName, estimatedSize); | |
71 } | |
72 return true; | |
73 } | |
kinuko
2017/03/31 16:13:12
Moved the impl from DatabaseClientImpl and removed
| |
74 | |
60 void DatabaseClient::didOpenDatabase(blink::Database* database, | 75 void DatabaseClient::didOpenDatabase(blink::Database* database, |
61 const String& domain, | 76 const String& domain, |
62 const String& name, | 77 const String& name, |
63 const String& version) { | 78 const String& version) { |
64 if (m_inspectorAgent) | 79 if (m_inspectorAgent) |
65 m_inspectorAgent->didOpenDatabase(database, domain, name, version); | 80 m_inspectorAgent->didOpenDatabase(database, domain, name, version); |
66 } | 81 } |
67 | 82 |
68 void DatabaseClient::setInspectorAgent(InspectorDatabaseAgent* agent) { | 83 void DatabaseClient::setInspectorAgent(InspectorDatabaseAgent* agent) { |
69 // TODO(dgozman): we should not set agent twice, but it's happening in OOPIF | 84 // TODO(dgozman): we should not set agent twice, but it's happening in OOPIF |
70 // case. | 85 // case. |
71 m_inspectorAgent = agent; | 86 m_inspectorAgent = agent; |
72 } | 87 } |
73 | 88 |
74 void provideDatabaseClientTo(Page& page, DatabaseClient* client) { | 89 void provideDatabaseClientTo(Page& page, DatabaseClient* client) { |
75 page.provideSupplement(DatabaseClient::supplementName(), client); | 90 page.provideSupplement(DatabaseClient::supplementName(), client); |
76 } | 91 } |
77 | 92 |
78 } // namespace blink | 93 } // namespace blink |
OLD | NEW |