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

Side by Side Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 7 years, 11 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 #include "chrome/browser/ui/search/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include "chrome/browser/google/google_util.h" 7 #include "chrome/browser/google/google_util.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search_engines/template_url.h" 9 #include "chrome/browser/search_engines/template_url.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return; 92 return;
93 UpdateModelBasedOnURL(web_contents()->GetURL()); 93 UpdateModelBasedOnURL(web_contents()->GetURL());
94 } 94 }
95 95
96 void SearchTabHelper::NavigateToPendingEntry( 96 void SearchTabHelper::NavigateToPendingEntry(
97 const GURL& url, 97 const GURL& url,
98 content::NavigationController::ReloadType reload_type) { 98 content::NavigationController::ReloadType reload_type) {
99 if (!is_search_enabled_) 99 if (!is_search_enabled_)
100 return; 100 return;
101 101
102 // NTP mode changes are initiated at "pending", all others are initiated 102 // TODO(samarth): check with Kuan that this is safe to remove.
dhollowa 2013/01/10 18:50:29 I expect this is ok, but you'll need to change lin
samarth 2013/01/11 19:43:05 Done (I assume you meant line 118?). I've sent an
103 // when "committed". This is because NTP is rendered natively so is faster 103 // // NTP mode changes are initiated at "pending", all others are initiated
104 // to render than the web contents and we need to coordinate the animations. 104 // // when "committed". This is because NTP is rendered natively so is faster
105 if (IsNTP(url)) 105 // // to render than the web contents and we need to coordinate the animations.
106 UpdateModelBasedOnURL(url); 106 // if (IsNTP(url))
107 // UpdateModelBasedOnURL(url);
107 } 108 }
108 109
109 void SearchTabHelper::Observe( 110 void SearchTabHelper::Observe(
110 int type, 111 int type,
111 const content::NotificationSource& source, 112 const content::NotificationSource& source,
112 const content::NotificationDetails& details) { 113 const content::NotificationDetails& details) {
113 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); 114 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
114 content::LoadCommittedDetails* committed_details = 115 content::LoadCommittedDetails* committed_details =
115 content::Details<content::LoadCommittedDetails>(details).ptr(); 116 content::Details<content::LoadCommittedDetails>(details).ptr();
116 // See comment in |NavigateToPendingEntry()| about why |!IsNTP()| is used. 117 // See comment in |NavigateToPendingEntry()| about why |!IsNTP()| is used.
117 if (!IsNTP(committed_details->entry->GetURL())) { 118 if (!IsNTP(committed_details->entry->GetVirtualURL()))
118 UpdateModelBasedOnURL(committed_details->entry->GetURL()); 119 UpdateModelBasedOnURL(committed_details->entry->GetVirtualURL());
119 }
120 } 120 }
121 121
122 void SearchTabHelper::UpdateModelBasedOnURL(const GURL& url) { 122 void SearchTabHelper::UpdateModelBasedOnURL(const GURL& url) {
123 Mode::Type type = Mode::MODE_DEFAULT; 123 Mode::Type type = Mode::MODE_DEFAULT;
124 Mode::Origin origin = Mode::ORIGIN_DEFAULT; 124 Mode::Origin origin = Mode::ORIGIN_DEFAULT;
125 if (IsNTP(url)) { 125 if (IsNTP(url)) {
126 type = Mode::MODE_NTP; 126 type = Mode::MODE_NTP;
127 origin = Mode::ORIGIN_NTP; 127 origin = Mode::ORIGIN_NTP;
128 } else if (IsSearchResults(url, ProfileFromWebContents(web_contents()))) { 128 } else if (IsSearchResults(url, ProfileFromWebContents(web_contents()))) {
129 type = Mode::MODE_SEARCH_RESULTS; 129 type = Mode::MODE_SEARCH_RESULTS;
130 origin = Mode::ORIGIN_SEARCH; 130 origin = Mode::ORIGIN_SEARCH;
131 } 131 }
132 if (user_input_in_progress_) 132 if (user_input_in_progress_)
133 type = Mode::MODE_SEARCH_SUGGESTIONS; 133 type = Mode::MODE_SEARCH_SUGGESTIONS;
134 model_.SetMode(Mode(type, origin)); 134 model_.SetMode(Mode(type, origin));
135 } 135 }
136 136
137 const content::WebContents* SearchTabHelper::web_contents() const { 137 const content::WebContents* SearchTabHelper::web_contents() const {
138 return model_.web_contents(); 138 return model_.web_contents();
139 } 139 }
140 140
141 } // namespace search 141 } // namespace search
142 } // namespace chrome 142 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698