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

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

Issue 13375017: Move the ViewType enum to extensions\common. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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) 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/extension_custom_bindings.h" 5 #include "chrome/renderer/extensions/extension_custom_bindings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
13 #include "chrome/common/view_type.h"
14 #include "chrome/renderer/extensions/dispatcher.h" 13 #include "chrome/renderer/extensions/dispatcher.h"
15 #include "chrome/renderer/extensions/extension_helper.h" 14 #include "chrome/renderer/extensions/extension_helper.h"
16 #include "content/public/renderer/render_view.h" 15 #include "content/public/renderer/render_view.h"
17 #include "content/public/renderer/v8_value_converter.h" 16 #include "content/public/renderer/v8_value_converter.h"
17 #include "extensions/common/view_type.h"
18 #include "grit/renderer_resources.h" 18 #include "grit/renderer_resources.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
21 #include "webkit/glue/webkit_glue.h" 21 #include "webkit/glue/webkit_glue.h"
22 #include "v8/include/v8.h" 22 #include "v8/include/v8.h"
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 namespace { 26 namespace {
27 27
(...skipping 15 matching lines...) Expand all
43 43
44 if (!args[0]->IsInt32() || !args[1]->IsString()) 44 if (!args[0]->IsInt32() || !args[1]->IsString())
45 return v8::Undefined(); 45 return v8::Undefined();
46 46
47 // |browser_window_id| == extension_misc::kUnknownWindowId means getting 47 // |browser_window_id| == extension_misc::kUnknownWindowId means getting
48 // views attached to any browser window. 48 // views attached to any browser window.
49 int browser_window_id = args[0]->Int32Value(); 49 int browser_window_id = args[0]->Int32Value();
50 50
51 std::string view_type_string = *v8::String::Utf8Value(args[1]->ToString()); 51 std::string view_type_string = *v8::String::Utf8Value(args[1]->ToString());
52 StringToUpperASCII(&view_type_string); 52 StringToUpperASCII(&view_type_string);
53 // |view_type| == chrome::VIEW_TYPE_INVALID means getting any type of 53 // |view_type| == extensions::VIEW_TYPE_INVALID means getting any type of
Yoyo Zhou 2013/04/01 17:36:51 ''
54 // views. 54 // views.
55 chrome::ViewType view_type = chrome::VIEW_TYPE_INVALID; 55 extensions::ViewType view_type = extensions::VIEW_TYPE_INVALID;
56 if (view_type_string == chrome::kViewTypeBackgroundPage) { 56 if (view_type_string == extensions::kViewTypeBackgroundPage) {
57 view_type = chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; 57 view_type = extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE;
58 } else if (view_type_string == chrome::kViewTypeInfobar) { 58 } else if (view_type_string == extensions::kViewTypeInfobar) {
59 view_type = chrome::VIEW_TYPE_EXTENSION_INFOBAR; 59 view_type = extensions::VIEW_TYPE_EXTENSION_INFOBAR;
60 } else if (view_type_string == chrome::kViewTypeNotification) { 60 } else if (view_type_string == extensions::kViewTypeNotification) {
61 view_type = chrome::VIEW_TYPE_NOTIFICATION; 61 view_type = extensions::VIEW_TYPE_NOTIFICATION;
62 } else if (view_type_string == chrome::kViewTypeTabContents) { 62 } else if (view_type_string == extensions::kViewTypeTabContents) {
63 view_type = chrome::VIEW_TYPE_TAB_CONTENTS; 63 view_type = extensions::VIEW_TYPE_TAB_CONTENTS;
64 } else if (view_type_string == chrome::kViewTypePopup) { 64 } else if (view_type_string == extensions::kViewTypePopup) {
65 view_type = chrome::VIEW_TYPE_EXTENSION_POPUP; 65 view_type = extensions::VIEW_TYPE_EXTENSION_POPUP;
66 } else if (view_type_string == chrome::kViewTypeExtensionDialog) { 66 } else if (view_type_string == extensions::kViewTypeExtensionDialog) {
67 view_type = chrome::VIEW_TYPE_EXTENSION_DIALOG; 67 view_type = extensions::VIEW_TYPE_EXTENSION_DIALOG;
68 } else if (view_type_string == chrome::kViewTypeAppShell) { 68 } else if (view_type_string == extensions::kViewTypeAppShell) {
69 view_type = chrome::VIEW_TYPE_APP_SHELL; 69 view_type = extensions::VIEW_TYPE_APP_SHELL;
70 } else if (view_type_string == chrome::kViewTypePanel) { 70 } else if (view_type_string == extensions::kViewTypePanel) {
71 view_type = chrome::VIEW_TYPE_PANEL; 71 view_type = extensions::VIEW_TYPE_PANEL;
72 } else if (view_type_string != chrome::kViewTypeAll) { 72 } else if (view_type_string != extensions::kViewTypeAll) {
73 return v8::Undefined(); 73 return v8::Undefined();
74 } 74 }
75 75
76 const Extension* extension = GetExtensionForRenderView(); 76 const Extension* extension = GetExtensionForRenderView();
77 if (!extension) 77 if (!extension)
78 return v8::Undefined(); 78 return v8::Undefined();
79 79
80 std::vector<content::RenderView*> views = ExtensionHelper::GetExtensionViews( 80 std::vector<content::RenderView*> views = ExtensionHelper::GetExtensionViews(
81 extension->id(), browser_window_id, view_type); 81 extension->id(), browser_window_id, view_type);
82 v8::Local<v8::Array> v8_views = v8::Array::New(); 82 v8::Local<v8::Array> v8_views = v8::Array::New();
83 int v8_index = 0; 83 int v8_index = 0;
84 for (size_t i = 0; i < views.size(); ++i) { 84 for (size_t i = 0; i < views.size(); ++i) {
85 v8::Local<v8::Context> context = 85 v8::Local<v8::Context> context =
86 views[i]->GetWebView()->mainFrame()->mainWorldScriptContext(); 86 views[i]->GetWebView()->mainFrame()->mainWorldScriptContext();
87 if (!context.IsEmpty()) { 87 if (!context.IsEmpty()) {
88 v8::Local<v8::Value> window = context->Global(); 88 v8::Local<v8::Value> window = context->Global();
89 DCHECK(!window.IsEmpty()); 89 DCHECK(!window.IsEmpty());
90 v8_views->Set(v8::Integer::New(v8_index++), window); 90 v8_views->Set(v8::Integer::New(v8_index++), window);
91 } 91 }
92 } 92 }
93 93
94 return v8_views; 94 return v8_views;
95 } 95 }
96 96
97 } // namespace extensions 97 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698