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.
5 #include "chrome/browser/ui/search/instant_ipc_sender.h"
7 #include "chrome/common/render_messages.h"
11 // Implementation for regular profiles.
12 class InstantIPCSenderImpl : public InstantIPCSender {
14 InstantIPCSenderImpl() {}
15 virtual ~InstantIPCSenderImpl() {}
18 virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE {
19 Send(new ChromeViewMsg_SearchBoxMarginChange(
20 routing_id(), bounds.x(), bounds.width()));
23 virtual void FocusChanged(OmniboxFocusState state,
24 OmniboxFocusChangeReason reason) OVERRIDE {
25 Send(new ChromeViewMsg_SearchBoxFocusChanged(routing_id(), state, reason));
28 virtual void SetInputInProgress(bool input_in_progress) OVERRIDE {
29 Send(new ChromeViewMsg_SearchBoxSetInputInProgress(
30 routing_id(), input_in_progress));
33 DISALLOW_COPY_AND_ASSIGN(InstantIPCSenderImpl);
36 // Implementation for incognito profiles.
37 class IncognitoInstantIPCSenderImpl : public InstantIPCSender {
39 IncognitoInstantIPCSenderImpl() {}
40 virtual ~IncognitoInstantIPCSenderImpl() {}
43 virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE {
44 Send(new ChromeViewMsg_SearchBoxMarginChange(
45 routing_id(), bounds.x(), bounds.width()));
48 DISALLOW_COPY_AND_ASSIGN(IncognitoInstantIPCSenderImpl);
51 } // anonymous namespace
54 scoped_ptr<InstantIPCSender> InstantIPCSender::Create(bool is_incognito) {
55 scoped_ptr<InstantIPCSender> sender(
57 static_cast<InstantIPCSender*>(new IncognitoInstantIPCSenderImpl()) :
58 static_cast<InstantIPCSender*>(new InstantIPCSenderImpl()));
62 void InstantIPCSender::SetContents(content::WebContents* web_contents) {
63 Observe(web_contents);