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

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

Issue 1113783002: Use Local instead of Handle in src/content/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/renderer/web_ui_mojo.h ('k') | content/renderer/web_ui_mojo_context_state.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 "content/renderer/web_ui_mojo.h" 5 #include "content/renderer/web_ui_mojo.h"
6 6
7 #include "content/common/view_messages.h" 7 #include "content/common/view_messages.h"
8 #include "content/public/renderer/render_frame.h" 8 #include "content/public/renderer/render_frame.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "content/renderer/web_ui_mojo_context_state.h" 10 #include "content/renderer/web_ui_mojo_context_state.h"
(...skipping 18 matching lines...) Expand all
29 WebUIMojo::MainFrameObserver::MainFrameObserver(WebUIMojo* web_ui_mojo) 29 WebUIMojo::MainFrameObserver::MainFrameObserver(WebUIMojo* web_ui_mojo)
30 : RenderFrameObserver(RenderFrame::FromWebFrame( 30 : RenderFrameObserver(RenderFrame::FromWebFrame(
31 web_ui_mojo->render_view()->GetWebView()->mainFrame())), 31 web_ui_mojo->render_view()->GetWebView()->mainFrame())),
32 web_ui_mojo_(web_ui_mojo) { 32 web_ui_mojo_(web_ui_mojo) {
33 } 33 }
34 34
35 WebUIMojo::MainFrameObserver::~MainFrameObserver() { 35 WebUIMojo::MainFrameObserver::~MainFrameObserver() {
36 } 36 }
37 37
38 void WebUIMojo::MainFrameObserver::WillReleaseScriptContext( 38 void WebUIMojo::MainFrameObserver::WillReleaseScriptContext(
39 v8::Handle<v8::Context> context, 39 v8::Local<v8::Context> context,
40 int world_id) { 40 int world_id) {
41 web_ui_mojo_->DestroyContextState(context); 41 web_ui_mojo_->DestroyContextState(context);
42 } 42 }
43 43
44 void WebUIMojo::MainFrameObserver::DidFinishDocumentLoad() { 44 void WebUIMojo::MainFrameObserver::DidFinishDocumentLoad() {
45 web_ui_mojo_->OnDidFinishDocumentLoad(); 45 web_ui_mojo_->OnDidFinishDocumentLoad();
46 } 46 }
47 47
48 WebUIMojo::WebUIMojo(RenderView* render_view) 48 WebUIMojo::WebUIMojo(RenderView* render_view)
49 : RenderViewObserver(render_view), 49 : RenderViewObserver(render_view),
50 RenderViewObserverTracker<WebUIMojo>(render_view), 50 RenderViewObserverTracker<WebUIMojo>(render_view),
51 main_frame_observer_(this) { 51 main_frame_observer_(this) {
52 } 52 }
53 53
54 WebUIMojo::~WebUIMojo() { 54 WebUIMojo::~WebUIMojo() {
55 } 55 }
56 56
57 void WebUIMojo::CreateContextState() { 57 void WebUIMojo::CreateContextState() {
58 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 58 v8::HandleScope handle_scope(blink::mainThreadIsolate());
59 blink::WebLocalFrame* frame = 59 blink::WebLocalFrame* frame =
60 render_view()->GetWebView()->mainFrame()->toWebLocalFrame(); 60 render_view()->GetWebView()->mainFrame()->toWebLocalFrame();
61 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); 61 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
62 gin::PerContextData* context_data = gin::PerContextData::From(context); 62 gin::PerContextData* context_data = gin::PerContextData::From(context);
63 WebUIMojoContextStateData* data = new WebUIMojoContextStateData; 63 WebUIMojoContextStateData* data = new WebUIMojoContextStateData;
64 data->state.reset(new WebUIMojoContextState( 64 data->state.reset(new WebUIMojoContextState(
65 render_view()->GetWebView()->mainFrame(), context)); 65 render_view()->GetWebView()->mainFrame(), context));
66 context_data->SetUserData(kWebUIMojoContextStateKey, data); 66 context_data->SetUserData(kWebUIMojoContextStateKey, data);
67 } 67 }
68 68
69 void WebUIMojo::DestroyContextState(v8::Handle<v8::Context> context) { 69 void WebUIMojo::DestroyContextState(v8::Local<v8::Context> context) {
70 gin::PerContextData* context_data = gin::PerContextData::From(context); 70 gin::PerContextData* context_data = gin::PerContextData::From(context);
71 if (!context_data) 71 if (!context_data)
72 return; 72 return;
73 context_data->RemoveUserData(kWebUIMojoContextStateKey); 73 context_data->RemoveUserData(kWebUIMojoContextStateKey);
74 } 74 }
75 75
76 void WebUIMojo::OnDidFinishDocumentLoad() { 76 void WebUIMojo::OnDidFinishDocumentLoad() {
77 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 77 v8::HandleScope handle_scope(blink::mainThreadIsolate());
78 WebUIMojoContextState* state = GetContextState(); 78 WebUIMojoContextState* state = GetContextState();
79 if (state) 79 if (state)
80 state->Run(); 80 state->Run();
81 } 81 }
82 82
83 WebUIMojoContextState* WebUIMojo::GetContextState() { 83 WebUIMojoContextState* WebUIMojo::GetContextState() {
84 blink::WebLocalFrame* frame = 84 blink::WebLocalFrame* frame =
85 render_view()->GetWebView()->mainFrame()->toWebLocalFrame(); 85 render_view()->GetWebView()->mainFrame()->toWebLocalFrame();
86 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 86 v8::HandleScope handle_scope(blink::mainThreadIsolate());
87 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); 87 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
88 gin::PerContextData* context_data = gin::PerContextData::From(context); 88 gin::PerContextData* context_data = gin::PerContextData::From(context);
89 if (!context_data) 89 if (!context_data)
90 return NULL; 90 return NULL;
91 WebUIMojoContextStateData* context_state = 91 WebUIMojoContextStateData* context_state =
92 static_cast<WebUIMojoContextStateData*>( 92 static_cast<WebUIMojoContextStateData*>(
93 context_data->GetUserData(kWebUIMojoContextStateKey)); 93 context_data->GetUserData(kWebUIMojoContextStateKey));
94 return context_state ? context_state->state.get() : NULL; 94 return context_state ? context_state->state.get() : NULL;
95 } 95 }
96 96
97 void WebUIMojo::DidCreateDocumentElement(blink::WebLocalFrame* frame) { 97 void WebUIMojo::DidCreateDocumentElement(blink::WebLocalFrame* frame) {
(...skipping 13 matching lines...) Expand all
111 // be empty and we don't need to destroy it. 111 // be empty and we don't need to destroy it.
112 WebUIMojoContextState* state = GetContextState(); 112 WebUIMojoContextState* state = GetContextState();
113 if (state && !state->module_added()) 113 if (state && !state->module_added())
114 return; 114 return;
115 115
116 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 116 v8::HandleScope handle_scope(blink::mainThreadIsolate());
117 DestroyContextState(frame->mainWorldScriptContext()); 117 DestroyContextState(frame->mainWorldScriptContext());
118 } 118 }
119 119
120 } // namespace content 120 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/web_ui_mojo.h ('k') | content/renderer/web_ui_mojo_context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698