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 "blimp/engine/browser/blimp_engine_session.h" | 5 #include "blimp/engine/browser/blimp_engine_session.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | |
7 #include "blimp/common/proto/blimp_message.pb.h" | 8 #include "blimp/common/proto/blimp_message.pb.h" |
8 #include "blimp/common/proto/control.pb.h" | 9 #include "blimp/common/proto/control.pb.h" |
9 #include "blimp/engine/browser/blimp_browser_context.h" | 10 #include "blimp/engine/browser/blimp_browser_context.h" |
10 #include "blimp/engine/ui/blimp_layout_manager.h" | 11 #include "blimp/engine/ui/blimp_layout_manager.h" |
11 #include "blimp/engine/ui/blimp_screen.h" | 12 #include "blimp/engine/ui/blimp_screen.h" |
12 #include "blimp/engine/ui/blimp_ui_context_factory.h" | 13 #include "blimp/engine/ui/blimp_ui_context_factory.h" |
13 #include "blimp/net/blimp_connection.h" | 14 #include "blimp/net/blimp_connection.h" |
14 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/render_widget_host.h" | 19 #include "content/public/browser/render_widget_host.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 #include "net/base/net_errors.h" | |
20 #include "ui/aura/client/default_capture_client.h" | 22 #include "ui/aura/client/default_capture_client.h" |
21 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
22 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
23 #include "ui/aura/window_tree_host.h" | 25 #include "ui/aura/window_tree_host.h" |
24 #include "ui/wm/core/base_focus_rules.h" | 26 #include "ui/wm/core/base_focus_rules.h" |
25 #include "ui/wm/core/default_activation_client.h" | 27 #include "ui/wm/core/default_activation_client.h" |
26 #include "ui/wm/core/focus_controller.h" | 28 #include "ui/wm/core/focus_controller.h" |
27 | 29 |
28 #if !defined(USE_X11) | 30 #if !defined(USE_X11) |
29 #include "blimp/engine/ui/blimp_window_tree_host.h" | 31 #include "blimp/engine/ui/blimp_window_tree_host.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 void BlimpEngineSession::AttachClientConnection( | 91 void BlimpEngineSession::AttachClientConnection( |
90 scoped_ptr<BlimpConnection> client_connection) { | 92 scoped_ptr<BlimpConnection> client_connection) { |
91 DCHECK(client_connection); | 93 DCHECK(client_connection); |
92 client_connection_ = client_connection.Pass(); | 94 client_connection_ = client_connection.Pass(); |
93 | 95 |
94 // TODO(haibinlu): Remove this once we can use client connection to send in | 96 // TODO(haibinlu): Remove this once we can use client connection to send in |
95 // a navigation message. | 97 // a navigation message. |
96 BlimpMessage message; | 98 BlimpMessage message; |
97 message.set_type(BlimpMessage::CONTROL); | 99 message.set_type(BlimpMessage::CONTROL); |
98 message.mutable_control()->set_type(ControlMessage::CREATE_TAB); | 100 message.mutable_control()->set_type(ControlMessage::CREATE_TAB); |
99 OnBlimpMessage(message); | 101 ProcessMessage(message, base::Callback<void(int)>()); |
haibinlu
2015/11/04 20:33:20
net::CompletionCallback() ?
Kevin M
2015/11/04 20:49:48
Done.
| |
100 message.mutable_control()->set_type(ControlMessage::LOAD_URL); | 102 message.mutable_control()->set_type(ControlMessage::LOAD_URL); |
101 message.mutable_control()->mutable_load_url()->set_url( | 103 message.mutable_control()->mutable_load_url()->set_url( |
102 "https://www.google.com/"); | 104 "https://www.google.com/"); |
103 OnBlimpMessage(message); | 105 ProcessMessage(message, base::Callback<void(int)>()); |
104 } | 106 } |
105 | 107 |
106 void BlimpEngineSession::CreateWebContents(const int target_tab_id) { | 108 void BlimpEngineSession::CreateWebContents(const int target_tab_id) { |
107 // TODO(haibinlu): Support more than one active WebContents (crbug/547231). | 109 // TODO(haibinlu): Support more than one active WebContents (crbug/547231). |
108 DCHECK(!web_contents_); | 110 DCHECK(!web_contents_); |
109 content::WebContents::CreateParams create_params(browser_context_.get(), | 111 content::WebContents::CreateParams create_params(browser_context_.get(), |
110 nullptr); | 112 nullptr); |
111 scoped_ptr<content::WebContents> new_contents = | 113 scoped_ptr<content::WebContents> new_contents = |
112 make_scoped_ptr(content::WebContents::Create(create_params)); | 114 make_scoped_ptr(content::WebContents::Create(create_params)); |
113 PlatformSetContents(new_contents.Pass()); | 115 PlatformSetContents(new_contents.Pass()); |
114 } | 116 } |
115 | 117 |
116 void BlimpEngineSession::LoadUrl(const int target_tab_id, const GURL& url) { | 118 void BlimpEngineSession::LoadUrl(const int target_tab_id, const GURL& url) { |
117 if (url.is_empty() || !web_contents_) | 119 if (url.is_empty() || !web_contents_) |
118 return; | 120 return; |
119 | 121 |
120 content::NavigationController::LoadURLParams params(url); | 122 content::NavigationController::LoadURLParams params(url); |
121 params.transition_type = ui::PageTransitionFromInt( | 123 params.transition_type = ui::PageTransitionFromInt( |
122 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 124 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
123 web_contents_->GetController().LoadURLWithParams(params); | 125 web_contents_->GetController().LoadURLWithParams(params); |
124 web_contents_->Focus(); | 126 web_contents_->Focus(); |
125 } | 127 } |
126 | 128 |
127 net::Error BlimpEngineSession::OnBlimpMessage(const BlimpMessage& message) { | 129 void BlimpEngineSession::ProcessMessage( |
130 const BlimpMessage& message, | |
131 const net::CompletionCallback& callback) { | |
128 DCHECK(message.type() == BlimpMessage::CONTROL); | 132 DCHECK(message.type() == BlimpMessage::CONTROL); |
129 | 133 |
130 switch (message.control().type()) { | 134 switch (message.control().type()) { |
131 case ControlMessage::CREATE_TAB: | 135 case ControlMessage::CREATE_TAB: |
132 CreateWebContents(message.target_tab_id()); | 136 CreateWebContents(message.target_tab_id()); |
133 break; | 137 break; |
134 case ControlMessage::LOAD_URL: | 138 case ControlMessage::LOAD_URL: |
135 LoadUrl(message.target_tab_id(), | 139 LoadUrl(message.target_tab_id(), |
136 GURL(message.control().load_url().url())); | 140 GURL(message.control().load_url().url())); |
137 break; | 141 break; |
138 default: | 142 default: |
139 NOTIMPLEMENTED(); | 143 NOTIMPLEMENTED(); |
140 } | 144 } |
haibinlu
2015/11/04 20:33:20
invoke callback with net::OK?
Kevin M
2015/11/04 20:49:48
Done.
| |
141 | |
142 return net::OK; | |
143 } | 145 } |
144 | 146 |
145 void BlimpEngineSession::AddNewContents(content::WebContents* source, | 147 void BlimpEngineSession::AddNewContents(content::WebContents* source, |
146 content::WebContents* new_contents, | 148 content::WebContents* new_contents, |
147 WindowOpenDisposition disposition, | 149 WindowOpenDisposition disposition, |
148 const gfx::Rect& initial_rect, | 150 const gfx::Rect& initial_rect, |
149 bool user_gesture, | 151 bool user_gesture, |
150 bool* was_blocked) { | 152 bool* was_blocked) { |
151 NOTIMPLEMENTED(); | 153 NOTIMPLEMENTED(); |
152 } | 154 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 209 |
208 aura::Window* parent = window_tree_host_->window(); | 210 aura::Window* parent = window_tree_host_->window(); |
209 aura::Window* content = web_contents_->GetNativeView(); | 211 aura::Window* content = web_contents_->GetNativeView(); |
210 if (!parent->Contains(content)) | 212 if (!parent->Contains(content)) |
211 parent->AddChild(content); | 213 parent->AddChild(content); |
212 content->Show(); | 214 content->Show(); |
213 } | 215 } |
214 | 216 |
215 } // namespace engine | 217 } // namespace engine |
216 } // namespace blimp | 218 } // namespace blimp |
OLD | NEW |