1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EDIT_CONTROLLER_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EDIT_CONTROLLER_H_
7 
8 #include "base/time/time.h"
9 #include "components/omnibox/browser/autocomplete_match_type.h"
10 #include "components/search_engines/template_url.h"
11 #include "ui/base/page_transition_types.h"
12 #include "ui/base/window_open_disposition.h"
13 #include "url/gurl.h"
14 
15 class LocationBarModel;
16 
17 class OmniboxEditController {
18  public:
19   virtual void OnAutocompleteAccept(const GURL& destination_url,
20                                     TemplateURLRef::PostContent* post_content,
21                                     WindowOpenDisposition disposition,
22                                     ui::PageTransition transition,
23                                     AutocompleteMatchType::Type match_type,
24                                     base::TimeTicks match_selection_timestamp);
25 
26   virtual void OnInputInProgress(bool in_progress);
27 
28   // Called when anything has changed that might affect the layout or contents
29   // of the views around the edit, including the text of the edit and the
30   // status of any keyword- or hint-related state.
31   virtual void OnChanged();
32 
33   // Called when the omnibox popup is shown or hidden.
34   virtual void OnPopupVisibilityChanged();
35 
36   virtual LocationBarModel* GetLocationBarModel() = 0;
37   virtual const LocationBarModel* GetLocationBarModel() const = 0;
38 
39  protected:
40   OmniboxEditController();
41   virtual ~OmniboxEditController();
42   OmniboxEditController(const OmniboxEditController&) = delete;
43   OmniboxEditController& operator=(const OmniboxEditController&) = delete;
44 
destination_url()45   GURL destination_url() const { return destination_url_; }
post_content()46   TemplateURLRef::PostContent* post_content() const { return post_content_; }
disposition()47   WindowOpenDisposition disposition() const { return disposition_; }
transition()48   ui::PageTransition transition() const { return transition_; }
match_selection_timestamp()49   base::TimeTicks match_selection_timestamp() const {
50     return match_selection_timestamp_;
51   }
52 
53  private:
54   // The details necessary to open the user's desired omnibox match.
55   GURL destination_url_;
56   TemplateURLRef::PostContent* post_content_;
57   WindowOpenDisposition disposition_;
58   ui::PageTransition transition_;
59   base::TimeTicks match_selection_timestamp_;
60 };
61 
62 #endif  // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EDIT_CONTROLLER_H_
63