Commit f9779cbd authored by yusukes's avatar yusukes Committed by Commit bot

Refactor IntentPickerBubbleView::ShowBubble()

so that the function takes content::WebContents* instead of
content::NavigationHandle*. That allows us to use the bubble
view class outside the throttle.

BUG=b:29079617, b:31406784
TEST=try

Review-Url: https://codereview.chromium.org/2335313003
Cr-Commit-Position: refs/heads/master@{#418628}
parent a959cf63
......@@ -221,7 +221,7 @@ void ArcNavigationThrottle::OnAppIconsReceived(
}
show_intent_picker_callback_.Run(
navigation_handle(), app_info,
navigation_handle()->GetWebContents(), app_info,
base::Bind(&ArcNavigationThrottle::OnIntentPickerClosed,
weak_ptr_factory_.GetWeakPtr(), base::Passed(&handlers)));
}
......
......@@ -19,6 +19,7 @@
namespace content {
class NavigationHandle;
class WebContents;
} // namespace content
namespace arc {
......@@ -46,7 +47,7 @@ class ArcNavigationThrottle : public content::NavigationThrottle {
using NameAndIcon = std::pair<std::string, gfx::Image>;
using ShowIntentPickerCallback =
base::Callback<void(content::NavigationHandle* handle,
base::Callback<void(content::WebContents* web_contents,
const std::vector<NameAndIcon>& app_info,
const base::Callback<void(size_t, CloseReason)>& cb)>;
ArcNavigationThrottle(content::NavigationHandle* navigation_handle,
......
......@@ -175,11 +175,11 @@ class ContentSettingBubbleViewsBridge {
#if defined(OS_CHROMEOS)
// Return a pointer to the IntentPickerBubbleView::ShowBubble method.
using BubbleShowPtr =
void(*)(content::NavigationHandle*,
const std::vector<std::pair<std::basic_string<char>, gfx::Image> >&,
const base::Callback<void(size_t,
arc::ArcNavigationThrottle::CloseReason)>&);
using BubbleShowPtr = void (*)(
content::WebContents*,
const std::vector<std::pair<std::basic_string<char>, gfx::Image>>&,
const base::Callback<void(size_t,
arc::ArcNavigationThrottle::CloseReason)>&);
BubbleShowPtr ShowIntentPickerBubble();
......
......@@ -50,11 +50,10 @@ enum class Option : int { ALWAYS = -2, JUST_ONCE };
// static
void IntentPickerBubbleView::ShowBubble(
content::NavigationHandle* handle,
content::WebContents* web_contents,
const std::vector<NameAndIcon>& app_info,
const ThrottleCallback& throttle_cb) {
Browser* browser =
chrome::FindBrowserWithWebContents(handle->GetWebContents());
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
if (!browser) {
throttle_cb.Run(kAppTagNoneSelected,
arc::ArcNavigationThrottle::CloseReason::ERROR);
......@@ -67,8 +66,8 @@ void IntentPickerBubbleView::ShowBubble(
return;
}
IntentPickerBubbleView* delegate = new IntentPickerBubbleView(
app_info, throttle_cb, handle->GetWebContents());
IntentPickerBubbleView* delegate =
new IntentPickerBubbleView(app_info, throttle_cb, web_contents);
delegate->set_margins(gfx::Insets());
delegate->set_parent_window(browser_view->GetNativeWindow());
views::Widget* widget =
......
......@@ -17,7 +17,6 @@
#include "ui/views/controls/button/button.h"
namespace content {
class NavigationHandle;
class WebContents;
} // namespace content
......@@ -61,7 +60,7 @@ class IntentPickerBubbleView : public views::BubbleDialogDelegateView,
base::Callback<void(size_t, arc::ArcNavigationThrottle::CloseReason)>;
~IntentPickerBubbleView() override;
static void ShowBubble(content::NavigationHandle* handle,
static void ShowBubble(content::WebContents* web_contents,
const std::vector<NameAndIcon>& app_info,
const ThrottleCallback& throttle_cb);
static std::unique_ptr<IntentPickerBubbleView> CreateBubbleView(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment