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

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

Issue 20388003: Reload Instant NTP and Instant-process tabs on search url change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ui and unit tests Created 7 years, 4 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 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_BROWSER_INSTANT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_change_registrar.h" 12 #include "chrome/browser/search/instant_service_observer.h"
13 #include "chrome/browser/ui/search/instant_controller.h" 13 #include "chrome/browser/ui/search/instant_controller.h"
14 #include "chrome/browser/ui/search/instant_unload_handler.h" 14 #include "chrome/browser/ui/search/instant_unload_handler.h"
15 #include "chrome/browser/ui/search/search_model_observer.h" 15 #include "chrome/browser/ui/search/search_model_observer.h"
16 #include "ui/base/window_open_disposition.h" 16 #include "ui/base/window_open_disposition.h"
17 17
18 class Browser; 18 class Browser;
19 struct InstantSuggestion; 19 struct InstantSuggestion;
20 class Profile; 20 class Profile;
21 21
22 namespace content { 22 namespace content {
23 class WebContents; 23 class WebContents;
24 } 24 }
25 25
26 namespace gfx { 26 namespace gfx {
27 class Rect; 27 class Rect;
28 } 28 }
29 29
30 class BrowserInstantController : public SearchModelObserver { 30 class BrowserInstantController : public SearchModelObserver,
31 public InstantServiceObserver {
31 public: 32 public:
32 explicit BrowserInstantController(Browser* browser); 33 explicit BrowserInstantController(Browser* browser);
33 virtual ~BrowserInstantController(); 34 virtual ~BrowserInstantController();
34 35
35 // If |url| is the new tab page URL, set |target_contents| to the preloaded 36 // If |url| is the new tab page URL, set |target_contents| to the preloaded
36 // NTP contents from InstantController. If |source_contents| is not NULL, we 37 // NTP contents from InstantController. If |source_contents| is not NULL, we
37 // replace it with the new |target_contents| in the tabstrip and delete 38 // replace it with the new |target_contents| in the tabstrip and delete
38 // |source_contents|. Otherwise, the caller owns |target_contents| and is 39 // |source_contents|. Otherwise, the caller owns |target_contents| and is
39 // responsible for inserting it into the tabstrip. 40 // responsible for inserting it into the tabstrip.
40 // 41 //
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void SetOmniboxBounds(const gfx::Rect& bounds); 78 void SetOmniboxBounds(const gfx::Rect& bounds);
78 79
79 // Notifies |instant_| to toggle voice search. 80 // Notifies |instant_| to toggle voice search.
80 void ToggleVoiceSearch(); 81 void ToggleVoiceSearch();
81 82
82 private: 83 private:
83 // Overridden from search::SearchModelObserver: 84 // Overridden from search::SearchModelObserver:
84 virtual void ModelChanged(const SearchModel::State& old_state, 85 virtual void ModelChanged(const SearchModel::State& old_state,
85 const SearchModel::State& new_state) OVERRIDE; 86 const SearchModel::State& new_state) OVERRIDE;
86 87
87 // Called when the default search provider changes. Revokes the searchbox API 88 // Overridden from InstantServiceObserver:
88 // privileges for any existing WebContents (that belong to the erstwhile 89 virtual void DefaultSearchProviderChanged() OVERRIDE;
89 // default search provider) by simply reloading all such WebContents. This 90 virtual void GoogleURLUpdated() OVERRIDE;
90 // ensures that they are reloaded in a non-privileged renderer process. 91
91 void OnDefaultSearchProviderChanged(const std::string& pref_name); 92 // Reloads the tabs in instant process to ensure that their privileged status
93 // is still valid.
94 void ReloadTabsInInstantProcess();
92 95
93 // Replaces the contents at tab |index| with |new_contents| and deletes the 96 // Replaces the contents at tab |index| with |new_contents| and deletes the
94 // existing contents. 97 // existing contents.
95 void ReplaceWebContentsAt(int index, 98 void ReplaceWebContentsAt(int index,
96 scoped_ptr<content::WebContents> new_contents); 99 scoped_ptr<content::WebContents> new_contents);
97 100
98 Browser* const browser_; 101 Browser* const browser_;
99 102
100 InstantController instant_; 103 InstantController instant_;
101 InstantUnloadHandler instant_unload_handler_; 104 InstantUnloadHandler instant_unload_handler_;
102 105
103 PrefChangeRegistrar profile_pref_registrar_;
104
105 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); 106 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController);
106 }; 107 };
107 108
108 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ 109 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698