| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/tabs/tab_utils.h" | 5 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 13 #include "chrome/browser/media/media_stream_capture_indicator.h" | 13 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "grit/theme_resources.h" | |
| 20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | |
| 22 #include "ui/base/theme_provider.h" | 20 #include "ui/base/theme_provider.h" |
| 23 #include "ui/gfx/animation/multi_animation.h" | 21 #include "ui/gfx/animation/multi_animation.h" |
| 22 #include "ui/gfx/image/image.h" |
| 24 #include "ui/gfx/vector_icons_public.h" | 23 #include "ui/gfx/vector_icons_public.h" |
| 25 #include "ui/native_theme/common_theme.h" | 24 #include "ui/native_theme/common_theme.h" |
| 26 #include "ui/native_theme/native_theme.h" | 25 #include "ui/native_theme/native_theme.h" |
| 27 | 26 |
| 28 #if !defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
| 28 #include "grit/theme_resources.h" |
| 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #else |
| 29 #include "ui/gfx/paint_vector_icon.h" | 31 #include "ui/gfx/paint_vector_icon.h" |
| 30 #endif | 32 #endif |
| 31 | 33 |
| 32 struct LastMuteMetadata | 34 struct LastMuteMetadata |
| 33 : public content::WebContentsUserData<LastMuteMetadata> { | 35 : public content::WebContentsUserData<LastMuteMetadata> { |
| 34 TabMutedReason reason = TAB_MUTED_REASON_NONE; | 36 TabMutedReason reason = TAB_MUTED_REASON_NONE; |
| 35 std::string extension_id; | 37 std::string extension_id; |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 explicit LastMuteMetadata(content::WebContents* contents) {} | 40 explicit LastMuteMetadata(content::WebContents* contents) {} |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 if (contents->IsAudioMuted()) | 162 if (contents->IsAudioMuted()) |
| 161 return TAB_MEDIA_STATE_AUDIO_MUTING; | 163 return TAB_MEDIA_STATE_AUDIO_MUTING; |
| 162 if (contents->WasRecentlyAudible()) | 164 if (contents->WasRecentlyAudible()) |
| 163 return TAB_MEDIA_STATE_AUDIO_PLAYING; | 165 return TAB_MEDIA_STATE_AUDIO_PLAYING; |
| 164 | 166 |
| 165 return TAB_MEDIA_STATE_NONE; | 167 return TAB_MEDIA_STATE_NONE; |
| 166 } | 168 } |
| 167 | 169 |
| 168 gfx::Image GetTabMediaIndicatorImage(TabMediaState media_state, | 170 gfx::Image GetTabMediaIndicatorImage(TabMediaState media_state, |
| 169 SkColor button_color) { | 171 SkColor button_color) { |
| 172 #if defined(OS_MACOSX) |
| 170 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 173 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 171 switch (media_state) { | 174 switch (media_state) { |
| 172 #if !defined(OS_MACOSX) | |
| 173 case TAB_MEDIA_STATE_AUDIO_PLAYING: | |
| 174 case TAB_MEDIA_STATE_AUDIO_MUTING: { | |
| 175 return gfx::Image( | |
| 176 gfx::CreateVectorIcon(media_state == TAB_MEDIA_STATE_AUDIO_PLAYING | |
| 177 ? gfx::VectorIconId::TAB_AUDIO | |
| 178 : gfx::VectorIconId::TAB_AUDIO_MUTING, | |
| 179 16, button_color)); | |
| 180 } | |
| 181 #else | |
| 182 case TAB_MEDIA_STATE_AUDIO_PLAYING: | 175 case TAB_MEDIA_STATE_AUDIO_PLAYING: |
| 183 return rb->GetNativeImageNamed(IDR_TAB_AUDIO_INDICATOR); | 176 return rb->GetNativeImageNamed(IDR_TAB_AUDIO_INDICATOR); |
| 184 case TAB_MEDIA_STATE_AUDIO_MUTING: | 177 case TAB_MEDIA_STATE_AUDIO_MUTING: |
| 185 return rb->GetNativeImageNamed(IDR_TAB_AUDIO_MUTING_INDICATOR); | 178 return rb->GetNativeImageNamed(IDR_TAB_AUDIO_MUTING_INDICATOR); |
| 186 #endif | |
| 187 case TAB_MEDIA_STATE_RECORDING: | 179 case TAB_MEDIA_STATE_RECORDING: |
| 188 return rb->GetNativeImageNamed(IDR_TAB_RECORDING_INDICATOR); | 180 return rb->GetNativeImageNamed(IDR_TAB_RECORDING_INDICATOR); |
| 189 case TAB_MEDIA_STATE_CAPTURING: | 181 case TAB_MEDIA_STATE_CAPTURING: |
| 190 return rb->GetNativeImageNamed(IDR_TAB_CAPTURE_INDICATOR); | 182 return rb->GetNativeImageNamed(IDR_TAB_CAPTURE_INDICATOR); |
| 191 case TAB_MEDIA_STATE_NONE: | 183 case TAB_MEDIA_STATE_NONE: |
| 192 break; | 184 break; |
| 193 } | 185 } |
| 186 #else |
| 187 gfx::VectorIconId icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; |
| 188 switch (media_state) { |
| 189 case TAB_MEDIA_STATE_AUDIO_PLAYING: |
| 190 icon_id = gfx::VectorIconId::TAB_AUDIO; |
| 191 break; |
| 192 case TAB_MEDIA_STATE_AUDIO_MUTING: |
| 193 icon_id = gfx::VectorIconId::TAB_AUDIO_MUTING; |
| 194 break; |
| 195 case TAB_MEDIA_STATE_RECORDING: |
| 196 icon_id = gfx::VectorIconId::TAB_MEDIA_RECORDING; |
| 197 break; |
| 198 case TAB_MEDIA_STATE_CAPTURING: |
| 199 icon_id = gfx::VectorIconId::TAB_MEDIA_CAPTURING; |
| 200 break; |
| 201 case TAB_MEDIA_STATE_NONE: |
| 202 break; |
| 203 } |
| 204 if (icon_id != gfx::VectorIconId::VECTOR_ICON_NONE) |
| 205 return gfx::Image(gfx::CreateVectorIcon(icon_id, 16, button_color)); |
| 206 #endif |
| 194 NOTREACHED(); | 207 NOTREACHED(); |
| 195 return gfx::Image(); | 208 return gfx::Image(); |
| 196 } | 209 } |
| 197 | 210 |
| 198 gfx::Image GetTabMediaIndicatorAffordanceImage(TabMediaState media_state, | 211 gfx::Image GetTabMediaIndicatorAffordanceImage(TabMediaState media_state, |
| 199 SkColor button_color) { | 212 SkColor button_color) { |
| 200 switch (media_state) { | 213 switch (media_state) { |
| 201 case TAB_MEDIA_STATE_AUDIO_PLAYING: | 214 case TAB_MEDIA_STATE_AUDIO_PLAYING: |
| 202 return GetTabMediaIndicatorImage(TAB_MEDIA_STATE_AUDIO_MUTING, | 215 return GetTabMediaIndicatorImage(TAB_MEDIA_STATE_AUDIO_MUTING, |
| 203 button_color); | 216 button_color); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 const std::vector<int>& indices) { | 361 const std::vector<int>& indices) { |
| 349 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); | 362 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); |
| 350 ++i) { | 363 ++i) { |
| 351 if (!tab_strip.GetWebContentsAt(*i)->IsAudioMuted()) | 364 if (!tab_strip.GetWebContentsAt(*i)->IsAudioMuted()) |
| 352 return false; | 365 return false; |
| 353 } | 366 } |
| 354 return true; | 367 return true; |
| 355 } | 368 } |
| 356 | 369 |
| 357 } // namespace chrome | 370 } // namespace chrome |
| OLD | NEW |