blob: b9d5f5c5c64ebbbd1095ee804de43309f0cbe5c6 [file] [log] [blame]
// Copyright (c) 2011 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.
#pragma once
#include <string>
#include <vector>
#include "base/string16.h"
#include "chrome/common/instant_types.h"
#include "content/renderer/render_view_observer.h"
#include "content/renderer/render_view_observer_tracker.h"
#include "ui/gfx/rect.h"
class SearchBox : public RenderViewObserver,
public RenderViewObserverTracker<SearchBox> {
explicit SearchBox(RenderView* render_view);
virtual ~SearchBox();
// Sends ViewHostMsg_SetSuggestions to the browser.
void SetSuggestions(const std::vector<std::string>& suggestions,
InstantCompleteBehavior behavior);
const string16& value() { return value_; }
bool verbatim() { return verbatim_; }
uint32 selection_start() { return selection_start_; }
uint32 selection_end() { return selection_end_; }
const gfx::Rect& rect() { return rect_; }
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message);
void OnChange(const string16& value,
bool verbatim,
int selection_start,
int selection_end);
void OnSubmit(const string16& value, bool verbatim);
void OnCancel();
void OnResize(const gfx::Rect& bounds);
void OnDetermineIfPageSupportsInstant(const string16& value,
bool verbatim,
int selection_start,
int selection_end);
// Sets the searchbox values to their initial value.
void Reset();
string16 value_;
bool verbatim_;
uint32 selection_start_;
uint32 selection_end_;
gfx::Rect rect_;