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

Side by Side Diff: chrome/browser/chromeos/frame/browser_view.cc

Issue 2060004: Removing the app launcher button on ChromeOS (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: One more clean up Created 10 years, 7 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/chromeos/frame/browser_view.h ('k') | chrome/browser/chromeos/view_ids.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/frame/browser_view.h" 5 #include "chrome/browser/chromeos/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 DISALLOW_COPY_AND_ASSIGN(ChromeosTabStrip); 116 DISALLOW_COPY_AND_ASSIGN(ChromeosTabStrip);
117 }; 117 };
118 */ 118 */
119 119
120 } // namespace 120 } // namespace
121 121
122 namespace chromeos { 122 namespace chromeos {
123 123
124 // LayoutManager for BrowserView, which layouts extra components such as 124 // LayoutManager for BrowserView, which layouts extra components such as
125 // main menu, stataus views as follows: 125 // the status views as follows:
126 // ____ __ __ 126 // ____ __ __
127 // [AppLauncher] / \ \ \ [StatusArea] 127 // / \ \ \ [StatusArea]
128 // 128 //
129 class BrowserViewLayout : public ::BrowserViewLayout { 129 class BrowserViewLayout : public ::BrowserViewLayout {
130 public: 130 public:
131 BrowserViewLayout() : ::BrowserViewLayout() {} 131 BrowserViewLayout() : ::BrowserViewLayout() {}
132 virtual ~BrowserViewLayout() {} 132 virtual ~BrowserViewLayout() {}
133 133
134 ////////////////////////////////////////////////////////////////////////////// 134 //////////////////////////////////////////////////////////////////////////////
135 // BrowserViewLayout overrides: 135 // BrowserViewLayout overrides:
136 136
137 void Installed(views::View* host) { 137 void Installed(views::View* host) {
138 main_menu_button_ = NULL;
139 compact_navigation_bar_ = NULL; 138 compact_navigation_bar_ = NULL;
140 status_area_ = NULL; 139 status_area_ = NULL;
141 spacer_ = NULL; 140 spacer_ = NULL;
142 ::BrowserViewLayout::Installed(host); 141 ::BrowserViewLayout::Installed(host);
143 } 142 }
144 143
145 void ViewAdded(views::View* host, 144 void ViewAdded(views::View* host,
146 views::View* view) { 145 views::View* view) {
147 ::BrowserViewLayout::ViewAdded(host, view); 146 ::BrowserViewLayout::ViewAdded(host, view);
148 switch (view->GetID()) { 147 switch (view->GetID()) {
149 case VIEW_ID_SPACER: 148 case VIEW_ID_SPACER:
150 spacer_ = view; 149 spacer_ = view;
151 break; 150 break;
152 case VIEW_ID_APP_MENU_BUTTON:
153 main_menu_button_ = view;
154 break;
155 case VIEW_ID_STATUS_AREA: 151 case VIEW_ID_STATUS_AREA:
156 status_area_ = static_cast<chromeos::StatusAreaView*>(view); 152 status_area_ = static_cast<chromeos::StatusAreaView*>(view);
157 break; 153 break;
158 case VIEW_ID_COMPACT_NAV_BAR: 154 case VIEW_ID_COMPACT_NAV_BAR:
159 compact_navigation_bar_ = view; 155 compact_navigation_bar_ = view;
160 break; 156 break;
161 case VIEW_ID_OTR_AVATAR: 157 case VIEW_ID_OTR_AVATAR:
162 otr_avatar_icon_ = view; 158 otr_avatar_icon_ = view;
163 break; 159 break;
164 } 160 }
165 } 161 }
166 162
167 // In the normal and the compact navigation bar mode, ChromeOS 163 // In the normal and the compact navigation bar mode, ChromeOS
168 // layouts compact navigation buttons and status views in the title 164 // layouts compact navigation buttons and status views in the title
169 // area. See Layout 165 // area. See Layout
170 virtual int LayoutTabStrip() { 166 virtual int LayoutTabStrip() {
171 if (browser_view_->IsFullscreen() || 167 if (browser_view_->IsFullscreen() ||
172 !browser_view_->IsTabStripVisible()) { 168 !browser_view_->IsTabStripVisible()) {
173 main_menu_button_->SetVisible(false);
174 compact_navigation_bar_->SetVisible(false); 169 compact_navigation_bar_->SetVisible(false);
175 status_area_->SetVisible(false); 170 status_area_->SetVisible(false);
176 otr_avatar_icon_->SetVisible(false); 171 otr_avatar_icon_->SetVisible(false);
177 tabstrip_->SetVisible(false); 172 tabstrip_->SetVisible(false);
178 tabstrip_->SetBounds(0, 0, 0, 0); 173 tabstrip_->SetBounds(0, 0, 0, 0);
179 return 0; 174 return 0;
180 } else { 175 } else {
181 gfx::Rect layout_bounds = 176 gfx::Rect layout_bounds =
182 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_); 177 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_);
183 gfx::Point tabstrip_origin = layout_bounds.origin(); 178 gfx::Point tabstrip_origin = layout_bounds.origin();
(...skipping 20 matching lines...) Expand all
204 199
205 private: 200 private:
206 chromeos::BrowserView* chromeos_browser_view() { 201 chromeos::BrowserView* chromeos_browser_view() {
207 return static_cast<chromeos::BrowserView*>(browser_view_); 202 return static_cast<chromeos::BrowserView*>(browser_view_);
208 } 203 }
209 204
210 // Tests if the point is on one of views that are within the 205 // Tests if the point is on one of views that are within the
211 // considered title bar area of client view. 206 // considered title bar area of client view.
212 bool IsPointInViewsInTitleArea(const gfx::Point& point) 207 bool IsPointInViewsInTitleArea(const gfx::Point& point)
213 const { 208 const {
214 gfx::Point point_in_main_menu_coords(point);
215 views::View::ConvertPointToView(browser_view_, main_menu_button_,
216 &point_in_main_menu_coords);
217 if (main_menu_button_->HitTest(point_in_main_menu_coords))
218 return true;
219
220 gfx::Point point_in_status_area_coords(point); 209 gfx::Point point_in_status_area_coords(point);
221 views::View::ConvertPointToView(browser_view_, status_area_, 210 views::View::ConvertPointToView(browser_view_, status_area_,
222 &point_in_status_area_coords); 211 &point_in_status_area_coords);
223 if (status_area_->HitTest(point_in_status_area_coords)) 212 if (status_area_->HitTest(point_in_status_area_coords))
224 return true; 213 return true;
225 214
226 if (compact_navigation_bar_->IsVisible()) { 215 if (compact_navigation_bar_->IsVisible()) {
227 gfx::Point point_in_cnb_coords(point); 216 gfx::Point point_in_cnb_coords(point);
228 views::View::ConvertPointToView(browser_view_, 217 views::View::ConvertPointToView(browser_view_,
229 compact_navigation_bar_, 218 compact_navigation_bar_,
230 &point_in_cnb_coords); 219 &point_in_cnb_coords);
231 return compact_navigation_bar_->HitTest(point_in_cnb_coords); 220 return compact_navigation_bar_->HitTest(point_in_cnb_coords);
232 } 221 }
233 return false; 222 return false;
234 } 223 }
235 224
236 // Layouts components in the title bar area (given by 225 // Layouts components in the title bar area (given by
237 // |bounds|). These include the main menu, the compact navigation 226 // |bounds|). These include the main menu, the compact navigation
238 // buttons (in compact navbar mode), the otr avatar icon (in 227 // buttons (in compact navbar mode), the otr avatar icon (in
239 // incognito window), the tabstrip and the the status area. 228 // incognito window), the tabstrip and the the status area.
240 int LayoutTitlebarComponents(const gfx::Rect& bounds) { 229 int LayoutTitlebarComponents(const gfx::Rect& bounds) {
241 if (bounds.IsEmpty()) { 230 if (bounds.IsEmpty()) {
242 return 0; 231 return 0;
243 } 232 }
244 main_menu_button_->SetVisible(true);
245 compact_navigation_bar_->SetVisible( 233 compact_navigation_bar_->SetVisible(
246 chromeos_browser_view()->is_compact_style()); 234 chromeos_browser_view()->is_compact_style());
247 tabstrip_->SetVisible(true); 235 tabstrip_->SetVisible(true);
248 otr_avatar_icon_->SetVisible(browser_view_->ShouldShowOffTheRecordAvatar()); 236 otr_avatar_icon_->SetVisible(browser_view_->ShouldShowOffTheRecordAvatar());
249 status_area_->SetVisible(true); 237 status_area_->SetVisible(true);
250 238
251 int bottom = bounds.bottom(); 239 int bottom = bounds.bottom();
252 240
253 /* TODO(oshima): 241 /* TODO(oshima):
254 * Disabling the ability to update location bar on re-layout bacause 242 * Disabling the ability to update location bar on re-layout bacause
255 * tabstrip state may not be in sync with the browser's state when 243 * tabstrip state may not be in sync with the browser's state when
256 * new tab is added. We should decide when we know more about this 244 * new tab is added. We should decide when we know more about this
257 * feature. May be we should simply hide the location? 245 * feature. May be we should simply hide the location?
258 * Filed a bug: http://crbug.com/30612. 246 * Filed a bug: http://crbug.com/30612.
259 if (compact_navigation_bar_->IsVisible()) { 247 if (compact_navigation_bar_->IsVisible()) {
260 // Update the size and location of the compact location bar. 248 // Update the size and location of the compact location bar.
261 int index = browser_view()->browser()->selected_index(); 249 int index = browser_view()->browser()->selected_index();
262 compact_location_bar_host_->Update(index, false, true); 250 compact_location_bar_host_->Update(index, false, true);
263 } 251 }
264 */ 252 */
265 253
266 // Layout main menu before tab strip.
267 gfx::Size main_menu_size = main_menu_button_->GetPreferredSize();
268 main_menu_button_->SetBounds(0, bounds.y(),
269 main_menu_size.width(), bounds.height());
270
271 status_area_->Update(); 254 status_area_->Update();
272 // Layout status area after tab strip. 255 // Layout status area after tab strip.
273 gfx::Size status_size = status_area_->GetPreferredSize(); 256 gfx::Size status_size = status_area_->GetPreferredSize();
274 status_area_->SetBounds(bounds.x() + bounds.width() - status_size.width(), 257 status_area_->SetBounds(bounds.x() + bounds.width() - status_size.width(),
275 bounds.y(), status_size.width(), 258 bounds.y(), status_size.width(),
276 status_size.height()); 259 status_size.height());
277 LayoutOTRAvatar(bounds); 260 LayoutOTRAvatar(bounds);
278 261
279 int curx = bounds.x() + main_menu_size.width(); 262 int curx = bounds.x();
280 263
281 if (compact_navigation_bar_->IsVisible()) { 264 if (compact_navigation_bar_->IsVisible()) {
282 gfx::Size cnb_size = compact_navigation_bar_->GetPreferredSize(); 265 gfx::Size cnb_size = compact_navigation_bar_->GetPreferredSize();
283 // Adjust the size of the compact nativation bar to avoid creating 266 // Adjust the size of the compact nativation bar to avoid creating
284 // a fixed widget with its own gdk window. AutocompleteEditView 267 // a fixed widget with its own gdk window. AutocompleteEditView
285 // expects the parent view to be transparent, but a fixed with 268 // expects the parent view to be transparent, but a fixed with
286 // its own window is not. 269 // its own window is not.
287 gfx::Rect cnb_bounds(curx, bounds.y(), cnb_size.width(), bounds.height()); 270 gfx::Rect cnb_bounds(curx, bounds.y(), cnb_size.width(), bounds.height());
288 compact_navigation_bar_->SetBounds( 271 compact_navigation_bar_->SetBounds(
289 cnb_bounds.Intersect(browser_view_->GetVisibleBounds())); 272 cnb_bounds.Intersect(browser_view_->GetVisibleBounds()));
(...skipping 29 matching lines...) Expand all
319 gfx::Size preferred_size = otr_avatar_icon_->GetPreferredSize(); 302 gfx::Size preferred_size = otr_avatar_icon_->GetPreferredSize();
320 303
321 int y = bounds.bottom() - preferred_size.height() - kOTRBottomSpacing; 304 int y = bounds.bottom() - preferred_size.height() - kOTRBottomSpacing;
322 int x = status_bounds.x() - kOTRSideSpacing - preferred_size.width(); 305 int x = status_bounds.x() - kOTRSideSpacing - preferred_size.width();
323 otr_avatar_icon_->SetBounds(x, y, preferred_size.width(), 306 otr_avatar_icon_->SetBounds(x, y, preferred_size.width(),
324 preferred_size.height()); 307 preferred_size.height());
325 } 308 }
326 } 309 }
327 310
328 311
329 views::View* main_menu_button_;
330 chromeos::StatusAreaView* status_area_; 312 chromeos::StatusAreaView* status_area_;
331 views::View* compact_navigation_bar_; 313 views::View* compact_navigation_bar_;
332 views::View* spacer_; 314 views::View* spacer_;
333 views::View* otr_avatar_icon_; 315 views::View* otr_avatar_icon_;
334 316
335 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); 317 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout);
336 }; 318 };
337 319
338 BrowserView::BrowserView(Browser* browser) 320 BrowserView::BrowserView(Browser* browser)
339 : ::BrowserView(browser), 321 : ::BrowserView(browser),
340 main_menu_button_(NULL),
341 status_area_(NULL), 322 status_area_(NULL),
342 compact_navigation_bar_(NULL), 323 compact_navigation_bar_(NULL),
343 // Standard style is default. 324 // Standard style is default.
344 // TODO(oshima): Get this info from preference. 325 // TODO(oshima): Get this info from preference.
345 ui_style_(StandardStyle), 326 ui_style_(StandardStyle),
346 force_maximized_window_(false), 327 force_maximized_window_(false),
347 spacer_(NULL), 328 spacer_(NULL),
348 otr_avatar_icon_(new views::ImageView()) { 329 otr_avatar_icon_(new views::ImageView()) {
349 } 330 }
350 331
351 BrowserView::~BrowserView() { 332 BrowserView::~BrowserView() {
352 } 333 }
353 334
354 //////////////////////////////////////////////////////////////////////////////// 335 ////////////////////////////////////////////////////////////////////////////////
355 // BrowserView, ::BrowserView overrides: 336 // BrowserView, ::BrowserView overrides:
356 337
357 void BrowserView::Init() { 338 void BrowserView::Init() {
358 ::BrowserView::Init(); 339 ::BrowserView::Init();
359 main_menu_button_ = new views::ImageButton(this);
360 main_menu_button_->SetID(VIEW_ID_APP_MENU_BUTTON);
361 ThemeProvider* theme_provider = 340 ThemeProvider* theme_provider =
362 frame()->GetThemeProviderForFrame(); 341 frame()->GetThemeProviderForFrame();
363 SkBitmap* image = theme_provider->GetBitmapNamed(IDR_APP_LAUNCHER_BUTTON);
364 main_menu_button_->SetImage(views::CustomButton::BS_NORMAL, image);
365 main_menu_button_->SetImage(views::CustomButton::BS_HOT, image);
366 main_menu_button_->SetImage(views::CustomButton::BS_PUSHED, image);
367 AddChildView(main_menu_button_);
368 342
369 compact_location_bar_host_.reset( 343 compact_location_bar_host_.reset(
370 new chromeos::CompactLocationBarHost(this)); 344 new chromeos::CompactLocationBarHost(this));
371 compact_navigation_bar_ = 345 compact_navigation_bar_ =
372 new chromeos::CompactNavigationBar(this); 346 new chromeos::CompactNavigationBar(this);
373 compact_navigation_bar_->SetID(VIEW_ID_COMPACT_NAV_BAR); 347 compact_navigation_bar_->SetID(VIEW_ID_COMPACT_NAV_BAR);
374 AddChildView(compact_navigation_bar_); 348 AddChildView(compact_navigation_bar_);
375 compact_navigation_bar_->Init(); 349 compact_navigation_bar_->Init();
376 status_area_ = new BrowserStatusAreaView(this); 350 status_area_ = new BrowserStatusAreaView(this);
377 status_area_->SetID(VIEW_ID_STATUS_AREA); 351 status_area_->SetID(VIEW_ID_STATUS_AREA);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 419
446 views::LayoutManager* BrowserView::CreateLayoutManager() const { 420 views::LayoutManager* BrowserView::CreateLayoutManager() const {
447 return new BrowserViewLayout(); 421 return new BrowserViewLayout();
448 } 422 }
449 423
450 void BrowserView::ChildPreferredSizeChanged(View* child) { 424 void BrowserView::ChildPreferredSizeChanged(View* child) {
451 Layout(); 425 Layout();
452 SchedulePaint(); 426 SchedulePaint();
453 } 427 }
454 428
455 // views::ButtonListener overrides.
456 void BrowserView::ButtonPressed(views::Button* sender,
457 const views::Event& event) {
458 gfx::Rect bounds = main_menu_button_->bounds();
459 gfx::Point origin = bounds.origin();
460 // Move the origin to the right otherwise the app launcher info bubble left
461 // border will show out of screen.
462 origin.Offset(kAppLauncherLeftPadding, 0);
463 views::RootView::ConvertPointToScreen(this, &origin);
464 bounds.set_origin(origin);
465 ::AppLauncher::Show(browser(), bounds, gfx::Point(), std::string());
466 }
467
468 // views::ContextMenuController overrides. 429 // views::ContextMenuController overrides.
469 void BrowserView::ShowContextMenu(views::View* source, 430 void BrowserView::ShowContextMenu(views::View* source,
470 const gfx::Point& p, 431 const gfx::Point& p,
471 bool is_mouse_gesture) { 432 bool is_mouse_gesture) {
472 // Only show context menu if point is in unobscured parts of browser, i.e. 433 // Only show context menu if point is in unobscured parts of browser, i.e.
473 // if NonClientHitTest returns : 434 // if NonClientHitTest returns :
474 // - HTCAPTION: in title bar or unobscured part of tabstrip 435 // - HTCAPTION: in title bar or unobscured part of tabstrip
475 // - HTNOWHERE: as the name implies. 436 // - HTNOWHERE: as the name implies.
476 gfx::Point point_in_parent_coords(p); 437 gfx::Point point_in_parent_coords(p);
477 views::View::ConvertPointToView(NULL, GetParent(), &point_in_parent_coords); 438 views::View::ConvertPointToView(NULL, GetParent(), &point_in_parent_coords);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 506 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
546 // Create a browser view for chromeos. 507 // Create a browser view for chromeos.
547 BrowserView* view; 508 BrowserView* view;
548 if (browser->type() & Browser::TYPE_POPUP) 509 if (browser->type() & Browser::TYPE_POPUP)
549 view = new chromeos::PanelBrowserView(browser); 510 view = new chromeos::PanelBrowserView(browser);
550 else 511 else
551 view = new chromeos::BrowserView(browser); 512 view = new chromeos::BrowserView(browser);
552 BrowserFrame::Create(view, browser->profile()); 513 BrowserFrame::Create(view, browser->profile());
553 return view; 514 return view;
554 } 515 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/frame/browser_view.h ('k') | chrome/browser/chromeos/view_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698