| 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 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "chrome/browser/extensions/tab_helper.h" | 11 #include "chrome/browser/extensions/tab_helper.h" |
| 12 #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" | 12 #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" |
| 13 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" | 13 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" |
| 14 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h" | 14 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h" |
| 15 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" | 15 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
| 16 #include "chrome/common/extensions/api/web_view_internal.h" | 16 #include "chrome/common/extensions/api/web_view_internal.h" |
| 17 #include "content/public/browser/javascript_dialog_manager.h" | 17 #include "content/public/browser/javascript_dialog_manager.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "extensions/browser/guest_view/guest_view.h" | 19 #include "extensions/browser/guest_view/guest_view.h" |
| 20 #include "third_party/WebKit/public/web/WebFindOptions.h" | 20 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 21 | 21 |
| 22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 23 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 23 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace webview_api = extensions::api::web_view_internal; | |
| 27 | |
| 28 class RenderViewContextMenu; | 26 class RenderViewContextMenu; |
| 29 | 27 |
| 30 namespace ui { | 28 namespace ui { |
| 31 class SimpleMenuModel; | 29 class SimpleMenuModel; |
| 32 } // namespace ui | 30 } // namespace ui |
| 33 | 31 |
| 34 namespace extensions { | 32 namespace extensions { |
| 33 |
| 34 namespace webview_api = api::web_view_internal; |
| 35 |
| 35 class ScriptExecutor; | 36 class ScriptExecutor; |
| 36 class WebViewInternalFindFunction; | 37 class WebViewInternalFindFunction; |
| 37 | 38 |
| 38 // A WebViewGuest provides the browser-side implementation of the <webview> API | 39 // A WebViewGuest provides the browser-side implementation of the <webview> API |
| 39 // and manages the dispatch of <webview> extension events. WebViewGuest is | 40 // and manages the dispatch of <webview> extension events. WebViewGuest is |
| 40 // created on attachment. That is, when a guest WebContents is associated with | 41 // created on attachment. That is, when a guest WebContents is associated with |
| 41 // a particular embedder WebContents. This happens on either initial navigation | 42 // a particular embedder WebContents. This happens on either initial navigation |
| 42 // or through the use of the New Window API, when a new window is attached to | 43 // or through the use of the New Window API, when a new window is attached to |
| 43 // a particular <webview>. | 44 // a particular <webview>. |
| 44 class WebViewGuest : public GuestView<WebViewGuest>, | 45 class WebViewGuest : public GuestView<WebViewGuest>, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 const content::NotificationSource& source, | 169 const content::NotificationSource& source, |
| 169 const content::NotificationDetails& details) OVERRIDE; | 170 const content::NotificationDetails& details) OVERRIDE; |
| 170 | 171 |
| 171 // Returns the current zoom factor. | 172 // Returns the current zoom factor. |
| 172 double GetZoom(); | 173 double GetZoom(); |
| 173 | 174 |
| 174 // Begin or continue a find request. | 175 // Begin or continue a find request. |
| 175 void Find( | 176 void Find( |
| 176 const base::string16& search_text, | 177 const base::string16& search_text, |
| 177 const blink::WebFindOptions& options, | 178 const blink::WebFindOptions& options, |
| 178 scoped_refptr<extensions::WebViewInternalFindFunction> find_function); | 179 scoped_refptr<WebViewInternalFindFunction> find_function); |
| 179 | 180 |
| 180 // Conclude a find request to clear highlighting. | 181 // Conclude a find request to clear highlighting. |
| 181 void StopFinding(content::StopFindAction); | 182 void StopFinding(content::StopFindAction); |
| 182 | 183 |
| 183 // If possible, navigate the guest to |relative_index| entries away from the | 184 // If possible, navigate the guest to |relative_index| entries away from the |
| 184 // current navigation entry. | 185 // current navigation entry. |
| 185 void Go(int relative_index); | 186 void Go(int relative_index); |
| 186 | 187 |
| 187 // Reload the guest. | 188 // Reload the guest. |
| 188 void Reload(); | 189 void Reload(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 void Terminate(); | 227 void Terminate(); |
| 227 | 228 |
| 228 // Clears data in the storage partition of this guest. | 229 // Clears data in the storage partition of this guest. |
| 229 // | 230 // |
| 230 // Partition data that are newer than |removal_since| will be removed. | 231 // Partition data that are newer than |removal_since| will be removed. |
| 231 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. | 232 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. |
| 232 bool ClearData(const base::Time remove_since, | 233 bool ClearData(const base::Time remove_since, |
| 233 uint32 removal_mask, | 234 uint32 removal_mask, |
| 234 const base::Closure& callback); | 235 const base::Closure& callback); |
| 235 | 236 |
| 236 extensions::ScriptExecutor* script_executor() { | 237 ScriptExecutor* script_executor() { return script_executor_.get(); } |
| 237 return script_executor_.get(); | |
| 238 } | |
| 239 | 238 |
| 240 private: | 239 private: |
| 241 friend class WebViewPermissionHelper; | 240 friend class WebViewPermissionHelper; |
| 242 WebViewGuest(content::BrowserContext* browser_context, | 241 WebViewGuest(content::BrowserContext* browser_context, |
| 243 int guest_instance_id); | 242 int guest_instance_id); |
| 244 | 243 |
| 245 virtual ~WebViewGuest(); | 244 virtual ~WebViewGuest(); |
| 246 | 245 |
| 247 // Returns the top level items (ignoring submenus) as Value. | 246 // Returns the top level items (ignoring submenus) as Value. |
| 248 static scoped_ptr<base::ListValue> MenuModelToValue( | 247 static scoped_ptr<base::ListValue> MenuModelToValue( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // Creates a new guest window owned by this WebViewGuest. | 328 // Creates a new guest window owned by this WebViewGuest. |
| 330 void CreateNewGuestWebViewWindow(const content::OpenURLParams& params); | 329 void CreateNewGuestWebViewWindow(const content::OpenURLParams& params); |
| 331 | 330 |
| 332 void NewGuestWebViewCallback(const content::OpenURLParams& params, | 331 void NewGuestWebViewCallback(const content::OpenURLParams& params, |
| 333 content::WebContents* guest_web_contents); | 332 content::WebContents* guest_web_contents); |
| 334 | 333 |
| 335 bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event); | 334 bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event); |
| 336 | 335 |
| 337 void SetUpAutoSize(); | 336 void SetUpAutoSize(); |
| 338 | 337 |
| 339 ObserverList<extensions::TabHelper::ScriptExecutionObserver> | 338 ObserverList<TabHelper::ScriptExecutionObserver> script_observers_; |
| 340 script_observers_; | 339 scoped_ptr<ScriptExecutor> script_executor_; |
| 341 scoped_ptr<extensions::ScriptExecutor> script_executor_; | |
| 342 | 340 |
| 343 content::NotificationRegistrar notification_registrar_; | 341 content::NotificationRegistrar notification_registrar_; |
| 344 | 342 |
| 345 // A counter to generate a unique request id for a context menu request. | 343 // A counter to generate a unique request id for a context menu request. |
| 346 // We only need the ids to be unique for a given WebViewGuest. | 344 // We only need the ids to be unique for a given WebViewGuest. |
| 347 int pending_context_menu_request_id_; | 345 int pending_context_menu_request_id_; |
| 348 | 346 |
| 349 // True if the user agent is overridden. | 347 // True if the user agent is overridden. |
| 350 bool is_overriding_user_agent_; | 348 bool is_overriding_user_agent_; |
| 351 | 349 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 392 |
| 395 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; | 393 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; |
| 396 PendingWindowMap pending_new_windows_; | 394 PendingWindowMap pending_new_windows_; |
| 397 | 395 |
| 398 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 396 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 399 }; | 397 }; |
| 400 | 398 |
| 401 } // namespace extensions | 399 } // namespace extensions |
| 402 | 400 |
| 403 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 401 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| OLD | NEW |