summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/chrome_to_mobile_bubble_view.h
blob: 02c6ab95641cab624665bd347ab84c370666d99d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_VIEWS_CHROME_TO_MOBILE_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_CHROME_TO_MOBILE_BUBBLE_VIEW_H_
#pragma once

#include <map>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chrome_to_mobile_service.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"

class Profile;

namespace base {
class DictionaryValue;
}

namespace ui {
class ThrobAnimation;
}

namespace views {
class Checkbox;
class Label;
class RadioButton;
class TextButton;
}

// ChromeToMobileBubbleView is a bubble view for the Chrome To Mobile service.
class ChromeToMobileBubbleView : public views::BubbleDelegateView,
                                 public views::ButtonListener,
                                 public ChromeToMobileService::Observer {
 public:
  virtual ~ChromeToMobileBubbleView();

  static void ShowBubble(views::View* anchor_view, Profile* profile);
  static bool IsShowing();
  static void Hide();

  // views::BubbleDelegateView methods.
  virtual views::View* GetInitiallyFocusedView() OVERRIDE;
  virtual gfx::Rect GetAnchorRect() OVERRIDE;
  virtual void WindowClosing() OVERRIDE;
  virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
  virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;

  // views::ButtonListener method.
  virtual void ButtonPressed(views::Button* sender,
                             const views::Event& event) OVERRIDE;

  // ChromeToMobileService::Observer methods.
  virtual void SnapshotGenerated(const FilePath& path, int64 bytes) OVERRIDE;
  virtual void OnSendComplete(bool success) OVERRIDE;

 protected:
  // views::BubbleDelegateView method.
  virtual void Init() OVERRIDE;

 private:
  ChromeToMobileBubbleView(views::View* anchor_view, Profile* profile);

  // Handle the message when the user presses a button.
  void HandleButtonPressed(views::Button* sender);

  // Send the page to the mobile device.
  void Send();

  // The Chrome To Mobile bubble, if we're showing one.
  static ChromeToMobileBubbleView* bubble_;

  base::WeakPtrFactory<ChromeToMobileBubbleView> weak_ptr_factory_;

  // The Chrome To Mobile service associated with this bubble.
  ChromeToMobileService* service_;

  // A map of radio buttons for each mobile device to the device's information.
  typedef std::map<views::RadioButton*, base::DictionaryValue*> DeviceMap;
  DeviceMap mobile_map_;

  // The currently selected (or solitary) mobile device's info.
  base::DictionaryValue* selected_mobile_;

  // The file path for the MHTML page snapshot.
  FilePath snapshot_path_;

  views::Checkbox* send_copy_;
  views::TextButton* send_;
  views::TextButton* cancel_;

  // An animation used to cycle through the "Sending..." status messages.
  scoped_ptr<ui::ThrobAnimation> progress_animation_;

  DISALLOW_COPY_AND_ASSIGN(ChromeToMobileBubbleView);
};

#endif  // CHROME_BROWSER_UI_VIEWS_CHROME_TO_MOBILE_BUBBLE_VIEW_H_