Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: chrome/browser/ui/search/instant_page.h

Issue 2147483002: Cleanup: remove dead code from InstantPage and InstantController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_PAGE_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
7 7
8 #include <vector>
9
10 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 10 #include "base/macros.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/ui/search/search_model_observer.h" 11 #include "chrome/browser/ui/search/search_model_observer.h"
15 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
16 #include "ui/base/page_transition_types.h" 13 #include "ui/base/page_transition_types.h"
17 14
18 class GURL; 15 class GURL;
19 class Profile;
20 16
21 namespace content { 17 namespace content {
22 struct FrameNavigateParams; 18 class RenderFrameHost;
23 struct LoadCommittedDetails;
24 class WebContents; 19 class WebContents;
25 } 20 }
26 21
27 namespace gfx {
28 class Rect;
29 }
30
31 // InstantPage is used to exchange messages with a page that implements the 22 // InstantPage is used to exchange messages with a page that implements the
32 // Instant/Embedded Search API (http://dev.chromium.org/embeddedsearch). 23 // Instant/Embedded Search API (http://dev.chromium.org/embeddedsearch).
33 // InstantPage is not used directly but via one of its derived classes, 24 // InstantPage is not used directly but via its derived class, InstantTab.
sfiera 2016/07/12 13:41:40 Should I just delete InstantTab then in https://co
Marc Treib 2016/07/12 13:46:16 I guess InstantPage should be merged into it? I'd
34 // InstantNTP and InstantTab.
35 class InstantPage : public content::WebContentsObserver, 25 class InstantPage : public content::WebContentsObserver,
36 public SearchModelObserver { 26 public SearchModelObserver {
37 public: 27 public:
38 // InstantPage calls its delegate in response to messages received from the 28 // InstantPage calls its delegate in response to messages received from the
39 // page. Each method is called with the |contents| corresponding to the page 29 // page. Each method is called with the |contents| corresponding to the page
40 // we are observing. 30 // we are observing.
41 class Delegate { 31 class Delegate {
42 public: 32 public:
43 // Called upon determination of Instant API support. Either in response to 33 // Called upon determination of Instant API support. Either in response to
44 // the page loading or because we received some other message. 34 // the page loading or because we received some other message.
45 virtual void InstantSupportDetermined(const content::WebContents* contents, 35 virtual void InstantSupportDetermined(const content::WebContents* contents,
46 bool supports_instant) = 0; 36 bool supports_instant) = 0;
47 37
48 // Called when the page is about to navigate to |url|. 38 // Called when the page is about to navigate to |url|.
49 virtual void InstantPageAboutToNavigateMainFrame( 39 virtual void InstantPageAboutToNavigateMainFrame(
50 const content::WebContents* contents, 40 const content::WebContents* contents,
51 const GURL& url) = 0; 41 const GURL& url) = 0;
52 42
53 protected: 43 protected:
54 virtual ~Delegate(); 44 virtual ~Delegate();
55 }; 45 };
56 46
57 ~InstantPage() override; 47 ~InstantPage() override;
58 48
59 // Returns the Instant URL that was loaded for this page. Returns the empty
60 // string if no URL was explicitly loaded as is the case for InstantTab.
61 virtual const std::string& instant_url() const;
62
63 // Returns true if the page is known to support the Instant API. This starts 49 // Returns true if the page is known to support the Instant API. This starts
64 // out false, and is set to true whenever we get any message from the page. 50 // out false, and is set to true whenever we get any message from the page.
65 // Once true, it never becomes false (the page isn't expected to drop API 51 // Once true, it never becomes false (the page isn't expected to drop API
66 // support suddenly). 52 // support suddenly).
67 virtual bool supports_instant() const; 53 bool supports_instant() const;
68 54
69 // Returns true if the page is the local NTP (i.e. its URL is 55 // Returns true if the page is the local NTP (i.e. its URL is
70 // chrome::kChromeSearchLocalNTPURL). 56 // chrome::kChromeSearchLocalNTPURL).
71 virtual bool IsLocal() const; 57 bool IsLocal() const;
72 58
73 protected: 59 protected:
74 InstantPage(Delegate* delegate, 60 explicit InstantPage(Delegate* delegate);
75 const std::string& instant_url,
76 Profile* profile);
77 61
78 // Sets |web_contents| as the page to communicate with. |web_contents| may be 62 // Sets |web_contents| as the page to communicate with. |web_contents| may be
79 // NULL, which effectively stops all communication. 63 // NULL, which effectively stops all communication.
80 void SetContents(content::WebContents* web_contents); 64 void SetContents(content::WebContents* web_contents);
81 65
82 Delegate* delegate() const { return delegate_; } 66 Delegate* delegate() const { return delegate_; }
83 67
84 Profile* profile() const { return profile_; } 68 // This method is called before processing messages received from the page.
85
86 // These functions are called before processing messages received from the
87 // page. By default, all messages are handled, but any derived classes may
88 // choose to ignore some or all of the received messages by overriding these
89 // methods.
90 virtual bool ShouldProcessAboutToNavigateMainFrame(); 69 virtual bool ShouldProcessAboutToNavigateMainFrame();
91 70
92 private: 71 private:
93 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, IsLocal); 72 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, IsLocal);
94 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 73 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
95 DetermineIfPageSupportsInstant_Local); 74 DetermineIfPageSupportsInstant_Local);
96 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 75 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
97 DetermineIfPageSupportsInstant_NonLocal); 76 DetermineIfPageSupportsInstant_NonLocal);
98 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 77 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
99 PageURLDoesntBelongToInstantRenderer); 78 PageURLDoesntBelongToInstantRenderer);
100 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, PageSupportsInstant); 79 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, PageSupportsInstant);
101 80
102 // Overridden from content::WebContentsObserver: 81 // Overridden from content::WebContentsObserver:
103 void DidCommitProvisionalLoadForFrame( 82 void DidCommitProvisionalLoadForFrame(
104 content::RenderFrameHost* render_frame_host, 83 content::RenderFrameHost* render_frame_host,
105 const GURL& url, 84 const GURL& url,
106 ui::PageTransition transition_type) override; 85 ui::PageTransition transition_type) override;
107 86
108 // Overridden from SearchModelObserver: 87 // Overridden from SearchModelObserver:
109 void ModelChanged(const SearchModel::State& old_state, 88 void ModelChanged(const SearchModel::State& old_state,
110 const SearchModel::State& new_state) override; 89 const SearchModel::State& new_state) override;
111 90
112 // Update the status of Instant support. 91 // Update the status of Instant support.
113 void InstantSupportDetermined(bool supports_instant); 92 void InstantSupportDetermined(bool supports_instant);
114 93
115 void ClearContents(); 94 void ClearContents();
116 95
117 // TODO(kmadhusu): Remove |profile_| from here and update InstantNTP to get
118 // |profile| from InstantNTPPrerenderer.
119 Profile* profile_;
120
121 Delegate* const delegate_; 96 Delegate* const delegate_;
122 const std::string instant_url_;
123 97
124 DISALLOW_COPY_AND_ASSIGN(InstantPage); 98 DISALLOW_COPY_AND_ASSIGN(InstantPage);
125 }; 99 };
126 100
127 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_ 101 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_PAGE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/browser/ui/search/instant_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698