OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" | 55 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" |
56 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" | 56 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" |
57 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 57 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
58 #include "extensions/common/constants.h" | 58 #include "extensions/common/constants.h" |
59 #include "extensions/common/extension_messages.h" | 59 #include "extensions/common/extension_messages.h" |
60 #include "extensions/common/manifest_constants.h" | 60 #include "extensions/common/manifest_constants.h" |
61 #include "extensions/strings/grit/extensions_strings.h" | 61 #include "extensions/strings/grit/extensions_strings.h" |
62 #include "ipc/ipc_message_macros.h" | 62 #include "ipc/ipc_message_macros.h" |
63 #include "net/base/escape.h" | 63 #include "net/base/escape.h" |
64 #include "net/base/net_errors.h" | 64 #include "net/base/net_errors.h" |
65 #include "net/cookies/canonical_cookie.h" | |
65 #include "ui/base/models/simple_menu_model.h" | 66 #include "ui/base/models/simple_menu_model.h" |
66 #include "ui/events/keycodes/keyboard_codes.h" | 67 #include "ui/events/keycodes/keyboard_codes.h" |
67 #include "url/url_constants.h" | 68 #include "url/url_constants.h" |
68 | 69 |
69 using base::UserMetricsAction; | 70 using base::UserMetricsAction; |
70 using content::GlobalRequestID; | 71 using content::GlobalRequestID; |
71 using content::RenderFrameHost; | 72 using content::RenderFrameHost; |
72 using content::RenderProcessHost; | 73 using content::RenderProcessHost; |
73 using content::StoragePartition; | 74 using content::StoragePartition; |
74 using content::WebContents; | 75 using content::WebContents; |
75 using guest_view::GuestViewBase; | 76 using guest_view::GuestViewBase; |
76 using guest_view::GuestViewEvent; | 77 using guest_view::GuestViewEvent; |
77 using guest_view::GuestViewManager; | 78 using guest_view::GuestViewManager; |
78 using zoom::ZoomController; | 79 using zoom::ZoomController; |
79 | 80 |
80 namespace extensions { | 81 namespace extensions { |
81 | 82 |
82 namespace { | 83 namespace { |
83 | 84 |
84 // Returns storage partition removal mask from web_view clearData mask. Note | 85 // Returns storage partition removal mask from web_view clearData mask. Note |
85 // that storage partition mask is a subset of webview's data removal mask. | 86 // that storage partition mask is a subset of webview's data removal mask. |
86 uint32_t GetStoragePartitionRemovalMask(uint32_t web_view_removal_mask) { | 87 uint32_t GetStoragePartitionRemovalMask(uint32_t web_view_removal_mask) { |
87 uint32_t mask = 0; | 88 uint32_t mask = 0; |
88 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_APPCACHE) | 89 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_APPCACHE) |
89 mask |= StoragePartition::REMOVE_DATA_MASK_APPCACHE; | 90 mask |= StoragePartition::REMOVE_DATA_MASK_APPCACHE; |
90 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES) | 91 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES || |
92 web_view_removal_mask & | |
93 webview::WEB_VIEW_REMOVE_DATA_MASK_SESSION_COOKIES || | |
94 web_view_removal_mask & | |
95 webview::WEB_VIEW_REMOVE_DATA_MASK_PERSISTENT_COOKIES) | |
91 mask |= StoragePartition::REMOVE_DATA_MASK_COOKIES; | 96 mask |= StoragePartition::REMOVE_DATA_MASK_COOKIES; |
lazyboy
2017/02/15 21:45:27
nit: {}
lfg
2017/02/15 22:44:00
Done.
| |
92 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_FILE_SYSTEMS) | 97 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_FILE_SYSTEMS) |
93 mask |= StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; | 98 mask |= StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; |
94 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_INDEXEDDB) | 99 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_INDEXEDDB) |
95 mask |= StoragePartition::REMOVE_DATA_MASK_INDEXEDDB; | 100 mask |= StoragePartition::REMOVE_DATA_MASK_INDEXEDDB; |
96 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_LOCAL_STORAGE) | 101 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_LOCAL_STORAGE) |
97 mask |= StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE; | 102 mask |= StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE; |
98 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_WEBSQL) | 103 if (web_view_removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_WEBSQL) |
99 mask |= StoragePartition::REMOVE_DATA_MASK_WEBSQL; | 104 mask |= StoragePartition::REMOVE_DATA_MASK_WEBSQL; |
100 | 105 |
101 return mask; | 106 return mask; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 | 423 |
419 void WebViewGuest::ClearDataInternal(base::Time remove_since, | 424 void WebViewGuest::ClearDataInternal(base::Time remove_since, |
420 uint32_t removal_mask, | 425 uint32_t removal_mask, |
421 const base::Closure& callback) { | 426 const base::Closure& callback) { |
422 uint32_t storage_partition_removal_mask = | 427 uint32_t storage_partition_removal_mask = |
423 GetStoragePartitionRemovalMask(removal_mask); | 428 GetStoragePartitionRemovalMask(removal_mask); |
424 if (!storage_partition_removal_mask) { | 429 if (!storage_partition_removal_mask) { |
425 callback.Run(); | 430 callback.Run(); |
426 return; | 431 return; |
427 } | 432 } |
433 | |
434 content::StoragePartition::CookieMatcherFunction cookie_matcher; | |
435 | |
436 if ((removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES) || | |
lazyboy
2017/02/15 21:45:27
It's a bit more code, but for readability, conside
lfg
2017/02/15 22:44:00
Done, but the NOTREACHED part isn't correct, since
lazyboy
2017/02/16 02:15:34
Acknowledged.
| |
437 ((removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_SESSION_COOKIES) && | |
438 (removal_mask & | |
439 webview::WEB_VIEW_REMOVE_DATA_MASK_PERSISTENT_COOKIES))) { | |
440 cookie_matcher = base::Bind( | |
441 [](const net::CanonicalCookie& cookie) -> bool { return true; }); | |
lazyboy
2017/02/15 21:45:27
I also wonder if we should continue to use the non
lfg
2017/02/15 22:44:00
Good point. I switched so that the CookieMatcherFu
lazyboy
2017/02/16 02:15:34
Great, I'd also comment this before line 434 sayin
lfg
2017/02/16 17:44:25
Done.
| |
442 } else if (removal_mask & | |
443 webview::WEB_VIEW_REMOVE_DATA_MASK_SESSION_COOKIES) { | |
444 cookie_matcher = base::Bind([](const net::CanonicalCookie& cookie) -> bool { | |
445 return !cookie.IsPersistent(); | |
446 }); | |
447 } else if (removal_mask & | |
448 webview::WEB_VIEW_REMOVE_DATA_MASK_PERSISTENT_COOKIES) { | |
449 cookie_matcher = base::Bind([](const net::CanonicalCookie& cookie) -> bool { | |
450 return cookie.IsPersistent(); | |
451 }); | |
452 } | |
453 | |
428 content::StoragePartition* partition = | 454 content::StoragePartition* partition = |
429 content::BrowserContext::GetStoragePartition( | 455 content::BrowserContext::GetStoragePartition( |
430 web_contents()->GetBrowserContext(), | 456 web_contents()->GetBrowserContext(), |
431 web_contents()->GetSiteInstance()); | 457 web_contents()->GetSiteInstance()); |
432 partition->ClearData( | 458 partition->ClearData( |
433 storage_partition_removal_mask, | 459 storage_partition_removal_mask, |
434 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), | 460 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
435 content::StoragePartition::OriginMatcherFunction(), remove_since, | 461 content::StoragePartition::OriginMatcherFunction(), cookie_matcher, |
436 base::Time::Now(), callback); | 462 remove_since, base::Time::Now(), callback); |
437 } | 463 } |
438 | 464 |
439 void WebViewGuest::GuestViewDidStopLoading() { | 465 void WebViewGuest::GuestViewDidStopLoading() { |
440 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 466 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
441 DispatchEventToView(base::MakeUnique<GuestViewEvent>(webview::kEventLoadStop, | 467 DispatchEventToView(base::MakeUnique<GuestViewEvent>(webview::kEventLoadStop, |
442 std::move(args))); | 468 std::move(args))); |
443 } | 469 } |
444 | 470 |
445 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { | 471 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { |
446 is_embedder_fullscreen_ = entered_fullscreen; | 472 is_embedder_fullscreen_ = entered_fullscreen; |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1528 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1554 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
1529 DispatchEventToView(base::MakeUnique<GuestViewEvent>( | 1555 DispatchEventToView(base::MakeUnique<GuestViewEvent>( |
1530 webview::kEventExitFullscreen, std::move(args))); | 1556 webview::kEventExitFullscreen, std::move(args))); |
1531 } | 1557 } |
1532 // Since we changed fullscreen state, sending a Resize message ensures that | 1558 // Since we changed fullscreen state, sending a Resize message ensures that |
1533 // renderer/ sees the change. | 1559 // renderer/ sees the change. |
1534 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); | 1560 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); |
1535 } | 1561 } |
1536 | 1562 |
1537 } // namespace extensions | 1563 } // namespace extensions |
OLD | NEW |