| 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 "chrome/browser/guest_view/guest_view_base.h" | 5 #include "chrome/browser/guest_view/guest_view_base.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" | 9 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" |
| 10 #include "chrome/browser/guest_view/guest_view_constants.h" | 10 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 11 #include "chrome/browser/guest_view/guest_view_manager.h" | 11 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 12 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 12 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/content_settings.h" | 14 #include "chrome/common/content_settings.h" |
| 15 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 20 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 21 #include "net/base/escape.h" | |
| 22 #include "third_party/WebKit/public/web/WebInputEvent.h" | 21 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 23 | 22 |
| 24 using content::WebContents; | 23 using content::WebContents; |
| 25 | 24 |
| 26 namespace { | 25 namespace { |
| 27 | 26 |
| 28 typedef std::map<WebContents*, GuestViewBase*> WebContentsGuestViewMap; | 27 typedef std::map<WebContents*, GuestViewBase*> WebContentsGuestViewMap; |
| 29 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = | 28 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = |
| 30 LAZY_INSTANCE_INITIALIZER; | 29 LAZY_INSTANCE_INITIALIZER; |
| 31 | 30 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 127 |
| 129 return GuestViewBase::FromWebContents(guest_web_contents); | 128 return GuestViewBase::FromWebContents(guest_web_contents); |
| 130 } | 129 } |
| 131 | 130 |
| 132 // static | 131 // static |
| 133 bool GuestViewBase::IsGuest(WebContents* web_contents) { | 132 bool GuestViewBase::IsGuest(WebContents* web_contents) { |
| 134 return !!GuestViewBase::FromWebContents(web_contents); | 133 return !!GuestViewBase::FromWebContents(web_contents); |
| 135 } | 134 } |
| 136 | 135 |
| 137 // static | 136 // static |
| 138 bool GuestViewBase::GetGuestPartitionConfigForSite( | |
| 139 const GURL& site, | |
| 140 std::string* partition_domain, | |
| 141 std::string* partition_name, | |
| 142 bool* in_memory) { | |
| 143 if (!site.SchemeIs(content::kGuestScheme)) | |
| 144 return false; | |
| 145 | |
| 146 // Since guest URLs are only used for packaged apps, there must be an app | |
| 147 // id in the URL. | |
| 148 CHECK(site.has_host()); | |
| 149 *partition_domain = site.host(); | |
| 150 // Since persistence is optional, the path must either be empty or the | |
| 151 // literal string. | |
| 152 *in_memory = (site.path() != "/persist"); | |
| 153 // The partition name is user supplied value, which we have encoded when the | |
| 154 // URL was created, so it needs to be decoded. | |
| 155 *partition_name = | |
| 156 net::UnescapeURLComponent(site.query(), net::UnescapeRule::NORMAL); | |
| 157 return true; | |
| 158 } | |
| 159 | |
| 160 // static | |
| 161 void GuestViewBase::GetDefaultContentSettingRules( | 137 void GuestViewBase::GetDefaultContentSettingRules( |
| 162 RendererContentSettingRules* rules, | 138 RendererContentSettingRules* rules, |
| 163 bool incognito) { | 139 bool incognito) { |
| 164 rules->image_rules.push_back( | 140 rules->image_rules.push_back( |
| 165 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | 141 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), |
| 166 ContentSettingsPattern::Wildcard(), | 142 ContentSettingsPattern::Wildcard(), |
| 167 CONTENT_SETTING_ALLOW, | 143 CONTENT_SETTING_ALLOW, |
| 168 std::string(), | 144 std::string(), |
| 169 incognito)); | 145 incognito)); |
| 170 | 146 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 275 |
| 300 void GuestViewBase::SendQueuedEvents() { | 276 void GuestViewBase::SendQueuedEvents() { |
| 301 if (!attached()) | 277 if (!attached()) |
| 302 return; | 278 return; |
| 303 while (!pending_events_.empty()) { | 279 while (!pending_events_.empty()) { |
| 304 linked_ptr<Event> event_ptr = pending_events_.front(); | 280 linked_ptr<Event> event_ptr = pending_events_.front(); |
| 305 pending_events_.pop_front(); | 281 pending_events_.pop_front(); |
| 306 DispatchEvent(event_ptr.release()); | 282 DispatchEvent(event_ptr.release()); |
| 307 } | 283 } |
| 308 } | 284 } |
| OLD | NEW |