15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/omnibox/omnibox_view.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/toolbar/toolbar_model.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/window_open_disposition.h"
1558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "ui/gfx/range/range.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/views/controls/textfield/textfield.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/controls/textfield/textfield_controller.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_CHROMEOS)
20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/input_method_manager.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LocationBarView;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class OmniboxPopupView;
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class OSExchangeData;
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace ui
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Views-implementation of OmniboxView, based on the gtk implementation.
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class OmniboxViewViews
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    : public views::Textfield,
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      public OmniboxView,
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_CHROMEOS)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      public
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          chromeos::input_method::InputMethodManager::CandidateWindowObserver,
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      public views::TextfieldController {
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The internal view class name.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const char kViewClassName[];
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  OmniboxViewViews(OmniboxEditController* controller,
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                   Profile* profile,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                   CommandUpdater* command_updater,
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                   bool popup_window_mode,
4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                   LocationBarView* location_bar,
490f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                   const gfx::FontList& font_list);
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~OmniboxViewViews();
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initialize, create the underlying views, etc;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Init();
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the colors of the text view according to the theme.
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetBaseColor();
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // views::Textfield:
59b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  virtual const char* GetClassName() const OVERRIDE;
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE;
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool SkipDefaultKeyEventProcessing(
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const ui::KeyEvent& event) OVERRIDE;
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnFocus() OVERRIDE;
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnBlur() OVERRIDE;
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // OmniboxView:
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE;
74424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void OnTabChanged(const content::WebContents* web_contents) OVERRIDE;
75424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void Update() OVERRIDE;
76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetText() const OVERRIDE;
77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void SetUserText(const base::string16& text,
78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                           const base::string16& display_text,
7968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                           bool update_popup) OVERRIDE;
80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void SetWindowTextAndCaretPos(const base::string16& text,
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        size_t caret_pos,
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        bool update_popup,
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        bool notify_text_changed) OVERRIDE;
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetForcedQuery() OVERRIDE;
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsSelectAll() const OVERRIDE;
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool DeleteAtEndPressed() OVERRIDE;
87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void GetSelectionBounds(
88a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      base::string16::size_type* start,
89a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      base::string16::size_type* end) const OVERRIDE;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SelectAll(bool reversed) OVERRIDE;
9168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  virtual void RevertAll() OVERRIDE;
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdatePopup() OVERRIDE;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetFocus() OVERRIDE;
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void ApplyCaretVisibility() OVERRIDE;
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnTemporaryTextMaybeChanged(
96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& display_text,
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      bool save_original_selection,
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      bool notify_text_changed) OVERRIDE;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnInlineAutocompleteTextMaybeChanged(
100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& display_text, size_t user_text_length) OVERRIDE;
101f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void OnInlineAutocompleteTextCleared() OVERRIDE;
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnRevertTemporaryText() OVERRIDE;
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnBeforePossibleChange() OVERRIDE;
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnAfterPossibleChange() OVERRIDE;
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::NativeView GetNativeView() const OVERRIDE;
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE;
107a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void SetGrayTextAutocompletion(const base::string16& input) OVERRIDE;
108a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE;
109d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles)  virtual int GetTextWidth() const OVERRIDE;
110d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles)  virtual int GetWidth() const OVERRIDE;
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsImeComposing() const OVERRIDE;
112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual bool IsImeShowingPopup() const OVERRIDE;
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // views::TextfieldController:
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ContentsChanged(views::Textfield* sender,
117a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                               const base::string16& new_contents) OVERRIDE;
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool HandleKeyEvent(views::Textfield* sender,
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const ui::KeyEvent& key_event) OVERRIDE;
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnBeforeUserAction(views::Textfield* sender) OVERRIDE;
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnAfterUserAction(views::Textfield* sender) OVERRIDE;
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnAfterCutOrCopy() OVERRIDE;
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnWriteDragData(ui::OSExchangeData* data) OVERRIDE;
124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnGetDragOperationsForTextfield(int* drag_operations) OVERRIDE;
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void AppendDropFormats(
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      int* formats,
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual int OnDrop(const ui::OSExchangeData& data) OVERRIDE;
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) OVERRIDE;
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE;
132a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE;
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool HandlesCommand(int command_id) const OVERRIDE;
1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_CHROMEOS)
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // chromeos::input_method::InputMethodManager::CandidateWindowObserver:
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void CandidateWindowOpened(
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      chromeos::input_method::InputMethodManager* manager) OVERRIDE;
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void CandidateWindowClosed(
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      chromeos::input_method::InputMethodManager* manager) OVERRIDE;
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return the number of characers in the current buffer.
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetOmniboxTextLength() const OVERRIDE;
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Try to parse the current text as a URL and colorize the components.
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void EmphasizeURLComponents() OVERRIDE;
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Update the field with |text| and set the selection.
152a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void SetTextAndSelectedRange(const base::string16& text,
15358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                               const gfx::Range& range);
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the selected text.
156a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 GetSelectedText() const;
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Paste text from the clipboard into the omnibox.
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Textfields implementation of Paste() pastes the contents of the clipboard
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // as is. We want to strip whitespace and other things (see GetClipboardText()
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // for details).
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // It is assumed this is invoked after a call to OnBeforePossibleChange() and
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // that after invoking this OnAfterPossibleChange() is invoked.
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnPaste();
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Handle keyword hint tab-to-search and tabbing through dropdown results.
1674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  bool HandleEarlyTabActions(const ui::KeyEvent& event);
1684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When true, the location bar view is read only and also is has a slightly
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // different presentation (smaller font size). This is used for popups.
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool popup_window_mode_;
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<OmniboxPopupView> popup_view_;
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ToolbarModel::SecurityLevel security_level_;
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
17790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Selection persisted across temporary text changes, like popup suggestions.
17858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  gfx::Range saved_temporary_selection_;
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
18068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Holds the user's selection across focus changes.  There is only a saved
18168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // selection if this range IsValid().
18268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  gfx::Range saved_selection_for_focus_change_;
18368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tracking state before and after a possible change.
185a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 text_before_change_;
18658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  gfx::Range sel_before_change_;
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ime_composing_before_change_;
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Was the delete key pressed with an empty selection at the end of the edit?
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool delete_at_end_pressed_;
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  LocationBarView* location_bar_view_;
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the IME candidate window is open. When this is true, we want to
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // avoid showing the popup. So far, the candidate window is detected only
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on Chrome OS.
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ime_candidate_window_open_;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Should we select all the text when we see the mouse button get released?
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // We select in response to a click that focuses the omnibox, but we defer
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // until release, setting this variable back to false if we saw a drag, to
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // allow the user to select just a portion of the text.
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool select_all_on_mouse_release_;
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Indicates if we want to select all text in the omnibox when we get a
2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // GESTURE_TAP. We want to select all only when the textfield is not in focus
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // and gets a tap. So we use this variable to remember focus state before tap.
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool select_all_on_gesture_tap_;
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews);
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
213