X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fui%2Fviews%2Fomnibox%2Fomnibox_view_views.cc;h=8f46c64e6161abb2cbfbf77d92b92ab689841f2a;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=538d386de3322ea57b9ef5a4efb83bd48ab7abf8;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/src/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 538d386..8f46c64 100644 --- a/src/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/src/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -4,14 +4,15 @@ #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" +#include + #include "base/command_line.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/autocomplete/autocomplete_input.h" -#include "chrome/browser/autocomplete/autocomplete_match.h" +#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/search/search.h" #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" @@ -23,6 +24,9 @@ #include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h" #include "components/bookmarks/browser/bookmark_node_data.h" +#include "components/omnibox/autocomplete_input.h" +#include "components/omnibox/autocomplete_match.h" +#include "components/omnibox/omnibox_field_trial.h" #include "content/public/browser/web_contents.h" #include "extensions/common/constants.h" #include "grit/app_locale_settings.h" @@ -40,7 +44,6 @@ #include "ui/base/ime/text_input_type.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" #include "ui/events/event.h" #include "ui/gfx/canvas.h" @@ -59,6 +62,7 @@ #include "chrome/browser/browser_process.h" #endif +using bookmarks::BookmarkNodeData; namespace { @@ -144,7 +148,8 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, location_bar_view_(location_bar), ime_candidate_window_open_(false), select_all_on_mouse_release_(false), - select_all_on_gesture_tap_(false) { + select_all_on_gesture_tap_(false), + weak_ptr_factory_(this) { SetBorder(views::Border::NullBorder()); set_id(VIEW_ID_OMNIBOX); SetFontList(font_list); @@ -216,8 +221,7 @@ void OmniboxViewViews::OnTabChanged(const content::WebContents* web_contents) { } void OmniboxViewViews::Update() { - if (chrome::ShouldDisplayOriginChip()) - set_placeholder_text(GetHintText()); + UpdatePlaceholderText(); const ToolbarModel::SecurityLevel old_security_level = security_level_; security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); @@ -253,6 +257,12 @@ void OmniboxViewViews::Update() { } } +void OmniboxViewViews::UpdatePlaceholderText() { + if (chrome::ShouldDisplayOriginChip() || + OmniboxFieldTrial::DisplayHintTextWhenPossible()) + set_placeholder_text(GetHintText()); +} + base::string16 OmniboxViewViews::GetText() const { // TODO(oshima): IME support return text(); @@ -385,24 +395,29 @@ void OmniboxViewViews::OnPaste() { bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) { // This must run before acclerator handling invokes a focus change on tab. // Note the parallel with SkipDefaultKeyEventProcessing above. - if (views::FocusManager::IsTabTraversalKeyEvent(event)) { - if (model()->is_keyword_hint() && !event.IsShiftDown()) { - model()->AcceptKeyword(ENTERED_KEYWORD_MODE_VIA_TAB); - return true; - } - if (model()->popup_model()->IsOpen()) { - if (event.IsShiftDown() && - model()->popup_model()->selected_line_state() == - OmniboxPopupModel::KEYWORD) { - model()->ClearKeyword(text()); - } else { - model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1); - } - return true; - } + if (!views::FocusManager::IsTabTraversalKeyEvent(event)) + return false; + + if (model()->is_keyword_hint() && !event.IsShiftDown()) { + model()->AcceptKeyword(ENTERED_KEYWORD_MODE_VIA_TAB); + return true; } - return false; + if (!model()->popup_model()->IsOpen()) + return false; + + if (event.IsShiftDown() && + (model()->popup_model()->selected_line_state() == + OmniboxPopupModel::KEYWORD)) + model()->ClearKeyword(text()); + else + model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1); + + return true; +} + +void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value) { + SetUserText(new_value, new_value, true); } void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text, @@ -561,10 +576,9 @@ void OmniboxViewViews::ShowImeIfNeeded() { } void OmniboxViewViews::OnMatchOpened(const AutocompleteMatch& match, - Profile* profile, - content::WebContents* web_contents) const { + content::WebContents* web_contents) { extensions::MaybeShowExtensionControlledSearchNotification( - profile, web_contents, match); + profile(), web_contents, match); } int OmniboxViewViews::GetOmniboxTextLength() const { @@ -580,7 +594,8 @@ void OmniboxViewViews::EmphasizeURLComponents() { // be treated as a search or a navigation, and is the same method the Paste // And Go system uses. url::Component scheme, host; - AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host); + AutocompleteInput::ParseForEmphasizeComponents( + text(), ChromeAutocompleteSchemeClassifier(profile()), &scheme, &host); bool grey_out_url = text().substr(scheme.begin, scheme.len) == base::UTF8ToUTF16(extensions::kExtensionScheme); bool grey_base = model()->CurrentTextIsURL() && @@ -754,8 +769,10 @@ void OmniboxViewViews::OnGestureEvent(ui::GestureEvent* event) { saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); } + views::Textfield::OnGestureEvent(event); + if (select_all_on_gesture_tap_ && event->type() == ui::ET_GESTURE_TAP) - SelectAll(false); + SelectAll(true); if (event->type() == ui::ET_GESTURE_TAP || event->type() == ui::ET_GESTURE_TAP_CANCEL || @@ -766,8 +783,6 @@ void OmniboxViewViews::OnGestureEvent(ui::GestureEvent* event) { event->type() == ui::ET_GESTURE_LONG_TAP) { select_all_on_gesture_tap_ = false; } - - views::Textfield::OnGestureEvent(event); } void OmniboxViewViews::AboutToRequestFocusFromTabTraversal(bool reverse) { @@ -788,8 +803,24 @@ bool OmniboxViewViews::SkipDefaultKeyEventProcessing( } void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { - location_bar_view_->GetAccessibleState(state); state->role = ui::AX_ROLE_TEXT_FIELD; + state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); + state->value = GetText(); + + base::string16::size_type entry_start; + base::string16::size_type entry_end; + GetSelectionBounds(&entry_start, &entry_end); + state->selection_start = entry_start; + state->selection_end = entry_end; + + if (popup_window_mode_) { + state->AddStateFlag(ui::AX_STATE_READ_ONLY); + } else { + state->set_value_callback = + base::Bind(&OmniboxViewViews::AccessibilitySetValue, + weak_ptr_factory_.GetWeakPtr()); + } + } void OmniboxViewViews::OnFocus() {