OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "blimp/client/core/contents/tab_control_feature.h" | |
6 | |
7 #include "blimp/common/create_blimp_message.h" | |
8 #include "blimp/common/proto/blimp_message.pb.h" | |
9 #include "blimp/common/proto/tab_control.pb.h" | |
10 #include "blimp/net/blimp_message_processor.h" | |
11 #include "net/base/net_errors.h" | |
12 | |
13 namespace blimp { | |
14 namespace client { | |
15 | |
16 TabControlFeature::TabControlFeature() {} | |
17 | |
18 TabControlFeature::~TabControlFeature() {} | |
19 | |
20 void TabControlFeature::set_outgoing_message_processor( | |
21 std::unique_ptr<BlimpMessageProcessor> processor) { | |
22 outgoing_message_processor_ = std::move(processor); | |
23 } | |
24 | |
25 void TabControlFeature::SetSizeAndScale(const gfx::Size& size, | |
26 float device_pixel_ratio) { | |
27 last_size_ = size; | |
28 last_device_pixel_ratio_ = device_pixel_ratio; | |
29 | |
30 SizeMessage* size_details; | |
31 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&size_details); | |
32 size_details->set_width(size.width()); | |
33 size_details->set_height(size.height()); | |
34 size_details->set_device_pixel_ratio(device_pixel_ratio); | |
35 | |
36 // TODO(dtrainor): Don't keep sending size events to the server. Wait for a | |
37 // CompletionCallback to return before sending future size updates. | |
38 outgoing_message_processor_->ProcessMessage(std::move(message), | |
39 net::CompletionCallback()); | |
40 } | |
41 | |
42 void TabControlFeature::CreateTab(int tab_id) { | |
43 TabControlMessage* tab_control; | |
44 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&tab_control); | |
45 tab_control->mutable_create_tab(); | |
46 message->set_target_tab_id(tab_id); | |
47 outgoing_message_processor_->ProcessMessage(std::move(message), | |
48 net::CompletionCallback()); | |
49 } | |
50 | |
51 void TabControlFeature::CloseTab(int tab_id) { | |
52 TabControlMessage* tab_control; | |
53 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&tab_control); | |
54 tab_control->mutable_close_tab(); | |
55 message->set_target_tab_id(tab_id); | |
56 outgoing_message_processor_->ProcessMessage(std::move(message), | |
57 net::CompletionCallback()); | |
58 } | |
59 | |
60 void TabControlFeature::ProcessMessage( | |
61 std::unique_ptr<BlimpMessage> message, | |
62 const net::CompletionCallback& callback) { | |
63 DCHECK(!callback.is_null()); | |
64 callback.Run(net::OK); | |
65 | |
66 NOTIMPLEMENTED(); | |
67 } | |
68 | |
69 } // namespace client | |
70 } // namespace blimp | |
OLD | NEW |