Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / search / instant_ipc_sender.cc
1 // Copyright 2013 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 "chrome/browser/ui/search/instant_ipc_sender.h"
6
7 #include "chrome/common/render_messages.h"
8
9 namespace {
10
11 // Implementation for regular profiles.
12 class InstantIPCSenderImpl : public InstantIPCSender {
13  public:
14   InstantIPCSenderImpl() {}
15   virtual ~InstantIPCSenderImpl() {}
16
17  private:
18   virtual void FocusChanged(OmniboxFocusState state,
19                     OmniboxFocusChangeReason reason) OVERRIDE {
20     Send(new ChromeViewMsg_SearchBoxFocusChanged(routing_id(), state, reason));
21   }
22
23   virtual void SetInputInProgress(bool input_in_progress) OVERRIDE {
24     Send(new ChromeViewMsg_SearchBoxSetInputInProgress(
25         routing_id(), input_in_progress));
26   }
27
28   DISALLOW_COPY_AND_ASSIGN(InstantIPCSenderImpl);
29 };
30
31 // Implementation for incognito profiles.
32 class IncognitoInstantIPCSenderImpl : public InstantIPCSender {
33  public:
34   IncognitoInstantIPCSenderImpl() {}
35   virtual ~IncognitoInstantIPCSenderImpl() {}
36
37  private:
38   DISALLOW_COPY_AND_ASSIGN(IncognitoInstantIPCSenderImpl);
39 };
40
41 }  // anonymous namespace
42
43 // static
44 scoped_ptr<InstantIPCSender> InstantIPCSender::Create(bool is_incognito) {
45   scoped_ptr<InstantIPCSender> sender(
46       is_incognito ?
47       static_cast<InstantIPCSender*>(new IncognitoInstantIPCSenderImpl()) :
48       static_cast<InstantIPCSender*>(new InstantIPCSenderImpl()));
49   return sender.Pass();
50 }
51
52 void InstantIPCSender::SetContents(content::WebContents* web_contents) {
53   Observe(web_contents);
54 }