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

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

Issue 16413002: Moved theme related state from BrowserInstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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 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_INSTANT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "base/timer.h" 18 #include "base/timer.h"
19 #include "chrome/browser/search/instant_service_observer.h"
19 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 20 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
20 #include "chrome/browser/ui/search/instant_commit_type.h" 21 #include "chrome/browser/ui/search/instant_commit_type.h"
21 #include "chrome/browser/ui/search/instant_overlay_model.h" 22 #include "chrome/browser/ui/search/instant_overlay_model.h"
22 #include "chrome/browser/ui/search/instant_page.h" 23 #include "chrome/browser/ui/search/instant_page.h"
23 #include "chrome/common/instant_types.h" 24 #include "chrome/common/instant_types.h"
24 #include "chrome/common/omnibox_focus_state.h" 25 #include "chrome/common/omnibox_focus_state.h"
25 #include "chrome/common/search_types.h" 26 #include "chrome/common/search_types.h"
26 #include "content/public/common/page_transition_types.h" 27 #include "content/public/common/page_transition_types.h"
27 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
28 #include "ui/base/window_open_disposition.h" 29 #include "ui/base/window_open_disposition.h"
29 #include "ui/gfx/native_widget_types.h" 30 #include "ui/gfx/native_widget_types.h"
30 #include "ui/gfx/rect.h" 31 #include "ui/gfx/rect.h"
31 32
32 struct AutocompleteMatch; 33 struct AutocompleteMatch;
33 struct InstantAutocompleteResult; 34 struct InstantAutocompleteResult;
34 35
35 class AutocompleteProvider; 36 class AutocompleteProvider;
36 class AutocompleteResult; 37 class AutocompleteResult;
37 class BrowserInstantController; 38 class BrowserInstantController;
38 class InstantNTP; 39 class InstantNTP;
39 class InstantOverlay; 40 class InstantOverlay;
41 class InstantService;
40 class InstantTab; 42 class InstantTab;
41 class TemplateURL; 43 class TemplateURL;
42 44
43 namespace content { 45 namespace content {
44 class WebContents; 46 class WebContents;
45 } 47 }
46 48
47 // Macro used for logging debug events. |message| should be a std::string. 49 // Macro used for logging debug events. |message| should be a std::string.
48 #define LOG_INSTANT_DEBUG_EVENT(controller, message) \ 50 #define LOG_INSTANT_DEBUG_EVENT(controller, message) \
49 controller->LogDebugEvent(message) 51 controller->LogDebugEvent(message)
50 52
51 // InstantController drives Chrome Instant, i.e., the browser implementation of 53 // InstantController drives Chrome Instant, i.e., the browser implementation of
52 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch). 54 // the Embedded Search API (see http://dev.chromium.org/embeddedsearch).
53 // 55 //
54 // In extended mode, InstantController maintains and coordinates three 56 // In extended mode, InstantController maintains and coordinates three
55 // instances of InstantPage: 57 // instances of InstantPage:
56 // (1) An InstantOverlay instance that is used to show search suggestions and 58 // (1) An InstantOverlay instance that is used to show search suggestions and
57 // results in an overlay over a non-search page. 59 // results in an overlay over a non-search page.
58 // (2) An InstantNTP instance which is a preloaded search page that will be 60 // (2) An InstantNTP instance which is a preloaded search page that will be
59 // swapped-in the next time the user navigates to the New Tab Page. It is 61 // swapped-in the next time the user navigates to the New Tab Page. It is
60 // never shown to the user in an uncommitted state. 62 // never shown to the user in an uncommitted state.
61 // (3) An InstantTab instance which points to the currently active tab, if it 63 // (3) An InstantTab instance which points to the currently active tab, if it
62 // supports the Embedded Search API. 64 // supports the Embedded Search API.
63 // 65 //
64 // All three are backed by a WebContents. InstantOverlay and InstantNTP own 66 // All three are backed by a WebContents. InstantOverlay and InstantNTP own
65 // their corresponding WebContents; InstantTab does not. In non-extended mode, 67 // their corresponding WebContents; InstantTab does not. In non-extended mode,
66 // only an InstantOverlay instance is kept. 68 // only an InstantOverlay instance is kept.
67 // 69 //
68 // InstantController is owned by Browser via BrowserInstantController. 70 // InstantController is owned by Browser via BrowserInstantController.
69 class InstantController : public InstantPage::Delegate { 71 class InstantController : public InstantPage::Delegate,
72 public InstantServiceObserver {
70 public: 73 public:
71 // For reporting fallbacks to local overlay. 74 // For reporting fallbacks to local overlay.
72 enum InstantFallbackReason { 75 enum InstantFallbackReason {
73 INSTANT_FALLBACK_NONE = 0, 76 INSTANT_FALLBACK_NONE = 0,
74 INSTANT_FALLBACK_UNKNOWN = 1, 77 INSTANT_FALLBACK_UNKNOWN = 1,
75 INSTANT_FALLBACK_INSTANT_URL_EMPTY = 2, 78 INSTANT_FALLBACK_INSTANT_URL_EMPTY = 2,
76 INSTANT_FALLBACK_ORIGIN_PATH_MISMATCH = 3, 79 INSTANT_FALLBACK_ORIGIN_PATH_MISMATCH = 3,
77 INSTANT_FALLBACK_INSTANT_NOT_SUPPORTED = 4, 80 INSTANT_FALLBACK_INSTANT_NOT_SUPPORTED = 4,
78 INSTANT_FALLBACK_NO_OVERLAY = 5, 81 INSTANT_FALLBACK_NO_OVERLAY = 5,
79 INSTANT_FALLBACK_JAVASCRIPT_DISABLED = 6, 82 INSTANT_FALLBACK_JAVASCRIPT_DISABLED = 6,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void ActiveTabChanged(); 190 void ActiveTabChanged();
188 191
189 // The user is about to switch tabs. Commit the overlay if needed. 192 // The user is about to switch tabs. Commit the overlay if needed.
190 void TabDeactivated(content::WebContents* contents); 193 void TabDeactivated(content::WebContents* contents);
191 194
192 // Sets whether Instant should show result overlays. |use_local_page_only| 195 // Sets whether Instant should show result overlays. |use_local_page_only|
193 // will force the use of baked-in page as the Instant URL and is only 196 // will force the use of baked-in page as the Instant URL and is only
194 // applicable if |extended_enabled_| is true. 197 // applicable if |extended_enabled_| is true.
195 void SetInstantEnabled(bool instant_enabled, bool use_local_page_only); 198 void SetInstantEnabled(bool instant_enabled, bool use_local_page_only);
196 199
197 // The theme has changed. Pass the message to the overlay page.
198 void ThemeChanged(const ThemeBackgroundInfo& theme_info);
199
200 // Called when someone else swapped in a different contents in the |overlay_|. 200 // Called when someone else swapped in a different contents in the |overlay_|.
201 void SwappedOverlayContents(); 201 void SwappedOverlayContents();
202 202
203 // Called when contents for |overlay_| received focus. 203 // Called when contents for |overlay_| received focus.
204 void FocusedOverlayContents(); 204 void FocusedOverlayContents();
205 205
206 // Called when the |overlay_| might be stale. If it's actually stale, and the 206 // Called when the |overlay_| might be stale. If it's actually stale, and the
207 // omnibox doesn't have focus, and the overlay isn't showing, the |overlay_| 207 // omnibox doesn't have focus, and the overlay isn't showing, the |overlay_|
208 // is deleted and recreated. Else the refresh is skipped. 208 // is deleted and recreated. Else the refresh is skipped.
209 void ReloadOverlayIfStale(); 209 void ReloadOverlayIfStale();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 virtual void FocusOmnibox(const content::WebContents* contents, 333 virtual void FocusOmnibox(const content::WebContents* contents,
334 OmniboxFocusState state) OVERRIDE; 334 OmniboxFocusState state) OVERRIDE;
335 virtual void NavigateToURL( 335 virtual void NavigateToURL(
336 const content::WebContents* contents, 336 const content::WebContents* contents,
337 const GURL& url, 337 const GURL& url,
338 content::PageTransition transition, 338 content::PageTransition transition,
339 WindowOpenDisposition disposition, 339 WindowOpenDisposition disposition,
340 bool is_search_type) OVERRIDE; 340 bool is_search_type) OVERRIDE;
341 virtual void InstantPageLoadFailed(content::WebContents* contents) OVERRIDE; 341 virtual void InstantPageLoadFailed(content::WebContents* contents) OVERRIDE;
342 342
343 // Overridden from InstantServiceObserver:
344 virtual void ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) OVERRIDE;
345
343 // Invoked by the InstantLoader when the Instant page wants to delete a 346 // Invoked by the InstantLoader when the Instant page wants to delete a
344 // Most Visited item. 347 // Most Visited item.
345 virtual void DeleteMostVisitedItem(const GURL& url) OVERRIDE; 348 virtual void DeleteMostVisitedItem(const GURL& url) OVERRIDE;
346 349
347 // Invoked by the InstantLoader when the Instant page wants to undo a 350 // Invoked by the InstantLoader when the Instant page wants to undo a
348 // Most Visited deletion. 351 // Most Visited deletion.
349 virtual void UndoMostVisitedDeletion(const GURL& url) OVERRIDE; 352 virtual void UndoMostVisitedDeletion(const GURL& url) OVERRIDE;
350 353
351 // Invoked by the InstantLoader when the Instant page wants to undo all 354 // Invoked by the InstantLoader when the Instant page wants to undo all
352 // Most Visited deletions. 355 // Most Visited deletions.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 426
424 // Populates InstantAutocompleteResult with AutocompleteMatch details. 427 // Populates InstantAutocompleteResult with AutocompleteMatch details.
425 // |autocomplete_match_index| specifies the index of |match| in the 428 // |autocomplete_match_index| specifies the index of |match| in the
426 // AutocompleteResult. If the |match| is obtained from auto complete 429 // AutocompleteResult. If the |match| is obtained from auto complete
427 // providers, then the |autocomplete_match_index| is set to kNoMatchIndex. 430 // providers, then the |autocomplete_match_index| is set to kNoMatchIndex.
428 void PopulateInstantAutocompleteResultFromMatch( 431 void PopulateInstantAutocompleteResultFromMatch(
429 const AutocompleteMatch& match, 432 const AutocompleteMatch& match,
430 size_t autocomplete_match_index, 433 size_t autocomplete_match_index,
431 InstantAutocompleteResult* result); 434 InstantAutocompleteResult* result);
432 435
436 // Returns the InstantService for the browser profile.
437 InstantService* GetInstantService() const;
438
433 BrowserInstantController* const browser_; 439 BrowserInstantController* const browser_;
434 440
435 // Whether the extended API and regular API are enabled. If both are false, 441 // Whether the extended API and regular API are enabled. If both are false,
436 // Instant is effectively disabled. 442 // Instant is effectively disabled.
437 const bool extended_enabled_; 443 const bool extended_enabled_;
438 bool instant_enabled_; 444 bool instant_enabled_;
439 445
440 // If true, the Instant URL is set to kChromeSearchLocalNtpUrl. 446 // If true, the Instant URL is set to kChromeSearchLocalNtpUrl.
441 bool use_local_page_only_; 447 bool use_local_page_only_;
442 448
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. 537 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false.
532 bool allow_overlay_to_show_search_suggestions_; 538 bool allow_overlay_to_show_search_suggestions_;
533 539
534 // List of events and their timestamps, useful in debugging Instant behaviour. 540 // List of events and their timestamps, useful in debugging Instant behaviour.
535 mutable std::list<std::pair<int64, std::string> > debug_events_; 541 mutable std::list<std::pair<int64, std::string> > debug_events_;
536 542
537 DISALLOW_COPY_AND_ASSIGN(InstantController); 543 DISALLOW_COPY_AND_ASSIGN(InstantController);
538 }; 544 };
539 545
540 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ 546 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.cc ('k') | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698