Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/browser/gtk/location_bar_view_gtk.cc

Issue 40013: Implement a GTK LocationBarView and Autocomplete. (Closed)
Patch Set: Feedback Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "chrome/browser/gtk/location_bar_view_gtk.h"
2
3 #include <string>
4
5 #include "base/basictypes.h"
6 #include "base/logging.h"
7 #include "base/string_util.h"
8 #include "chrome/app/chrome_dll_resource.h"
9 #include "chrome/browser/alternate_nav_url_fetcher.h"
10 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
11 #include "chrome/browser/command_updater.h"
12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/common/page_transition_types.h"
14 #include "skia/include/SkBitmap.h"
15 #include "webkit/glue/window_open_disposition.h"
16
17 LocationBarViewGtk::LocationBarViewGtk(CommandUpdater* command_updater,
18 ToolbarModel* toolbar_model)
19 : vbox_(NULL),
20 profile_(NULL),
21 command_updater_(command_updater),
22 toolbar_model_(toolbar_model),
23 disposition_(CURRENT_TAB),
24 transition_(PageTransition::TYPED) {
25 }
26
27 LocationBarViewGtk::~LocationBarViewGtk(){
28 // TODO(deanm): Should I destroy the widgets here, or leave it up to the
29 // embedder? When the embedder destroys their widget, if we're a child, we
30 // will also get destroyed, so the ownership is kinda unclear.
31 }
32
33 void LocationBarViewGtk::Init(){
34 edit_view_.reset(new AutocompleteEditViewGtk(this, toolbar_model_, profile_,
35 command_updater_));
36 edit_view_->Init();
37
38 vbox_ = gtk_vbox_new(false, 0);
39
40 // Get the location bar to fit nicely in the toolbar, kinda ugly.
41 static const int kTopPadding = 2;
42 static const int kBottomPadding = 3;
43 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
44 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
45 kTopPadding, kBottomPadding, 0, 0);
46 gtk_container_add(GTK_CONTAINER(alignment), edit_view_->widget());
47
48 gtk_box_pack_start(GTK_BOX(vbox_), alignment, TRUE, TRUE, 0);
49 }
50
51 void LocationBarViewGtk::SetProfile(Profile* profile) {
52 profile_ = profile;
53 }
54
55 void LocationBarViewGtk::Update(const TabContents* contents) {
56 edit_view_->Update(contents);
57 }
58
59 void LocationBarViewGtk::OnAutocompleteAccept(const GURL& url,
60 WindowOpenDisposition disposition,
61 PageTransition::Type transition,
62 const GURL& alternate_nav_url) {
63 if (!url.is_valid())
64 return;
65
66 location_input_ = UTF8ToWide(url.spec());
67 disposition_ = disposition;
68 transition_ = transition;
69
70 if (!command_updater_)
71 return;
72
73 if (!alternate_nav_url.is_valid()) {
74 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
75 return;
76 }
77
78 scoped_ptr<AlternateNavURLFetcher> fetcher(
79 new AlternateNavURLFetcher(alternate_nav_url));
80 // The AlternateNavURLFetcher will listen for the pending navigation
81 // notification that will be issued as a result of the "open URL." It
82 // will automatically install itself into that navigation controller.
83 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
84 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) {
85 // I'm not sure this should be reachable, but I'm not also sure enough
86 // that it shouldn't to stick in a NOTREACHED(). In any case, this is
87 // harmless; we can simply let the fetcher get deleted here and it will
88 // clean itself up properly.
89 } else {
90 fetcher.release(); // The navigation controller will delete the fetcher.
91 }
92 }
93
94 void LocationBarViewGtk::OnChanged() {
95 // TODO(deanm): Here is where we would do layout when we have things like
96 // the keyword display, ssl icons, etc.
97 }
98
99 void LocationBarViewGtk::OnInputInProgress(bool in_progress) {
100 NOTIMPLEMENTED();
101 }
102
103 SkBitmap LocationBarViewGtk::GetFavIcon() const {
104 NOTIMPLEMENTED();
105 return SkBitmap();
106 }
107
108 std::wstring LocationBarViewGtk::GetTitle() const {
109 NOTIMPLEMENTED();
110 return std::wstring();
111 }
112
113 void LocationBarViewGtk::ShowFirstRunBubble(){
114 NOTIMPLEMENTED();
115 }
116
117 std::wstring LocationBarViewGtk::GetInputString() const{
118 return location_input_;
119 }
120
121 WindowOpenDisposition LocationBarViewGtk::GetWindowOpenDisposition() const{
122 return disposition_;
123 }
124
125 PageTransition::Type LocationBarViewGtk::GetPageTransition() const{
126 return transition_;
127 }
128
129 void LocationBarViewGtk::AcceptInput(){
130 NOTIMPLEMENTED();
131 }
132
133 void LocationBarViewGtk::FocusLocation(){
134 edit_view_->FocusLocation();
135 }
136
137 void LocationBarViewGtk::FocusSearch(){
138 NOTIMPLEMENTED();
139 }
140
141 void LocationBarViewGtk::SaveStateToContents(TabContents* contents){
142 NOTIMPLEMENTED();
143 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698