OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/ui/omnibox/omnibox_edit_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 model_.SetMode(Mode(mode, true)); | 85 model_.SetMode(Mode(mode, true)); |
86 } | 86 } |
87 | 87 |
88 void SearchTabHelper::NavigateToPendingEntry( | 88 void SearchTabHelper::NavigateToPendingEntry( |
89 const GURL& url, | 89 const GURL& url, |
90 content::NavigationController::ReloadType reload_type) { | 90 content::NavigationController::ReloadType reload_type) { |
91 if (!is_search_enabled_) | 91 if (!is_search_enabled_) |
92 return; | 92 return; |
93 | 93 |
94 UpdateModel(url); | 94 UpdateModel(url, !web_contents()->GetController().IsInitialNavigation()); |
95 FlushNTP(url); | 95 FlushNTP(url); |
96 } | 96 } |
97 | 97 |
98 void SearchTabHelper::Observe( | 98 void SearchTabHelper::Observe( |
99 int type, | 99 int type, |
100 const content::NotificationSource& source, | 100 const content::NotificationSource& source, |
101 const content::NotificationDetails& details) { | 101 const content::NotificationDetails& details) { |
102 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); | 102 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); |
103 content::LoadCommittedDetails* committed_details = | 103 content::LoadCommittedDetails* committed_details = |
104 content::Details<content::LoadCommittedDetails>(details).ptr(); | 104 content::Details<content::LoadCommittedDetails>(details).ptr(); |
105 UpdateModel(committed_details->entry->GetURL()); | 105 UpdateModel(committed_details->entry->GetURL(), |
| 106 web_contents()->GetController().IsInitialNavigation()); |
106 FlushNTP(committed_details->entry->GetURL()); | 107 FlushNTP(committed_details->entry->GetURL()); |
107 } | 108 } |
108 | 109 |
109 void SearchTabHelper::UpdateModel(const GURL& url) { | 110 void SearchTabHelper::UpdateModel(const GURL& url, bool animate) { |
110 Mode::Type type = Mode::MODE_DEFAULT; | 111 Mode::Type type = Mode::MODE_DEFAULT; |
111 if (IsNTP(url)) | 112 if (IsNTP(url)) |
112 type = Mode::MODE_NTP; | 113 type = Mode::MODE_NTP; |
113 else if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) | 114 else if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) |
114 type = Mode::MODE_SEARCH; | 115 type = Mode::MODE_SEARCH; |
115 model_.SetMode(Mode(type, true)); | 116 model_.SetMode(Mode(type, animate)); |
116 } | 117 } |
117 | 118 |
118 void SearchTabHelper::FlushNTP(const GURL& url) { | 119 void SearchTabHelper::FlushNTP(const GURL& url) { |
119 if (!IsNTP(url) && | 120 if (!IsNTP(url) && |
120 !google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) { | 121 !google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) { |
121 ntp_web_contents_.reset(); | 122 ntp_web_contents_.reset(); |
122 } | 123 } |
123 } | 124 } |
124 | 125 |
125 } // namespace search | 126 } // namespace search |
126 } // namespace chrome | 127 } // namespace chrome |
OLD | NEW |