autofill_popup_controller.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// Copyright (c) 2012 The Chromium Authors. All rights reserved.
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Use of this source code is governed by a BSD-style license that can be
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// found in the LICENSE file.
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <vector>
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/compiler_specific.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/string16.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/gfx/native_widget_types.h"
13daaafa6e81860e3dc52660ba019c336f0a43f1e7reed@google.com
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnamespace gfx {
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass Font;
162ac4ef5e6e0c9c95c9200408ba25a95ca758eac2junov@chromium.orgclass Point;
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass Rect;
18fbcd415aa01801df5f554963d7463649b49ead73senorblanco@chromium.orgclass RectF;
19cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org}
20491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnamespace autofill {
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// This interface provides data to an AutofillPopupView.
24045e62d715f5ee9b03deb5af3c750f8318096179reed@google.comclass AutofillPopupController {
25a8e33a92e27ca1523601226cad83c79a7e00c93bscroggo@google.com public:
26cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org  // Called when the popup should get hidden.
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void Hide() = 0;
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Called whent the popup view was destroyed.
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void ViewDestroyed() = 0;
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Recalculates the height and width of the popup and triggers a redraw.
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void UpdateBoundsAndRedrawPopup() = 0;
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // The user has moved the mouse within the popup.
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void MouseHovered(int x, int y) = 0;
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // The user clicked the mouse within the popup.
394200dfe9c1a2c0e99a7155a63fbffb01e9d1fd28bungeman@google.com  virtual void MouseClicked(int x, int y) = 0;
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
410456e0b7b85060e9b9597ce414c4c2b19aff4f58robertphillips@google.com  // The user has moved the mouse outside of the popup.
420456e0b7b85060e9b9597ce414c4c2b19aff4f58robertphillips@google.com  virtual void MouseExitedPopup() = 0;
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Accepts the suggestion at |index|.
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void AcceptSuggestion(size_t index) = 0;
4630711b764be6bbb58caa30a0ac5d1474c894efe7reed@google.com
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Gets the resource value for the given resource, returning -1 if the
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // resource isn't recognized.
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual int GetIconResourceID(const string16& resource_name) = 0;
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Returns true if the given index refers to an element that can be deleted.
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual bool CanDelete(size_t index) const = 0;
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Updates the bounds of the popup and initiates a redraw.
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void SetPopupBounds(const gfx::Rect& bounds) = 0;
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Returns the bounds of the item at |index| in the popup, relative to
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // the top left of the popup.
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual gfx::Rect GetRowBounds(size_t index) = 0;
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
614135f2893289dd37b662a32dd1f3d9e79a0eabf3mike@reedtribe.org  // The actual bounds of the popup.
6230711b764be6bbb58caa30a0ac5d1474c894efe7reed@google.com  virtual const gfx::Rect& popup_bounds() const = 0;
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
64491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  // The view that the form field element sits in.
65491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  virtual gfx::NativeView container_view() const = 0;
66b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt
6741bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org  // The bounds of the form field element (screen coordinates).
6841bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org  virtual const gfx::RectF& element_bounds() const = 0;
6941bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org
7041bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org  // TODO(csharp): The names, subtexts and icon getters can probably be adjusted
71491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  // to take in the row index and return a single element, instead of the
72b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt  // whole vector.
73b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt  // The main labels for each autofill item.
74491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  virtual const std::vector<string16>& names() const = 0;
75b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt
762b75f4279a237ceea929ff8ac019f7fbd3ad08b5reed@google.com  // Smaller labels for each autofill item.
77491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  virtual const std::vector<string16>& subtexts() const = 0;
78b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt
79b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt  // A string which identifies the icon to be shown for each autofill item.
80b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt  virtual const std::vector<string16>& icons() const = 0;
81b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt
8241bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org  // Identifier for the row.
83491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  virtual const std::vector<int>& identifiers() const = 0;
8441bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org
8541bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org#if !defined(OS_ANDROID)
8641bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org  // The same font can vary based on the type of data it is showing,
8741bf930039314cc71039b12957195f1c65c30ce1commit-bot@chromium.org  // so we need to know the row.
88491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  virtual const gfx::Font& GetNameFontForRow(size_t index) const = 0;
891842adf01320f9197b449de7375d08ccac43f389skia.committer@gmail.com  virtual const gfx::Font& subtext_font() const = 0;
90491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com#endif
91491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com
92491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  // Returns the index of the selected line. A line is "selected" when it is
93491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  // hovered or has keyboard focus.
94491493119c11206c5823b76eb6420a705be243a1robertphillips@google.com  virtual int selected_line() const = 0;
95cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org
96cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org protected:
97cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org  virtual ~AutofillPopupController() {}
98cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org};
99cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org
100cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org}  // namespace autofill
101cf34bc06347dd2734a7fdaef5cf8853e92979d5ecommit-bot@chromium.org
102821397018fdabea6b434ecb96f84fb5449c4025fcommit-bot@chromium.org#endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
103821397018fdabea6b434ecb96f84fb5449c4025fcommit-bot@chromium.org