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

Side by Side Diff: chrome/browser/chromeos/views/webui_menu_widget.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/views/webui_menu_widget.h" 5 #include "chrome/browser/chromeos/views/webui_menu_widget.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/singleton.h" 10 #include "base/singleton.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DISALLOW_COPY_AND_ASSIGN(RoundedBorder); 75 DISALLOW_COPY_AND_ASSIGN(RoundedBorder);
76 }; 76 };
77 77
78 class InsetsLayout : public views::LayoutManager { 78 class InsetsLayout : public views::LayoutManager {
79 public: 79 public:
80 InsetsLayout() : views::LayoutManager() {} 80 InsetsLayout() : views::LayoutManager() {}
81 81
82 private: 82 private:
83 // views::LayoutManager implementatios. 83 // views::LayoutManager implementatios.
84 virtual void Layout(views::View* host) { 84 virtual void Layout(views::View* host) {
85 if (host->GetChildViewCount() == 0) 85 if (!host->has_children())
86 return; 86 return;
87 gfx::Insets insets = host->GetInsets(); 87 gfx::Insets insets = host->GetInsets();
88 views::View* view = host->GetChildViewAt(0); 88 views::View* view = host->GetChildViewAt(0);
89 89
90 view->SetBounds(insets.left(), insets.top(), 90 view->SetBounds(insets.left(), insets.top(),
91 host->width() - insets.width(), 91 host->width() - insets.width(),
92 host->height() - insets.height()); 92 host->height() - insets.height());
93 } 93 }
94 94
95 virtual gfx::Size GetPreferredSize(views::View* host) { 95 virtual gfx::Size GetPreferredSize(views::View* host) {
96 DCHECK(host->GetChildViewCount() == 1); 96 DCHECK(host->child_count() == 1);
97 gfx::Insets insets = host->GetInsets(); 97 gfx::Insets insets = host->GetInsets();
98 gfx::Size size = host->GetChildViewAt(0)->GetPreferredSize(); 98 gfx::Size size = host->GetChildViewAt(0)->GetPreferredSize();
99 return gfx::Size(size.width() + insets.width(), 99 return gfx::Size(size.width() + insets.width(),
100 size.height() + insets.height()); 100 size.height() + insets.height());
101 } 101 }
102 102
103 DISALLOW_COPY_AND_ASSIGN(InsetsLayout); 103 DISALLOW_COPY_AND_ASSIGN(InsetsLayout);
104 }; 104 };
105 105
106 // A gtk widget key used to test if a given WidgetGtk instance is 106 // A gtk widget key used to test if a given WidgetGtk instance is
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 void WebUIMenuWidget::Hide() { 151 void WebUIMenuWidget::Hide() {
152 ReleaseGrab(); 152 ReleaseGrab();
153 WidgetGtk::Hide(); 153 WidgetGtk::Hide();
154 // Clears the content. 154 // Clears the content.
155 ExecuteJavascript(L"updateModel({'items':[]})"); 155 ExecuteJavascript(L"updateModel({'items':[]})");
156 } 156 }
157 157
158 void WebUIMenuWidget::Close() { 158 void WebUIMenuWidget::Close() {
159 if (dom_view_ != NULL) { 159 if (dom_view_ != NULL) {
160 dom_view_->GetParent()->RemoveChildView(dom_view_); 160 dom_view_->parent()->RemoveChildView(dom_view_);
161 delete dom_view_; 161 delete dom_view_;
162 dom_view_ = NULL; 162 dom_view_ = NULL;
163 } 163 }
164 164
165 // Detach the webui_menu_ which is being deleted. 165 // Detach the webui_menu_ which is being deleted.
166 webui_menu_ = NULL; 166 webui_menu_ = NULL;
167 views::WidgetGtk::Close(); 167 views::WidgetGtk::Close();
168 } 168 }
169 169
170 void WebUIMenuWidget::ReleaseGrab() { 170 void WebUIMenuWidget::ReleaseGrab() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 dom_view_->Init(webui_menu_->GetProfile(), NULL); 267 dom_view_->Init(webui_menu_->GetProfile(), NULL);
268 // TODO(oshima): remove extra view to draw rounded corner. 268 // TODO(oshima): remove extra view to draw rounded corner.
269 views::View* container = new views::View(); 269 views::View* container = new views::View();
270 container->AddChildView(dom_view_); 270 container->AddChildView(dom_view_);
271 container->set_border(new RoundedBorder(locator)); 271 container->set_border(new RoundedBorder(locator));
272 container->SetLayoutManager(new InsetsLayout()); 272 container->SetLayoutManager(new InsetsLayout());
273 SetContentsView(container); 273 SetContentsView(container);
274 dom_view_->LoadURL(webui_menu_->menu_url()); 274 dom_view_->LoadURL(webui_menu_->menu_url());
275 } else { 275 } else {
276 webui_menu_->UpdateStates(); 276 webui_menu_->UpdateStates();
277 dom_view_->GetParent()->set_border(new RoundedBorder(locator)); 277 dom_view_->parent()->set_border(new RoundedBorder(locator));
278 menu_locator_->Move(this); 278 menu_locator_->Move(this);
279 } 279 }
280 Show(); 280 Show();
281 281
282 // The pointer grab is captured only on the top level menu, 282 // The pointer grab is captured only on the top level menu,
283 // all mouse event events are delivered to submenu using gtk_add_grab. 283 // all mouse event events are delivered to submenu using gtk_add_grab.
284 if (is_root_) { 284 if (is_root_) {
285 CaptureGrab(); 285 CaptureGrab();
286 } 286 }
287 } 287 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 EnableInput(false /* no selection */); 331 EnableInput(false /* no selection */);
332 } 332 }
333 333
334 void WebUIMenuWidget::ClearGrabWidget() { 334 void WebUIMenuWidget::ClearGrabWidget() {
335 GtkWidget* grab_widget; 335 GtkWidget* grab_widget;
336 while ((grab_widget = gtk_grab_get_current())) 336 while ((grab_widget = gtk_grab_get_current()))
337 gtk_grab_remove(grab_widget); 337 gtk_grab_remove(grab_widget);
338 } 338 }
339 339
340 } // namespace chromeos 340 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/status_area_view.cc ('k') | chrome/browser/ui/views/about_chrome_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698