Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3377)

Unified Diff: chrome/browser/ui/search/instant_ipc_sender.cc

Issue 17303003: InstantExtended: hook up InstantTab in incognito. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile errors. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/instant_ipc_sender.h ('k') | chrome/browser/ui/search/instant_ntp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/instant_ipc_sender.cc
diff --git a/chrome/browser/ui/search/instant_ipc_sender.cc b/chrome/browser/ui/search/instant_ipc_sender.cc
new file mode 100644
index 0000000000000000000000000000000000000000..62f0b3b303ff83bf2bbbd0f55b0153b017058da9
--- /dev/null
+++ b/chrome/browser/ui/search/instant_ipc_sender.cc
@@ -0,0 +1,135 @@
+// Copyright 2013 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 "chrome/browser/ui/search/instant_ipc_sender.h"
+
+#include "chrome/common/render_messages.h"
+
+namespace {
+
+// Implementation for regular profiles.
+class InstantIPCSenderImpl : public InstantIPCSender {
+ public:
+ InstantIPCSenderImpl() {}
+ virtual ~InstantIPCSenderImpl() {}
+
+ private:
+ virtual void Update(const string16& text,
+ size_t selection_start,
+ size_t selection_end,
+ bool verbatim) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxChange(routing_id(), text, verbatim,
+ selection_start, selection_end));
+ }
+
+ virtual void Submit(const string16& text) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxSubmit(routing_id(), text));
+ }
+
+ virtual void Cancel(const string16& text) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxCancel(routing_id(), text));
+ }
+
+ virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxPopupResize(routing_id(), bounds));
+ }
+
+ virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxMarginChange(
+ routing_id(), bounds.x(), bounds.width()));
+ }
+
+ virtual void SetFontInformation(const string16& omnibox_font_name,
+ size_t omnibox_font_size) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxFontInformation(
+ routing_id(), omnibox_font_name, omnibox_font_size));
+ }
+
+ virtual void SendAutocompleteResults(
+ const std::vector<InstantAutocompleteResult>& results) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxAutocompleteResults(routing_id(), results));
+ }
+
+ virtual void UpOrDownKeyPressed(int count) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxUpOrDownKeyPressed(routing_id(), count));
+ }
+
+ virtual void EscKeyPressed() OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxEscKeyPressed(routing_id()));
+ }
+
+ virtual void CancelSelection(const string16& user_text,
+ size_t selection_start,
+ size_t selection_end,
+ bool verbatim) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxCancelSelection(
+ routing_id(), user_text, verbatim, selection_start, selection_end));
+ }
+
+ virtual void SendThemeBackgroundInfo(
+ const ThemeBackgroundInfo& theme_info) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxThemeChanged(routing_id(), theme_info));
+ }
+
+ virtual void SetDisplayInstantResults(bool display_instant_results) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(
+ routing_id(), display_instant_results));
+ }
+
+ virtual void FocusChanged(OmniboxFocusState state,
+ OmniboxFocusChangeReason reason) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxFocusChanged(routing_id(), state, reason));
+ }
+
+ virtual void SetInputInProgress(bool input_in_progress) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxSetInputInProgress(
+ routing_id(), input_in_progress));
+ }
+
+ virtual void SendMostVisitedItems(
+ const std::vector<InstantMostVisitedItem>& items) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxMostVisitedItemsChanged(
+ routing_id(), items));
+ }
+
+ virtual void ToggleVoiceSearch() OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxToggleVoiceSearch(routing_id()));
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(InstantIPCSenderImpl);
+};
+
+// Implementation for incognito profiles.
+class IncognitoInstantIPCSenderImpl : public InstantIPCSender {
+ public:
+ IncognitoInstantIPCSenderImpl() {}
+ virtual ~IncognitoInstantIPCSenderImpl() {}
+
+ private:
+ virtual void Submit(const string16& text) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxSubmit(routing_id(), text));
+ }
+
+ virtual void SetOmniboxBounds(const gfx::Rect& bounds) OVERRIDE {
+ Send(new ChromeViewMsg_SearchBoxMarginChange(
+ routing_id(), bounds.x(), bounds.width()));
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(IncognitoInstantIPCSenderImpl);
+};
+
+} // anonymous namespace
+
+// static
+scoped_ptr<InstantIPCSender> InstantIPCSender::Create(bool is_incognito) {
+ scoped_ptr<InstantIPCSender> sender(
+ is_incognito ?
+ static_cast<InstantIPCSender*>(new IncognitoInstantIPCSenderImpl()) :
+ static_cast<InstantIPCSender*>(new InstantIPCSenderImpl()));
+ return sender.Pass();
+}
+
+void InstantIPCSender::SetContents(content::WebContents* web_contents) {
+ Observe(web_contents);
+}
« no previous file with comments | « chrome/browser/ui/search/instant_ipc_sender.h ('k') | chrome/browser/ui/search/instant_ntp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698