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

Side by Side Diff: chrome/browser/ui/views/ash/app_list/search_builder.cc

Issue 10825317: Convert banned calls to use Navigate in ash app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/views/ash/app_list/extension_app_item.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/views/ash/app_list/search_builder.h" 5 #include "chrome/browser/ui/views/ash/app_list/search_builder.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/autocomplete/autocomplete_controller.h" 10 #include "chrome/browser/autocomplete/autocomplete_controller.h"
11 #include "chrome/browser/autocomplete/autocomplete_input.h" 11 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/autocomplete/autocomplete_match.h" 12 #include "chrome/browser/autocomplete/autocomplete_match.h"
13 #include "chrome/browser/autocomplete/autocomplete_result.h" 13 #include "chrome/browser/autocomplete/autocomplete_result.h"
14 #include "chrome/browser/autocomplete/extension_app_provider.h" 14 #include "chrome/browser/autocomplete/extension_app_provider.h"
15 #include "chrome/browser/event_disposition.h" 15 #include "chrome/browser/event_disposition.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/image_loading_tracker.h" 17 #include "chrome/browser/extensions/image_loading_tracker.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_navigator.h"
21 #include "chrome/browser/ui/browser_tabstrip.h" 21 #include "chrome/browser/ui/browser_tabstrip.h"
22 #include "chrome/browser/ui/views/ash/extension_utils.h" 22 #include "chrome/browser/ui/views/ash/extension_utils.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/extensions/extension_icon_set.h" 24 #include "chrome/common/extensions/extension_icon_set.h"
25 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
29 #include "ui/app_list/app_list_switches.h" 29 #include "ui/app_list/app_list_switches.h"
30 #include "ui/app_list/search_box_model.h" 30 #include "ui/app_list/search_box_model.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 const SearchBuilderResult* builder_result = 231 const SearchBuilderResult* builder_result =
232 static_cast<const SearchBuilderResult*>(&result); 232 static_cast<const SearchBuilderResult*>(&result);
233 const AutocompleteMatch& match = builder_result->match(); 233 const AutocompleteMatch& match = builder_result->match();
234 234
235 if (match.type == AutocompleteMatch::EXTENSION_APP) { 235 if (match.type == AutocompleteMatch::EXTENSION_APP) {
236 const extensions::Extension* extension = 236 const extensions::Extension* extension =
237 GetExtensionByURL(profile_, match.destination_url); 237 GetExtensionByURL(profile_, match.destination_url);
238 if (extension) 238 if (extension)
239 extension_utils::OpenExtension(profile_, extension, event_flags); 239 extension_utils::OpenExtension(profile_, extension, event_flags);
240 } else { 240 } else {
241 WindowOpenDisposition disposition =
242 chrome::DispositionFromEventFlags(event_flags);
243 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_);
244
245 if (disposition == CURRENT_TAB) {
246 // If current tab is not NTP, change disposition to NEW_FOREGROUND_TAB.
247 const GURL& url = chrome::GetActiveWebContents(browser) ?
248 chrome::GetActiveWebContents(browser)->GetURL() : GURL();
249 if (!url.SchemeIs(chrome::kChromeUIScheme) ||
250 url.host() != chrome::kChromeUINewTabHost) {
251 disposition = NEW_FOREGROUND_TAB;
252 }
253 }
254
255 // TODO(xiyuan): What should we do for alternate url case? 241 // TODO(xiyuan): What should we do for alternate url case?
256 browser->OpenURL( 242 chrome::NavigateParams params(NULL,
jennb 2012/08/14 00:33:01 Does it work to pass a NULL browser here? One of t
benwells 2012/08/14 02:46:36 This code from chrome::Navigate() makes it safe:
257 content::OpenURLParams(match.destination_url, 243 match.destination_url,
258 content::Referrer(), 244 match.transition);
259 disposition, 245 params.disposition = chrome::DispositionFromEventFlags(event_flags);
xiyuan 2012/08/13 16:20:55 Think we still need the special case for dispositi
xiyuan 2012/08/13 17:49:00 One simple work around might be like this: params
benwells 2012/08/14 08:49:03 The navigate function will change disposition from
xiyuan 2012/08/14 16:18:17 Okay. Good to know that NormalizeDisposition will
260 match.transition, 246 chrome::Navigate(&params);
261 false));
262 } 247 }
263 } 248 }
264 249
265 void SearchBuilder::PopulateFromACResult(const AutocompleteResult& ac_result) { 250 void SearchBuilder::PopulateFromACResult(const AutocompleteResult& ac_result) {
266 results_->DeleteAll(); 251 results_->DeleteAll();
267 for (ACMatches::const_iterator it = ac_result.begin(); 252 for (ACMatches::const_iterator it = ac_result.begin();
268 it != ac_result.end(); 253 it != ac_result.end();
269 ++it) { 254 ++it) {
270 results_->Add(new SearchBuilderResult(profile_, *it)); 255 results_->Add(new SearchBuilderResult(profile_, *it));
271 } 256 }
272 } 257 }
273 258
274 void SearchBuilder::OnResultChanged(bool default_match_changed) { 259 void SearchBuilder::OnResultChanged(bool default_match_changed) {
275 // TODO(xiyuan): Handle default match properly. 260 // TODO(xiyuan): Handle default match properly.
276 const AutocompleteResult& ac_result = controller_->result(); 261 const AutocompleteResult& ac_result = controller_->result();
277 PopulateFromACResult(ac_result); 262 PopulateFromACResult(ac_result);
278 } 263 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/app_list/extension_app_item.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698