omnibox_edit_controller.cc revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
14e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 24e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 34e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// found in the LICENSE file. 44e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 54e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 64e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 74e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "chrome/app/chrome_command_ids.h" 84e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "chrome/browser/command_updater.h" 9effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/browser/ui/toolbar/toolbar_model.h" 104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)void OmniboxEditController::OnAutocompleteAccept( 124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) const GURL& destination_url, 134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) WindowOpenDisposition disposition, 141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PageTransition transition) { 154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) destination_url_ = destination_url; 164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) disposition_ = disposition; 174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) transition_ = transition; 184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (command_updater_) 194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); 204e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)OmniboxEditController::OmniboxEditController(CommandUpdater* command_updater) 234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) : command_updater_(command_updater), 244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) disposition_(CURRENT_TAB), 251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci transition_(ui::PageTransitionFromInt( 261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PAGE_TRANSITION_TYPED | 271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)) { 284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 30effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid OmniboxEditController::HideOriginChip() { 31effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch GetToolbarModel()->set_origin_chip_enabled(false); 32effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch OnChanged(); 33effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch} 34effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 35effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid OmniboxEditController::ShowOriginChip() { 36effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // If URL replacement is still enabled, we can simply show the chip. If it 37effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // was disabled by an action to show the URL then the URL needs to be hidden. 38effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch if (GetToolbarModel()->url_replacement_enabled()) { 39effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch GetToolbarModel()->set_origin_chip_enabled(true); 40effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch OnChanged(); 41effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch } else { 42effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch HideURL(); 43effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch } 44effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch} 45effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)OmniboxEditController::~OmniboxEditController() { 474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 48