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

Side by Side Diff: extensions/renderer/api/automation/automation_api_helper.cc

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Split a DCHECK in two as suggested by boliu@. Created 3 years, 6 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
« no previous file with comments | « content/test/layouttest_support.cc ('k') | extensions/renderer/script_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer/api/automation/automation_api_helper.h" 5 #include "extensions/renderer/api/automation/automation_api_helper.h"
6 6
7 #include "content/public/renderer/render_view.h" 7 #include "content/public/renderer/render_view.h"
8 #include "extensions/common/extension_messages.h" 8 #include "extensions/common/extension_messages.h"
9 #include "third_party/WebKit/public/web/WebAXObject.h" 9 #include "third_party/WebKit/public/web/WebAXObject.h"
10 #include "third_party/WebKit/public/web/WebDocument.h" 10 #include "third_party/WebKit/public/web/WebDocument.h"
11 #include "third_party/WebKit/public/web/WebElement.h" 11 #include "third_party/WebKit/public/web/WebElement.h"
12 #include "third_party/WebKit/public/web/WebExceptionCode.h" 12 #include "third_party/WebKit/public/web/WebExceptionCode.h"
13 #include "third_party/WebKit/public/web/WebFrame.h" 13 #include "third_party/WebKit/public/web/WebLocalFrame.h"
14 #include "third_party/WebKit/public/web/WebNode.h" 14 #include "third_party/WebKit/public/web/WebNode.h"
15 #include "third_party/WebKit/public/web/WebView.h" 15 #include "third_party/WebKit/public/web/WebView.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 AutomationApiHelper::AutomationApiHelper(content::RenderView* render_view) 19 AutomationApiHelper::AutomationApiHelper(content::RenderView* render_view)
20 : content::RenderViewObserver(render_view) { 20 : content::RenderViewObserver(render_view) {
21 } 21 }
22 22
23 AutomationApiHelper::~AutomationApiHelper() { 23 AutomationApiHelper::~AutomationApiHelper() {
(...skipping 16 matching lines...) Expand all
40 int acc_obj_id, 40 int acc_obj_id,
41 const base::string16& selector) { 41 const base::string16& selector) {
42 ExtensionHostMsg_AutomationQuerySelector_Error error; 42 ExtensionHostMsg_AutomationQuerySelector_Error error;
43 if (!render_view() || !render_view()->GetWebView() || 43 if (!render_view() || !render_view()->GetWebView() ||
44 !render_view()->GetWebView()->MainFrame()) { 44 !render_view()->GetWebView()->MainFrame()) {
45 error.value = ExtensionHostMsg_AutomationQuerySelector_Error::kNoMainFrame; 45 error.value = ExtensionHostMsg_AutomationQuerySelector_Error::kNoMainFrame;
46 Send(new ExtensionHostMsg_AutomationQuerySelector_Result( 46 Send(new ExtensionHostMsg_AutomationQuerySelector_Result(
47 routing_id(), request_id, error, 0)); 47 routing_id(), request_id, error, 0));
48 return; 48 return;
49 } 49 }
50 blink::WebDocument document = 50
51 render_view()->GetWebView()->MainFrame()->GetDocument(); 51 // ExtensionMsg_AutomationQuerySelector should only be sent to an active view.
52 DCHECK(render_view()->GetWebView()->MainFrame()->IsWebLocalFrame());
53
54 blink::WebDocument document = render_view()
55 ->GetWebView()
56 ->MainFrame()
57 ->ToWebLocalFrame()
58 ->GetDocument();
52 if (document.IsNull()) { 59 if (document.IsNull()) {
53 error.value = ExtensionHostMsg_AutomationQuerySelector_Error::kNoDocument; 60 error.value = ExtensionHostMsg_AutomationQuerySelector_Error::kNoDocument;
54 Send(new ExtensionHostMsg_AutomationQuerySelector_Result( 61 Send(new ExtensionHostMsg_AutomationQuerySelector_Result(
55 routing_id(), request_id, error, 0)); 62 routing_id(), request_id, error, 0));
56 return; 63 return;
57 } 64 }
58 blink::WebNode start_node = document; 65 blink::WebNode start_node = document;
59 if (acc_obj_id > 0) { 66 if (acc_obj_id > 0) {
60 blink::WebAXObject start_acc_obj = 67 blink::WebAXObject start_acc_obj =
61 blink::WebAXObject::FromWebDocumentByID(document, acc_obj_id); 68 blink::WebAXObject::FromWebDocumentByID(document, acc_obj_id);
(...skipping 21 matching lines...) Expand all
83 result_acc_obj = result_acc_obj.ParentObject(); 90 result_acc_obj = result_acc_obj.ParentObject();
84 91
85 result_acc_obj_id = result_acc_obj.AxID(); 92 result_acc_obj_id = result_acc_obj.AxID();
86 } 93 }
87 } 94 }
88 Send(new ExtensionHostMsg_AutomationQuerySelector_Result( 95 Send(new ExtensionHostMsg_AutomationQuerySelector_Result(
89 routing_id(), request_id, error, result_acc_obj_id)); 96 routing_id(), request_id, error, result_acc_obj_id));
90 } 97 }
91 98
92 } // namespace extensions 99 } // namespace extensions
OLDNEW
« no previous file with comments | « content/test/layouttest_support.cc ('k') | extensions/renderer/script_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698