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

Side by Side Diff: chrome/browser/search/instant_service.cc

Issue 13375003: Fixing iframe jank in the local omnibox popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing sites, too. Created 7 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/search/instant_service.h" 5 #include "chrome/browser/search/instant_service.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "chrome/browser/history/history_notifications.h" 8 #include "chrome/browser/history/history_notifications.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_io_context.h" 10 #include "chrome/browser/search/instant_io_context.h"
11 #include "chrome/browser/search/instant_service_factory.h" 11 #include "chrome/browser/search/instant_service_factory.h"
12 #include "chrome/browser/search/local_ntp_source.h" 12 #include "chrome/browser/search/local_ntp_source.h"
13 #include "chrome/browser/search/local_omnibox_popup_source.h" 13 #include "chrome/browser/search/local_omnibox_popup_source.h"
14 #include "chrome/browser/search/suggestion_source.h"
14 #include "chrome/browser/ui/webui/favicon_source.h" 15 #include "chrome/browser/ui/webui/favicon_source.h"
15 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 16 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
16 #include "chrome/browser/ui/webui/theme_source.h" 17 #include "chrome/browser/ui/webui/theme_source.h"
17 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
21 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/url_data_source.h" 23 #include "content/public/browser/url_data_source.h"
23 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
(...skipping 23 matching lines...) Expand all
47 48
48 // Set up the data sources that Instant uses on the NTP. 49 // Set up the data sources that Instant uses on the NTP.
49 #if defined(ENABLE_THEMES) 50 #if defined(ENABLE_THEMES)
50 content::URLDataSource::Add(profile, new ThemeSource(profile)); 51 content::URLDataSource::Add(profile, new ThemeSource(profile));
51 #endif 52 #endif
52 content::URLDataSource::Add(profile, new ThumbnailSource(profile)); 53 content::URLDataSource::Add(profile, new ThumbnailSource(profile));
53 content::URLDataSource::Add(profile, new FaviconSource( 54 content::URLDataSource::Add(profile, new FaviconSource(
54 profile, FaviconSource::FAVICON)); 55 profile, FaviconSource::FAVICON));
55 content::URLDataSource::Add(profile, new LocalOmniboxPopupSource()); 56 content::URLDataSource::Add(profile, new LocalOmniboxPopupSource());
56 content::URLDataSource::Add(profile, new LocalNtpSource()); 57 content::URLDataSource::Add(profile, new LocalNtpSource());
58 content::URLDataSource::Add(profile, new SuggestionSource());
57 } 59 }
58 60
59 InstantService::~InstantService() { 61 InstantService::~InstantService() {
60 } 62 }
61 63
62 // static 64 // static
63 const std::string InstantService::MaybeTranslateInstantPathOnUI( 65 const std::string InstantService::MaybeTranslateInstantPathOnUI(
64 Profile* profile, const std::string& path) { 66 Profile* profile, const std::string& path) {
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
66 InstantService* instant_service = 68 InstantService* instant_service =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // static 100 // static
99 bool InstantService::IsInstantPath(const GURL& url) { 101 bool InstantService::IsInstantPath(const GURL& url) {
100 // Strip leading slash. 102 // Strip leading slash.
101 std::string path = url.path().substr(1); 103 std::string path = url.path().substr(1);
102 104
103 // Check that path is of Most Visited item ID form. 105 // Check that path is of Most Visited item ID form.
104 InstantRestrictedID dummy = 0; 106 InstantRestrictedID dummy = 0;
105 return base::StringToInt(path, &dummy); 107 return base::StringToInt(path, &dummy);
106 } 108 }
107 109
108 void InstantService::AddInstantProcess(int process_id) { 110 void InstantService::AddInstantProcess(int process_id, const GURL& site_url) {
109 process_ids_.insert(process_id); 111 process_ids_.insert(process_id);
110 112
111 if (instant_io_context_) { 113 if (instant_io_context_) {
112 BrowserThread::PostTask( 114 BrowserThread::PostTask(
113 BrowserThread::IO, FROM_HERE, 115 BrowserThread::IO, FROM_HERE,
114 base::Bind(&InstantIOContext::AddInstantProcessOnIO, 116 base::Bind(&InstantIOContext::AddInstantProcessOnIO,
115 instant_io_context_, process_id)); 117 instant_io_context_, process_id, site_url));
116 } 118 }
117 } 119 }
118 120
119 bool InstantService::IsInstantProcess(int process_id) const { 121 bool InstantService::IsInstantProcess(int process_id) const {
120 return process_ids_.find(process_id) != process_ids_.end(); 122 return process_ids_.find(process_id) != process_ids_.end();
121 } 123 }
122 124
123 void InstantService::AddMostVisitedItems( 125 void InstantService::AddMostVisitedItems(
124 const std::vector<InstantMostVisitedItem>& items) { 126 const std::vector<InstantMostVisitedItem>& items) {
125 most_visited_item_cache_.AddItems(items); 127 most_visited_item_cache_.AddItems(items);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 BrowserThread::IO, FROM_HERE, 176 BrowserThread::IO, FROM_HERE,
175 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO, 177 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO,
176 instant_io_context_, process_id)); 178 instant_io_context_, process_id));
177 } 179 }
178 break; 180 break;
179 } 181 }
180 default: 182 default:
181 NOTREACHED() << "Unexpected notification type in InstantService."; 183 NOTREACHED() << "Unexpected notification type in InstantService.";
182 } 184 }
183 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698