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

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: Addressed comments, added a test to address the bug 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void SetOmniboxBounds(const gfx::Rect& bounds); 82 void SetOmniboxBounds(const gfx::Rect& bounds);
82 83
83 // Notifies |instant_| to toggle voice search. 84 // Notifies |instant_| to toggle voice search.
84 void ToggleVoiceSearch(); 85 void ToggleVoiceSearch();
85 86
86 private: 87 private:
87 // Overridden from search::SearchModelObserver: 88 // Overridden from search::SearchModelObserver:
88 virtual void ModelChanged(const SearchModel::State& old_state, 89 virtual void ModelChanged(const SearchModel::State& old_state,
89 const SearchModel::State& new_state) OVERRIDE; 90 const SearchModel::State& new_state) OVERRIDE;
90 91
91 // Called when the default search provider changes. Revokes the searchbox API 92 // Overridden from InstantServiceObserver:
92 // privileges for any existing WebContents (that belong to the erstwhile 93 virtual void DefaultSearchProviderChanged() OVERRIDE;
93 // default search provider) by simply reloading all such WebContents. This 94 virtual void GoogleURLUpdated() OVERRIDE;
94 // ensures that they are reloaded in a non-privileged renderer process. 95
95 void OnDefaultSearchProviderChanged(const std::string& pref_name); 96 // Reloads the tabs in instant process to ensure that their privileged status
97 // is still valid.
98 void ReloadTabsInInstantProcess();
96 99
97 // Replaces the contents at tab |index| with |new_contents| and deletes the 100 // Replaces the contents at tab |index| with |new_contents| and deletes the
98 // existing contents. 101 // existing contents.
99 void ReplaceWebContentsAt(int index, 102 void ReplaceWebContentsAt(int index,
100 scoped_ptr<content::WebContents> new_contents); 103 scoped_ptr<content::WebContents> new_contents);
101 104
102 Browser* const browser_; 105 Browser* const browser_;
103 106
104 InstantController instant_; 107 InstantController instant_;
105 InstantUnloadHandler instant_unload_handler_; 108 InstantUnloadHandler instant_unload_handler_;
106 109
107 PrefChangeRegistrar profile_pref_registrar_;
108
109 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); 110 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController);
110 }; 111 };
111 112
112 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ 113 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698