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

Side by Side Diff: chrome/browser/ui/views/aura/status_area_host_aura.cc

Issue 8509027: Add status area to Aura builds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/aura/status_area_host_aura.h"
6
7 #include "base/command_line.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/view_ids.h"
11 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
12 #include "chrome/browser/chromeos/status/clock_menu_button.h"
13 #include "chrome/browser/chromeos/status/memory_menu_button.h"
14 #include "chrome/browser/chromeos/status/status_area_view.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "ui/aura/window.h"
17 #include "ui/aura_shell/shell.h"
18 #include "ui/aura_shell/shell_window_ids.h"
19 #include "views/widget/widget.h"
20
21 #if defined(OS_CHROMEOS)
22 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
23 #endif
24
25 StatusAreaHostAura::StatusAreaHostAura()
26 : status_area_widget_(NULL),
27 status_area_view_(NULL) {
28 }
29
30 views::Widget* StatusAreaHostAura::CreateStatusArea() {
31 aura_shell::Shell* aura_shell = aura_shell::Shell::GetInstance();
32 aura::Window* status_window = aura_shell->GetContainer(
33 aura_shell::internal::kShellWindowId_StatusContainer);
34
35 // Create status area view.
36 status_area_view_ = new StatusAreaView();
37
38 // Add child buttons.
39 #if defined(OS_CHROMEOS)
40 chromeos::StatusAreaViewChromeos::AddChromeosButtons(
41 status_area_view_, this, chromeos::StatusAreaViewChromeos::BROWSER_MODE);
42 #else
43 const bool border = true;
44 const bool no_border = false;
45 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget))
46 status_area_view_->AddButton(new MemoryMenuButton(this), no_border);
47 status_area_view_->AddButton(new ClockMenuButton(this), border);
48 #endif
49
50 // Create widget to hold status area view.
51 status_area_widget_ = new views::Widget;
52 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
53 gfx::Size ps = status_area_view_->GetPreferredSize();
54 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height());
55 params.parent = status_window;
56 status_area_widget_->Init(params);
57 status_area_widget_->SetContentsView(status_area_view_);
58 status_area_widget_->Show();
59 status_area_widget_->GetNativeView()->set_name("StatusAreaView");
60
61 return status_area_widget_;
62 }
63
64 // StatusAreaButton::Delegate implementation.
65
66 bool StatusAreaHostAura::ShouldExecuteStatusAreaCommand(
67 const views::View* button_view, int command_id) const {
68 #if defined(OS_CHROMEOS)
69 return true;
70 #else
71 // TODO(stevenjb): system options for non-chromeos Aura?
72 return false;
73 #endif
74 }
75
76 void StatusAreaHostAura::ExecuteStatusAreaCommand(
77 const views::View* button_view, int command_id) {
78 #if defined(OS_CHROMEOS)
79 Browser* browser = BrowserList::FindBrowserWithProfile(
80 ProfileManager::GetDefaultProfile());
81 switch (command_id) {
82 case StatusAreaButton::Delegate::SHOW_NETWORK_OPTIONS:
83 browser->OpenInternetOptionsDialog();
84 break;
85 case StatusAreaButton::Delegate::SHOW_LANGUAGE_OPTIONS:
86 browser->OpenLanguageOptionsDialog();
87 break;
88 case StatusAreaButton::Delegate::SHOW_SYSTEM_OPTIONS:
89 browser->OpenSystemOptionsDialog();
90 break;
91 default:
92 NOTREACHED();
93 }
94 #endif
95 }
96
97 gfx::Font StatusAreaHostAura::GetStatusAreaFont(const gfx::Font& font) const {
98 return font.DeriveFont(0, gfx::Font::BOLD);
99 }
100
101 StatusAreaButton::TextStyle StatusAreaHostAura::GetStatusAreaTextStyle() const {
102 return StatusAreaButton::WHITE_HALOED;
103 }
104
105 void StatusAreaHostAura::ButtonVisibilityChanged(views::View* button_view) {
106 if (status_area_view_)
107 status_area_view_->UpdateButtonVisibility();
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698