diff options
author | blundell <blundell@chromium.org> | 2015-07-31 04:16:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-31 11:17:23 +0000 |
commit | 26a618e5d798bcdfae7636aa258f6eeda338b8ee (patch) | |
tree | b183b5596d077ad64fa2dd4cba21823a5dc43058 /components/omnibox | |
parent | be408ee0d34e3a5d85bed83bc07c137c120881fa (diff) | |
download | chromium_src-26a618e5d798bcdfae7636aa258f6eeda338b8ee.zip chromium_src-26a618e5d798bcdfae7636aa258f6eeda338b8ee.tar.gz chromium_src-26a618e5d798bcdfae7636aa258f6eeda338b8ee.tar.bz2 |
Abstract OmniboxEditModel's knowledge of Navigation{Controller, Entry}
One more step on the way to abstracting OmniboxEditModel's knowledge of
//content and //chrome for sharing with iOS.
Additionally removes the now-obsolete (and incorrectly-layered)
OmniboxClient::GetNavigationController and componentizes the OmniboxClient
interface.
As a side note, replaces the usage of WebContents::GetURL() in
chrome_omnibox_client.cc with WebContents::GetVisibleURL(); the two methods
have the same implementation but the former is deprecated per the comments on
web_contents.h.
BUG=514631
Review URL: https://codereview.chromium.org/1259053004
Cr-Commit-Position: refs/heads/master@{#341313}
Diffstat (limited to 'components/omnibox')
-rw-r--r-- | components/omnibox/browser/BUILD.gn | 2 | ||||
-rw-r--r-- | components/omnibox/browser/omnibox_client.h | 115 |
2 files changed, 117 insertions, 0 deletions
diff --git a/components/omnibox/browser/BUILD.gn b/components/omnibox/browser/BUILD.gn index eea5eaf..2a2f49c 100644 --- a/components/omnibox/browser/BUILD.gn +++ b/components/omnibox/browser/BUILD.gn @@ -44,6 +44,7 @@ source_set("browser") { "keyword_extensions_delegate.h", "keyword_provider.cc", "keyword_provider.h", + "omnibox_client.h", "omnibox_field_trial.cc", "omnibox_field_trial.h", "omnibox_log.cc", @@ -87,6 +88,7 @@ source_set("browser") { "//base:prefs", "//components/bookmarks/browser", "//components/keyed_service/core", + "//components/omnibox/common", "//components/pref_registry", "//components/query_parser", "//components/resources", diff --git a/components/omnibox/browser/omnibox_client.h b/components/omnibox/browser/omnibox_client.h new file mode 100644 index 0000000..d54c2ce --- /dev/null +++ b/components/omnibox/browser/omnibox_client.h @@ -0,0 +1,115 @@ +// 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. + +#ifndef COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_CLIENT_H_ +#define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_CLIENT_H_ + +#include "base/basictypes.h" +#include "components/omnibox/browser/autocomplete_provider_client.h" +#include "components/omnibox/common/omnibox_focus_state.h" +#include "ui/base/window_open_disposition.h" + +class AutocompleteResult; +class GURL; +class SessionID; +class TemplateURL; +class TemplateURLService; +struct AutocompleteMatch; +struct OmniboxLog; + +namespace bookmarks { +class BookmarkModel; +} + +typedef base::Callback<void(const SkBitmap& bitmap)> BitmapFetchedCallback; + +// Interface that allows the omnibox component to interact with its embedder +// (e.g., getting information about the current page, retrieving objects +// associated with the current tab, or performing operations that rely on such +// objects under the hood). +class OmniboxClient { + public: + virtual ~OmniboxClient() {} + + // Returns an AutocompleteProviderClient specific to the embedder context. + virtual scoped_ptr<AutocompleteProviderClient> + CreateAutocompleteProviderClient() = 0; + + // Returns whether there is any associated current page. For example, during + // startup or shutdown, the omnibox may exist but have no attached page. + virtual bool CurrentPageExists() const = 0; + + // Returns the URL of the current page. + virtual const GURL& GetURL() const = 0; + + // Returns true if the visible entry is a New Tab Page rendered by Instant. + virtual bool IsInstantNTP() const = 0; + + // Returns true if the committed entry is a search results page. + virtual bool IsSearchResultsPage() const = 0; + + // Returns whether the current page is loading. + virtual bool IsLoading() const = 0; + + // Returns whether paste-and-go functionality is enabled. + virtual bool IsPasteAndGoEnabled() const = 0; + + // Returns the session ID of the current page. + virtual const SessionID& GetSessionID() const = 0; + + virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0; + virtual TemplateURLService* GetTemplateURLService() = 0; + + // Returns the icon corresponding to |match| if match is an extension match + // and an empty icon otherwise. + virtual gfx::Image GetIconIfExtensionMatch( + const AutocompleteMatch& match) const = 0; + + // Checks whether |template_url| is an extension keyword; if so, asks the + // ExtensionOmniboxEventRouter to process |match| for it and returns true. + // Otherwise returns false. + virtual bool ProcessExtensionKeyword(TemplateURL* template_url, + const AutocompleteMatch& match, + WindowOpenDisposition disposition) = 0; + + // Called to notify clients that the omnibox input state has changed. + virtual void OnInputStateChanged() = 0; + + // Called to notify clients that the omnibox focus state has changed. + virtual void OnFocusChanged(OmniboxFocusState state, + OmniboxFocusChangeReason reason) = 0; + + // Called when the autocomplete result has changed. If the embedder supports + // fetching of bitmaps for URLs (not all embedders do), |on_bitmap_fetched| + // will be called when the bitmap has been fetched. + virtual void OnResultChanged( + const AutocompleteResult& result, + bool default_match_changed, + const BitmapFetchedCallback& on_bitmap_fetched) = 0; + + // Called when the current autocomplete match has changed. + virtual void OnCurrentMatchChanged(const AutocompleteMatch& match) = 0; + + // Called to notify clients that a URL was opened from the omnibox. + // TODO(blundell): Eliminate this method in favor of having all //chrome- + // level listeners of the OMNIBOX_OPENED_URL instead observe OmniboxEditModel. + // Note that this is not trivial because (a) most of those listeners listen + // for the notification from all Profiles and (b) the notification is also + // sent from AutocompleteControllerAndroid, and it's unclear which listeners + // are also listening from it being sent from there. + virtual void OnURLOpenedFromOmnibox(OmniboxLog* log) = 0; + + // Discards the state for all pending and transient navigations. + virtual void DiscardNonCommittedNavigations() = 0; + + // Performs prerendering for |match|. + virtual void DoPrerender(const AutocompleteMatch& match) = 0; + + // Performs preconnection for |match|. + // TODO(blundell): Remove from this interface once OmniboxEditModel no + // longer refers to it. + virtual void DoPreconnect(const AutocompleteMatch& match) = 0; +}; + +#endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_CLIENT_H_ |