| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/web_view/frame.h" | 5 #include "components/web_view/frame.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "components/mus/public/cpp/window.h" | 16 #include "components/mus/public/cpp/window.h" |
| 17 #include "components/mus/public/cpp/window_property.h" | 17 #include "components/mus/public/cpp/window_property.h" |
| 18 #include "components/web_view/frame_tree.h" | 18 #include "components/web_view/frame_tree.h" |
| 19 #include "components/web_view/frame_tree_delegate.h" | 19 #include "components/web_view/frame_tree_delegate.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 const uint32_t kNoParentId = 0u; | 37 const uint32_t kNoParentId = 0u; |
| 38 const mus::ConnectionSpecificId kInvalidConnectionId = 0u; | 38 const mus::ConnectionSpecificId kInvalidConnectionId = 0u; |
| 39 | 39 |
| 40 mojom::FrameDataPtr FrameToFrameData(const Frame* frame) { | 40 mojom::FrameDataPtr FrameToFrameData(const Frame* frame) { |
| 41 mojom::FrameDataPtr frame_data(mojom::FrameData::New()); | 41 mojom::FrameDataPtr frame_data(mojom::FrameData::New()); |
| 42 frame_data->frame_id = frame->id(); | 42 frame_data->frame_id = frame->id(); |
| 43 frame_data->parent_id = frame->parent() ? frame->parent()->id() : kNoParentId; | 43 frame_data->parent_id = frame->parent() ? frame->parent()->id() : kNoParentId; |
| 44 frame_data->client_properties = | 44 frame_data->client_properties = |
| 45 mojo::Map<mojo::String, mojo::Array<uint8_t>>::From( | 45 mojo::Map<mojo::String, mojo::Array<uint8_t>>::From( |
| 46 frame->client_properties()); | 46 frame->client_properties()); |
| 47 return frame_data.Pass(); | 47 return frame_data; |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 struct Frame::FrameUserDataAndBinding { | 52 struct Frame::FrameUserDataAndBinding { |
| 53 scoped_ptr<FrameUserData> user_data; | 53 scoped_ptr<FrameUserData> user_data; |
| 54 scoped_ptr<mojo::Binding<mojom::Frame>> frame_binding; | 54 scoped_ptr<mojo::Binding<mojom::Frame>> frame_binding; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 Frame::Frame(FrameTree* tree, | 57 Frame::Frame(FrameTree* tree, |
| 58 Window* window, | 58 Window* window, |
| 59 uint32_t frame_id, | 59 uint32_t frame_id, |
| 60 uint32_t app_id, | 60 uint32_t app_id, |
| 61 WindowOwnership window_ownership, | 61 WindowOwnership window_ownership, |
| 62 mojom::FrameClient* frame_client, | 62 mojom::FrameClient* frame_client, |
| 63 scoped_ptr<FrameUserData> user_data, | 63 scoped_ptr<FrameUserData> user_data, |
| 64 const ClientPropertyMap& client_properties) | 64 const ClientPropertyMap& client_properties) |
| 65 : tree_(tree), | 65 : tree_(tree), |
| 66 window_(nullptr), | 66 window_(nullptr), |
| 67 embedded_connection_id_(kInvalidConnectionId), | 67 embedded_connection_id_(kInvalidConnectionId), |
| 68 id_(frame_id), | 68 id_(frame_id), |
| 69 app_id_(app_id), | 69 app_id_(app_id), |
| 70 parent_(nullptr), | 70 parent_(nullptr), |
| 71 window_ownership_(window_ownership), | 71 window_ownership_(window_ownership), |
| 72 user_data_(user_data.Pass()), | 72 user_data_(std::move(user_data)), |
| 73 frame_client_(frame_client), | 73 frame_client_(frame_client), |
| 74 loading_(false), | 74 loading_(false), |
| 75 progress_(0.f), | 75 progress_(0.f), |
| 76 client_properties_(client_properties), | 76 client_properties_(client_properties), |
| 77 waiting_for_on_will_navigate_ack_(false), | 77 waiting_for_on_will_navigate_ack_(false), |
| 78 embed_weak_ptr_factory_(this), | 78 embed_weak_ptr_factory_(this), |
| 79 navigate_weak_ptr_factory_(this) { | 79 navigate_weak_ptr_factory_(this) { |
| 80 if (window) | 80 if (window) |
| 81 SetWindow(window); | 81 SetWindow(window); |
| 82 } | 82 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 // add before OnConnect(). | 106 // add before OnConnect(). |
| 107 base::AutoReset<mojom::FrameClient*> frame_client_resetter(&frame_client_, | 107 base::AutoReset<mojom::FrameClient*> frame_client_resetter(&frame_client_, |
| 108 nullptr); | 108 nullptr); |
| 109 if (parent) | 109 if (parent) |
| 110 parent->Add(this); | 110 parent->Add(this); |
| 111 } | 111 } |
| 112 | 112 |
| 113 const ClientType client_type = frame_request.is_pending() | 113 const ClientType client_type = frame_request.is_pending() |
| 114 ? ClientType::NEW_CHILD_FRAME | 114 ? ClientType::NEW_CHILD_FRAME |
| 115 : ClientType::EXISTING_FRAME_NEW_APP; | 115 : ClientType::EXISTING_FRAME_NEW_APP; |
| 116 InitClient(client_type, nullptr, window_tree_client.Pass(), | 116 InitClient(client_type, nullptr, std::move(window_tree_client), |
| 117 frame_request.Pass(), navigation_start_time); | 117 std::move(frame_request), navigation_start_time); |
| 118 | 118 |
| 119 tree_->delegate_->DidCreateFrame(this); | 119 tree_->delegate_->DidCreateFrame(this); |
| 120 | 120 |
| 121 DVLOG(2) << "Frame id=" << id_ << " parent=" << (parent_ ? parent_->id_ : 0) | 121 DVLOG(2) << "Frame id=" << id_ << " parent=" << (parent_ ? parent_->id_ : 0) |
| 122 << " app_id=" << app_id_ << " this=" << this; | 122 << " app_id=" << app_id_ << " this=" << this; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | 125 // static |
| 126 Frame* Frame::FindFirstFrameAncestor(Window* window) { | 126 Frame* Frame::FindFirstFrameAncestor(Window* window) { |
| 127 while (window && !window->GetLocalProperty(kFrame)) | 127 while (window && !window->GetLocalProperty(kFrame)) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 for (const Frame* child : children_) | 164 for (const Frame* child : children_) |
| 165 progress += child->GatherProgress(frame_count); | 165 progress += child->GatherProgress(frame_count); |
| 166 return progress_; | 166 return progress_; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void Frame::Find(int32_t request_id, | 169 void Frame::Find(int32_t request_id, |
| 170 const mojo::String& search_text, | 170 const mojo::String& search_text, |
| 171 mojom::FindOptionsPtr options, | 171 mojom::FindOptionsPtr options, |
| 172 bool wrap_within_frame, | 172 bool wrap_within_frame, |
| 173 const FindCallback& callback) { | 173 const FindCallback& callback) { |
| 174 frame_client_->Find(request_id, search_text, options.Pass(), | 174 frame_client_->Find(request_id, search_text, std::move(options), |
| 175 wrap_within_frame, callback); | 175 wrap_within_frame, callback); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void Frame::StopFinding(bool clear_selection) { | 178 void Frame::StopFinding(bool clear_selection) { |
| 179 frame_client_->StopFinding(clear_selection); | 179 frame_client_->StopFinding(clear_selection); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void Frame::HighlightFindResults(int32_t request_id, | 182 void Frame::HighlightFindResults(int32_t request_id, |
| 183 const mojo::String& search_text, | 183 const mojo::String& search_text, |
| 184 mojom::FindOptionsPtr options, | 184 mojom::FindOptionsPtr options, |
| 185 bool reset) { | 185 bool reset) { |
| 186 frame_client_->HighlightFindResults(request_id, search_text, options.Pass(), | 186 frame_client_->HighlightFindResults(request_id, search_text, |
| 187 reset); | 187 std::move(options), reset); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void Frame::StopHighlightingFindResults() { | 190 void Frame::StopHighlightingFindResults() { |
| 191 frame_client_->StopHighlightingFindResults(); | 191 frame_client_->StopHighlightingFindResults(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void Frame::InitClient(ClientType client_type, | 194 void Frame::InitClient(ClientType client_type, |
| 195 scoped_ptr<FrameUserDataAndBinding> data_and_binding, | 195 scoped_ptr<FrameUserDataAndBinding> data_and_binding, |
| 196 mus::mojom::WindowTreeClientPtr window_tree_client, | 196 mus::mojom::WindowTreeClientPtr window_tree_client, |
| 197 mojo::InterfaceRequest<mojom::Frame> frame_request, | 197 mojo::InterfaceRequest<mojom::Frame> frame_request, |
| 198 base::TimeTicks navigation_start_time) { | 198 base::TimeTicks navigation_start_time) { |
| 199 if (client_type == ClientType::EXISTING_FRAME_NEW_APP && window_tree_client) { | 199 if (client_type == ClientType::EXISTING_FRAME_NEW_APP && window_tree_client) { |
| 200 embedded_connection_id_ = kInvalidConnectionId; | 200 embedded_connection_id_ = kInvalidConnectionId; |
| 201 embed_weak_ptr_factory_.InvalidateWeakPtrs(); | 201 embed_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 202 window_->Embed( | 202 window_->Embed( |
| 203 window_tree_client.Pass(), | 203 std::move(window_tree_client), |
| 204 mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT, | 204 mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT, |
| 205 base::Bind(&Frame::OnEmbedAck, embed_weak_ptr_factory_.GetWeakPtr())); | 205 base::Bind(&Frame::OnEmbedAck, embed_weak_ptr_factory_.GetWeakPtr())); |
| 206 } | 206 } |
| 207 | 207 |
| 208 if (client_type == ClientType::NEW_CHILD_FRAME) { | 208 if (client_type == ClientType::NEW_CHILD_FRAME) { |
| 209 // Don't install an error handler. We allow for the target to only | 209 // Don't install an error handler. We allow for the target to only |
| 210 // implement WindowTreeClient. | 210 // implement WindowTreeClient. |
| 211 // This frame (and client) was created by an existing FrameClient. There | 211 // This frame (and client) was created by an existing FrameClient. There |
| 212 // is no need to send it OnConnect(). | 212 // is no need to send it OnConnect(). |
| 213 frame_binding_.reset( | 213 frame_binding_.reset( |
| 214 new mojo::Binding<mojom::Frame>(this, frame_request.Pass())); | 214 new mojo::Binding<mojom::Frame>(this, std::move(frame_request))); |
| 215 frame_client_->OnConnect( | 215 frame_client_->OnConnect( |
| 216 nullptr, tree_->change_id(), id_, mojom::WINDOW_CONNECT_TYPE_USE_NEW, | 216 nullptr, tree_->change_id(), id_, mojom::WINDOW_CONNECT_TYPE_USE_NEW, |
| 217 mojo::Array<mojom::FrameDataPtr>(), | 217 mojo::Array<mojom::FrameDataPtr>(), |
| 218 navigation_start_time.ToInternalValue(), | 218 navigation_start_time.ToInternalValue(), |
| 219 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); | 219 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); |
| 220 } else { | 220 } else { |
| 221 std::vector<const Frame*> frames; | 221 std::vector<const Frame*> frames; |
| 222 tree_->root()->BuildFrameTree(&frames); | 222 tree_->root()->BuildFrameTree(&frames); |
| 223 | 223 |
| 224 mojo::Array<mojom::FrameDataPtr> array(frames.size()); | 224 mojo::Array<mojom::FrameDataPtr> array(frames.size()); |
| 225 for (size_t i = 0; i < frames.size(); ++i) | 225 for (size_t i = 0; i < frames.size(); ++i) |
| 226 array[i] = FrameToFrameData(frames[i]).Pass(); | 226 array[i] = FrameToFrameData(frames[i]); |
| 227 | 227 |
| 228 mojom::FramePtr frame_ptr; | 228 mojom::FramePtr frame_ptr; |
| 229 // Don't install an error handler. We allow for the target to only | 229 // Don't install an error handler. We allow for the target to only |
| 230 // implement WindowTreeClient. | 230 // implement WindowTreeClient. |
| 231 frame_binding_.reset( | 231 frame_binding_.reset( |
| 232 new mojo::Binding<mojom::Frame>(this, GetProxy(&frame_ptr).Pass())); | 232 new mojo::Binding<mojom::Frame>(this, GetProxy(&frame_ptr))); |
| 233 frame_client_->OnConnect( | 233 frame_client_->OnConnect( |
| 234 frame_ptr.Pass(), tree_->change_id(), id_, | 234 std::move(frame_ptr), tree_->change_id(), id_, |
| 235 client_type == ClientType::EXISTING_FRAME_SAME_APP | 235 client_type == ClientType::EXISTING_FRAME_SAME_APP |
| 236 ? mojom::WINDOW_CONNECT_TYPE_USE_EXISTING | 236 ? mojom::WINDOW_CONNECT_TYPE_USE_EXISTING |
| 237 : mojom::WINDOW_CONNECT_TYPE_USE_NEW, | 237 : mojom::WINDOW_CONNECT_TYPE_USE_NEW, |
| 238 array.Pass(), navigation_start_time.ToInternalValue(), | 238 std::move(array), navigation_start_time.ToInternalValue(), |
| 239 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); | 239 base::Bind(&OnConnectAck, base::Passed(&data_and_binding))); |
| 240 tree_->delegate_->DidStartNavigation(this); | 240 tree_->delegate_->DidStartNavigation(this); |
| 241 | 241 |
| 242 // We need |embedded_connection_id_| is order to validate requests to | 242 // We need |embedded_connection_id_| is order to validate requests to |
| 243 // create a child frame (OnCreatedFrame()). Pause incoming methods until | 243 // create a child frame (OnCreatedFrame()). Pause incoming methods until |
| 244 // we get the id to prevent race conditions. | 244 // we get the id to prevent race conditions. |
| 245 if (embedded_connection_id_ == kInvalidConnectionId) | 245 if (embedded_connection_id_ == kInvalidConnectionId) |
| 246 frame_binding_->PauseIncomingMethodCallProcessing(); | 246 frame_binding_->PauseIncomingMethodCallProcessing(); |
| 247 } | 247 } |
| 248 } | 248 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 260 delete children_[0]; | 260 delete children_[0]; |
| 261 | 261 |
| 262 ClientType client_type = !window_tree_client | 262 ClientType client_type = !window_tree_client |
| 263 ? ClientType::EXISTING_FRAME_SAME_APP | 263 ? ClientType::EXISTING_FRAME_SAME_APP |
| 264 : ClientType::EXISTING_FRAME_NEW_APP; | 264 : ClientType::EXISTING_FRAME_NEW_APP; |
| 265 scoped_ptr<FrameUserDataAndBinding> data_and_binding; | 265 scoped_ptr<FrameUserDataAndBinding> data_and_binding; |
| 266 | 266 |
| 267 if (client_type == ClientType::EXISTING_FRAME_SAME_APP) { | 267 if (client_type == ClientType::EXISTING_FRAME_SAME_APP) { |
| 268 // See comment in InitClient() for details. | 268 // See comment in InitClient() for details. |
| 269 data_and_binding.reset(new FrameUserDataAndBinding); | 269 data_and_binding.reset(new FrameUserDataAndBinding); |
| 270 data_and_binding->user_data = user_data_.Pass(); | 270 data_and_binding->user_data = std::move(user_data_); |
| 271 data_and_binding->frame_binding = frame_binding_.Pass(); | 271 data_and_binding->frame_binding = std::move(frame_binding_); |
| 272 } else { | 272 } else { |
| 273 loading_ = false; | 273 loading_ = false; |
| 274 progress_ = 0.f; | 274 progress_ = 0.f; |
| 275 } | 275 } |
| 276 | 276 |
| 277 user_data_ = user_data.Pass(); | 277 user_data_ = std::move(user_data); |
| 278 frame_client_ = frame_client; | 278 frame_client_ = frame_client; |
| 279 frame_binding_.reset(); | 279 frame_binding_.reset(); |
| 280 app_id_ = app_id; | 280 app_id_ = app_id; |
| 281 | 281 |
| 282 InitClient(client_type, data_and_binding.Pass(), window_tree_client.Pass(), | 282 InitClient(client_type, std::move(data_and_binding), |
| 283 nullptr, navigation_start_time); | 283 std::move(window_tree_client), nullptr, navigation_start_time); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void Frame::OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id) { | 286 void Frame::OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id) { |
| 287 if (success) | 287 if (success) |
| 288 embedded_connection_id_ = connection_id; | 288 embedded_connection_id_ = connection_id; |
| 289 if (frame_binding_->is_bound()) | 289 if (frame_binding_->is_bound()) |
| 290 frame_binding_->ResumeIncomingMethodCallProcessing(); | 290 frame_binding_->ResumeIncomingMethodCallProcessing(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void Frame::OnWillNavigateAck( | 293 void Frame::OnWillNavigateAck( |
| 294 mojom::FrameClient* frame_client, | 294 mojom::FrameClient* frame_client, |
| 295 scoped_ptr<FrameUserData> user_data, | 295 scoped_ptr<FrameUserData> user_data, |
| 296 mus::mojom::WindowTreeClientPtr window_tree_client, | 296 mus::mojom::WindowTreeClientPtr window_tree_client, |
| 297 uint32_t app_id, | 297 uint32_t app_id, |
| 298 base::TimeTicks navigation_start_time) { | 298 base::TimeTicks navigation_start_time) { |
| 299 DCHECK(waiting_for_on_will_navigate_ack_); | 299 DCHECK(waiting_for_on_will_navigate_ack_); |
| 300 DVLOG(2) << "Frame::OnWillNavigateAck id=" << id_; | 300 DVLOG(2) << "Frame::OnWillNavigateAck id=" << id_; |
| 301 waiting_for_on_will_navigate_ack_ = false; | 301 waiting_for_on_will_navigate_ack_ = false; |
| 302 ChangeClient(frame_client, user_data.Pass(), window_tree_client.Pass(), | 302 ChangeClient(frame_client, std::move(user_data), |
| 303 app_id, navigation_start_time); | 303 std::move(window_tree_client), app_id, navigation_start_time); |
| 304 if (pending_navigate_.get()) | 304 if (pending_navigate_.get()) |
| 305 StartNavigate(pending_navigate_.Pass()); | 305 StartNavigate(std::move(pending_navigate_)); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void Frame::SetWindow(mus::Window* window) { | 308 void Frame::SetWindow(mus::Window* window) { |
| 309 DCHECK(!window_); | 309 DCHECK(!window_); |
| 310 DCHECK_EQ(id_, window->id()); | 310 DCHECK_EQ(id_, window->id()); |
| 311 window_ = window; | 311 window_ = window; |
| 312 window_->SetLocalProperty(kFrame, this); | 312 window_->SetLocalProperty(kFrame, this); |
| 313 window_->AddObserver(this); | 313 window_->AddObserver(this); |
| 314 if (pending_navigate_.get()) | 314 if (pending_navigate_.get()) |
| 315 StartNavigate(pending_navigate_.Pass()); | 315 StartNavigate(std::move(pending_navigate_)); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void Frame::BuildFrameTree(std::vector<const Frame*>* frames) const { | 318 void Frame::BuildFrameTree(std::vector<const Frame*>* frames) const { |
| 319 frames->push_back(this); | 319 frames->push_back(this); |
| 320 for (const Frame* frame : children_) | 320 for (const Frame* frame : children_) |
| 321 frame->BuildFrameTree(frames); | 321 frame->BuildFrameTree(frames); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void Frame::Add(Frame* node) { | 324 void Frame::Add(Frame* node) { |
| 325 DCHECK(!node->parent_); | 325 DCHECK(!node->parent_); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 337 node->parent_ = nullptr; | 337 node->parent_ = nullptr; |
| 338 children_.erase(iter); | 338 children_.erase(iter); |
| 339 | 339 |
| 340 tree_->root()->NotifyRemoved(this, node, tree_->AdvanceChangeID()); | 340 tree_->root()->NotifyRemoved(this, node, tree_->AdvanceChangeID()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 void Frame::StartNavigate(mojo::URLRequestPtr request) { | 343 void Frame::StartNavigate(mojo::URLRequestPtr request) { |
| 344 if (waiting_for_on_will_navigate_ack_) { | 344 if (waiting_for_on_will_navigate_ack_) { |
| 345 // We're waiting for OnWillNavigate(). We need to wait until that completes | 345 // We're waiting for OnWillNavigate(). We need to wait until that completes |
| 346 // before attempting any other loads. | 346 // before attempting any other loads. |
| 347 pending_navigate_ = request.Pass(); | 347 pending_navigate_ = std::move(request); |
| 348 return; | 348 return; |
| 349 } | 349 } |
| 350 | 350 |
| 351 pending_navigate_.reset(); | 351 pending_navigate_.reset(); |
| 352 | 352 |
| 353 // We need a Window to navigate. When we get the Window we'll complete the | 353 // We need a Window to navigate. When we get the Window we'll complete the |
| 354 // navigation. | 354 // navigation. |
| 355 if (!window_) { | 355 if (!window_) { |
| 356 pending_navigate_ = request.Pass(); | 356 pending_navigate_ = std::move(request); |
| 357 return; | 357 return; |
| 358 } | 358 } |
| 359 | 359 |
| 360 // Drop any pending navigation requests. | 360 // Drop any pending navigation requests. |
| 361 navigate_weak_ptr_factory_.InvalidateWeakPtrs(); | 361 navigate_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 362 | 362 |
| 363 DVLOG(2) << "Frame::StartNavigate id=" << id_ << " url=" << request->url; | 363 DVLOG(2) << "Frame::StartNavigate id=" << id_ << " url=" << request->url; |
| 364 | 364 |
| 365 const GURL requested_url(request->url); | 365 const GURL requested_url(request->url); |
| 366 base::TimeTicks navigation_start_time = | 366 base::TimeTicks navigation_start_time = |
| 367 base::TimeTicks::FromInternalValue(request->originating_time_ticks); | 367 base::TimeTicks::FromInternalValue(request->originating_time_ticks); |
| 368 tree_->delegate_->CanNavigateFrame( | 368 tree_->delegate_->CanNavigateFrame( |
| 369 this, request.Pass(), base::Bind(&Frame::OnCanNavigateFrame, | 369 this, std::move(request), |
| 370 navigate_weak_ptr_factory_.GetWeakPtr(), | 370 base::Bind(&Frame::OnCanNavigateFrame, |
| 371 requested_url, navigation_start_time)); | 371 navigate_weak_ptr_factory_.GetWeakPtr(), requested_url, |
| 372 navigation_start_time)); |
| 372 } | 373 } |
| 373 | 374 |
| 374 void Frame::OnCanNavigateFrame( | 375 void Frame::OnCanNavigateFrame( |
| 375 const GURL& url, | 376 const GURL& url, |
| 376 base::TimeTicks navigation_start_time, | 377 base::TimeTicks navigation_start_time, |
| 377 uint32_t app_id, | 378 uint32_t app_id, |
| 378 mojom::FrameClient* frame_client, | 379 mojom::FrameClient* frame_client, |
| 379 scoped_ptr<FrameUserData> user_data, | 380 scoped_ptr<FrameUserData> user_data, |
| 380 mus::mojom::WindowTreeClientPtr window_tree_client) { | 381 mus::mojom::WindowTreeClientPtr window_tree_client) { |
| 381 TRACE_EVENT1("web_view", "Frame::OnCanNavigateFrame", | 382 TRACE_EVENT1("web_view", "Frame::OnCanNavigateFrame", |
| 382 "url", url.possibly_invalid_spec()); | 383 "url", url.possibly_invalid_spec()); |
| 383 | 384 |
| 384 DVLOG(2) << "Frame::OnCanNavigateFrame id=" << id_ | 385 DVLOG(2) << "Frame::OnCanNavigateFrame id=" << id_ |
| 385 << " equal=" << (AreAppIdsEqual(app_id, app_id_) ? "true" : "false"); | 386 << " equal=" << (AreAppIdsEqual(app_id, app_id_) ? "true" : "false"); |
| 386 if (AreAppIdsEqual(app_id, app_id_)) { | 387 if (AreAppIdsEqual(app_id, app_id_)) { |
| 387 // The app currently rendering the frame will continue rendering it. In this | 388 // The app currently rendering the frame will continue rendering it. In this |
| 388 // case we do not use the WindowTreeClient (because the app has a Window | 389 // case we do not use the WindowTreeClient (because the app has a Window |
| 389 // already | 390 // already |
| 390 // and ends up reusing it). | 391 // and ends up reusing it). |
| 391 DCHECK(!window_tree_client); | 392 DCHECK(!window_tree_client); |
| 392 ChangeClient(frame_client, user_data.Pass(), window_tree_client.Pass(), | 393 ChangeClient(frame_client, std::move(user_data), |
| 393 app_id, navigation_start_time); | 394 std::move(window_tree_client), app_id, navigation_start_time); |
| 394 } else { | 395 } else { |
| 395 waiting_for_on_will_navigate_ack_ = true; | 396 waiting_for_on_will_navigate_ack_ = true; |
| 396 DCHECK(window_tree_client); | 397 DCHECK(window_tree_client); |
| 397 // TODO(sky): url isn't correct here, it should be a security origin. | 398 // TODO(sky): url isn't correct here, it should be a security origin. |
| 398 frame_client_->OnWillNavigate( | 399 frame_client_->OnWillNavigate( |
| 399 url.spec(), | 400 url.spec(), |
| 400 base::Bind(&Frame::OnWillNavigateAck, base::Unretained(this), | 401 base::Bind(&Frame::OnWillNavigateAck, base::Unretained(this), |
| 401 frame_client, base::Passed(&user_data), | 402 frame_client, base::Passed(&user_data), |
| 402 base::Passed(&window_tree_client), app_id, | 403 base::Passed(&window_tree_client), app_id, |
| 403 navigation_start_time)); | 404 navigation_start_time)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 482 } |
| 482 | 483 |
| 483 void Frame::PostMessageEventToFrame(uint32_t target_frame_id, | 484 void Frame::PostMessageEventToFrame(uint32_t target_frame_id, |
| 484 mojom::HTMLMessageEventPtr event) { | 485 mojom::HTMLMessageEventPtr event) { |
| 485 // NOTE: |target_frame_id| is allowed to be from another connection. | 486 // NOTE: |target_frame_id| is allowed to be from another connection. |
| 486 Frame* target = tree_->root()->FindFrame(target_frame_id); | 487 Frame* target = tree_->root()->FindFrame(target_frame_id); |
| 487 if (!target || target == this || | 488 if (!target || target == this || |
| 488 !tree_->delegate_->CanPostMessageEventToFrame(this, target, event.get())) | 489 !tree_->delegate_->CanPostMessageEventToFrame(this, target, event.get())) |
| 489 return; | 490 return; |
| 490 | 491 |
| 491 target->frame_client_->OnPostMessageEvent(id_, target_frame_id, event.Pass()); | 492 target->frame_client_->OnPostMessageEvent(id_, target_frame_id, |
| 493 std::move(event)); |
| 492 } | 494 } |
| 493 | 495 |
| 494 void Frame::LoadingStateChanged(bool loading, double progress) { | 496 void Frame::LoadingStateChanged(bool loading, double progress) { |
| 495 bool loading_state_changed = loading_ != loading; | 497 bool loading_state_changed = loading_ != loading; |
| 496 loading_ = loading; | 498 loading_ = loading; |
| 497 progress_ = progress; | 499 progress_ = progress; |
| 498 tree_->LoadingStateChanged(); | 500 tree_->LoadingStateChanged(); |
| 499 | 501 |
| 500 if (loading_state_changed && parent_ && | 502 if (loading_state_changed && parent_ && |
| 501 !AreAppIdsEqual(app_id_, parent_->app_id_)) { | 503 !AreAppIdsEqual(app_id_, parent_->app_id_)) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 return; | 548 return; |
| 547 } | 549 } |
| 548 | 550 |
| 549 if (FindFrame(frame_id)) { | 551 if (FindFrame(frame_id)) { |
| 550 // TODO(sky): kill connection here? | 552 // TODO(sky): kill connection here? |
| 551 DVLOG(1) << "OnCreatedFrame supplied id of existing frame."; | 553 DVLOG(1) << "OnCreatedFrame supplied id of existing frame."; |
| 552 return; | 554 return; |
| 553 } | 555 } |
| 554 | 556 |
| 555 Frame* child_frame = tree_->CreateChildFrame( | 557 Frame* child_frame = tree_->CreateChildFrame( |
| 556 this, frame_request.Pass(), client.Pass(), frame_id, app_id_, | 558 this, std::move(frame_request), std::move(client), frame_id, app_id_, |
| 557 client_properties.To<ClientPropertyMap>()); | 559 client_properties.To<ClientPropertyMap>()); |
| 558 child_frame->embedded_connection_id_ = embedded_connection_id_; | 560 child_frame->embedded_connection_id_ = embedded_connection_id_; |
| 559 } | 561 } |
| 560 | 562 |
| 561 void Frame::RequestNavigate(mojom::NavigationTargetType target_type, | 563 void Frame::RequestNavigate(mojom::NavigationTargetType target_type, |
| 562 uint32_t target_frame_id, | 564 uint32_t target_frame_id, |
| 563 mojo::URLRequestPtr request) { | 565 mojo::URLRequestPtr request) { |
| 564 if (target_type == mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME) { | 566 if (target_type == mojom::NAVIGATION_TARGET_TYPE_EXISTING_FRAME) { |
| 565 // |target_frame| is allowed to come from another connection. | 567 // |target_frame| is allowed to come from another connection. |
| 566 Frame* target_frame = tree_->root()->FindFrame(target_frame_id); | 568 Frame* target_frame = tree_->root()->FindFrame(target_frame_id); |
| 567 if (!target_frame) { | 569 if (!target_frame) { |
| 568 DVLOG(1) << "RequestNavigate EXISTING_FRAME with no matching frame"; | 570 DVLOG(1) << "RequestNavigate EXISTING_FRAME with no matching frame"; |
| 569 return; | 571 return; |
| 570 } | 572 } |
| 571 if (target_frame != tree_->root()) { | 573 if (target_frame != tree_->root()) { |
| 572 target_frame->StartNavigate(request.Pass()); | 574 target_frame->StartNavigate(std::move(request)); |
| 573 return; | 575 return; |
| 574 } | 576 } |
| 575 // Else case if |target_frame| == root. Treat at top level request. | 577 // Else case if |target_frame| == root. Treat at top level request. |
| 576 } | 578 } |
| 577 tree_->delegate_->NavigateTopLevel(this, request.Pass()); | 579 tree_->delegate_->NavigateTopLevel(this, std::move(request)); |
| 578 } | 580 } |
| 579 | 581 |
| 580 void Frame::DidNavigateLocally(const mojo::String& url) { | 582 void Frame::DidNavigateLocally(const mojo::String& url) { |
| 581 tree_->DidNavigateLocally(this, url.To<GURL>()); | 583 tree_->DidNavigateLocally(this, url.To<GURL>()); |
| 582 } | 584 } |
| 583 | 585 |
| 584 void Frame::DispatchLoadEventToParent() { | 586 void Frame::DispatchLoadEventToParent() { |
| 585 if (parent_ && !AreAppIdsEqual(app_id_, parent_->app_id_)) { | 587 if (parent_ && !AreAppIdsEqual(app_id_, parent_->app_id_)) { |
| 586 // Send notification to fire a load event in the parent, if the parent is in | 588 // Send notification to fire a load event in the parent, if the parent is in |
| 587 // a different app. If the parent is in the same app, we assume that the app | 589 // a different app. If the parent is in the same app, we assume that the app |
| (...skipping 10 matching lines...) Expand all Loading... |
| 598 final_update); | 600 final_update); |
| 599 } | 601 } |
| 600 | 602 |
| 601 void Frame::OnFindInPageSelectionUpdated(int32_t request_id, | 603 void Frame::OnFindInPageSelectionUpdated(int32_t request_id, |
| 602 int32_t active_match_ordinal) { | 604 int32_t active_match_ordinal) { |
| 603 tree_->delegate_->OnFindInPageSelectionUpdated(request_id, this, | 605 tree_->delegate_->OnFindInPageSelectionUpdated(request_id, this, |
| 604 active_match_ordinal); | 606 active_match_ordinal); |
| 605 } | 607 } |
| 606 | 608 |
| 607 } // namespace web_view | 609 } // namespace web_view |
| OLD | NEW |