summaryrefslogtreecommitdiffstats
path: root/blimp/engine/browser/blimp_browser_main_parts.cc
blob: 992f740b1c2a8bbbbd55794a612a08208f077e0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "blimp/engine/browser/blimp_browser_main_parts.h"

#include "blimp/common/proto/blimp_message.pb.h"
#include "blimp/engine/browser/blimp_browser_context.h"
#include "blimp/engine/browser/blimp_engine_session.h"
#include "blimp/net/blimp_connection.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/main_function_params.h"
#include "net/base/net_module.h"
#include "net/log/net_log.h"

#if defined(USE_X11)
#include "ui/base/ime/input_method_initializer.h"
#endif

namespace blimp {
namespace engine {

BlimpBrowserMainParts::BlimpBrowserMainParts(
    const content::MainFunctionParams& parameters) {}

BlimpBrowserMainParts::~BlimpBrowserMainParts() {}

void BlimpBrowserMainParts::PreEarlyInitialization() {
#if defined(USE_X11)
  // TODO(haibinlu): Rename the method below. crbug/548330.
  ui::InitializeInputMethodForTesting();
#endif
}

void BlimpBrowserMainParts::PreMainMessageLoopRun() {
  net_log_.reset(new net::NetLog());
  scoped_ptr<BlimpBrowserContext> browser_context(
      new BlimpBrowserContext(false, net_log_.get()));
  engine_session_.reset(new BlimpEngineSession(std::move(browser_context)));
  engine_session_->Initialize();

  // TODO(haibinlu): Create EngineConnectionManager to accept new connections.
  // TODO(haibinlu): Remove these test messages and switch to using the
  // MessageDispatcher for incoming messages.
  scoped_ptr<BlimpMessage> message(new BlimpMessage);
  message->set_type(BlimpMessage::TAB_CONTROL);
  message->mutable_tab_control()->set_type(TabControlMessage::CREATE_TAB);
  engine_session_->ProcessMessage(std::move(message),
                                  net::CompletionCallback());
  message.reset(new BlimpMessage);
  message->set_type(BlimpMessage::NAVIGATION);
  message->mutable_navigation()->set_type(NavigationMessage::LOAD_URL);
  message->mutable_navigation()->mutable_load_url()->set_url(
      "https://www.google.com/");
  engine_session_->ProcessMessage(std::move(message),
                                  net::CompletionCallback());
}

void BlimpBrowserMainParts::PostMainMessageLoopRun() {
  engine_session_.reset();
}

BlimpBrowserContext* BlimpBrowserMainParts::GetBrowserContext() {
  return engine_session_->browser_context();
}

}  // namespace engine
}  // namespace blimp