Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: chrome/browser/extensions/api/webview/webview_api.cc

Issue 11953121: Fix up how the JSON Schema compiler decides whether to include or forward (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extensions/api/webview/webview_api.h" 5 #include "chrome/browser/extensions/api/webview/webview_api.h"
6 6
7 #include "chrome/common/extensions/api/tabs.h"
7 #include "chrome/common/extensions/api/webview.h" 8 #include "chrome/common/extensions/api/webview.h"
8 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
9 10
10 using namespace extensions::api::webview; 11 using namespace extensions::api;
11 12
12 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { 13 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() {
13 } 14 }
14 15
15 WebviewExecuteScriptFunction::~WebviewExecuteScriptFunction() { 16 WebviewExecuteScriptFunction::~WebviewExecuteScriptFunction() {
16 } 17 }
17 18
18 bool WebviewExecuteScriptFunction::RunImpl() { 19 bool WebviewExecuteScriptFunction::RunImpl() {
19 scoped_ptr<ExecuteScript::Params> params( 20 scoped_ptr<webview::ExecuteScript::Params> params(
20 extensions::api::webview::ExecuteScript::Params::Create(*args_)); 21 webview::ExecuteScript::Params::Create(*args_));
21 EXTENSION_FUNCTION_VALIDATE(params.get()); 22 EXTENSION_FUNCTION_VALIDATE(params.get());
22 23
23 content::RenderViewHost* guest_rvh = 24 content::RenderViewHost* guest_rvh =
24 content::RenderViewHost::FromID(params->process_id, params->route_id); 25 content::RenderViewHost::FromID(params->process_id, params->route_id);
25 // If we haven't loaded a guest yet, then this will be NULL. 26 // If we haven't loaded a guest yet, then this will be NULL.
26 if (!guest_rvh) 27 if (!guest_rvh)
27 return false; 28 return false;
28 content::WebContents* guest_web_contents = 29 content::WebContents* guest_web_contents =
29 content::WebContents::FromRenderViewHost(guest_rvh); 30 content::WebContents::FromRenderViewHost(guest_rvh);
30 CHECK(guest_web_contents); 31 CHECK(guest_web_contents);
31 32
32 ObserverList<extensions::TabHelper::ScriptExecutionObserver> 33 ObserverList<extensions::TabHelper::ScriptExecutionObserver>
33 script_observers; 34 script_observers;
34 scoped_ptr<extensions::ScriptExecutor> script_executor( 35 scoped_ptr<extensions::ScriptExecutor> script_executor(
35 new extensions::ScriptExecutor(guest_web_contents, &script_observers)); 36 new extensions::ScriptExecutor(guest_web_contents, &script_observers));
36 37
37 extensions::ScriptExecutor::FrameScope frame_scope = 38 extensions::ScriptExecutor::FrameScope frame_scope =
38 params->details.all_frames.get() && *params->details.all_frames ? 39 params->details.all_frames.get() && *params->details.all_frames ?
39 extensions::ScriptExecutor::ALL_FRAMES : 40 extensions::ScriptExecutor::ALL_FRAMES :
40 extensions::ScriptExecutor::TOP_FRAME; 41 extensions::ScriptExecutor::TOP_FRAME;
41 42
42 extensions::UserScript::RunLocation run_at = 43 extensions::UserScript::RunLocation run_at =
43 extensions::UserScript::UNDEFINED; 44 extensions::UserScript::UNDEFINED;
44 switch (params->details.run_at) { 45 switch (params->details.run_at) {
45 case InjectDetails::RUN_AT_NONE: 46 case tabs::InjectDetails::RUN_AT_NONE:
46 case InjectDetails::RUN_AT_DOCUMENT_IDLE: 47 case tabs::InjectDetails::RUN_AT_DOCUMENT_IDLE:
47 run_at = extensions::UserScript::DOCUMENT_IDLE; 48 run_at = extensions::UserScript::DOCUMENT_IDLE;
48 break; 49 break;
49 case InjectDetails::RUN_AT_DOCUMENT_START: 50 case tabs::InjectDetails::RUN_AT_DOCUMENT_START:
50 run_at = extensions::UserScript::DOCUMENT_START; 51 run_at = extensions::UserScript::DOCUMENT_START;
51 break; 52 break;
52 case InjectDetails::RUN_AT_DOCUMENT_END: 53 case tabs::InjectDetails::RUN_AT_DOCUMENT_END:
53 run_at = extensions::UserScript::DOCUMENT_END; 54 run_at = extensions::UserScript::DOCUMENT_END;
54 break; 55 break;
55 } 56 }
56 CHECK_NE(extensions::UserScript::UNDEFINED, run_at); 57 CHECK_NE(extensions::UserScript::UNDEFINED, run_at);
57 58
58 script_executor->ExecuteScript( 59 script_executor->ExecuteScript(
59 GetExtension()->id(), 60 GetExtension()->id(),
60 extensions::ScriptExecutor::JAVASCRIPT, 61 extensions::ScriptExecutor::JAVASCRIPT,
61 *params->details.code.get(), 62 *params->details.code.get(),
62 frame_scope, 63 frame_scope,
(...skipping 16 matching lines...) Expand all
79 const ListValue& result) { 80 const ListValue& result) {
80 if (error.empty()) { 81 if (error.empty()) {
81 SetResult(result.DeepCopy()); 82 SetResult(result.DeepCopy());
82 } else { 83 } else {
83 SetError(error); 84 SetError(error);
84 } 85 }
85 SendResponse(error.empty()); 86 SendResponse(error.empty());
86 Release(); // Added in RunImpl(). 87 Release(); // Added in RunImpl().
87 } 88 }
88 89
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/app_window.idl » ('j') | tools/json_schema_compiler/cpp_type_generator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698