| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/search/instant_ipc_sender.h" | 5 #include "chrome/browser/ui/search/instant_ipc_sender.h" |
| 6 | 6 |
| 7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| 11 // Implementation for regular profiles. | 11 // Implementation for regular profiles. |
| 12 class InstantIPCSenderImpl : public InstantIPCSender { | 12 class InstantIPCSenderImpl : public InstantIPCSender { |
| 13 public: | 13 public: |
| 14 InstantIPCSenderImpl() {} | 14 InstantIPCSenderImpl() {} |
| 15 virtual ~InstantIPCSenderImpl() {} | 15 virtual ~InstantIPCSenderImpl() {} |
| 16 | 16 |
| 17 private: | 17 private: |
| 18 virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE { | 18 virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE { |
| 19 Send(new ChromeViewMsg_SearchBoxMarginChange( | 19 Send(new ChromeViewMsg_SearchBoxMarginChange(routing_id(), bounds.x())); |
| 20 routing_id(), bounds.x(), bounds.width())); | |
| 21 } | 20 } |
| 22 | 21 |
| 23 virtual void FocusChanged(OmniboxFocusState state, | 22 virtual void FocusChanged(OmniboxFocusState state, |
| 24 OmniboxFocusChangeReason reason) OVERRIDE { | 23 OmniboxFocusChangeReason reason) OVERRIDE { |
| 25 Send(new ChromeViewMsg_SearchBoxFocusChanged(routing_id(), state, reason)); | 24 Send(new ChromeViewMsg_SearchBoxFocusChanged(routing_id(), state, reason)); |
| 26 } | 25 } |
| 27 | 26 |
| 28 virtual void SetInputInProgress(bool input_in_progress) OVERRIDE { | 27 virtual void SetInputInProgress(bool input_in_progress) OVERRIDE { |
| 29 Send(new ChromeViewMsg_SearchBoxSetInputInProgress( | 28 Send(new ChromeViewMsg_SearchBoxSetInputInProgress( |
| 30 routing_id(), input_in_progress)); | 29 routing_id(), input_in_progress)); |
| 31 } | 30 } |
| 32 | 31 |
| 33 DISALLOW_COPY_AND_ASSIGN(InstantIPCSenderImpl); | 32 DISALLOW_COPY_AND_ASSIGN(InstantIPCSenderImpl); |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 // Implementation for incognito profiles. | 35 // Implementation for incognito profiles. |
| 37 class IncognitoInstantIPCSenderImpl : public InstantIPCSender { | 36 class IncognitoInstantIPCSenderImpl : public InstantIPCSender { |
| 38 public: | 37 public: |
| 39 IncognitoInstantIPCSenderImpl() {} | 38 IncognitoInstantIPCSenderImpl() {} |
| 40 virtual ~IncognitoInstantIPCSenderImpl() {} | 39 virtual ~IncognitoInstantIPCSenderImpl() {} |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE { | 42 virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE { |
| 44 Send(new ChromeViewMsg_SearchBoxMarginChange( | 43 Send(new ChromeViewMsg_SearchBoxMarginChange(routing_id(), bounds.x())); |
| 45 routing_id(), bounds.x(), bounds.width())); | |
| 46 } | 44 } |
| 47 | 45 |
| 48 DISALLOW_COPY_AND_ASSIGN(IncognitoInstantIPCSenderImpl); | 46 DISALLOW_COPY_AND_ASSIGN(IncognitoInstantIPCSenderImpl); |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 } // anonymous namespace | 49 } // anonymous namespace |
| 52 | 50 |
| 53 // static | 51 // static |
| 54 scoped_ptr<InstantIPCSender> InstantIPCSender::Create(bool is_incognito) { | 52 scoped_ptr<InstantIPCSender> InstantIPCSender::Create(bool is_incognito) { |
| 55 scoped_ptr<InstantIPCSender> sender( | 53 scoped_ptr<InstantIPCSender> sender( |
| 56 is_incognito ? | 54 is_incognito ? |
| 57 static_cast<InstantIPCSender*>(new IncognitoInstantIPCSenderImpl()) : | 55 static_cast<InstantIPCSender*>(new IncognitoInstantIPCSenderImpl()) : |
| 58 static_cast<InstantIPCSender*>(new InstantIPCSenderImpl())); | 56 static_cast<InstantIPCSender*>(new InstantIPCSenderImpl())); |
| 59 return sender.Pass(); | 57 return sender.Pass(); |
| 60 } | 58 } |
| 61 | 59 |
| 62 void InstantIPCSender::SetContents(content::WebContents* web_contents) { | 60 void InstantIPCSender::SetContents(content::WebContents* web_contents) { |
| 63 Observe(web_contents); | 61 Observe(web_contents); |
| 64 } | 62 } |
| OLD | NEW |