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

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

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/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"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/views/menu_locator.h" 13 #include "chrome/browser/chromeos/views/menu_locator.h"
13 #include "chrome/browser/chromeos/views/native_menu_webui.h" 14 #include "chrome/browser/chromeos/views/native_menu_webui.h"
14 #include "chrome/browser/chromeos/wm_ipc.h" 15 #include "chrome/browser/chromeos/wm_ipc.h"
15 #include "chrome/browser/renderer_host/render_view_host.h" 16 #include "chrome/browser/renderer_host/render_view_host.h"
16 #include "chrome/browser/renderer_host/render_widget_host_view.h" 17 #include "chrome/browser/renderer_host/render_widget_host_view.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/ui/views/dom_view.h" 19 #include "chrome/browser/ui/views/dom_view.h"
19 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
20 #include "gfx/canvas_skia.h" 21 #include "gfx/canvas_skia.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 #include "third_party/cros/chromeos_wm_ipc_enums.h" 23 #include "third_party/cros/chromeos_wm_ipc_enums.h"
23 #include "third_party/skia/include/effects/SkGradientShader.h" 24 #include "third_party/skia/include/effects/SkGradientShader.h"
24 #include "views/border.h" 25 #include "views/border.h"
25 #include "views/layout/layout_manager.h" 26 #include "views/layout/layout_manager.h"
26 #include "views/widget/root_view.h" 27 #include "views/widget/root_view.h"
27 28
28 namespace { 29 namespace {
29 30
30 // Colors for menu's graident background. 31 // Colors for the menu's gradient background.
31 const SkColor kMenuStartColor = SK_ColorWHITE; 32 const SkColor kMenuStartColor = SK_ColorWHITE;
32 const SkColor kMenuEndColor = 0xFFEEEEEE; 33 const SkColor kMenuEndColor = 0xFFEEEEEE;
33 34
34 // Rounded border for menu. This draws three types of rounded border, 35 // Rounded border for menu. This draws three types of rounded border,
35 // for context menu, dropdown menu and submenu. Please see 36 // for context menu, dropdown menu and submenu. Please see
36 // menu_locator.cc for details. 37 // menu_locator.cc for details.
37 class RoundedBorder : public views::Border { 38 class RoundedBorder : public views::Border {
38 public: 39 public:
39 explicit RoundedBorder(chromeos::MenuLocator* locator) 40 explicit RoundedBorder(chromeos::MenuLocator* locator)
40 : menu_locator_(locator) { 41 : menu_locator_(locator) {
41 } 42 }
42 43
43 private: 44 private:
44 // views::Border implementatios. 45 // views::Border implementations.
45 virtual void Paint(const views::View& view, gfx::Canvas* canvas) const { 46 virtual void Paint(const views::View& view, gfx::Canvas* canvas) const {
46 const SkScalar* corners = menu_locator_->GetCorners(); 47 const SkScalar* corners = menu_locator_->GetCorners();
47 // The menu is in off screen so no need to draw corners. 48 // The menu is in off screen so no need to draw corners.
48 if (!corners) 49 if (!corners)
49 return; 50 return;
50 int w = view.width(); 51 int w = view.width();
51 int h = view.height(); 52 int h = view.height();
52 SkRect rect = {0, 0, w, h}; 53 SkRect rect = {0, 0, w, h};
53 SkPath path; 54 SkPath path;
54 path.addRoundRect(rect, corners); 55 path.addRoundRect(rect, corners);
(...skipping 18 matching lines...) Expand all
73 chromeos::MenuLocator* menu_locator_; // not owned 74 chromeos::MenuLocator* menu_locator_; // not owned
74 75
75 DISALLOW_COPY_AND_ASSIGN(RoundedBorder); 76 DISALLOW_COPY_AND_ASSIGN(RoundedBorder);
76 }; 77 };
77 78
78 class InsetsLayout : public views::LayoutManager { 79 class InsetsLayout : public views::LayoutManager {
79 public: 80 public:
80 InsetsLayout() : views::LayoutManager() {} 81 InsetsLayout() : views::LayoutManager() {}
81 82
82 private: 83 private:
83 // views::LayoutManager implementatios. 84 // views::LayoutManager implementations.
84 virtual void Layout(views::View* host) { 85 virtual void Layout(views::View* host) {
85 if (host->GetChildViewCount() == 0) 86 if (host->GetChildViewCount() == 0)
86 return; 87 return;
87 gfx::Insets insets = host->GetInsets(); 88 gfx::Insets insets = host->GetInsets();
88 views::View* view = host->GetChildViewAt(0); 89 views::View* view = host->GetChildViewAt(0);
89 90
90 view->SetBounds(insets.left(), insets.top(), 91 view->SetBounds(insets.left(), insets.top(),
91 host->width() - insets.width(), 92 host->width() - insets.width(),
92 host->height() - insets.height()); 93 host->height() - insets.height());
93 } 94 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 247
247 void WebUIMenuWidget::ExecuteJavascript(const std::wstring& script) { 248 void WebUIMenuWidget::ExecuteJavascript(const std::wstring& script) {
248 // Don't execute if there is no DOMView associated. This is fine because 249 // Don't execute if there is no DOMView associated. This is fine because
249 // 1) selectItem make sense only when DOMView is associated. 250 // 1) selectItem make sense only when DOMView is associated.
250 // 2) updateModel will be called again when a DOMView is created/assigned. 251 // 2) updateModel will be called again when a DOMView is created/assigned.
251 if (!dom_view_) 252 if (!dom_view_)
252 return; 253 return;
253 254
254 DCHECK(dom_view_->tab_contents()->render_view_host()); 255 DCHECK(dom_view_->tab_contents()->render_view_host());
255 dom_view_->tab_contents()->render_view_host()-> 256 dom_view_->tab_contents()->render_view_host()->
256 ExecuteJavascriptInWebFrame(std::wstring(), script); 257 ExecuteJavascriptInWebFrame(string16(), WideToUTF16Hack(script));
257 } 258 }
258 259
259 void WebUIMenuWidget::ShowAt(chromeos::MenuLocator* locator) { 260 void WebUIMenuWidget::ShowAt(chromeos::MenuLocator* locator) {
260 DCHECK(webui_menu_); 261 DCHECK(webui_menu_);
261 menu_locator_.reset(locator); 262 menu_locator_.reset(locator);
262 if (!dom_view_) { 263 if (!dom_view_) {
263 // TODO(oshima): Replace DOMView with direct use of RVH for beta. 264 // TODO(oshima): Replace DOMView with direct use of RVH for beta.
264 // DOMView should be refactored to use RVH directly, but 265 // DOMView should be refactored to use RVH directly, but
265 // it'll require a lot of change and will take time. 266 // it'll require a lot of change and will take time.
266 dom_view_ = new DOMView(); 267 dom_view_ = new DOMView();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 EnableInput(false /* no selection */); 332 EnableInput(false /* no selection */);
332 } 333 }
333 334
334 void WebUIMenuWidget::ClearGrabWidget() { 335 void WebUIMenuWidget::ClearGrabWidget() {
335 GtkWidget* grab_widget; 336 GtkWidget* grab_widget;
336 while ((grab_widget = gtk_grab_get_current())) 337 while ((grab_widget = gtk_grab_get_current()))
337 gtk_grab_remove(grab_widget); 338 gtk_grab_remove(grab_widget);
338 } 339 }
339 340
340 } // namespace chromeos 341 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698