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

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

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_SEARCH_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_H_
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_H_ 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 14
15 class GURL; 15 class GURL;
16 class PrefRegistrySyncable;
16 class Profile; 17 class Profile;
17 class TemplateURL; 18 class TemplateURL;
18 class TemplateURLRef; 19 class TemplateURLRef;
19 20
20 namespace content { 21 namespace content {
21 class NavigationEntry; 22 class NavigationEntry;
22 class WebContents; 23 class WebContents;
23 } 24 }
24 25
25 namespace chrome { 26 namespace chrome {
26 namespace search { 27 namespace search {
27 28
28 // The key used to store search terms data in the NavigationEntry to be later 29 // The key used to store search terms data in the NavigationEntry to be later
29 // displayed in the omnibox. With the context of the user's exact query, 30 // displayed in the omnibox. With the context of the user's exact query,
30 // InstantController sets the correct search terms to be displayed. 31 // InstantController sets the correct search terms to be displayed.
31 extern const char kInstantExtendedSearchTermsKey[]; 32 extern const char kInstantExtendedSearchTermsKey[];
32 33
33 // The URL for the local omnibox popup (rendered in a WebContents). 34 // The URL for the local omnibox popup (rendered in a WebContents).
34 extern const char kLocalOmniboxPopupURL[]; 35 extern const char kLocalOmniboxPopupURL[];
35 36
36 // The default value we should assign to the instant_extended.enabled pref.
37 // As with other prefs, the default is used only when the user hasn't toggled
38 // the pref explicitly.
39 enum InstantExtendedDefault {
40 INSTANT_DEFAULT_ON, // Default the pref to be enabled.
41 INSTANT_USE_EXISTING, // Use the current value of the instant.enabled pref.
42 INSTANT_DEFAULT_OFF, // Default the pref to be disabled.
43 };
44
45 // Returns an enum value indicating which mode to set the new
46 // instant_extended.enabled pref to by default.
47 InstantExtendedDefault GetInstantExtendedDefaultSetting();
48
49 // Returns whether the Instant Extended API is enabled in this profile. 37 // Returns whether the Instant Extended API is enabled in this profile.
50 bool IsInstantExtendedAPIEnabled(const Profile* profile); 38 bool IsInstantExtendedAPIEnabled(const Profile* profile);
51 39
52 // Returns the value to pass to the &espv CGI parameter when loading the 40 // Returns the value to pass to the &espv CGI parameter when loading the
53 // embedded search page from the user's default search provider. Will be 41 // embedded search page from the user's default search provider. Will be
54 // 0 if the Instant Extended API is not enabled. 42 // 0 if the Instant Extended API is not enabled.
55 uint64 EmbeddedSearchPageVersion(const Profile* profile); 43 uint64 EmbeddedSearchPageVersion(const Profile* profile);
56 44
57 // Returns whether query extraction is enabled. 45 // Returns whether query extraction is enabled.
58 bool IsQueryExtractionEnabled(const Profile* profile); 46 bool IsQueryExtractionEnabled(const Profile* profile);
59 47
60 // Returns the search terms attached to a specific NavigationEntry, or empty 48 // Returns the search terms attached to a specific NavigationEntry, or empty
61 // string otherwise. Does not consider IsQueryExtractionEnabled(), so most 49 // string otherwise. Does not consider IsQueryExtractionEnabled(), so most
62 // callers should use GetSearchTerms() below instead. 50 // callers should use GetSearchTerms() below instead.
63 string16 GetSearchTermsFromNavigationEntry( 51 string16 GetSearchTermsFromNavigationEntry(
64 const content::NavigationEntry* entry); 52 const content::NavigationEntry* entry);
65 53
66 // Returns search terms if this WebContents is a search results page. It looks 54 // Returns search terms if this WebContents is a search results page. It looks
67 // in the visible NavigationEntry first, to see if search terms have already 55 // in the visible NavigationEntry first, to see if search terms have already
68 // been extracted. Failing that, it tries to extract search terms from the URL. 56 // been extracted. Failing that, it tries to extract search terms from the URL.
69 // Returns a blank string if search terms were not found, or if search terms 57 // Returns a blank string if search terms were not found, or if search terms
70 // extraction is disabled for this WebContents or profile. 58 // extraction is disabled for this WebContents or profile.
71 string16 GetSearchTerms(const content::WebContents* contents); 59 string16 GetSearchTerms(const content::WebContents* contents);
72 60
73 // Returns true if |url| should be rendered in the Instant renderer process. 61 // Returns true if |url| should be rendered in the Instant renderer process.
74 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile); 62 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile);
75 63
64 // Registers Instant-related user preferences. Called at startup.
65 void RegisterUserPrefs(PrefRegistrySyncable* registry);
66
67 // Returns prefs::kInstantExtendedEnabled in extended mode;
68 // prefs::kInstantEnabled otherwise.
69 const char* GetInstantPrefName(const Profile* profile);
70
71 // Returns whether the Instant pref (as per GetInstantPrefName()) is enabled.
72 bool IsInstantPrefEnabled(Profile* profile);
73
74 // Sets the default value of prefs::kInstantExtendedEnabled, based on field
75 // trials and the current value of prefs::kInstantEnabled.
76 void SetInstantExtendedPrefDefault(Profile* profile);
77
78 // Returns the Instant URL of the default search engine. Returns an empty GURL
79 // if the engine doesn't have an Instant URL, or if it shouldn't be used (say
80 // because it doesn't satisfy the requirements for extended mode or if Instant
81 // is disabled through preferences). Callers must check that the returned URL is
82 // valid before using it.
83 // NOTE: This method expands the default search engine's instant_url, so it
84 // shouldn't be called from SearchTermsData or other such code that would lead
85 // to an infinite recursion.
86 GURL GetInstantURL(Profile* profile);
87
88 // Instant (loading a remote server page and talking to it using the searchbox
89 // API) is considered enabled if there's a valid Instant URL that can be used,
90 // so this simply returns whether GetInstantURL() is a valid URL.
91 // NOTE: This method expands the default search engine's instant_url, so it
92 // shouldn't be called from SearchTermsData or other such code that would lead
93 // to an infinite recursion.
94 bool IsInstantEnabled(Profile* profile);
95
76 // ----------------------------------------------------- 96 // -----------------------------------------------------
77 // The following APIs are exposed for use in tests only. 97 // The following APIs are exposed for use in tests only.
78 // ----------------------------------------------------- 98 // -----------------------------------------------------
79 99
80 // Forces the Instant Extended API to be enabled for tests. 100 // Forces the Instant Extended API to be enabled for tests.
81 void EnableInstantExtendedAPIForTesting(); 101 void EnableInstantExtendedAPIForTesting();
82 102
83 // Forces query extraction to be enabled for tests. 103 // Forces query extraction to be enabled for tests.
84 void EnableQueryExtractionForTesting(); 104 void EnableQueryExtractionForTesting();
85 105
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 145
126 // Coerces the commandline Instant URL to look like a template URL, so that we 146 // Coerces the commandline Instant URL to look like a template URL, so that we
127 // can extract search terms from it. 147 // can extract search terms from it.
128 GURL CoerceCommandLineURLToTemplateURL(const GURL& instant_url, 148 GURL CoerceCommandLineURLToTemplateURL(const GURL& instant_url,
129 const TemplateURLRef& ref); 149 const TemplateURLRef& ref);
130 150
131 } // namespace search 151 } // namespace search
132 } // namespace chrome 152 } // namespace chrome
133 153
134 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_H_ 154 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698