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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 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/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/command_updater.h" 16 #include "chrome/browser/command_updater.h"
17 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" 18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
19 #include "chrome/browser/extensions/location_bar_controller.h" 19 #include "chrome/browser/extensions/location_bar_controller.h"
20 #include "chrome/browser/extensions/script_bubble_controller.h" 20 #include "chrome/browser/extensions/script_bubble_controller.h"
21 #include "chrome/browser/extensions/tab_helper.h" 21 #include "chrome/browser/extensions/tab_helper.h"
22 #include "chrome/browser/favicon/favicon_tab_helper.h" 22 #include "chrome/browser/favicon/favicon_tab_helper.h"
23 #include "chrome/browser/instant/instant_controller.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/search_engines/template_url.h" 25 #include "chrome/browser/search_engines/template_url.h"
25 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
26 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_finder.h" 29 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/browser_instant_controller.h" 30 #include "chrome/browser/ui/browser_instant_controller.h"
30 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" 31 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h"
31 #include "chrome/browser/ui/omnibox/location_bar_util.h" 32 #include "chrome/browser/ui/omnibox/location_bar_util.h"
32 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { 1231 if (views::FocusManager::IsTabTraversalKeyEvent(event)) {
1231 if (location_entry_->model()->popup_model()->IsOpen()) { 1232 if (location_entry_->model()->popup_model()->IsOpen()) {
1232 // Return true so that the edit sees the tab and moves the selection. 1233 // Return true so that the edit sees the tab and moves the selection.
1233 return true; 1234 return true;
1234 } 1235 }
1235 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { 1236 if (keyword_hint_view_->visible() && !event.IsShiftDown()) {
1236 // Return true so the edit gets the tab event and enters keyword mode. 1237 // Return true so the edit gets the tab event and enters keyword mode.
1237 return true; 1238 return true;
1238 } 1239 }
1239 1240
1240 // Tab while showing Instant commits instant immediately. 1241 // Tab while showing Instant commits Instant immediately.
1241 // Return true so that focus traversal isn't attempted. The edit ends 1242 // Return true so that focus traversal isn't attempted. The edit ends
1242 // up doing nothing in this case. 1243 // up doing nothing in this case.
1243 if (location_entry_->model()->AcceptCurrentInstantPreview()) 1244 if (location_entry_->model()->AcceptCurrentInstantPreview())
1244 return true; 1245 return true;
1245 } 1246 }
1246 1247
1247 #if defined(USE_AURA) 1248 #if defined(USE_AURA)
1248 NOTIMPLEMENTED(); 1249 NOTIMPLEMENTED();
1249 return false; 1250 return false;
1250 #else 1251 #else
(...skipping 18 matching lines...) Expand all
1269 location_entry_->GetSelectionBounds(&entry_start, &entry_end); 1270 location_entry_->GetSelectionBounds(&entry_start, &entry_end);
1270 state->selection_start = entry_start; 1271 state->selection_start = entry_start;
1271 state->selection_end = entry_end; 1272 state->selection_end = entry_end;
1272 } 1273 }
1273 1274
1274 bool LocationBarView::HasFocus() const { 1275 bool LocationBarView::HasFocus() const {
1275 return location_entry_->model()->has_focus(); 1276 return location_entry_->model()->has_focus();
1276 } 1277 }
1277 1278
1278 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1279 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1279 if (browser_ && browser_->instant_controller() && parent()) { 1280 if (browser_ && GetInstant() && parent())
1280 browser_->instant_controller()->SetOmniboxBounds(bounds()); 1281 GetInstant()->SetOmniboxBounds(bounds());
1281 }
1282 } 1282 }
1283 1283
1284 void LocationBarView::WriteDragDataForView(views::View* sender, 1284 void LocationBarView::WriteDragDataForView(views::View* sender,
1285 const gfx::Point& press_pt, 1285 const gfx::Point& press_pt,
1286 OSExchangeData* data) { 1286 OSExchangeData* data) {
1287 DCHECK_NE(GetDragOperationsForView(sender, press_pt), 1287 DCHECK_NE(GetDragOperationsForView(sender, press_pt),
1288 ui::DragDropTypes::DRAG_NONE); 1288 ui::DragDropTypes::DRAG_NONE);
1289 1289
1290 WebContents* web_contents = GetWebContents(); 1290 WebContents* web_contents = GetWebContents();
1291 FaviconTabHelper* favicon_tab_helper = 1291 FaviconTabHelper* favicon_tab_helper =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 TemplateURLServiceFactory::GetForProfile(profile_); 1323 TemplateURLServiceFactory::GetForProfile(profile_);
1324 if (!url_service->loaded()) { 1324 if (!url_service->loaded()) {
1325 template_url_service_ = url_service; 1325 template_url_service_ = url_service;
1326 template_url_service_->AddObserver(this); 1326 template_url_service_->AddObserver(this);
1327 template_url_service_->Load(); 1327 template_url_service_->Load();
1328 return; 1328 return;
1329 } 1329 }
1330 ShowFirstRunBubbleInternal(); 1330 ShowFirstRunBubbleInternal();
1331 } 1331 }
1332 1332
1333 void LocationBarView::SetInstantSuggestion(
1334 const InstantSuggestion& suggestion) {
1335 location_entry_->model()->SetInstantSuggestion(suggestion);
1336 }
1337
1338 string16 LocationBarView::GetInputString() const { 1333 string16 LocationBarView::GetInputString() const {
1339 return location_input_; 1334 return location_input_;
1340 } 1335 }
1341 1336
1342 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { 1337 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const {
1343 return disposition_; 1338 return disposition_;
1344 } 1339 }
1345 1340
1346 content::PageTransition LocationBarView::GetPageTransition() const { 1341 content::PageTransition LocationBarView::GetPageTransition() const {
1347 return transition_; 1342 return transition_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 1468 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
1474 int total_height = 1469 int total_height =
1475 use_preferred_size ? GetPreferredSize().height() : height(); 1470 use_preferred_size ? GetPreferredSize().height() : height();
1476 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); 1471 return std::max(total_height - (kVerticalEdgeThickness * 2), 0);
1477 } 1472 }
1478 1473
1479 bool LocationBarView::HasValidSuggestText() const { 1474 bool LocationBarView::HasValidSuggestText() const {
1480 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1475 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1481 !suggested_text_view_->text().empty(); 1476 !suggested_text_view_->text().empty();
1482 } 1477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698