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

Side by Side Diff: chrome/renderer/extensions/app_window_custom_bindings.cc

Issue 10915085: Functions for accessing app window properties, and modifying AppWindow-specifics (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: stray event, js linter Created 8 years, 3 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) 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/renderer/extensions/app_window_custom_bindings.h" 5 #include "chrome/renderer/extensions/app_window_custom_bindings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/common/extensions/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 private: 47 private:
48 Dispatcher* dispatcher_; 48 Dispatcher* dispatcher_;
49 }; 49 };
50 50
51 AppWindowCustomBindings::AppWindowCustomBindings(Dispatcher* dispatcher) 51 AppWindowCustomBindings::AppWindowCustomBindings(Dispatcher* dispatcher)
52 : ChromeV8Extension(dispatcher) { 52 : ChromeV8Extension(dispatcher) {
53 RouteFunction("GetView", 53 RouteFunction("GetView",
54 base::Bind(&AppWindowCustomBindings::GetView, 54 base::Bind(&AppWindowCustomBindings::GetView,
55 base::Unretained(this))); 55 base::Unretained(this)));
56 RouteFunction("GetCurrentRoutingID",
57 base::Bind(&AppWindowCustomBindings::GetCurrentRoutingID,
58 base::Unretained(this)));
56 } 59 }
57 60
58 namespace { 61 namespace {
59 class FindViewByID : public content::RenderViewVisitor { 62 class FindViewByID : public content::RenderViewVisitor {
60 public: 63 public:
61 explicit FindViewByID(int route_id) : route_id_(route_id), view_(NULL) { 64 explicit FindViewByID(int route_id) : route_id_(route_id), view_(NULL) {
62 } 65 }
63 66
64 content::RenderView* view() { return view_; } 67 content::RenderView* view() { return view_; }
65 68
66 // Returns false to terminate the iteration. 69 // Returns false to terminate the iteration.
67 virtual bool Visit(content::RenderView* render_view) { 70 virtual bool Visit(content::RenderView* render_view) {
68 if (render_view->GetRoutingID() == route_id_) { 71 if (render_view->GetRoutingID() == route_id_) {
69 view_ = render_view; 72 view_ = render_view;
70 return false; 73 return false;
71 } 74 }
72 return true; 75 return true;
73 } 76 }
74 77
75 private: 78 private:
76 int route_id_; 79 int route_id_;
77 content::RenderView* view_; 80 content::RenderView* view_;
78 }; 81 };
79 } // namespace 82 } // namespace
80 83
84 v8::Handle<v8::Value> AppWindowCustomBindings::GetCurrentRoutingID(
85 const v8::Arguments& args) {
86 content::RenderView* render_view = GetCurrentRenderView();
87 if (!render_view)
88 return v8::Undefined();
89 return v8::Integer::New(render_view->GetRoutingID());
90 }
91
81 v8::Handle<v8::Value> AppWindowCustomBindings::GetView( 92 v8::Handle<v8::Value> AppWindowCustomBindings::GetView(
82 const v8::Arguments& args) { 93 const v8::Arguments& args) {
83 // TODO(jeremya): convert this to IDL nocompile to get validation, and turn 94 // TODO(jeremya): convert this to IDL nocompile to get validation, and turn
84 // these argument checks into CHECK(). 95 // these argument checks into CHECK().
85 if (args.Length() != 2) 96 if (args.Length() != 2)
86 return v8::Undefined(); 97 return v8::Undefined();
87 98
88 if (!args[0]->IsInt32()) 99 if (!args[0]->IsInt32())
89 return v8::Undefined(); 100 return v8::Undefined();
90 101
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); 134 WebKit::WebFrame* frame = view->GetWebView()->mainFrame();
124 frame->setOpener(opener); 135 frame->setOpener(opener);
125 content::RenderThread::Get()->Send( 136 content::RenderThread::Get()->Send(
126 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); 137 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID()));
127 138
128 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); 139 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global();
129 return window; 140 return window;
130 } 141 }
131 142
132 } // namespace extensions 143 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698