OLD | NEW |
1 // Copyright 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/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
56 #include "chrome/common/net/url_fixer_upper.h" | 56 #include "chrome/common/net/url_fixer_upper.h" |
57 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
58 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
59 #include "content/public/browser/navigation_controller.h" | 59 #include "content/public/browser/navigation_controller.h" |
60 #include "content/public/browser/navigation_entry.h" | 60 #include "content/public/browser/navigation_entry.h" |
61 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
62 #include "content/public/browser/render_view_host.h" | 62 #include "content/public/browser/render_view_host.h" |
63 #include "content/public/browser/user_metrics.h" | 63 #include "content/public/browser/user_metrics.h" |
64 #include "extensions/common/constants.h" | 64 #include "extensions/common/constants.h" |
| 65 #include "net/base/url_constants.h" |
65 #include "ui/gfx/image/image.h" | 66 #include "ui/gfx/image/image.h" |
66 #include "url/url_util.h" | 67 #include "url/url_util.h" |
67 | 68 |
68 using predictors::AutocompleteActionPredictor; | 69 using predictors::AutocompleteActionPredictor; |
69 | 70 |
70 | 71 |
71 // Helpers -------------------------------------------------------------------- | 72 // Helpers -------------------------------------------------------------------- |
72 | 73 |
73 namespace { | 74 namespace { |
74 | 75 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 *text, KeywordIsSelected(), true, ClassifyPage(), &match, NULL); | 475 *text, KeywordIsSelected(), true, ClassifyPage(), &match, NULL); |
475 if (AutocompleteMatch::IsSearchType(match.type)) | 476 if (AutocompleteMatch::IsSearchType(match.type)) |
476 return; | 477 return; |
477 *url = match.destination_url; | 478 *url = match.destination_url; |
478 | 479 |
479 // Prefix the text with 'http://' if the text doesn't start with 'http://', | 480 // Prefix the text with 'http://' if the text doesn't start with 'http://', |
480 // the text parses as a url with a scheme of http, the user selected the | 481 // the text parses as a url with a scheme of http, the user selected the |
481 // entire host, and the user hasn't edited the host or manually removed the | 482 // entire host, and the user hasn't edited the host or manually removed the |
482 // scheme. | 483 // scheme. |
483 GURL perm_url(PermanentURL()); | 484 GURL perm_url(PermanentURL()); |
484 if (perm_url.SchemeIs(content::kHttpScheme) && | 485 if (perm_url.SchemeIs(net::kHttpScheme) && url->SchemeIs(net::kHttpScheme) && |
485 url->SchemeIs(content::kHttpScheme) && perm_url.host() == url->host()) { | 486 perm_url.host() == url->host()) { |
486 *write_url = true; | 487 *write_url = true; |
487 base::string16 http = base::ASCIIToUTF16(content::kHttpScheme) + | 488 base::string16 http = base::ASCIIToUTF16(net::kHttpScheme) + |
488 base::ASCIIToUTF16(content::kStandardSchemeSeparator); | 489 base::ASCIIToUTF16(content::kStandardSchemeSeparator); |
489 if (text->compare(0, http.length(), http) != 0) | 490 if (text->compare(0, http.length(), http) != 0) |
490 *text = http + *text; | 491 *text = http + *text; |
491 } | 492 } |
492 } | 493 } |
493 | 494 |
494 void OmniboxEditModel::SetInputInProgress(bool in_progress) { | 495 void OmniboxEditModel::SetInputInProgress(bool in_progress) { |
495 if (in_progress && !user_input_since_focus_) { | 496 if (in_progress && !user_input_since_focus_) { |
496 base::TimeTicks now = base::TimeTicks::Now(); | 497 base::TimeTicks now = base::TimeTicks::Now(); |
497 DCHECK(last_omnibox_focus_ <= now); | 498 DCHECK(last_omnibox_focus_ <= now); |
498 UMA_HISTOGRAM_TIMES(kFocusToEditTimeHistogram, now - last_omnibox_focus_); | 499 UMA_HISTOGRAM_TIMES(kFocusToEditTimeHistogram, now - last_omnibox_focus_); |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 // Update state and notify view if the omnibox has focus and the caret | 1453 // Update state and notify view if the omnibox has focus and the caret |
1453 // visibility changed. | 1454 // visibility changed. |
1454 const bool was_caret_visible = is_caret_visible(); | 1455 const bool was_caret_visible = is_caret_visible(); |
1455 focus_state_ = state; | 1456 focus_state_ = state; |
1456 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1457 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1457 is_caret_visible() != was_caret_visible) | 1458 is_caret_visible() != was_caret_visible) |
1458 view_->ApplyCaretVisibility(); | 1459 view_->ApplyCaretVisibility(); |
1459 | 1460 |
1460 delegate_->OnFocusChanged(focus_state_, reason); | 1461 delegate_->OnFocusChanged(focus_state_, reason); |
1461 } | 1462 } |
OLD | NEW |