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

Side by Side Diff: chrome/browser/extensions/api/webview/webview_api.cc

Issue 299753011: Move allocate instance id to chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: refactor one method, Created 6 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extensions/api/webview/webview_api.h" 5 #include "chrome/browser/extensions/api/webview/webview_api.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" 8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h" 9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h"
10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers. h" 10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers. h"
11 #include "chrome/browser/extensions/tab_helper.h" 11 #include "chrome/browser/extensions/tab_helper.h"
12 #include "chrome/browser/guest_view/guest_view_manager.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/extensions/api/webview.h" 14 #include "chrome/common/extensions/api/webview.h"
14 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/storage_partition.h" 17 #include "content/public/browser/storage_partition.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/stop_find_action.h" 19 #include "content/public/common/stop_find_action.h"
19 #include "extensions/common/error_utils.h" 20 #include "extensions/common/error_utils.h"
20 #include "third_party/WebKit/public/web/WebFindOptions.h" 21 #include "third_party/WebKit/public/web/WebFindOptions.h"
21 22
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 params->create_properties, 83 params->create_properties,
83 Profile::FromBrowserContext(browser_context()), 84 Profile::FromBrowserContext(browser_context()),
84 GetExtension(), 85 GetExtension(),
85 id, 86 id,
86 &error_); 87 &error_);
87 88
88 SendResponse(success); 89 SendResponse(success);
89 return success; 90 return success;
90 } 91 }
91 92
93 WebviewAllocateInstanceIdFunction::WebviewAllocateInstanceIdFunction() {
94 printf("++++ %s\n", __PRETTY_FUNCTION__);
95 }
96
97 bool WebviewAllocateInstanceIdFunction::RunAsync() {
98 printf("++++ %s\n", __PRETTY_FUNCTION__);
99 int instanceId =
100 GuestViewManager::FromBrowserContext(
101 browser_context())->GetNextInstanceID();
Fady Samuel 2014/05/27 14:19:06 Let's make this a "GuestView" API, as this will ap
lazyboy 2014/05/27 20:43:00 Done.
102 SetResult(base::Value::CreateIntegerValue(instanceId));
103 SendResponse(true);
104 return true;
105 }
106
107 bool WebviewNavigateFunction::RunAsyncSafe(WebViewGuest* guest) {
108 printf("++++ %s, guest = [%p]\n", __PRETTY_FUNCTION__, guest);
109 scoped_ptr<webview::Navigate::Params> params(
110 webview::Navigate::Params::Create(*args_));
111 EXTENSION_FUNCTION_VALIDATE(params.get());
112 std::string src = params->src;
113 printf("src was: %s\n", src.c_str());
114 guest->NavigateGuest(src);
115 return true;
116 }
117
92 bool WebviewContextMenusUpdateFunction::RunAsync() { 118 bool WebviewContextMenusUpdateFunction::RunAsync() {
93 scoped_ptr<webview::ContextMenusUpdate::Params> params( 119 scoped_ptr<webview::ContextMenusUpdate::Params> params(
94 webview::ContextMenusUpdate::Params::Create(*args_)); 120 webview::ContextMenusUpdate::Params::Create(*args_));
95 EXTENSION_FUNCTION_VALIDATE(params.get()); 121 EXTENSION_FUNCTION_VALIDATE(params.get());
96 122
97 Profile* profile = Profile::FromBrowserContext(browser_context()); 123 Profile* profile = Profile::FromBrowserContext(browser_context());
98 MenuItem::Id item_id( 124 MenuItem::Id item_id(
99 profile->IsOffTheRecord(), 125 profile->IsOffTheRecord(),
100 MenuItem::ExtensionKey(extension_id(), params->instance_id)); 126 MenuItem::ExtensionKey(extension_id(), params->instance_id));
101 127
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 599
574 WebviewTerminateFunction::~WebviewTerminateFunction() { 600 WebviewTerminateFunction::~WebviewTerminateFunction() {
575 } 601 }
576 602
577 bool WebviewTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { 603 bool WebviewTerminateFunction::RunAsyncSafe(WebViewGuest* guest) {
578 guest->Terminate(); 604 guest->Terminate();
579 return true; 605 return true;
580 } 606 }
581 607
582 } // namespace extensions 608 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698