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

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

Issue 10816027: alternate ntp: toolbar background and separator animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove separator fading, address comments Created 8 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 | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
27 } // namespace 27 } // namespace
28 28
29 namespace chrome { 29 namespace chrome {
30 namespace search { 30 namespace search {
31 31
32 SearchTabHelper::SearchTabHelper( 32 SearchTabHelper::SearchTabHelper(
33 TabContents* contents, 33 TabContents* contents,
34 bool is_search_enabled) 34 bool is_search_enabled)
35 : WebContentsObserver(contents->web_contents()), 35 : WebContentsObserver(contents->web_contents()),
36 is_search_enabled_(is_search_enabled), 36 is_search_enabled_(is_search_enabled),
37 model_(contents) { 37 model_(contents),
38 has_navigated_(false) {
38 if (!is_search_enabled) 39 if (!is_search_enabled)
39 return; 40 return;
40 41
41 registrar_.Add( 42 registrar_.Add(
42 this, 43 this,
43 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 44 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
44 content::Source<content::NavigationController>( 45 content::Source<content::NavigationController>(
45 &contents->web_contents()->GetController())); 46 &contents->web_contents()->GetController()));
46 } 47 }
47 48
(...skipping 30 matching lines...) Expand all
78 Mode::Type mode = Mode::MODE_DEFAULT; 79 Mode::Type mode = Mode::MODE_DEFAULT;
79 GURL url(web_contents()->GetURL()); 80 GURL url(web_contents()->GetURL());
80 // TODO(kuan): revisit this condition when zero suggest becomes available. 81 // TODO(kuan): revisit this condition when zero suggest becomes available.
81 if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec()) || 82 if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec()) ||
82 (edit_model->has_focus() && edit_model->user_input_in_progress())) { 83 (edit_model->has_focus() && edit_model->user_input_in_progress())) {
83 mode = Mode::MODE_SEARCH; 84 mode = Mode::MODE_SEARCH;
84 } 85 }
85 model_.SetMode(Mode(mode, true)); 86 model_.SetMode(Mode(mode, true));
86 } 87 }
87 88
88 void SearchTabHelper::NavigateToPendingEntry(
89 const GURL& url,
90 content::NavigationController::ReloadType reload_type) {
91 if (!is_search_enabled_)
92 return;
93
94 UpdateModel(url);
95 FlushNTP(url);
96 }
97
98 void SearchTabHelper::Observe( 89 void SearchTabHelper::Observe(
99 int type, 90 int type,
100 const content::NotificationSource& source, 91 const content::NotificationSource& source,
101 const content::NotificationDetails& details) { 92 const content::NotificationDetails& details) {
102 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); 93 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
103 content::LoadCommittedDetails* committed_details = 94 content::LoadCommittedDetails* committed_details =
104 content::Details<content::LoadCommittedDetails>(details).ptr(); 95 content::Details<content::LoadCommittedDetails>(details).ptr();
105 UpdateModel(committed_details->entry->GetURL()); 96 UpdateModel(committed_details->entry->GetURL(), has_navigated_);
97 has_navigated_ = true;
106 FlushNTP(committed_details->entry->GetURL()); 98 FlushNTP(committed_details->entry->GetURL());
107 } 99 }
108 100
109 void SearchTabHelper::UpdateModel(const GURL& url) { 101 void SearchTabHelper::UpdateModel(const GURL& url, bool animate) {
110 Mode::Type type = Mode::MODE_DEFAULT; 102 Mode::Type type = Mode::MODE_DEFAULT;
111 if (IsNTP(url)) 103 if (IsNTP(url))
112 type = Mode::MODE_NTP; 104 type = Mode::MODE_NTP;
113 else if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) 105 else if (google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec()))
114 type = Mode::MODE_SEARCH; 106 type = Mode::MODE_SEARCH;
115 model_.SetMode(Mode(type, true)); 107 model_.SetMode(Mode(type, animate));
116 } 108 }
117 109
118 void SearchTabHelper::FlushNTP(const GURL& url) { 110 void SearchTabHelper::FlushNTP(const GURL& url) {
119 if (!IsNTP(url) && 111 if (!IsNTP(url) &&
120 !google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) { 112 !google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) {
121 ntp_web_contents_.reset(); 113 ntp_web_contents_.reset();
122 } 114 }
123 } 115 }
124 116
125 } // namespace search 117 } // namespace search
126 } // namespace chrome 118 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698