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

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

Issue 9664072: Removing WmIpc and related files from ChromeOS (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Copyright Created 8 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
OLDNEW
1 // Copyright (c) 2011 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/chromeos/frame/layout_mode_button.h" 5 #include "chrome/browser/chromeos/frame/layout_mode_button.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/view_ids.h" 9 #include "chrome/browser/chromeos/view_ids.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
11 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
12 #include "content/public/browser/notification_source.h" 12 #include "content/public/browser/notification_source.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "grit/theme_resources.h" 14 #include "grit/theme_resources.h"
15 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" 15 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
19 19
20 #if defined(TOOLKIT_USES_GTK)
21 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h"
22 #endif
23
24 namespace { 20 namespace {
25 const int kHorizontalPaddingPixels = 2; 21 const int kHorizontalPaddingPixels = 2;
26 } // namespace 22 } // namespace
27 23
28 namespace chromeos { 24 namespace chromeos {
29 25
30 LayoutModeButton::LayoutModeButton() 26 LayoutModeButton::LayoutModeButton()
31 : ALLOW_THIS_IN_INITIALIZER_LIST(ImageButton(this)) { 27 : ALLOW_THIS_IN_INITIALIZER_LIST(ImageButton(this)) {
32 set_id(VIEW_ID_LAYOUT_MODE_BUTTON); 28 set_id(VIEW_ID_LAYOUT_MODE_BUTTON);
33 } 29 }
(...skipping 15 matching lines...) Expand all
49 } 45 }
50 46
51 void LayoutModeButton::Observe(int type, 47 void LayoutModeButton::Observe(int type,
52 const content::NotificationSource& source, 48 const content::NotificationSource& source,
53 const content::NotificationDetails& details) { 49 const content::NotificationDetails& details) {
54 DCHECK(type == chrome::NOTIFICATION_LAYOUT_MODE_CHANGED); 50 DCHECK(type == chrome::NOTIFICATION_LAYOUT_MODE_CHANGED);
55 UpdateForCurrentLayoutMode(); 51 UpdateForCurrentLayoutMode();
56 } 52 }
57 53
58 void LayoutModeButton::Init() { 54 void LayoutModeButton::Init() {
59 #if defined(TOOLKIT_USES_GTK)
60 WmIpc* wm_ipc = WmIpc::instance();
61 registrar_.Add(this,
62 chrome::NOTIFICATION_LAYOUT_MODE_CHANGED,
63 content::Source<WmIpc>(wm_ipc));
64 #endif
65 UpdateForCurrentLayoutMode(); 55 UpdateForCurrentLayoutMode();
66 } 56 }
67 57
68 void LayoutModeButton::ButtonPressed(views::Button* sender, 58 void LayoutModeButton::ButtonPressed(views::Button* sender,
69 const views::Event& event) { 59 const views::Event& event) {
70 DCHECK_EQ(sender, this); 60 DCHECK_EQ(sender, this);
71 #if defined(TOOLKIT_USES_GTK)
72 WmIpc* wm_ipc = WmIpc::instance();
73 const WmIpcLayoutMode mode = wm_ipc->layout_mode();
74
75 WmIpc::Message message(WM_IPC_MESSAGE_WM_SET_LAYOUT_MODE);
76 switch (mode) {
77 case WM_IPC_LAYOUT_MAXIMIZED:
78 message.set_param(0, WM_IPC_LAYOUT_OVERLAPPING);
79 break;
80 case WM_IPC_LAYOUT_OVERLAPPING:
81 message.set_param(0, WM_IPC_LAYOUT_MAXIMIZED);
82 break;
83 default:
84 DLOG(WARNING) << "Unknown layout mode " << mode;
85 message.set_param(0, WM_IPC_LAYOUT_MAXIMIZED);
86 }
87 wm_ipc->SendMessage(message);
88 #endif
89 } 61 }
90 62
91 void LayoutModeButton::UpdateForCurrentLayoutMode() { 63 void LayoutModeButton::UpdateForCurrentLayoutMode() {
92 #if defined(TOOLKIT_USES_GTK)
93 const WmIpcLayoutMode mode = WmIpc::instance()->layout_mode();
94 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
95 switch (mode) {
96 case WM_IPC_LAYOUT_MAXIMIZED:
97 SetImage(BS_NORMAL, rb.GetBitmapNamed(IDR_STATUSBAR_WINDOW_RESTORE));
98 SetTooltipText(
99 l10n_util::GetStringUTF16(IDS_STATUSBAR_WINDOW_RESTORE_TOOLTIP));
100 break;
101 case WM_IPC_LAYOUT_OVERLAPPING:
102 SetImage(BS_NORMAL, rb.GetBitmapNamed(IDR_STATUSBAR_WINDOW_MAXIMIZE));
103 SetTooltipText(
104 l10n_util::GetStringUTF16(IDS_STATUSBAR_WINDOW_MAXIMIZE_TOOLTIP));
105 break;
106 default:
107 DLOG(WARNING) << "Unknown layout mode " << mode;
108 }
109 #endif
110 } 64 }
111 65
112 } // namespace chromeos 66 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/frame/browser_view.cc ('k') | chrome/browser/chromeos/frame/panel_browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698