| 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/web_view/web_view_guest.h" | 5 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
| 42 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
| 43 #include "content/public/browser/web_contents_delegate.h" | 43 #include "content/public/browser/web_contents_delegate.h" |
| 44 #include "content/public/common/media_stream_request.h" | 44 #include "content/public/common/media_stream_request.h" |
| 45 #include "content/public/common/page_zoom.h" | 45 #include "content/public/common/page_zoom.h" |
| 46 #include "content/public/common/result_codes.h" | 46 #include "content/public/common/result_codes.h" |
| 47 #include "content/public/common/stop_find_action.h" | 47 #include "content/public/common/stop_find_action.h" |
| 48 #include "content/public/common/url_constants.h" | 48 #include "content/public/common/url_constants.h" |
| 49 #include "extensions/common/constants.h" | 49 #include "extensions/common/constants.h" |
| 50 #include "ipc/ipc_message_macros.h" | 50 #include "ipc/ipc_message_macros.h" |
| 51 #include "net/base/escape.h" |
| 51 #include "net/base/net_errors.h" | 52 #include "net/base/net_errors.h" |
| 52 #include "third_party/WebKit/public/web/WebFindOptions.h" | 53 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 53 #include "ui/base/models/simple_menu_model.h" | 54 #include "ui/base/models/simple_menu_model.h" |
| 54 | 55 |
| 55 #if defined(ENABLE_PRINTING) | 56 #if defined(ENABLE_PRINTING) |
| 56 #if defined(ENABLE_FULL_PRINTING) | 57 #if defined(ENABLE_FULL_PRINTING) |
| 57 #include "chrome/browser/printing/print_preview_message_handler.h" | 58 #include "chrome/browser/printing/print_preview_message_handler.h" |
| 58 #include "chrome/browser/printing/print_view_manager.h" | 59 #include "chrome/browser/printing/print_view_manager.h" |
| 59 #else | 60 #else |
| 60 #include "chrome/browser/printing/print_view_manager_basic.h" | 61 #include "chrome/browser/printing/print_view_manager_basic.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 CHECK(accessibility_manager); | 204 CHECK(accessibility_manager); |
| 204 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 205 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| 205 base::Bind(&WebViewGuest::OnAccessibilityStatusChanged, | 206 base::Bind(&WebViewGuest::OnAccessibilityStatusChanged, |
| 206 base::Unretained(this))); | 207 base::Unretained(this))); |
| 207 #endif | 208 #endif |
| 208 | 209 |
| 209 AttachWebViewHelpers(guest_web_contents); | 210 AttachWebViewHelpers(guest_web_contents); |
| 210 } | 211 } |
| 211 | 212 |
| 212 // static | 213 // static |
| 214 bool WebViewGuest::GetGuestPartitionConfigForSite( |
| 215 const GURL& site, |
| 216 std::string* partition_domain, |
| 217 std::string* partition_name, |
| 218 bool* in_memory) { |
| 219 if (!site.SchemeIs(content::kGuestScheme)) |
| 220 return false; |
| 221 |
| 222 // Since guest URLs are only used for packaged apps, there must be an app |
| 223 // id in the URL. |
| 224 CHECK(site.has_host()); |
| 225 *partition_domain = site.host(); |
| 226 // Since persistence is optional, the path must either be empty or the |
| 227 // literal string. |
| 228 *in_memory = (site.path() != "/persist"); |
| 229 // The partition name is user supplied value, which we have encoded when the |
| 230 // URL was created, so it needs to be decoded. |
| 231 *partition_name = |
| 232 net::UnescapeURLComponent(site.query(), net::UnescapeRule::NORMAL); |
| 233 return true; |
| 234 } |
| 235 |
| 236 // static |
| 213 const char WebViewGuest::Type[] = "webview"; | 237 const char WebViewGuest::Type[] = "webview"; |
| 214 | 238 |
| 215 // static. | 239 // static |
| 216 int WebViewGuest::GetViewInstanceId(WebContents* contents) { | 240 int WebViewGuest::GetViewInstanceId(WebContents* contents) { |
| 217 WebViewGuest* guest = FromWebContents(contents); | 241 WebViewGuest* guest = FromWebContents(contents); |
| 218 if (!guest) | 242 if (!guest) |
| 219 return guestview::kInstanceIDNone; | 243 return guestview::kInstanceIDNone; |
| 220 | 244 |
| 221 return guest->view_instance_id(); | 245 return guest->view_instance_id(); |
| 222 } | 246 } |
| 223 | 247 |
| 224 // static | 248 // static |
| 225 void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, | 249 void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 bool allow, | 1439 bool allow, |
| 1416 const std::string& user_input) { | 1440 const std::string& user_input) { |
| 1417 WebViewGuest* guest = | 1441 WebViewGuest* guest = |
| 1418 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1442 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
| 1419 if (!guest) | 1443 if (!guest) |
| 1420 return; | 1444 return; |
| 1421 | 1445 |
| 1422 if (!allow) | 1446 if (!allow) |
| 1423 guest->Destroy(); | 1447 guest->Destroy(); |
| 1424 } | 1448 } |
| OLD | NEW |