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

Side by Side Diff: chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 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 5
6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" 6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h"
7 7
8 #include <utility>
9
8 #include "build/build_config.h" 10 #include "build/build_config.h"
9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 11 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
10 #include "chrome/browser/favicon/favicon_utils.h" 12 #include "chrome/browser/favicon/favicon_utils.h"
11 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" 14 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
13 #include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h" 15 #include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
14 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
15 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" 17 #include "components/browsing_data/storage_partition_http_cache_data_remover.h"
16 #include "components/guest_view/browser/guest_view_event.h" 18 #include "components/guest_view/browser/guest_view_event.h"
17 #include "components/renderer_context_menu/context_menu_delegate.h" 19 #include "components/renderer_context_menu/context_menu_delegate.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return false; 61 return false;
60 62
61 // Pass it to embedder. 63 // Pass it to embedder.
62 int request_id = ++pending_context_menu_request_id_; 64 int request_id = ++pending_context_menu_request_id_;
63 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 65 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
64 scoped_ptr<base::ListValue> items = 66 scoped_ptr<base::ListValue> items =
65 MenuModelToValue(pending_menu_->menu_model()); 67 MenuModelToValue(pending_menu_->menu_model());
66 args->Set(webview::kContextMenuItems, items.release()); 68 args->Set(webview::kContextMenuItems, items.release());
67 args->SetInteger(webview::kRequestId, request_id); 69 args->SetInteger(webview::kRequestId, request_id);
68 web_view_guest()->DispatchEventToView( 70 web_view_guest()->DispatchEventToView(
69 new GuestViewEvent(webview::kEventContextMenuShow, args.Pass())); 71 new GuestViewEvent(webview::kEventContextMenuShow, std::move(args)));
70 return true; 72 return true;
71 } 73 }
72 74
73 void ChromeWebViewGuestDelegate::OnDidInitialize() { 75 void ChromeWebViewGuestDelegate::OnDidInitialize() {
74 #if defined(OS_CHROMEOS) 76 #if defined(OS_CHROMEOS)
75 chromeos::AccessibilityManager* accessibility_manager = 77 chromeos::AccessibilityManager* accessibility_manager =
76 chromeos::AccessibilityManager::Get(); 78 chromeos::AccessibilityManager::Get();
77 CHECK(accessibility_manager); 79 CHECK(accessibility_manager);
78 accessibility_subscription_ = accessibility_manager->RegisterCallback( 80 accessibility_subscription_ = accessibility_manager->RegisterCallback(
79 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged, 81 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged,
80 weak_ptr_factory_.GetWeakPtr())); 82 weak_ptr_factory_.GetWeakPtr()));
81 #endif 83 #endif
82 } 84 }
83 85
84 // static 86 // static
85 scoped_ptr<base::ListValue> ChromeWebViewGuestDelegate::MenuModelToValue( 87 scoped_ptr<base::ListValue> ChromeWebViewGuestDelegate::MenuModelToValue(
86 const ui::SimpleMenuModel& menu_model) { 88 const ui::SimpleMenuModel& menu_model) {
87 scoped_ptr<base::ListValue> items(new base::ListValue()); 89 scoped_ptr<base::ListValue> items(new base::ListValue());
88 for (int i = 0; i < menu_model.GetItemCount(); ++i) { 90 for (int i = 0; i < menu_model.GetItemCount(); ++i) {
89 base::DictionaryValue* item_value = new base::DictionaryValue(); 91 base::DictionaryValue* item_value = new base::DictionaryValue();
90 // TODO(lazyboy): We need to expose some kind of enum equivalent of 92 // TODO(lazyboy): We need to expose some kind of enum equivalent of
91 // |command_id| instead of plain integers. 93 // |command_id| instead of plain integers.
92 item_value->SetInteger(webview::kMenuItemCommandId, 94 item_value->SetInteger(webview::kMenuItemCommandId,
93 menu_model.GetCommandIdAt(i)); 95 menu_model.GetCommandIdAt(i));
94 item_value->SetString(webview::kMenuItemLabel, menu_model.GetLabelAt(i)); 96 item_value->SetString(webview::kMenuItemLabel, menu_model.GetLabelAt(i));
95 items->Append(item_value); 97 items->Append(item_value);
96 } 98 }
97 return items.Pass(); 99 return items;
98 } 100 }
99 101
100 void ChromeWebViewGuestDelegate::OnShowContextMenu( 102 void ChromeWebViewGuestDelegate::OnShowContextMenu(
101 int request_id, 103 int request_id,
102 const MenuItemVector* items) { 104 const MenuItemVector* items) {
103 if (!pending_menu_.get()) 105 if (!pending_menu_.get())
104 return; 106 return;
105 107
106 // Make sure this was the correct request. 108 // Make sure this was the correct request.
107 if (request_id != pending_context_menu_request_id_) 109 if (request_id != pending_context_menu_request_id_)
108 return; 110 return;
109 111
110 // TODO(lazyboy): Implement. 112 // TODO(lazyboy): Implement.
111 DCHECK(!items); 113 DCHECK(!items);
112 114
113 ContextMenuDelegate* menu_delegate = 115 ContextMenuDelegate* menu_delegate =
114 ContextMenuDelegate::FromWebContents(guest_web_contents()); 116 ContextMenuDelegate::FromWebContents(guest_web_contents());
115 menu_delegate->ShowMenu(pending_menu_.Pass()); 117 menu_delegate->ShowMenu(std::move(pending_menu_));
116 } 118 }
117 119
118 bool ChromeWebViewGuestDelegate::ShouldHandleFindRequestsForEmbedder() const { 120 bool ChromeWebViewGuestDelegate::ShouldHandleFindRequestsForEmbedder() const {
119 // Find requests will be handled by the guest for the Chrome signin page. 121 // Find requests will be handled by the guest for the Chrome signin page.
120 return web_view_guest_->owner_web_contents()->GetWebUI() != nullptr && 122 return web_view_guest_->owner_web_contents()->GetWebUI() != nullptr &&
121 web_view_guest_->GetOwnerSiteURL().GetOrigin().spec() == 123 web_view_guest_->GetOwnerSiteURL().GetOrigin().spec() ==
122 chrome::kChromeUIChromeSigninURL; 124 chrome::kChromeUIChromeSigninURL;
123 } 125 }
124 126
125 void ChromeWebViewGuestDelegate::InjectChromeVoxIfNeeded( 127 void ChromeWebViewGuestDelegate::InjectChromeVoxIfNeeded(
(...skipping 27 matching lines...) Expand all
153 155
154 void ChromeWebViewGuestDelegate::SetContextMenuPosition( 156 void ChromeWebViewGuestDelegate::SetContextMenuPosition(
155 const gfx::Point& position) { 157 const gfx::Point& position) {
156 if (context_menu_position_ == nullptr) 158 if (context_menu_position_ == nullptr)
157 context_menu_position_.reset(new gfx::Point()); 159 context_menu_position_.reset(new gfx::Point());
158 160
159 *context_menu_position_ = position; 161 *context_menu_position_ = position;
160 } 162 }
161 163
162 } // namespace extensions 164 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698