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/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return false; | 95 return false; |
96 | 96 |
97 base::DictionaryValue* details_value = NULL; | 97 base::DictionaryValue* details_value = NULL; |
98 if (!args_->GetDictionary(2, &details_value)) | 98 if (!args_->GetDictionary(2, &details_value)) |
99 return false; | 99 return false; |
100 scoped_ptr<InjectDetails> details(new InjectDetails()); | 100 scoped_ptr<InjectDetails> details(new InjectDetails()); |
101 if (!InjectDetails::Populate(*details_value, details.get())) | 101 if (!InjectDetails::Populate(*details_value, details.get())) |
102 return false; | 102 return false; |
103 | 103 |
104 details_ = details.Pass(); | 104 details_ = details.Pass(); |
| 105 script_injection_instance_id_ = |
| 106 WebViewGuest::GetOrGenerateScriptInjectionInstanceID( |
| 107 render_view_host()->GetProcess()->GetID(), guest_instance_id_); |
| 108 |
105 return true; | 109 return true; |
106 } | 110 } |
107 | 111 |
108 bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const { | 112 bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const { |
109 return false; | 113 return false; |
110 } | 114 } |
111 | 115 |
112 bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage() { | 116 bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage() { |
113 return true; | 117 return true; |
114 } | 118 } |
(...skipping 11 matching lines...) Expand all Loading... |
126 } | 130 } |
127 | 131 |
128 bool WebViewInternalExecuteCodeFunction::IsWebView() const { | 132 bool WebViewInternalExecuteCodeFunction::IsWebView() const { |
129 return true; | 133 return true; |
130 } | 134 } |
131 | 135 |
132 const GURL& WebViewInternalExecuteCodeFunction::GetWebViewSrc() const { | 136 const GURL& WebViewInternalExecuteCodeFunction::GetWebViewSrc() const { |
133 return guest_src_; | 137 return guest_src_; |
134 } | 138 } |
135 | 139 |
| 140 int WebViewInternalExecuteCodeFunction:: GetScriptInjectionInstanceId() const { |
| 141 return script_injection_instance_id_; |
| 142 } |
| 143 |
136 WebViewInternalExecuteScriptFunction::WebViewInternalExecuteScriptFunction() { | 144 WebViewInternalExecuteScriptFunction::WebViewInternalExecuteScriptFunction() { |
137 } | 145 } |
138 | 146 |
139 void WebViewInternalExecuteScriptFunction::OnExecuteCodeFinished( | 147 void WebViewInternalExecuteScriptFunction::OnExecuteCodeFinished( |
140 const std::string& error, | 148 const std::string& error, |
141 const GURL& on_url, | 149 const GURL& on_url, |
142 const base::ListValue& result) { | 150 const base::ListValue& result) { |
143 if (error.empty()) | 151 if (error.empty()) |
144 SetResult(result.DeepCopy()); | 152 SetResult(result.DeepCopy()); |
145 WebViewInternalExecuteCodeFunction::OnExecuteCodeFinished( | 153 WebViewInternalExecuteCodeFunction::OnExecuteCodeFinished( |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // Will finish asynchronously. | 501 // Will finish asynchronously. |
494 return true; | 502 return true; |
495 } | 503 } |
496 | 504 |
497 void WebViewInternalClearDataFunction::ClearDataDone() { | 505 void WebViewInternalClearDataFunction::ClearDataDone() { |
498 Release(); // Balanced in RunAsync(). | 506 Release(); // Balanced in RunAsync(). |
499 SendResponse(true); | 507 SendResponse(true); |
500 } | 508 } |
501 | 509 |
502 } // namespace extensions | 510 } // namespace extensions |
OLD | NEW |