Index: chrome/browser/gtk/location_bar_view_gtk.cc |
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4e9703243e0a984f1c4e898032eff09291123f91 |
--- /dev/null |
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc |
@@ -0,0 +1,143 @@ |
+#include "chrome/browser/gtk/location_bar_view_gtk.h" |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/logging.h" |
+#include "base/string_util.h" |
+#include "chrome/app/chrome_dll_resource.h" |
+#include "chrome/browser/alternate_nav_url_fetcher.h" |
+#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
+#include "chrome/browser/command_updater.h" |
+#include "chrome/browser/tab_contents/tab_contents.h" |
+#include "chrome/common/page_transition_types.h" |
+#include "skia/include/SkBitmap.h" |
+#include "webkit/glue/window_open_disposition.h" |
+ |
+LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater, |
+ ToolbarModel* toolbar_model) |
+ : vbox_(NULL), |
+ profile_(NULL), |
+ command_updater_(command_updater), |
+ toolbar_model_(toolbar_model), |
+ disposition_(CURRENT_TAB), |
+ transition_(PageTransition::TYPED) { |
+} |
+ |
+LocationBarViewGtk::~LocationBarViewGtk(){ |
+ // TODO(deanm): Should I destroy the widgets here, or leave it up to the |
+ // embedder? When the embedder destroys their widget, if we're a child, we |
+ // will also get destroyed, so the ownership is kinda unclear. |
+} |
+ |
+void LocationBarViewGtk::Init(){ |
+ edit_view_.reset(new AutocompleteEditViewGtk(this, toolbar_model_, profile_, |
+ command_updater_)); |
+ edit_view_->Init(); |
+ |
+ vbox_ = gtk_vbox_new(false, 0); |
+ |
+ // Get the location bar to fit nicely in the toolbar, kinda ugly. |
+ static const int kTopPadding = 2; |
+ static const int kBottomPadding = 3; |
+ GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); |
+ gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), |
+ kTopPadding, kBottomPadding, 0, 0); |
+ gtk_container_add(GTK_CONTAINER(alignment), edit_view_->widget()); |
+ |
+ gtk_box_pack_start(GTK_BOX(vbox_), alignment, TRUE, TRUE, 0); |
+} |
+ |
+void LocationBarViewGtk::SetProfile(Profile* profile) { |
+ profile_ = profile; |
+} |
+ |
+void LocationBarViewGtk::Update(const TabContents* contents) { |
+ edit_view_->Update(contents); |
+} |
+ |
+void LocationBarViewGtk::OnAutocompleteAccept(const GURL& url, |
+ WindowOpenDisposition disposition, |
+ PageTransition::Type transition, |
+ const GURL& alternate_nav_url) { |
+ if (!url.is_valid()) |
+ return; |
+ |
+ location_input_ = UTF8ToWide(url.spec()); |
+ disposition_ = disposition; |
+ transition_ = transition; |
+ |
+ if (!command_updater_) |
+ return; |
+ |
+ if (!alternate_nav_url.is_valid()) { |
+ command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
+ return; |
+ } |
+ |
+ scoped_ptr<AlternateNavURLFetcher> fetcher( |
+ new AlternateNavURLFetcher(alternate_nav_url)); |
+ // The AlternateNavURLFetcher will listen for the pending navigation |
+ // notification that will be issued as a result of the "open URL." It |
+ // will automatically install itself into that navigation controller. |
+ command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
+ if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { |
+ // I'm not sure this should be reachable, but I'm not also sure enough |
+ // that it shouldn't to stick in a NOTREACHED(). In any case, this is |
+ // harmless; we can simply let the fetcher get deleted here and it will |
+ // clean itself up properly. |
+ } else { |
+ fetcher.release(); // The navigation controller will delete the fetcher. |
+ } |
+} |
+ |
+void LocationBarViewGtk::OnChanged() { |
+ // TODO(deanm): Here is where we would do layout when we have things like |
+ // the keyword display, ssl icons, etc. |
+} |
+ |
+void LocationBarViewGtk::OnInputInProgress(bool in_progress) { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+SkBitmap LocationBarViewGtk::GetFavIcon() const { |
+ NOTIMPLEMENTED(); |
+ return SkBitmap(); |
+} |
+ |
+std::wstring LocationBarViewGtk::GetTitle() const { |
+ NOTIMPLEMENTED(); |
+ return std::wstring(); |
+} |
+ |
+void LocationBarViewGtk::ShowFirstRunBubble(){ |
+ NOTIMPLEMENTED(); |
+} |
+ |
+std::wstring LocationBarViewGtk::GetInputString() const{ |
+ return location_input_; |
+} |
+ |
+WindowOpenDisposition LocationBarViewGtk::GetWindowOpenDisposition() const{ |
+ return disposition_; |
+} |
+ |
+PageTransition::Type LocationBarViewGtk::GetPageTransition() const{ |
+ return transition_; |
+} |
+ |
+void LocationBarViewGtk::AcceptInput(){ |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void LocationBarViewGtk::FocusLocation(){ |
+ edit_view_->FocusLocation(); |
+} |
+ |
+void LocationBarViewGtk::FocusSearch(){ |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void LocationBarViewGtk::SaveStateToContents(TabContents* contents){ |
+ NOTIMPLEMENTED(); |
+} |