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