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

Side by Side Diff: content/renderer/web_ui_extension.cc

Issue 2566583002: Change allowed bindings to be per RenderFrame instead of per RenderView. (Closed)
Patch Set: rebase Created 3 years, 10 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "content/renderer/web_ui_extension.h" 5 #include "content/renderer/web_ui_extension.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
13 #include "content/public/child/v8_value_converter.h" 13 #include "content/public/child/v8_value_converter.h"
14 #include "content/public/common/bindings_policy.h" 14 #include "content/public/common/bindings_policy.h"
15 #include "content/public/common/url_constants.h" 15 #include "content/public/common/url_constants.h"
16 #include "content/public/renderer/chrome_object_extensions_utils.h" 16 #include "content/public/renderer/chrome_object_extensions_utils.h"
17 #include "content/public/renderer/render_frame.h"
17 #include "content/public/renderer/render_thread.h" 18 #include "content/public/renderer/render_thread.h"
18 #include "content/public/renderer/render_view.h" 19 #include "content/public/renderer/render_view.h"
19 #include "content/renderer/web_ui_extension_data.h" 20 #include "content/renderer/web_ui_extension_data.h"
20 #include "gin/arguments.h" 21 #include "gin/arguments.h"
21 #include "gin/function_template.h" 22 #include "gin/function_template.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebKit.h" 24 #include "third_party/WebKit/public/web/WebKit.h"
24 #include "third_party/WebKit/public/web/WebLocalFrame.h" 25 #include "third_party/WebKit/public/web/WebLocalFrame.h"
25 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 26 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
26 #include "third_party/WebKit/public/web/WebView.h" 27 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 10 matching lines...) Expand all
37 blink::WebFrame* frame = blink::WebLocalFrame::frameForCurrentContext(); 38 blink::WebFrame* frame = blink::WebLocalFrame::frameForCurrentContext();
38 if (!frame || !frame->view()) 39 if (!frame || !frame->view())
39 return false; 40 return false;
40 41
41 RenderView* render_view = RenderView::FromWebView(frame->view()); 42 RenderView* render_view = RenderView::FromWebView(frame->view());
42 if (!render_view) 43 if (!render_view)
43 return false; 44 return false;
44 45
45 GURL frame_url = frame->document().url(); 46 GURL frame_url = frame->document().url();
46 47
48 RenderFrame* render_frame = RenderFrame::FromWebFrame(frame);
49 if (!render_frame)
50 return false;
51
47 bool webui_enabled = 52 bool webui_enabled =
48 (render_view->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI) && 53 (render_frame->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI) &&
49 (frame_url.SchemeIs(kChromeUIScheme) || 54 (frame_url.SchemeIs(kChromeUIScheme) ||
50 frame_url.SchemeIs(url::kDataScheme)); 55 frame_url.SchemeIs(url::kDataScheme));
51 56
52 if (!webui_enabled) 57 if (!webui_enabled)
53 return false; 58 return false;
54 59
55 *frame_ptr = frame; 60 *frame_ptr = frame;
56 *render_view_ptr = render_view; 61 *render_view_ptr = render_view;
57 return true; 62 return true;
58 } 63 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::string WebUIExtension::GetVariableValue(const std::string& name) { 139 std::string WebUIExtension::GetVariableValue(const std::string& name) {
135 blink::WebFrame* frame; 140 blink::WebFrame* frame;
136 RenderView* render_view; 141 RenderView* render_view;
137 if (!ShouldRespondToRequest(&frame, &render_view)) 142 if (!ShouldRespondToRequest(&frame, &render_view))
138 return std::string(); 143 return std::string();
139 144
140 return WebUIExtensionData::Get(render_view)->GetValue(name); 145 return WebUIExtensionData::Get(render_view)->GetValue(name);
141 } 146 }
142 147
143 } // namespace content 148 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/shell/browser/layout_test/blink_test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698