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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 11365075: alternate ntp: tweaks and fixes for bookmark bar in ntp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/app/chrome_dll_resource.h" 16 #include "chrome/app/chrome_dll_resource.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
17 #include "chrome/browser/bookmarks/bookmark_utils.h" 19 #include "chrome/browser/bookmarks/bookmark_utils.h"
18 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/extensions/tab_helper.h" 21 #include "chrome/browser/extensions/tab_helper.h"
20 #include "chrome/browser/infobars/infobar_tab_helper.h" 22 #include "chrome/browser/infobars/infobar_tab_helper.h"
21 #include "chrome/browser/instant/instant_controller.h" 23 #include "chrome/browser/instant/instant_controller.h"
22 #include "chrome/browser/managed_mode/managed_mode.h" 24 #include "chrome/browser/managed_mode/managed_mode.h"
23 #include "chrome/browser/native_window_notification_source.h" 25 #include "chrome/browser/native_window_notification_source.h"
24 #include "chrome/browser/password_manager/password_manager.h" 26 #include "chrome/browser/password_manager/password_manager.h"
25 #include "chrome/browser/prefs/pref_service.h" 27 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/profiles/avatar_menu_model.h" 28 #include "chrome/browser/profiles/avatar_menu_model.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 BrowserView* browser_view, 215 BrowserView* browser_view,
214 DetachableToolbarView* host_view, 216 DetachableToolbarView* host_view,
215 Browser* browser) 217 Browser* browser)
216 : browser_view_(browser_view), 218 : browser_view_(browser_view),
217 host_view_(host_view), 219 host_view_(host_view),
218 browser_(browser) { 220 browser_(browser) {
219 } 221 }
220 222
221 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, 223 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
222 views::View* view) const { 224 views::View* view) const {
225 ui::ThemeProvider* tp = host_view_->GetThemeProvider();
226
223 // If search mode is |NTP|, bookmark bar is detached and floating on top of 227 // If search mode is |NTP|, bookmark bar is detached and floating on top of
224 // the content view (in z-order) and below the "Most Visited" thumbnails (in 228 // the content view (in z-order) and below the "Most Visited" thumbnails (in
225 // the y-direction). It's visually nicer without the bookmark background, so 229 // the y-direction). It's visually nicer without the bookmark background, so
226 // utilize the existing background of content view, giving the impression that 230 // utilize the existing background of content view, giving the impression that
227 // each bookmark button is part of the content view. 231 // each bookmark button is part of the content view.
228 const chrome::search::Mode& search_mode = 232 const chrome::search::Mode& search_mode =
229 browser_view_->browser()->search_model()->mode(); 233 browser_view_->browser()->search_model()->mode();
230 if (search_mode.is_ntp()) 234 if (search_mode.is_ntp()) {
235 BookmarkModel* bookmark_model =
236 BookmarkModelFactory::GetForProfile(browser_->profile());
237 if (bookmark_model && bookmark_model->HasBookmarks()) {
238 // If a theme is being used, paint the theme background color at maximum
239 // 80% opacity to make the the bookmark bar more legible;
240 // otherwise, use a transparent background.
241 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
242 const U8CPU kBackgroundOpacity = 204; // 80% opacity
243 SkColor color = tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND);
244 if (gfx::IsInvertedColorScheme())
245 color = color_utils::InvertColor(color);
246 if (SkColorGetA(color) > kBackgroundOpacity)
247 color = SkColorSetA(color, kBackgroundOpacity);
248 canvas->DrawColor(color);
249 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
250 } else {
251 const SkColor kBorderColor = SkColorSetARGB(25, 0, 0, 0); // 10% black
252 DetachableToolbarView::PaintHorizontalBorderWithColor(
253 canvas, host_view_, kBorderColor);
254 }
255 }
231 return; 256 return;
257 }
232 258
233 ui::ThemeProvider* tp = host_view_->GetThemeProvider();
234 int toolbar_overlap = host_view_->GetToolbarOverlap(); 259 int toolbar_overlap = host_view_->GetToolbarOverlap();
235 // The client edge is drawn below the toolbar bounds. 260 // The client edge is drawn below the toolbar bounds.
236 if (toolbar_overlap) 261 if (toolbar_overlap)
237 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness; 262 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness;
238 if (host_view_->IsDetached()) { 263 if (host_view_->IsDetached()) {
239 // Draw the background to match the new tab page. 264 // Draw the background to match the new tab page.
240 int height = 0; 265 int height = 0;
241 WebContents* contents = chrome::GetActiveWebContents(browser_); 266 WebContents* contents = chrome::GetActiveWebContents(browser_);
242 if (contents && contents->GetView()) 267 if (contents && contents->GetView())
243 height = contents->GetView()->GetContainerSize().height(); 268 height = contents->GetView()->GetContainerSize().height();
(...skipping 20 matching lines...) Expand all
264 v_padding, &rect, &roundness, host_view_); 289 v_padding, &rect, &roundness, host_view_);
265 DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect, 290 DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect,
266 roundness); 291 roundness);
267 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); 292 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness);
268 if (!toolbar_overlap) 293 if (!toolbar_overlap)
269 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); 294 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
270 } else { 295 } else {
271 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_, 296 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_,
272 browser_view_->OffsetPointForToolbarBackgroundImage( 297 browser_view_->OffsetPointForToolbarBackgroundImage(
273 gfx::Point(host_view_->GetMirroredX(), host_view_->y()))); 298 gfx::Point(host_view_->GetMirroredX(), host_view_->y())));
274 // For instant extended API, only draw bookmark separator for |MODE_DFEAULT| 299 if (host_view_->height() >= toolbar_overlap)
275 // mode.
276 if (host_view_->height() >= toolbar_overlap && search_mode.is_default())
277 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); 300 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
278 } 301 }
279 } 302 }
280 303
281 /////////////////////////////////////////////////////////////////////////////// 304 ///////////////////////////////////////////////////////////////////////////////
282 // ResizeCorner, private: 305 // ResizeCorner, private:
283 306
284 class ResizeCorner : public views::View { 307 class ResizeCorner : public views::View {
285 public: 308 public:
286 ResizeCorner() { 309 ResizeCorner() {
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 modal_browser->window()->Activate(); 2586 modal_browser->window()->Activate();
2564 } 2587 }
2565 2588
2566 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 2589 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
2567 } 2590 }
2568 2591
2569 void BrowserView::MaybeStackBookmarkBarAtTop() { 2592 void BrowserView::MaybeStackBookmarkBarAtTop() {
2570 if (bookmark_bar_view_.get()) 2593 if (bookmark_bar_view_.get())
2571 bookmark_bar_view_->MaybeStackAtTop(); 2594 bookmark_bar_view_->MaybeStackAtTop();
2572 } 2595 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/detachable_toolbar_view.cc ('k') | chrome/browser/ui/views/frame/browser_view_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698