OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/guest_view/extension_options/extension_options_guest.h" | 5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
9 #include "chrome/browser/guest_view/extension_options/extension_options_constant
s.h" | 9 #include "chrome/browser/guest_view/extension_options/extension_options_constant
s.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 ExtensionOptionsGuest::~ExtensionOptionsGuest() { | 36 ExtensionOptionsGuest::~ExtensionOptionsGuest() { |
37 } | 37 } |
38 | 38 |
39 const char* ExtensionOptionsGuest::GetAPINamespace() { | 39 const char* ExtensionOptionsGuest::GetAPINamespace() { |
40 return extensionoptions::kAPINamespace; | 40 return extensionoptions::kAPINamespace; |
41 } | 41 } |
42 | 42 |
43 // static | 43 // static |
44 GuestViewBase* ExtensionOptionsGuest::Create( | 44 extensions::GuestViewBase* ExtensionOptionsGuest::Create( |
45 content::BrowserContext* browser_context, | 45 content::BrowserContext* browser_context, |
46 int guest_instance_id) { | 46 int guest_instance_id) { |
47 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { | 47 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { |
48 return NULL; | 48 return NULL; |
49 } | 49 } |
50 return new ExtensionOptionsGuest(browser_context, guest_instance_id); | 50 return new ExtensionOptionsGuest(browser_context, guest_instance_id); |
51 } | 51 } |
52 | 52 |
53 void ExtensionOptionsGuest::CreateWebContents( | 53 void ExtensionOptionsGuest::CreateWebContents( |
54 const std::string& embedder_extension_id, | 54 const std::string& embedder_extension_id, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 void ExtensionOptionsGuest::DidInitialize() { | 108 void ExtensionOptionsGuest::DidInitialize() { |
109 extension_function_dispatcher_.reset( | 109 extension_function_dispatcher_.reset( |
110 new extensions::ExtensionFunctionDispatcher(browser_context(), this)); | 110 new extensions::ExtensionFunctionDispatcher(browser_context(), this)); |
111 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 111 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
112 guest_web_contents()); | 112 guest_web_contents()); |
113 } | 113 } |
114 | 114 |
115 void ExtensionOptionsGuest::DidStopLoading() { | 115 void ExtensionOptionsGuest::DidStopLoading() { |
116 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 116 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
117 DispatchEventToEmbedder(new GuestViewBase::Event( | 117 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( |
118 extensions::api::extension_options_internal::OnLoad::kEventName, | 118 extensions::api::extension_options_internal::OnLoad::kEventName, |
119 args.Pass())); | 119 args.Pass())); |
120 } | 120 } |
121 | 121 |
122 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { | 122 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { |
123 return guest_web_contents(); | 123 return guest_web_contents(); |
124 } | 124 } |
125 | 125 |
126 bool ExtensionOptionsGuest::OnMessageReceived(const IPC::Message& message) { | 126 bool ExtensionOptionsGuest::OnMessageReceived(const IPC::Message& message) { |
127 bool handled = true; | 127 bool handled = true; |
128 IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message) | 128 IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message) |
129 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 129 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
130 IPC_MESSAGE_UNHANDLED(handled = false) | 130 IPC_MESSAGE_UNHANDLED(handled = false) |
131 IPC_END_MESSAGE_MAP() | 131 IPC_END_MESSAGE_MAP() |
132 return handled; | 132 return handled; |
133 } | 133 } |
134 | 134 |
135 void ExtensionOptionsGuest::OnRequest( | 135 void ExtensionOptionsGuest::OnRequest( |
136 const ExtensionHostMsg_Request_Params& params) { | 136 const ExtensionHostMsg_Request_Params& params) { |
137 extension_function_dispatcher_->Dispatch( | 137 extension_function_dispatcher_->Dispatch( |
138 params, guest_web_contents()->GetRenderViewHost()); | 138 params, guest_web_contents()->GetRenderViewHost()); |
139 } | 139 } |
140 | 140 |
141 void ExtensionOptionsGuest::GuestSizeChangedDueToAutoSize( | 141 void ExtensionOptionsGuest::GuestSizeChangedDueToAutoSize( |
142 const gfx::Size& old_size, | 142 const gfx::Size& old_size, |
143 const gfx::Size& new_size) { | 143 const gfx::Size& new_size) { |
144 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 144 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
145 args->SetInteger(extensionoptions::kWidth, new_size.width()); | 145 args->SetInteger(extensionoptions::kWidth, new_size.width()); |
146 args->SetInteger(extensionoptions::kHeight, new_size.height()); | 146 args->SetInteger(extensionoptions::kHeight, new_size.height()); |
147 DispatchEventToEmbedder(new GuestViewBase::Event( | 147 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( |
148 extension_options_internal::OnSizeChanged::kEventName, args.Pass())); | 148 extension_options_internal::OnSizeChanged::kEventName, args.Pass())); |
149 } | 149 } |
150 | 150 |
151 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { | 151 bool ExtensionOptionsGuest::IsAutoSizeSupported() const { |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 void ExtensionOptionsGuest::SetUpAutoSize() { | 155 void ExtensionOptionsGuest::SetUpAutoSize() { |
156 // Read the autosize parameters passed in from the embedder. | 156 // Read the autosize parameters passed in from the embedder. |
157 bool auto_size_enabled = false; | 157 bool auto_size_enabled = false; |
(...skipping 10 matching lines...) Expand all Loading... |
168 int min_width = 0; | 168 int min_width = 0; |
169 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, | 169 extra_params()->GetInteger(extensionoptions::kAttributeMinHeight, |
170 &min_height); | 170 &min_height); |
171 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); | 171 extra_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); |
172 | 172 |
173 // Call SetAutoSize to apply all the appropriate validation and clipping of | 173 // Call SetAutoSize to apply all the appropriate validation and clipping of |
174 // values. | 174 // values. |
175 SetAutoSize( | 175 SetAutoSize( |
176 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); | 176 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); |
177 } | 177 } |
OLD | NEW |