| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // InstantOverlay is used to communicate with an overlay WebContents that it | 25 // InstantOverlay is used to communicate with an overlay WebContents that it |
| 26 // owns and loads the "Instant URL" into. This overlay can appear and disappear | 26 // owns and loads the "Instant URL" into. This overlay can appear and disappear |
| 27 // at will as the user types in the omnibox. | 27 // at will as the user types in the omnibox. |
| 28 class InstantOverlay : public InstantPage, | 28 class InstantOverlay : public InstantPage, |
| 29 public InstantLoader::Delegate { | 29 public InstantLoader::Delegate { |
| 30 public: | 30 public: |
| 31 // Returns the InstantOverlay for |contents| if it's used for Instant. | 31 // Returns the InstantOverlay for |contents| if it's used for Instant. |
| 32 static InstantOverlay* FromWebContents(const content::WebContents* contents); | 32 static InstantOverlay* FromWebContents(const content::WebContents* contents); |
| 33 | 33 |
| 34 InstantOverlay(InstantController* controller, | 34 InstantOverlay(InstantController* controller, |
| 35 const std::string& instant_url); | 35 const std::string& instant_url, |
| 36 bool is_incognito); |
| 36 virtual ~InstantOverlay(); | 37 virtual ~InstantOverlay(); |
| 37 | 38 |
| 38 // Creates a new WebContents and loads |instant_url_| into it. Uses | 39 // Creates a new WebContents and loads |instant_url_| into it. Uses |
| 39 // |active_tab|, if non-NULL, to initialize the size of the WebContents. | 40 // |active_tab|, if non-NULL, to initialize the size of the WebContents. |
| 40 void InitContents(Profile* profile, | 41 void InitContents(Profile* profile, |
| 41 const content::WebContents* active_tab); | 42 const content::WebContents* active_tab); |
| 42 | 43 |
| 43 // Releases the overlay WebContents. This should be called when the overlay | 44 // Releases the overlay WebContents. This should be called when the overlay |
| 44 // is committed. | 45 // is committed. |
| 45 scoped_ptr<content::WebContents> ReleaseContents(); | 46 scoped_ptr<content::WebContents> ReleaseContents(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 // Returns info about the last navigation by the Instant page. If the page | 58 // Returns info about the last navigation by the Instant page. If the page |
| 58 // hasn't navigated since the last Update(), the URL is empty. | 59 // hasn't navigated since the last Update(), the URL is empty. |
| 59 const history::HistoryAddPageArgs& last_navigation() const { | 60 const history::HistoryAddPageArgs& last_navigation() const { |
| 60 return last_navigation_; | 61 return last_navigation_; |
| 61 } | 62 } |
| 62 | 63 |
| 63 // Called by the history tab helper with information that it would have added | 64 // Called by the history tab helper with information that it would have added |
| 64 // to the history service had this WebContents not been used for Instant. | 65 // to the history service had this WebContents not been used for Instant. |
| 65 void DidNavigate(const history::HistoryAddPageArgs& add_page_args); | 66 void DidNavigate(const history::HistoryAddPageArgs& add_page_args); |
| 66 | 67 |
| 67 // Overridden from InstantPage: | 68 // Wrapper around InstantIPCSender::Update that also clears |
| 68 virtual void Update(const string16& text, | 69 // |last_navigation_|. |
| 69 size_t selection_start, | 70 void Update(const string16& text, |
| 70 size_t selection_end, | 71 size_t selection_start, |
| 71 bool verbatim) OVERRIDE; | 72 size_t selection_end, |
| 73 bool verbatim); |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefresh); | 76 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefresh); |
| 75 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefreshDifferentOrder); | 77 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantOverlayRefreshDifferentOrder); |
| 76 | 78 |
| 77 // Helper to access delegate() as an InstantController object. | 79 // Helper to access delegate() as an InstantController object. |
| 78 InstantController* instant_controller() const { | 80 InstantController* instant_controller() const { |
| 79 return static_cast<InstantController*>(delegate()); | 81 return static_cast<InstantController*>(delegate()); |
| 80 } | 82 } |
| 81 | 83 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 102 | 104 |
| 103 InstantLoader loader_; | 105 InstantLoader loader_; |
| 104 bool is_stale_; | 106 bool is_stale_; |
| 105 bool is_pointer_down_from_activate_; | 107 bool is_pointer_down_from_activate_; |
| 106 history::HistoryAddPageArgs last_navigation_; | 108 history::HistoryAddPageArgs last_navigation_; |
| 107 | 109 |
| 108 DISALLOW_COPY_AND_ASSIGN(InstantOverlay); | 110 DISALLOW_COPY_AND_ASSIGN(InstantOverlay); |
| 109 }; | 111 }; |
| 110 | 112 |
| 111 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_H_ | 113 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_H_ |
| OLD | NEW |