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