1dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// The LocationBar class is a virtual interface, defining access to the
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// window's location bar component.  This class exists so that cross-platform
7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// components like the browser command system can talk to the platform
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// specific implementations of the location bar control.  It also allows the
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// location bar to be mocked for testing.
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
1121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#ifndef CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_
1221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#define CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_
133345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string>
16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
173345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "base/string16.h"
183345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "chrome/browser/first_run/first_run.h"
19ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/instant/instant_delegate.h"
20ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/page_transition_types.h"
21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "webkit/glue/window_open_disposition.h"
22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass AutocompleteEditView;
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass ExtensionAction;
25dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass InstantController;
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass LocationBarTesting;
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass TabContents;
28dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass TabContentsWrapper;
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass LocationBar {
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Shows the first run information bubble anchored to the location bar.
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void ShowFirstRunBubble(FirstRun::BubbleType bubble_type) = 0;
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
353345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Sets the suggested text to show in the omnibox. This is shown in addition
363345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // to the current text of the omnibox.
37ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void SetSuggestedText(const string16& text,
38ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                InstantCompleteBehavior behavior) = 0;
393345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the string of text entered in the location bar.
41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual std::wstring GetInputString() const = 0;
42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the WindowOpenDisposition that should be used to determine where
44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // to open a URL entered in the location bar.
45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual WindowOpenDisposition GetWindowOpenDisposition() const = 0;
46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the PageTransition that should be recorded in history when the URL
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // entered in the location bar is loaded.
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual PageTransition::Type GetPageTransition() const = 0;
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Accepts the current string of text entered in the location bar.
52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void AcceptInput() = 0;
53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Focuses the location bar.  Optionally also selects its contents.
55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void FocusLocation(bool select_all) = 0;
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Clears the location bar, inserts an annoying little "?" turd and sets
58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // focus to it.
59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void FocusSearch() = 0;
60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Updates the state of the images showing the content settings status.
62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void UpdateContentSettingsIcons() = 0;
63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Updates the state of the page actions.
65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void UpdatePageActions() = 0;
66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Called when the page-action data needs to be refreshed, e.g. when an
68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // extension is unloaded or crashes.
69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void InvalidatePageActions() = 0;
70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Saves the state of the location bar to the specified TabContents, so that
72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // it can be restored later. (Done when switching tabs).
73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void SaveStateToContents(TabContents* contents) = 0;
74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Reverts the location bar.  The bar's permanent text will be shown.
76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void Revert() = 0;
77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns a pointer to the text entry view.
79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual const AutocompleteEditView* location_entry() const = 0;
80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual AutocompleteEditView* location_entry() = 0;
81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns a pointer to the testing interface.
83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual LocationBarTesting* GetLocationBarForTesting() = 0;
84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch protected:
86c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ~LocationBar() {}
87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass LocationBarTesting {
90c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
91c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the total number of page actions in the Omnibox.
92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual int PageActionCount() = 0;
93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the number of visible page actions in the Omnibox.
95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual int PageActionVisibleCount() = 0;
96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the ExtensionAction at |index|.
98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ExtensionAction* GetPageAction(size_t index) = 0;
99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the visible ExtensionAction at |index|.
101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ExtensionAction* GetVisiblePageAction(size_t index) = 0;
102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Simulates a left mouse pressed on the visible page action at |index|.
104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void TestPageActionPressed(size_t index) = 0;
105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch protected:
107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ~LocationBarTesting() {}
108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#endif  // CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_H_
111