| 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/api/web_view/web_view_internal_api.h" | 5 #include "extensions/browser/api/web_view/web_view_internal_api.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
| 9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
| 10 #include "content/public/browser/storage_partition.h" | 10 #include "content/public/browser/storage_partition.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 std::string src; | 88 std::string src; |
| 89 if (!args_->GetString(1, &src)) | 89 if (!args_->GetString(1, &src)) |
| 90 return false; | 90 return false; |
| 91 | 91 |
| 92 guest_src_ = GURL(src); | 92 guest_src_ = GURL(src); |
| 93 if (!guest_src_.is_valid()) | 93 if (!guest_src_.is_valid()) |
| 94 return false; | 94 return false; |
| 95 | 95 |
| 96 base::DictionaryValue* details_value = NULL; | 96 base::DictionaryValue* details_value = nullptr; |
| 97 if (!args_->GetDictionary(2, &details_value)) | 97 if (!args_->GetDictionary(2, &details_value)) |
| 98 return false; | 98 return false; |
| 99 scoped_ptr<InjectDetails> details(new InjectDetails()); | 99 scoped_ptr<InjectDetails> details(new InjectDetails()); |
| 100 if (!InjectDetails::Populate(*details_value, details.get())) | 100 if (!InjectDetails::Populate(*details_value, details.get())) |
| 101 return false; | 101 return false; |
| 102 | 102 |
| 103 details_ = details.Pass(); | 103 details_ = details.Pass(); |
| 104 return true; | 104 return true; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const { | 107 bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const { |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage() { | 111 bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage() { |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 extensions::ScriptExecutor* | 115 extensions::ScriptExecutor* |
| 116 WebViewInternalExecuteCodeFunction::GetScriptExecutor() { | 116 WebViewInternalExecuteCodeFunction::GetScriptExecutor() { |
| 117 WebViewGuest* guest = WebViewGuest::From( | 117 WebViewGuest* guest = WebViewGuest::From( |
| 118 render_view_host()->GetProcess()->GetID(), guest_instance_id_); | 118 render_view_host()->GetProcess()->GetID(), guest_instance_id_); |
| 119 if (!guest) | 119 if (!guest) |
| 120 return NULL; | 120 return nullptr; |
| 121 | 121 |
| 122 return guest->script_executor(); | 122 return guest->script_executor(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool WebViewInternalExecuteCodeFunction::IsWebView() const { | 125 bool WebViewInternalExecuteCodeFunction::IsWebView() const { |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 const GURL& WebViewInternalExecuteCodeFunction::GetWebViewSrc() const { | 129 const GURL& WebViewInternalExecuteCodeFunction::GetWebViewSrc() const { |
| 130 return guest_src_; | 130 return guest_src_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { | 161 bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 WebContents* WebViewInternalCaptureVisibleRegionFunction::GetWebContentsForID( | 165 WebContents* WebViewInternalCaptureVisibleRegionFunction::GetWebContentsForID( |
| 166 int instance_id) { | 166 int instance_id) { |
| 167 WebViewGuest* guest = WebViewGuest::From( | 167 WebViewGuest* guest = WebViewGuest::From( |
| 168 render_view_host()->GetProcess()->GetID(), instance_id); | 168 render_view_host()->GetProcess()->GetID(), instance_id); |
| 169 return guest ? guest->web_contents() : NULL; | 169 return guest ? guest->web_contents() : nullptr; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure( | 172 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure( |
| 173 FailureReason reason) { | 173 FailureReason reason) { |
| 174 SendResponse(false); | 174 SendResponse(false); |
| 175 } | 175 } |
| 176 | 176 |
| 177 WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() { | 177 WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() { |
| 178 } | 178 } |
| 179 | 179 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // Will finish asynchronously. | 487 // Will finish asynchronously. |
| 488 return true; | 488 return true; |
| 489 } | 489 } |
| 490 | 490 |
| 491 void WebViewInternalClearDataFunction::ClearDataDone() { | 491 void WebViewInternalClearDataFunction::ClearDataDone() { |
| 492 Release(); // Balanced in RunAsync(). | 492 Release(); // Balanced in RunAsync(). |
| 493 SendResponse(true); | 493 SendResponse(true); |
| 494 } | 494 } |
| 495 | 495 |
| 496 } // namespace extensions | 496 } // namespace extensions |
| OLD | NEW |